Gray Hat Python and over one million other books are available for Amazon Kindle. Learn more



or
Sign in to turn on 1-Click ordering
Sell Us Your Item
For a $3.77 Gift Card
Trade in
More Buying Choices
Have one to sell? Sell yours here
Start reading Gray Hat Python on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.
Sorry, this item is not available in
Image not available for
Color:
Image not available

To view this video download Flash Player

 

Gray Hat Python: Python Programming for Hackers and Reverse Engineers [Paperback]

Justin Seitz
3.7 out of 5 stars  See all reviews (22 customer reviews)

List Price: $39.95
Price: $24.80 & FREE Shipping on orders over $25. Details
You Save: $15.15 (38%)
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Only 4 left in stock (more on the way).
Ships from and sold by Amazon.com. Gift-wrap available.
Want it Wednesday, May 29? Choose One-Day Shipping at checkout. Details
Free Two-Day Shipping for College Students with Amazon Student

Formats

Amazon Price New from Used from
Kindle Edition $17.57  
Paperback $24.80  
Rent Your Textbooks
Save up to 70% when you rent your textbooks on Amazon. Keep your textbook rentals for a semester and rental return shipping is free.

Book Description

April 30, 2009 1593271921 978-1593271923 1

Python is fast becoming the programming language of choice for hackers, reverse engineers, and software testers because it's easy to write quickly, and it has the low-level support and libraries that make hackers happy. But until now, there has been no real manual on how to use Python for a variety of hacking tasks. You had to dig through forum posts and man pages, endlessly tweaking your own code to get everything working. Not anymore.

Gray Hat Python explains the concepts behind hacking tools and techniques like debuggers, trojans, fuzzers, and emulators. But author Justin Seitz goes beyond theory, showing you how to harness existing Python-based security tools - and how to build your own when the pre-built ones won't cut it.

You'll learn how to:

  • Automate tedious reversing and security tasks
  • Design and program your own debugger
  • Learn how to fuzz Windows drivers and create powerful fuzzers from scratch
  • Have fun with code and library injection, soft and hard hooking techniques, and other software trickery
  • Sniff secure traffic out of an encrypted web browser session
  • Use PyDBG, Immunity Debugger, Sulley, IDAPython, PyEMU, and more

The world's best hackers are using Python to do their handiwork. Shouldn't you?


Frequently Bought Together

Gray Hat Python: Python Programming for Hackers and Reverse Engineers + Violent Python: A Cookbook for Hackers, Forensic Analysts, Penetration Testers and Security Engineers + Hacking: The Art of Exploitation, 2nd Edition
Price for all three: $87.57

Buy the selected items together


Editorial Reviews

About the Author

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


Product Details

  • Paperback: 232 pages
  • Publisher: No Starch Press; 1 edition (April 30, 2009)
  • Language: English
  • ISBN-10: 1593271921
  • ISBN-13: 978-1593271923
  • Product Dimensions: 7.1 x 0.9 x 9.3 inches
  • Shipping Weight: 14.4 ounces (View shipping rates and policies)
  • Average Customer Review: 3.7 out of 5 stars  See all reviews (22 customer reviews)
  • Amazon Best Sellers Rank: #57,969 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, read author blogs, and more.

Customer Reviews

That being said, I found this book to be a very interesting read. Nicholas Sardo  |  5 reviewers made a similar statement
It was obviously lacking in many areas. Jesse G. Lands  |  3 reviewers made a similar statement
Most Helpful Customer Reviews
47 of 50 people found the following review helpful
Format:Paperback|Amazon Verified Purchase
I was extremely disappointed in this book. I had been waiting almost a year for the book to be released and in that time had spent time looking at the different applications that were currently written in Python that could possible be included. With the time spent in writing this book and bringing it into publication the poor quality of the book does not compare to the higher standards that most No Starch Press books have achieved.

While there were a few merits in the book the majority of the book was a futile attempt to put outdated or useless information to paper. Many of my coworkers were very interested in the publication, but having read it and having spoken with my collegues that have read it we can all agree that it falls well short of anticipation.

The first five chapters were about Immunity Debugger. While reading them it seemed as if it were a sales pitch and then after reading that the author was employed by the same company that produces Immunity it was plainly obvious that he was influenced.

The author spent a chapter on hooking(6), DLL and code injection(7), fuzzing(8), Sulley(9), Fuzzing Windows Drivers(10), IDAPython(11), PyEMU(12) and obviously the Immunity Debugger chapters that were 1 through 5. But where was the rest? It was obviously lacking in many areas. There was very little mentioned on networks, packet reassembly or capture (pynids). No mention was made of Scapy, Pcapy, Impacket, Inguma, Volatility and so many more. Libraries that would be extremely helpful were never even brushed. IronPython, Win32, CryptoPy,

