The Ghidra Book The Definitive Guide (Chris Eagle Kara Nance) (Z-Library)

Author: Chris Eagle, Kara Nance

非小说

A guide to using the Ghidra software reverse engineering tool suite. The result of more than a decade of research and development within the NSA, the Ghidra platform was developed to address some of the agency's most challenging reverse-engineering problems. With the open-source release of this formerly restricted tool suite, one of the world's most capable disassemblers and intuitive decompilers is now in the hands of cybersecurity defenders everywhere—and The Ghidra Book is the one and only guide you need to master it. In addition to discussing RE techniques useful in analyzing software and malware of all kinds, the book thoroughly introduces Ghidra's components, features, and unique capacity for group collaboration. You'll learn how to: • Navigate a disassembly • Use Ghidra's built-in decompiler to expedite analysis • Analyze obfuscated binaries • Extend Ghidra to recognize new data types • Build new Ghidra analyzers and loaders • Add support for new processors and instruction sets • Script Ghidra tasks to automate workflows • Set up and use a collaborative reverse engineering environment Designed for beginner and advanced users alike, The Ghidra Book will effectively prepare you to meet the needs and challenges of RE, so you can analyze files like a pro. Chris Eagle has been reverse engineering software for 40 years. He is the author of The IDA Pro Book (No Starch Press) and is a highly sought-after provider of reverse engineering training. Dr. Kara Nance is a private security consultant and has been a professor of computer science for many years. She has given numerous talks at conferences around the world and enjoys building Ghidra extensions as well as providing Ghidra training.

📄 File Format: PDF
💾 File Size: 17.6 MB
71
Views
0
Downloads
0.00
Total Donations

📄 Text Preview (First 20 pages)

ℹ️

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

