Black Hat Python 2nd Edition on Kali Linux 2026.2 – Full Lab Setup

I’m going through Black Hat Python 2nd Edition front to back, and I just finished my initial lab setup on Kali Linux 2026.2.

Lab Environment

  • OS: Kali GNU/Linux Rolling 2026.2
  • Python: 3.13 in a virtual environment
  • Project Folder: ~/bhp

Project Structure Created

~/bhp/
├── bhp_env/                  # Virtual Environment
├── bhp2nEd/                  # Cloned code examples
├── chapter01/
├── chapter02/
... up to chapter13

Basic TCP Client (Chapter 1)

import sockettarget_host = "www.google.com"
target_port = 80
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((target_host, target_port))
client.send(b"GET / HTTP/1.1\r\nHost: google.com\r\n\r\n")
response = client.recv(4096)
print(response.decode())
client.close()

Multi-threaded Port Scanner

Successfully scanned scanme.nmap.org and found open ports:22 (SSH) and 80 (HTTP)

Next up: Improving the scanner with banner grabbing and argument parsing.

I’ll be posting regular updates as I work through the book. Follow along if you’re also learning offensive Python!

#BlackHatPython #KaliLinux #PythonForHackers