The examples given were poor to say the least. The author never mentioned which versions of python that the examples worked with and they were built using the older releases. The author goes through the installation of Python 2.5, but that version had issues with a few of the examples that I managed to get to work on 2.4. No mention was made for the the Python 3 version and version 2.6 had issues with most of the examples.

At 188 pages with 80+ pages used for debuggers that book was sorely lacking in any amount of substance. Most of my notes have more content then this book. To think that a book written regarding security minded use of python could only yield this little bit of information is absured.

I had preordered the book well in advance of publication. Each time the book was delayed for a few months I was extremely disappointed, but continued to hold onto the preorder. Once I received the book the writing and content were so poor that I spent much of my time reading a few pages only to put it down to find something of more interest or better content.

As I had said previously, No Starch Press is known for their quality products and excellent material, but this book falls well short of expectations. If someone would ask if I recommend this book I would whole heartedly tell them they are better off buying seperate books and piecing together that with internet content.

With all the uses Python has in security today I feel the community needs a better resource for Python tools in pentesting, forensics, incident response, intrusion detection, and so on. The potential content could fill volumes. A book about Python and Security would benefit the community greatly if it was a quality product, but this is not it.
Was this review helpful to you?
33 of 35 people found the following review helpful
4.0 out of 5 stars GHPython Review May 3, 2009
Format:Paperback
I have to start off by saying that I've been looking forward to this book being published for months now. Since it initially popped up on the No Starch website I've been following it and nagging the publishers about it's release. I was fortunate enough to get a copy last Friday and I dove into it full force, even my final exam suffered because I was a little too focused on this book. I have mixed feelings about the book overall, there was definitely a few things I gained from it. On the other hand, there were many more things that could have been added. If you are new to Reverse Engineering then you will most likely obtain a leap of knowledge from the book. Packed with code examples on various open source tools and concepts to create your own, you'll be waste deep in python for a while. If you've been around for the last few years and have already checked out many of the open source tools discussed in the book you may only get a few things out of it.

Justin does a great job elaborating through the the code examples used throughout the book. The sheer scope of this book makes it difficult to cover everything but Justin definitely attempts to give you a taste for the more common scenarios you may find yourself in. Below I highlight a few chapters that I found interesting and useful. Overall the entire book is useful but a large portion covers open source tools that have a plethora of documentation and examples in existence.

Chapter 3 is just downright awesome. This chapter walks you through creating your own python based debugger that is similar to pydbg. Between the concepts and actual implementation you obtain a solid understanding of what is going on in a Windows based debugger.

Chapter 6 goes over Hooking in 5 pages. This topic could easily fill a few chapters by itself but Justin sums everything up quite nicely with plenty of examples.

Chapter 7 discusses DLL and Code injection which was a pretty interesting topic. The chapter even gets a little "Evil" by showing you how to hide files on a filesystem using python. It goes one step deeper into evilness by demonstrating how to code a back door into files.

Chapter 8 goes into fuzzing concepts and the demonstration is very practical for anyone doing exploitation. Justin shows us how to create a file format fuzzer which I thought was pretty slick.

The last chapter I found pretty interesting was chapter 10 titled "Fuzzing Windows Drivers." This chapter outlines methods of identifying Device names and IOCTL codes using Immunity Debugger. It continues to show examples of an IOCTL Fuzzer that can be used in conjunction with the rest of the scripts outlined in the chapter. Definately some cool stuff. Personally, I'm not quite up to a Drive level fuzzing level but I still found the knowledge very useful and was able to translate some of the immunity scripts into IDAPython scripts for static analysis to find the device names and IOCTL Codes.

The Cons

The entire book was based off Dynamic analysis. This is great for those out there doing RE through execution, but it really sucks for people like me who only does dynamic analysis 10% of the time.

The entire book is windows specific. Yes, most RE work is done on windows, for windows binaries. However, there are closed source applications and even embedded stuff that is Linux based. Would have definitely been useful to have some examples for these types of cases.

At times I found the book drifting into the direction of exploitation. Granted, RE and exploitation go hand in hand but I feel those of us who perform RE for the purpose of compatibility, protocol analysis, and other crap were left out a bit.

The chapter on debugger design did not have all that much to say about designing a debugger. In fact, it was probably more inline with a quick introduction to x86 architecture, specifically registers and stacks. It was not until chapter 3 that you really understand the elements involved.

Overall, I equate this book to Hacking the art of exploitation first edition but for Reverse Engineering. The book is packed with useful information for both the novice to the professional but I hope a second edition comes out with more information, that covers both static and dynamic analysis.
Comment | 
Was this review helpful to you?
14 of 14 people found the following review helpful
4.0 out of 5 stars Excellent book for rapid vulnerability testing May 7, 2009
By mjw
Format:Paperback
I've been eagerly awaiting the release of "Grey Hat Python" by Justin Seitz of Immunity. I think Python is a great language and it's used extensively in the security industry so I've been quite curious about the book. Overall, I'm happy with it. The book gives insight into some of the tips and tricks one of the best exploit development companies uses to quickly find and exploit bugs. I think most security professionals will find the book a useful addition to their shelves.

