Contents
GAME HACKING
Developing Autonomous Bots for Online Games
Nick Cano
San Francisco
GAME HACKING. Copyright 2016 by Nick Cano.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
Printed in USA
First printing
20 19 18 17 16 1 2 3 4 5 6 7 8 9
ISBN-10: 1-59327-669-9
ISBN-13: 978-1-59327-669-0
Publisher: William Pollock
Production Editor: Laurel Chun
Cover Illustration: Ryan Milner
Interior Design: Octopod Studios
Developmental Editor: Jennifer Griffith-Delgado
Technical Reviewer: Stephen Lawler
Copyeditor: Rachel Monaghan
Compositor: Laurel Chun
Proofreader: Paula L. Fleming
Indexer: BIM Creatives, LLC
For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 415.863.9900;
www.nostarch.com
Library of Congress Cataloging-in-Publication Data
Cano, Nick, author.
Game hacking : developing autonomous bots for online games / by Nick Cano.
pages cm
Includes index.
Summary: "A hands-on guide to hacking computer games. Shows programmers how to dissect computer games and create bots to alter their gaming environment. Covers the basics of game hacking, including reverse engineering, assembly code analysis, programmatic memory manipulation, persistent hacks, responsive hacks, and code injection."-- Provided by publisher.
ISBN 978-1-59327-669-0 -- ISBN 1-59327-669-9
1. Intelligent agents (Computer software) 2. Internet programming. 3. Internet games--Programming. 4. Hacking. I. Title.
QA76.76.I58C36 2016
005.8--dc23
2015036294
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this book is distributed on an As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
About the Author
Nick Cano wrote his first scripts for open source game servers when he was 12 and started a business selling his bots when he was 16. He has been a part of the game-hacking community ever since and advises game developers and designers on best practices to protect their games against bots. Nick also has years of experience in detecting and defending against malware, and he has spoken at many conferences about his research and tools.
About the Technical Reviewer
Stephen Lawler is the founder and president of a small computer software and security consulting firm. He has been actively working in information security for over 10 years, primarily in reverse engineering, malware analysis, and vulnerability research. He was a member of the Mandiant malware analysis team and assisted with high-profile computer intrusions affecting several Fortune 100 companies. Stephen also developed and teaches the Practical ARM Exploitation class, which has been offered at BlackHat and several other security conferences for the past five years.
BRIEF CONTENTS
CONTENTS IN DETAIL
PART 1
TOOLS OF THE TRADE
1
SCANNING MEMORY USING CHEAT ENGINE
2
DEBUGGING GAMES WITH OLLYDBG
3
RECONNAISSANCE WITH PROCESS MONITOR AND PROCESS EXPLORER
PART 2
GAME DISSECTION
4
FROM CODE TO MEMORY: A GENERAL PRIMER
5
ADVANCED MEMORY FORENSICS
6
READING FROM AND WRITING TO GAME MEMORY
PART 3
PROCESS PUPPETEERING
7
CODE INJECTION
8
MANIPULATING CONTROL FLOW IN A GAME
PART 4
CREATING BOTS
9
USING EXTRASENSORY PERCEPTION TO WARD OFF FOG OF WAR
10
RESPONSIVE HACKS
11
PUTTING IT ALL TOGETHER: WRITING AUTONOMOUS BOTS
12
STAYING HIDDEN
FOREWORD
Nick is great. We first hit it off in all the right and wrong ways, as you can imagine. Ive been in the security field a while; hes a little younger. Ive had the schooling, whereas hes not much for college. Im a faith guy, and hes not. The interesting thing is that none of that matters; weve had a blast anyway. Age, race, gender, degreeswhen it comes to gaming, hacking, and coding, no one cares!
Nick gets it done. Hes fun. Hes brilliant. Hes hard working. And probably most pertinent: hes one of the rare few who understand the intersection of gaming, hacking, and coding. Hes worked in this niche and created profitable bots.
In this first-of-its-kind book, Nick walks you through what it means to pull apart games. He teaches you the software investigation tools and tricks of the trade. Youll learn about game internals, how to pull them apart, and how to modify play. For example, Nick teaches how to avoid anti-cheat so that you can automate play. Wouldnt it be cool to have your own bot that collects experience, gold, items, and moreall while youre away?
Ever wonder how the cheaters cheat? Ever wanted to patch or protect your game? Grab a coffee, crack open your laptop, and enjoy.
Blessings to you and yours,
Dr. Jared DeMott
Security Expert & Software Builder
ACKNOWLEDGMENTS
Writing this book was an amazing journey, and I couldnt have done it alone. No Starch Press has been extremely supportive and worked closely with me to take this book from concept to reality. In particular, Id like to thank my developmental editor, Jennifer Griffith-Delgado, and my production editor, Laurel Chun. Bill Pollock, Tyler Ortman, Alison Law, and the rest of the team at No Starch are wonderful people, and Im pleased to have worked with them.
Thanks to copyeditor Rachel Monaghan, proofreader Paula L. Fleming, and technical reviewer Stephen Lawler. Thanks also to my friends Cavitt synt4x Glover and Vadim Kotov, who took the time to skim some chapters before submission, and to Jared DeMott for writing the books foreword.
Id like to thank all of the people on TPForums who took me in when I was just a naive kid and helped me learn how to hack games. In particular, I owe my thanks to Joseph jo3bingham Bingham, Ian Obermiller, and jeremic, who all had a significant influence on my progression as a hacker, and to TPForums founder Josh Zyphrus Hartzell, who helped me find my confidence and skills when my future looked its bleakest.