Gray Hat Python Python Programming for Hackers and Reverse Engineers

by
Format: Paperback
Pub. Date: 2009-04-15
Publisher(s): No Starch Press
  • Free Shipping Icon

    This Item Qualifies for Free Shipping!*

    *Excludes marketplace orders.

List Price: $41.95

Buy New

Arriving Soon. Will ship when available.
$39.95

Rent Book

Select for Price
There was a problem. Please try again later.

Used Book

We're Sorry
Sold Out

eBook

We're Sorry
Not Available

How Marketplace Works:

  • This item is offered by an independent seller and not shipped from our warehouse
  • Item details like edition and cover design may differ from our description; see seller's comments before ordering.
  • Sellers much confirm and ship within two business days; otherwise, the order will be cancelled and refunded.
  • Marketplace purchases cannot be returned to eCampus.com. Contact the seller directly for inquiries; if no response within two days, contact customer service.
  • Additional shipping costs apply to Marketplace purchases. Review shipping costs at checkout.

Summary

Python is the high-level language of choice for hacking, vulnerability discovery, and security research. Gray Hat Python, the first Python book written for advanced security analysts, explains the intricacies of using Python to assist in a range of security analysis tasks. Readers learn how to design and program their own debuggers, create powerful fuzzers, utilize open source libraries to automate tedious tasks, and interface with commercial and non-commercial security tools. Gray Hat Python covers everything from the nuts and bolts of how to use the language for basic code and DLL injection to using Python to analyze binaries and disassemble software. It also discusses a variety of open source Python tools (such as PyDbg, PaiMei, PyEmu, Sulley, and Immunity Debugger) and how to extend them. Fundamentally a security book, Gray Hat Python reveals just how superior the Python language is when it comes to hacking, reverse engineering, malware analysis and software testing.

Author Biography

Justin Seitz is a Senior Security Researcher for Immunity, Inc., where he spends his time bug hunting, reverse engineering, writing exploits, and coding Python.

Table of Contents

Forewordp. xiii
Acknowledgmentsp. xvii
Introductionp. xix
Setting up Your Development Environmentp. 1
Operating System Requirementsp. 2
Obtaining and Installing Python 2.5p. 2
Installing Python on Windowsp. 2
Installing Python for Linuxp. 3
Setting Up Eclipse and PyDevp. 4
The Hacker's Best Friend: ctypesp. 5
Using Dynamic Librariesp. 6
Constructing C Datatypesp. 8
Passing Parameters by Referencep. 9
Defining Structures and Unionsp. 9
Debuggers and Debugger Designp. 13
General-Purpose CPU Registersp. 14
The Stackp. 16
Debug Eventsp. 18
Breakpointsp. 18
Soft Breakpointsp. 19
Hardware Breakpointsp. 21
Memory Breakpointsp. 23
Building A Windows Debuggerp. 25
Debuggee, Where Art Thou?p. 25
Obtaining CPU Register Statep. 33
Thread Enumerationp. 33
Putting It All Togetherp. 35
Implementing Debug Event Handlersp. 39
The Almighty Breakpointp. 43
Soft Breakpointsp. 43
Hardware Breakpointsp. 47
Memory Breakpointsp. 52
Conclusionp. 55
Pydbg-A Pure Python Windows Debuggerp. 57
Extending Breakpoint Handlersp. 58
Access Violation Handlersp. 60
Process Snapshotsp. 63
Obtaining Process Snapshotsp. 63
Putting It All Togetherp. 65
Immunity Debugger-The Best Of Both Worldsp. 69
Installing Immunity Debuggerp. 70
Immunity Debugger 101p. 70
PyCommandsp. 71
PyHooksp. 71
Exploit Developmentp. 73
Finding Exploit-Friendly Instructionsp. 73
Bad-Character Filteringp. 75
Bypassing DEP on Windowsp. 77
Defeating Anti-Debugging Routines in Malwarep. 81
IsDebuggerPresentp. 81
Defeating Process Iterationp. 82
Hookingp. 85
Soft Hooking with PyDbgp. 86
Hard Hooking with Immunity Debuggerp. 90
DLL and Code Injectionp. 97
Remote Thread Creationp. 98
DLL Injectionp. 99
Code Injectionp. 101
Getting Evilp. 104
File Hidingp. 104
Coding the Backdoorp. 105
Compiling with py2exep. 108
Fuzzingp. 111
Bug Classesp. 112
Buffer Overflowsp. 112
Integer Overflowsp. 113
Format String Attacksp. 114
File Fuzzerp. 115
Future Considerationsp. 122
Code Coveragep. 122
Automated Static Analysisp. 122
Sulleyp. 123
Sulley Installationp. 124
Sulley Primitivesp. 125
Stringsp. 125
Delimitersp. 125
Static and Random Primitivesp. 126
Binary Datap. 126
Integersp. 126
Blocks and Groupsp. 127
Slaying WarFTPD with Sulleyp. 129
FTP 101p. 129
Creating the FTP Protocol Skeletonp. 130
Sulley Sessionsp. 131
Network and Process Monitoringp. 132
Fuzzing and the Sulley Web Interfacep. 133
Fuzzing Windows Driversp. 137
Driver Communicationp. 138
Driver Fuzzing with Immunity Debuggerp. 139
Driverlib-The Static Analysis Tool for Driversp. 142
Discovering Device Namesp. 143
Finding the IOCTL Dispatch Routinep. 144
Determining Supported IOCTL Codesp. 145
Building a Driver Fuzzerp. 147
Idapython-Scripting Ida Prop. 153
IDAPython Installationp. 154
IDAPython Functionsp. 155
Utility Functionsp. 155
Segmentsp. 155
Functionsp. 156
Cross-Referencesp. 156
Debugger Hooksp. 157
Example Scriptsp. 158
Finding Dangerous Function Cross-Referencesp. 158
Function Code Coveragep. 160
Calculating Stack Sizep. 161
Pyemu-The Scriptable Emulatorp. 163
Installing PyEmup. 164
PyEmu Overviewp. 164
PyCPUp. 164
PyMemoryp. 165
PyEmup. 165
Executionp. 165
Memory and Register Modifiersp. 165
Handlersp. 166
IDAPyEmup. 171
Function Emulationp. 172
PEPyEmup. 175
Executable Packersp. 176
UPX Packerp. 176
Unpacking UPX with PEPyEmup. 177
Indexp. 183
Table of Contents provided by Ingram. All Rights Reserved.

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

Digital License

You are licensing a digital product for a set duration. Durations are set forth in the product description, with "Lifetime" typically meaning five (5) years of online access and permanent download to a supported device. All licenses are non-transferable.

More details can be found here.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.