If the book has a fault, it's Justin's concise focus on using python as a tool to rapidly find and exploit bugs. As such the book is in a niche category. It doesn't really fulfill the subtitle "Python Programming for Hackers..." A more accurate subtitle might be "Python programming for expedited bug finding and exploitation". As such it lacks some things I would have expected from a more general book such as:

1. Using scapy or impacket for network tricks
2. Using python for phishing (this is a potential hot topic -- the Metasploit guys are working on a phishing addition for the framework so seeing something similar in python would be a plus).
3. Using python for generic security applications: web scraping, social network enumeration, gluing security tools, etc

All the above would have been nice additions to make the book more complete. As-is the book is very good, but you need to understand that it's not a general purpose python for hacking book. It is a great resource for debugging and automating dynamic analysis of executables.

Now for the super-hardcore exploit guys out there I would have liked to see more depth. I understand why the book didn't go into too much more detail -- the number of interested parties likely decreases exponentially. But I'd have liked to see a few things:

1. Some code that Nico uses to manipulate the heap for use in heap overflows. I do a lot of trial and error with little automated analysis. I assume Immunity does something better and I'd like to see it. In fairness, they do review the !hippie function that's in ID.
2. I'd like to see an easier intro to fuzzing RPC with python. RPC has always been a barrier for me and the Immunity folks have a lot of tools to do this. I'd like to see some more approachable examples than having the source and digging into spike.py
3. MOSDEF is one of things that makes CANVAS special. I'd have loved to see the book build a simpler win32MosdefShellServer

I'm a hardcore security geek and there are probably only a handful of people that would want to see the three items immediately above. So I'm not surprised they're not in the book, and can't fault anyone for that.

Overall, I recommend the book. Look at is a first iteration. It's a good book to help security engineers use python to begin analyzing software vulnerabilities. Primarily it's a book about using python to debug and to a lesser degree fuzz. It's a good insight into how Immunity does things and will help you look at CANVAS code a little easier. For that alone it's definitely worth buying.
Comment | 
Was this review helpful to you?
Most Recent Customer Reviews
5.0 out of 5 stars Best IT Book I ever read
I've read the following books, MCSE -Security, CCIE Security, CompTIA Security, A+, EC-Council Certified Ethical Hacker, EC-Council Computer Hacking Forensics Investigator, & this... Read more
Published 3 months ago by IT Guy
4.0 out of 5 stars Gray Hat Python for Windows
In my career, Python was the first programming language that I have learned. I then learned programming in Java and C++. Read more
Published 5 months ago by Michael Kim
1.0 out of 5 stars Very poorly edited, you WILL have to refer to its website
While the content is very interesting, I'm not sure this book even had an editor. To get most of the code to work, you'll have to refer to the errata on the book's site. Read more
Published 7 months ago by Corey LeBleu
4.0 out of 5 stars Excellent book, incorrectly titled
This is a fantastic book with excellent content, and gave me a huge boost forward in a number of tasks. Read more
Published 8 months ago by dj_nz
5.0 out of 5 stars Interesting & Educational Read
Gray Hat Python was a book recommended to me by a friend that is pretty knowledgeable in the computer security field. After the first chapter I was hooked. Read more
Published 20 months ago by Nisha
3.0 out of 5 stars Great content ... terrible code in Chapter 3
I purchased this book as an attempt to learn more about debugging and hacking using Python.

The content itself is good. Read more
Published on March 10, 2011 by Michael Rand
4.0 out of 5 stars Useful overview of debugging techniques in Python
I found this a very useful overview of how one should debug using Python. I also found it to be a reasonable introduction to developing C extensions for Python.
Published on December 12, 2010 by JoshN
4.0 out of 5 stars You need a lot of background for this book
I recommend knowing the basics of Intel assembly before approaching this book. The code is extremely unPythonic, but it's still extremely useful.
Published on July 2, 2010 by Micseydel
4.0 out of 5 stars Excellent coverage of Python for debugging
I quite enjoyed reading this book. In the first few chapters, it provides useful insights into how 'debuggers' work. Read more
Published on June 8, 2010 by A. Yampolskiy
3.0 out of 5 stars Definitely not for beginners!
Like others on here I eagerly awaited this publication for almost a year. I kept hearing about it in different circles (discussions) and was told "it would be worth your while to... Read more
Published on June 4, 2010 by William Scarbrough
Search Customer Reviews
Only search this product's reviews


Forums

There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
Topic:
First post:
Prompts for sign-in
 





Look for Similar Items by Category