📄 Page 1
C H R I S E A G L E A N D K A R A N A N C E T H E G H I D R A B O O K T H E D E F I N I T I V E G U I D E
📄 Page 2
(This page has no text content)
📄 Page 3
by Chris Eagle and Kara Nance San Francisco T H E G H I D R A B O O K T h e D e f i n i t i v e G u i d e
📄 Page 4
THE GHIDRA BOOK. Copyright © 2020 Chris Eagle and Kara Nance. 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. ISBN-13: 978-1-71850-102-7 (print) ISBN-13: 978-1-71850-103-4 (ebook) Publisher: William Pollock Executive Editor: Barbara Yien Production Editors: Laurel Chun and Katrina Taylor Cover Illustration: Gina Redman Interior Design: Octopod Studios Project Editor: Dapinder Dosanjh Developmental Editor: Athabasca Witschi Technical Reviewer: Brian Hay Copyeditor: Barton D. Reed Compositor: Danielle Foster Proofreader: Sharon Wilkey 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: 1.415.863.9900; info@nostarch.com www.nostarch.com Library of Congress Control Number: 2020938508 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 authors 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.
📄 Page 5
To all those who believe in science and fact-based decision making as well as all of the COVID-19 first responders around the world whose hard work and sacrifice provided a ray of hope in a time of global crisis. To all girls who are passionate about investigating and understanding technology and the men and women who support and encourage them. Dream big and keep exploring!
📄 Page 6
(This page has no text content)
📄 Page 7
About the Authors Chris Eagle has been reverse engineering software for 40 years. He is the author of The IDA Pro Book (No Starch Press) and is a highly sought-after provider of reverse engineering training. He has published numerous reverse engineering tools and given talks at conferences such as Blackhat, Defcon, and Shmoocon. Kara Nance is a private security consultant. She has been a pro- fessor of computer science for many years. She has served on the Honeynet Project Board of Directors and given numerous talks at conferences around the world. She enjoys building Ghidra exten- sions and regularly provides Ghidra training. About the Tech Reviewer Brian Hay has been a reverse engineer, professor, and software developer for many years. He has spoken and taught at many conferences and is currently a senior researcher for a boutique security research company. He specializes in designing and developing virtualized environments for training and testing exciting new tools like Ghidra.
📄 Page 8
(This page has no text content)
📄 Page 9
B R I E F C O N T E N T S Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi PART I: INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 1: Introduction to Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Chapter 2: Reversing and Disassembly Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Chapter 3: Meet Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 PART II: BASIC GHIDRA USAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Chapter 4: Getting Started with Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Chapter 5: Ghidra Data Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Chapter 6: Making Sense of a Ghidra Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Chapter 7: Disassembly Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Chapter 8: Data Types and Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Chapter 9: Cross-References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Chapter 10: Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 PART III: MAKING GHIDRA WORK FOR YOU . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Chapter 11: Collaborative SRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 Chapter 12: Customizing Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 Chapter 13: Extending Ghidra’s Worldview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Chapter 14: Basic Ghidra Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Chapter 15: Eclipse and GhidraDev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Chapter 16: Ghidra in Headless Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
📄 Page 10
viii Brief Contents PART IV: A DEEPER DIVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 Chapter 17: Ghidra Loaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 Chapter 18: Ghidra Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 Chapter 19: The Ghidra Decompiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427 Chapter 20: Compiler Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443 PART V: REAL-WORLD APPLICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 Chapter 21: Obfuscated Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 Chapter 22: Patching Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 Chapter 23: Binary Differencing and Version Tracking . . . . . . . . . . . . . . . . . . . . . . . 529 Ghidra for IDA Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
📄 Page 11
C O N T E N T S I N D E T A I L ACKNOWLEDGMENTS XIX INTRODUCTION XXI About This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii Who Should Read This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii What’s in This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii Part I: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii Part II: Basic Ghidra Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii Part III: Making Ghidra Work for You . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii Part IV: A Deeper Dive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiv Part V: Real-World Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiv PART I: INTRODUCTION 1 1 INTRODUCTION TO DISASSEMBLY 3 Disassembly Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 The What of Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 The Why of Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Malware Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Vulnerability Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Software Interoperability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Compiler Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Debugging Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 The How of Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 A Basic Disassembly Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Linear Sweep Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Recursive Descent Disassembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2 REVERSING AND DISASSEMBLY TOOLS 15 Classification Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 PE Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 PEiD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Summary Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 nm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 ldd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 objdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
📄 Page 12
x Contents In Detail otool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 dumpbin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 c++filt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Deep Inspection Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Disassemblers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3 MEET GHIDRA 33 Ghidra Licenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Ghidra Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Ghidra Support Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Downloading Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Installing Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 The Ghidra Directory Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Starting Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 PART II: BASIC GHIDRA USAGE 39 4 GETTING STARTED WITH GHIDRA 41 Launching Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Creating a New Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Ghidra File Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Using the Raw Binary Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Analyzing Files with Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Auto Analysis Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Desktop Behavior During Initial Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Saving Your Work and Exiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Ghidra Desktop Tips and Tricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 5 GHIDRA DATA DISPLAYS 55 CodeBrowser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 CodeBrowser Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 The Listing Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Creating Additional Disassembly Windows . . . . . . . . . . . . . . . . . . . . . . . . . 64 Ghidra Function Graph View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 The Program Trees Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 The Symbol Tree Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 The Data Type Manager Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 The Console Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 The Decompiler Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
📄 Page 13
Contents In Detail xi Other Ghidra Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 The Bytes Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 The Defined Data Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 The Defined Strings Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 The Symbol Table and Symbol References Windows . . . . . . . . . . . . . . . . . . . 82 The Memory Map Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 The Function Call Graph Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 6 MAKING SENSE OF A GHIDRA DISASSEMBLY 89 Disassembly Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Names and Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Navigation in Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Go To . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Navigation History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Stack Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Function Call Mechanics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Calling Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Additional Stack Frame Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Local Variable Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Stack Frame Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Ghidra Stack Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Ghidra Stack Frame Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Stack Frames in Listing View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Decompiler-Assisted Stack Frame Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 109 Local Variables as Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 The Ghidra Stack Frame Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Search Program Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Search Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 7 DISASSEMBLY MANIPULATION 119 Manipulating Names and Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Renaming Parameters and Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . 121 Renaming Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Adding a New Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Editing Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Removing a Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Navigating Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 End-of-Line Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Pre and Post Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Plate Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Repeatable Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Parameter and Local Variable Comments . . . . . . . . . . . . . . . . . . . . . . . . . . 132 Annotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
📄 Page 14
xii Contents In Detail Basic Code Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Changing Code Display Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Formatting Instruction Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Manipulating Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Converting Data to Code (and Vice Versa) . . . . . . . . . . . . . . . . . . . . . . . . . 139 Basic Data Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Specifying Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Working with Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Defining Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 8 DATA TYPES AND DATA STRUCTURES 147 Making Sense of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Recognizing Data Structure Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Array Member Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Structure Member Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Creating Structures with Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Creating a New Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Editing Structure Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Applying Structure Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 C++ Reversing Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 The this Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Virtual Functions and Vftables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 The Object Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Name Mangling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Runtime Type Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Inheritance Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 C++ Reverse Engineering References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 9 CROSS-REFERENCES 183 Referencing Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Cross-References (Back References) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 References Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Reference Management Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 XRefs Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 References To . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Symbol References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Advanced Reference Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 10 GRAPHS 197 Basic Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Function Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Function Call Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
📄 Page 15
Contents In Detail xiii Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 PART III: MAKING GHIDRA WORK FOR YOU 215 11 COLLABORATIVE SRE 217 Teamwork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Ghidra Server Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Shared Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 Creating a Shared Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 Project Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Project Window Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 Edit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Project Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 Version Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Example Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 12 CUSTOMIZING GHIDRA 241 CodeBrowser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Rearranging Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Editing Tool Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Editing the Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 Special Tool Editing Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Saving the CodeBrowser Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Ghidra Project Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Workspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 13 EXTENDING GHIDRA’S WORLDVIEW 261 Importing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 Analyzers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Word Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 Creating New Data Type Archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Function IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 Function ID Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Function ID Plugin Example: UPX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 Function ID Plugin Example: Profiling a Static Library . . . . . . . . . . . . . . . . . . 279 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
📄 Page 16
xiv Contents In Detail 14 BASIC GHIDRA SCRIPTING 285 Script Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 Script Manager Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 Script Manager Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 Script Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Writing Java Scripts (Not JavaScript!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 Edit Script Example: Regex Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 Python Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Support for Other Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 Introduction to the Ghidra API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 The Address Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 The Symbol Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 The Reference Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 The GhidraScript Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 The Program Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 The Function Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 The Instruction Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Ghidra Scripting Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Example 1: Enumerating Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Example 2: Enumerating Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 Example 3: Enumerating Cross-References . . . . . . . . . . . . . . . . . . . . . . . . . 308 Example 4: Finding Function Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 Example 5: Emulating Assembly Language Behavior . . . . . . . . . . . . . . . . . . 311 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 15 ECLIPSE AND GHIDRADEV 315 Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Eclipse Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Starting Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Editing Scripts with Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 GhidraDev Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 GhidraDev4New . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Navigating the Package Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 Example: Ghidra Analyzer Module Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Step 1: Define the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Step 2: Create the Eclipse Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 Step 3: Build the Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 Step 4: Test the Analyzer Within Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Step 5: Add the Analyzer to Our Ghidra Installation . . . . . . . . . . . . . . . . . . 337 Step 6: Test the Analyzer Within Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . 338 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 16 GHIDRA IN HEADLESS MODE 341 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 Step 1: Launch Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 Steps 2 and 3: Create a New Ghidra Project in a Specified Location . . . . . . 343
📄 Page 17
Contents In Detail xv Step 4: Import a File to the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 Steps 5 and 6: Auto Analyze the File, Save, and Exit . . . . . . . . . . . . . . . . . 344 Options and Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 Writing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 HeadlessSimpleROP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 Automated FidDb Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 PART IV: A DEEPER DIVE 361 17 GHIDRA LOADERS 363 Unknown File Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 Manually Loading a Windows PE File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Example 1: SimpleShellcode Loader Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 Step 0: Take a Step Back . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 Step 1: Define the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Step 2: Create the Eclipse Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Step 3: Build the Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 Step 4: Add the Loader to Our Ghidra Installation . . . . . . . . . . . . . . . . . . . 385 Step 5: Test the Loader Within Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 Example 2: Simple Shellcode Source Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387 Update 1: Modify the Response to the Importer Poll . . . . . . . . . . . . . . . . . . 388 Update 2: Find the Shellcode in the Source Code . . . . . . . . . . . . . . . . . . . . 388 Update 3: Convert Shellcode to Byte Values . . . . . . . . . . . . . . . . . . . . . . . . 389 Update 4: Load Converted Byte Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 Example 3: Simple ELF Shellcode Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 Housekeeping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 ELF Header Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 Find Supported Load Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 Load File Content into Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 Format Data Bytes and Add an Entry Point . . . . . . . . . . . . . . . . . . . . . . . . . 395 Language Definition Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396 Opinion Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 18 GHIDRA PROCESSORS 401 Understanding Ghidra Processor Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 Eclipse Processor Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 SLEIGH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 Processor Manuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406 Modifying a Ghidra Processor Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408 Example 1: Adding an Instruction to a Processor Module . . . . . . . . . . . . . . . 409
📄 Page 18
xvi Contents In Detail Example 2: Modifying an Instruction in a Processor Module . . . . . . . . . . . . . 415 Example 3: Adding a Register to a Processor Module . . . . . . . . . . . . . . . . . 424 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 19 THE GHIDRA DECOMPILER 427 Decompiler Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 Analysis Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 The Decompiler Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430 Example 1: Editing in the Decompiler Window . . . . . . . . . . . . . . . . . . . . . . 431 Example 2: Non-Returning Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 Example 3: Automated Structure Creation . . . . . . . . . . . . . . . . . . . . . . . . . 437 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 20 COMPILER VARIATIONS 443 High-Level Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 Example: Comparing gcc with Microsoft C/C++ Compiler . . . . . . . . . . . . . 449 Compiler Build Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 Example 1: Modulo Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 Example 2: The Ternary Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 Example 3: Function Inlining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 Compiler-Specific C++ Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 Function Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 RTTI Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 Locating the main Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 Example 1: _start to main with gcc on Linux x86-64 . . . . . . . . . . . . . . . . . . 464 Example 2: _start to main with clang on FreeBSD x86-64 . . . . . . . . . . . . . . 464 Example 3: _start to main with Microsoft’s C/C++ compiler . . . . . . . . . . . . . 465 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 PART V: REAL-WORLD APPLICATIONS 467 21 OBFUSCATED CODE ANALYSIS 469 Anti–Reverse Engineering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 Obfuscation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 Anti–Static Analysis Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 Imported Function Obfuscation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482 Anti–Dynamic Analysis Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487 Static Deobfuscation of Binaries Using Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 Script-Oriented Deobfuscation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 Emulation-Oriented Deobfuscation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496 Step 1: Define the Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498 Step 2: Create the Eclipse Script Project . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
📄 Page 19
Contents In Detail xvii Step 3: Build the Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 Step 4: Add the Script to Our Ghidra Installation . . . . . . . . . . . . . . . . . . . . 502 Step 5: Test the Script Within Ghidra . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504 22 PATCHING BINARIES 505 Planning Your Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 Finding Things to Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506 Searching Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507 Searching for Direct References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 Searching for Instruction Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 Finding Specific Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512 Applying Your Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 Making Basic Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 Making Nontrivial Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 Exporting Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 Ghidra Export Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522 The Binary Export Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 Script-Assisted Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523 Example: Patching a Binary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528 23 BINARY DIFFERENCING AND VERSION TRACKING 529 Binary Differencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 Program Diff Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531 Example: Merging Two Analyzed Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 534 Comparing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 Function Comparison Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 Example: Comparing Crypto Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541 Version Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546 Version Tracking Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 GHIDRA FOR IDA USERS 551 The Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 Database Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552 Basic Windows and Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554 Scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556 INDEX 557
📄 Page 20
(This page has no text content)
The above is a preview of the first 20 pages. Register to read the complete e-book.

💝 Support Author

0.00
Total Amount (¥)
0
Donation Count

Login to support the author

Login Now
Back to List