Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Justin Seitz

Rating No ratings yet

When it comes to creating powerful and effective hacking tools, Python is the language of choice for most security analysts. But just how does the magic happen? In Black Hat Python, the latest from Justin Seitz (author of the best-selling Gray Hat Python), you’ll explore the darker side of Python’s capabilities—writing network sniffers, manipulating packets, infecting virtual machines, creating stealthy trojans, and more. You’ll learn how to: –Create a trojan command-and-control using GitHub –Detect sandboxing and automate com­mon malware tasks, like keylogging and screenshotting –Escalate Windows privileges with creative process control –Use offensive memory forensics tricks to retrieve password hashes and inject shellcode into a virtual machine –Extend the popular Burp Suite web-hacking tool –Abuse Windows COM automation to perform a man-in-the-browser attack –Exfiltrate data from a network most sneakily Insider techniques and creative challenges throughout show you how to extend the hacks and how to write your own exploits. When it comes to offensive security, your ability to create powerful tools on the fly is indispensable. Learn how in Black Hat Python. Uses Python 2

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A hands-on field manual for turning Python into a working offensive-security toolkit—sniffers, proxies, trojans, and Windows post-exploitation tricks—written for pentesters who learn by building. Read it if you already know some Python and want to understand how real attack tooling is assembled from sockets, raw packets, and OS APIs. 【Book Arc】 - **Opening (~0%–10%)**: Sets up a Kali-based hacking VM and a Python IDE (WingIDE), then immediately builds the smallest useful primitives—a TCP client and server—establishing the "write a tool on the fly" mindset that drives the whole book. - **Early (~10%–30%)**: Extends those primitives into a reusable netcat-style tool (command execution, file upload, shell) and a TCP proxy, then moves into Paramiko-based SSH and raw-socket sniffing, teaching packet decoding with `ctypes` and C-struct mapping. - **Middle (~30%–55%)**: Shifts to Scapy for higher-level packet work—sniffing, ARP poisoning/MITM, and credential capture—showing how to escalate from passive observation to active network manipulation. - **Late (~55%–85%)**: Turns to the host: Windows privilege escalation via process control, offensive memory forensics (hash retrieval, shellcode injection), and COM automation for man-in-the-browser attacks. - **Ending (~85%–100%)**: Closes on stealth and exfiltration—sandbox detection, keylogging/screenshotting automation, GitHub-based command-and-control, and Burp Suite extension work—tying individual tools into end-to-end tradecraft. 【Book Arc note】The excerpts sample the opening through roughly the middle; later-chapter coverage is inferred from the book's stated table of contents, not from detailed excerpts. 【Key Takeaways】 - **Small primitives compound into real tools** (Opening): A bare TCP client and threaded server become a netcat replacement with command execution, upload, and shell modes—the book's core teaching pattern is "build the smallest piece, then extend it." - **Know your assumptions** (Opening): The first TCP client assumes the connection always succeeds and the server always waits for the client to speak first; the author flags these explicitly, training you to see where tools break in the wild. - **Raw sockets demand structure literacy** (Early–Middle): Decoding IP headers means mapping C structs to Python via `ctypes`, including bit fields—this is where low-level networking intuition is built. - **Scapy is the force multiplier** (Middle): A few lines of `sniff()` with BPF filters replace hand-rolled parsers; the book uses it for mail-credential capture and PCAP collection, and pairs it with ARP poisoning for MITM. - **Proxies are assessment instruments** (Early): A TCP proxy isn't just for bouncing traffic—it's how you inspect and fuzz network-based software, with hex dumps revealing protocol behavior (e.g., FTP banners and auth exchanges). - **Paramiko unlocks SSH-level tooling** (Early): Standing up a Paramiko SSH server/client pair shows how to build authenticated command channels rather than plain sockets. - **Offense crosses into the OS layer** (Late): Windows process control, memory forensics, and COM automation represent the pivot from network scripts to host-level exploitation—the excerpts do not detail these chapters. - **Stealth and exfiltration are design goals, not afterthoughts** (Ending): Sandbox detection, GitHub C2, and covert data exfiltration frame tooling as tradecraft, though the excerpts do not cover the specifics. 【Reading Tips】 - **Code along, don't just read**: Every concept arrives as a script; typing and running them (in an isolated VM) is where the learning happens—passive reading yields little. - **Deep-read the opening third**: The socket, proxy, and sniffing chapters establish patterns reused throughout; skim only if you're already fluent in raw sockets and Scapy. - **Mind the Python 2 gap**: The book uses Python 2 (`print` statements, `raw_input`); expect to mentally translate to Python 3 or run a legacy environment. - **Treat later chapters as guided labs**: Windows/memory/COM material is environment-sensitive—budget time for VM setup and expect platform-specific friction. - **Extract the method, not just the exploit**: The transferable skill is the build-extend-test loop and assumption-spotting, which outlasts any single tool. 【Coverage Limits】 This guide is built from stratified excerpts concentrated in the opening through middle chapters (setup, sockets, proxying, SSH, sniffing, Scapy); the Windows escalation, memory forensics, COM, and exfiltration chapters are represented only by the book's stated contents, so their specifics are not verified here.
Page 8
ion to keep pushing through no matter what. I love you all. To all my folks at Immunity (I would list each of you here if I had the room): thanks for tolerat...
View in text
Excerpt 2
client that is connected to us. The exception-handling code will catch generic errors and return back a message letting you know that the command failed. Now...
View in text
Excerpt 3
he bh_sshserver is sent to the bh_sshclient and executed on the bh_sshclient, and the output is returned to bh_sshserver. Let’s give it a go. Figure 2-3. SSH...
View in text
Excerpt 4
nd store it in a PCAP file for analysis, which we will also demonstrate. To get a feel for Scapy, let’s start by building a skeleton sniffer that simply diss...
View in text
Excerpt 5
artially downloaded or their format might not be supported. (I’ll leave building a robust image extraction and validation routine as a homework assignment fo...
View in text
Excerpt 6
whenever a tag is encountered. In particular, we’re looking for HTML input tags ➋ and our main processing occurs when we determine that we have found one. We...
View in text
Excerpt 7
tname is_ip = re.match("[0-9]+(?:\.[0-9]+){3}", host) ➋ if is_ip: ip_address = host domain = False else: ip_address = socket.gethostbyname(host) domain = Tru...
View in text
Excerpt 8
print "[*] Attempting to retrieve %s" % fullname ➊ new_library = get_file_contents("modules/%s" % fullname) if new_library is not None: ➋ self.c
View in text
Tags
AI categories
CybersecurityPythonProgramming
ISBN: 1593275900
Publisher: No Starch Press
Publish Year: 2014
Language: English
Pages: 195
File Format: PDF
File Size: 3.0 MB
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.

Generating text preview…