Fully-updated for Python 3, the second edition of this worldwide bestseller (over 100,000 copies sold) explores the stealthier side of programming and brings you all new strategies for your hacking projects. When it comes to creating powerful and effective hacking tools, Python is the language of choice for most security analysts. In Black Hat Python, 2nd Edition, you’ll explore the darker side of Python’s capabilities—writing network sniffers, stealing email credentials, brute forcing directories, crafting mutation fuzzers, infecting virtual machines, creating stealthy trojans, and more. The second edition of this bestselling hacking book contains code updated for the latest version of Python 3, as well as new techniques that reflect current industry best practices. You’ll also find expanded explanations of Python libraries such as ctypes, struct, lxml, and BeautifulSoup, and dig deeper into strategies, from splitting bytes to leveraging computer-vision libraries, that you can apply to future hacking projects. You’ll learn how to: • Create a trojan command-and-control using GitHub • Detect sandboxing and automate common 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 When it comes to offensive security, your ability to create powerful tools on the fly is indispensable. Learn how with the second edition of Black Hat Python. New to this edition: All Python code has been updated to cover Python 3 and includes updated libraries used in current Python applications. Additionally, there are more in-depth explanations of the code and the programming techniques have been updated to current, common tactics. Examples of new material that you'll learn include how to sniff network traffic, evade anti-virus software, brute-force web applications, and set up a command-and-control (C2) system using GitHub. Foreword Preface Acknowledgments Chapter 1: Setting Up Your Python Environment Installing Kali Linux Setting Up Python 3 Installing an IDE Code Hygiene Chapter 2: Basic Networking Tools Python Networking in a Paragraph TCP Client UDP Client TCP Server Replacing Netcat Kicking the Tires Building a TCP Proxy Kicking the Tires SSH with Paramiko Kicking the Tires SSH Tunneling Kicking the Tires Chapter 3: Writing a Sniffer Building a UDP Host Discovery Tool Packet Sniffing on Windows and Linux Kicking the Tires Decoding the IP Layer The ctypes Module The struct Module Writing the IP Decoder Kicking the Tires Decoding ICMP Kicking the Tires Chapter 4: Owning the Network with Scapy Stealing Email Credentials Kicking the Tires ARP Cache Poisoning with Scapy Kicking the Tires pcap Processing Kicking the Tires Chapter 5: Web Hackery Using Web Libraries The urllib2 Library for Python 2.x The urllib Library for Python 3.x The requests Library The lxml and BeautifulSoup Packages Mapping Open Source Web App Installations Mapping the WordPress Framework Testing the Live Target Kicking the Tires Brute-Forcing Directories and File Locations Kicking the Tires Brute-Forcing HTML Form Authentication Kicking the Tires Chapter 6: Extending Burp Proxy Setting Up Burp Fuzzing Kicking the Tires Using Bing for Burp Kicking the Tires Turning Website Content into Password Gold Kicking the Tires Chapter 7: GitHub Command and Control Setting Up a GitHub Account Creating Modules Configuring the Trojan Building a GitHub-Aware Trojan Hacking Python’s import Functionality Kicking the Tires Chapter 8: Common Trojaning Tasks on Windows Keylogging for Fun and Keystrokes Kicking the Tires Taking Screenshots Pythonic Shellcode Execution Kicking the Tires Sandbox Detection Chapter 9: Fun with Exfiltration Encrypting and Decrypting Files Email Exfiltration File Transfer Exfiltration Exfiltration via a Web Server Putting It All Together Kicking the Tires Chapter 10: Windows Privilege Escalation Installing the Prerequisites Creating the Vulnerable BlackHat Service Creating a Process Monitor Process Monitoring with WMI Kicking the Tires Windows Token Privileges Winning the Race Kicking the Tires Code Injection Kicking the Tires Chapter 11: Offensive Forensics Installation General Reconnaissance User Reconnaissance Vulnerability Reconnaissance The volshell Interface Custom Volatility Plug-Ins Kicking the Tires Onward! Index Fully-updated, second edition of this worldwide bestseller with over 100,000 copies sold. When it comes to creating powerful and effective hacking tools, Python is the language of choice for most security analysts. In Black 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. The second edition of this bestseller has been updated to cover Python 3, and the authors have added coverage of new modules and techniques that reflect current industry best practices. You will find expanded explanations of strategies, from splitting bytes to leveraging computer-vision libraries, that you can apply to future hacking projects. You will see how the hacking techniques work and create your own personal arsenal of readable and maintainable code using clean coding techniques as you learn how to: - Create a trojan command-and-control using GitHub - Detect sandboxing and automate common 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 When it comes to offensive security, your ability to create powerful tools on the fly is indispensable. Learn how with Black Hat Python . New to this edition All Python code has been updated to cover Python 3 and includes updated libraries used in current Python applications. Additionally, there are more in-depth explanations of the code and the programming techniques have been updated to current, common tactics. Examples of new material that readers will learn include how to sniff network traffic, evade anti-virus software, brute-force web applications, and set up a command-and-control (C2) system using GitHub. "When it comes to creating powerful and effective hacking tools, Python is the language of choice for most security analysts. In this second edition of the bestselling Black Hat Python, you'll explore the darker side of Python's capabilities: everything from writing network sniffers, stealing email credentials, and bruteforcing directories to crafting mutation fuzzers, investigating virtual machines, and creating stealthy trojans. All of the code in this edition has been updated to Python 3.x. You'll also find new coverage of bit shifting, code hygiene, and offensive forensics with the Volatility Framework as well as expanded explanations of the Python libraries ctypes, struct, lxml, and BeautifulSoup, and offensive hacking strategies like splitting bytes, leveraging computer vision libraries, and scraping websites. You'll even learn how to: " Create a trojan command-and-control server using GitHub " Detect sandboxing and automate common malware tasks like keylogging and screenshotting " Extend the Burp Suite web-hacking tool " Escalate Windows privileges with creative process control " Use offensive memory forensics tricks to retrieve password hashes and find vulnerabilities on a virtual machine " Abuse Windows COM automation " Exfiltrate data from a network undetected When it comes to offensive security, you need to be able to create powerful tools on the fly. Learn how with Black Hat Python."--Amazon.com