FOREWORD
PREFACE
ACKNOWLEDGMENTS
1. SETTING UP YOUR PYTHON ENVIRONMENT
Installing Kali Linux
Setting Up Python 3
Installing an IDE
Code Hygiene
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
3. WRITING A SNIFFER 35
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
4. OWNING THE NETWORK WITH SCAPY 53
Stealing Email Credentials
Kicking the Tires
ARP Cache Poisoning with Scapy
Kicking the Tires
pcap Processing
Kicking the Tires
5. WEB HACKERY
Using Web Libraries
The urllib2 Library for Python 2x
The urllib Library for Python 3x
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
6. EXTENDING BURP PROXY 93
Setting Up
Burp Fuzzing
Kicking the Tires
Using Bing for Burp
Kicking the Tires
Turning Website Content into Password Gold
Kicking the Tires
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
8. COMMON TROJANING TASKS ON WINDOWS
Keylogging for Fun and Keystrokes
Kicking the Tires
Taking Screenshots
Pythonic Shellcode Execution
Kicking the Tires
Sandbox Detection
9. FUN WITH EXFILTRATION 139
Encrypting and Decrypting Files
Email Exfiltration
File Transfer Exfiltration
Exfiltration via a Web Server
Putting It All Together
Kicking the Tires
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
11. OFFENSIVE FORENSICS
Installation
General Reconnaissance
User Reconnaissance
Vulnerability Reconnaissance
The volshell Interface
Custom Volatility Plug-Ins
Kicking the Tires
Onward!
INDEX