Copied to clipboard
SEC // 01

The OSI Model

Seven layers describing how data travels from an application on one machine to an application on another. In cybersecurity, naming the layer immediately tells you what kind of problem, log signature, or exploit you are dealing with.

The Stack (Physical to Application)

L1 Physical Bits on the wire — electrical signals, fiber optic pulses, radio frequencies. No addresses yet, pure physical transmission.
L2 Data Link Frames between devices on the same local segment. MAC addresses, network switches, and ARP operate here.
L3 Network Packets routed across distinct networks. IPv4/IPv6 addresses, routers, and ICMP live here.
L4 Transport Segments & Datagrams. End-to-end connections (TCP vs UDP) and destination port numbers (0–65535).
L5 Session Establishes, maintains, synchronizes, and terminates dialogues between communicating hosts.
L6 Presentation Syntax, translation, character encoding, compression, and TLS/SSL encryption/decryption.
L7 Application Protocols user software interacts with directly — HTTP/HTTPS, DNS, SSH, FTP, SMTP.

Mnemonic (Bottom-Up): Please Do Not Throw Sausage Pizza Away (Physical, Data Link, Network, Transport, Session, Presentation, Application).

Layer Breakdown & Offensive Security Angles

L1 — Physical Layer Cables, NICs, Hubs, Fiber, Wi-Fi Radio
Handles raw bitstreams over copper, fiber, or air. No MAC or IP addresses exist at this layer.
Security Angle: Hardware wiretaps, physical fiber tapping, RF jamming, Rogue APs / Evil Twin transmitters, rubber ducky USB hardware drops.
L2 — Data Link Layer Frames, MAC Addresses, Switches, ARP, VLANs
Delivers frames within a single local broadcast domain. Network switches learn MAC addresses per port to forward traffic efficiently.
Security Angle: ARP poisoning / MITM, MAC table flooding (fail-open state), VLAN hopping (double-tagging / switch spoofing), DHCP starvation.
L3 — Network Layer Packets, IP Addresses, Routers, Routing Tables, ICMP
Responsible for packet forwarding across multiple hops and routing between disparate subnets.
Security Angle: IP address spoofing, BGP hijacking, ICMP ping sweeps, IP fragmentation evasion, TTL manipulation.
L4 — Transport Layer TCP, UDP, Ports (0–65535), Three-Way Handshake
TCP guarantees delivery and ordering via sequence numbers; UDP provides fast, connectionless delivery.
Security Angle: Port scanning (Nmap SYN scan), SYN flood DDoS, TCP sequence prediction, session hijacking, UDP reflection amplification.
L5 — Session Layer RPC, NetBIOS, Sockets, Session Management
Maintains ongoing dialogs and handles synchronization checkpoints between active endpoints.
Security Angle: Session token prediction, session fixation, SMB relay attacks, NetBIOS name poisoning (Responder).
L6 — Presentation Layer TLS/SSL, ASCII/Unicode, MIME, Compression
Formats and translates data so application layers can parse it; handles encryption and decryption wrappers.
Security Angle: SSL/TLS downgrade attacks (POODLE, BEAST), weak cipher exploitation, certificate validation bypass, Unicode normalization evasion.
L7 — Application Layer HTTP/HTTPS, DNS, SSH, FTP, SMTP
The interface between software and network protocols that end users and web apps communicate with directly.
Security Angle: SQL Injection, XSS, SSRF, IDOR, DNS rebinding, HTTP request smuggling, API abuse, credential stuffing.
Practice Drill 01.1 · L2 Concepts

A switch forwards a frame based on a MAC address, and gets flooded with thousands of fake MAC addresses until its CAM table overflows and it starts broadcasting all packets to every port. What OSI layer is this attack, and what is it called?

Reveal Solution
Layer: L2 (Data Link) — MAC addresses and switch forwarding tables are Layer 2 mechanisms.
Attack Name: MAC Flooding (CAM Table Overflow) — Turns an intelligent switch into a dumb hub, allowing an attacker to sniff all traffic across the LAN without active ARP poisoning.
Practice Drill 01.2 · Transport Scanning

You run nmap -sS target.com and it discovers that port 443 is open. Which OSI layers were directly involved in producing this result?

Reveal Solution
Layers Involved: L3 (Network) and L4 (Transport).
Why: L3 routes IP packets to the target. L4 handles the TCP SYN packet and reads the SYN-ACK response on port 443. L7 is not touched because Nmap aborts with an RST before establishing a TLS/HTTPS handshake.
SEC // 02

TCP/IP Model & the Three-Way Handshake

The practical model the internet actually runs on. 4 layers instead of 7 — OSI is the conceptual reference, while TCP/IP is the implementation stack.

TCP/IP Layer Maps to OSI Protocols & Examples
Application L5, L6, L7 HTTP, HTTPS, DNS, SSH, FTP, SMTP
Transport L4 TCP (reliable), UDP (fast/stateless)
Internet L3 IPv4, IPv6, ICMP, ARP (L2/L3 hybrid)
Network Access L1, L2 Ethernet, 802.11 Wi-Fi, MAC frames, Fiber

TCP vs UDP Comparison

Property TCP (Transmission Control Protocol) UDP (User Datagram Protocol)
Connection State Connection-oriented (3-way handshake required) Connectionless (fire and forget)
Reliability Guaranteed delivery, acknowledgments, retransmission Best-effort, packets can be dropped or arrive out of order
Header Overhead 20–60 bytes (flags, sequence numbers, checksums) 8 bytes (minimal header, low latency)
Primary Uses HTTPS, SSH, SFTP, REST APIs, Database connections DNS queries, VoIP, Video streaming, DHCP, SNMP

The TCP Three-Way Handshake (SYN → SYN-ACK → ACK)

// TCP_3_WAY_HANDSHAKE.RAW
Client                                            Server
  |                                                  |
  | -------------- [SYN: Seq = X] -----------------> |   "Client initiating connection, my sequence is X"
  |                                                  |
  | <------- [SYN-ACK: Seq = Y, Ack = X+1] --------- |   "Server agrees, my sequence is Y, acknowledging X+1"
  |                                                  |
  | -------------- [ACK: Ack = Y+1] ---------------> |   "Client acknowledges Y+1, connection established!"
  |                                                  |
  | <============= Full Duplex Stream =============> |
Why This Matters for Security

Nmap's default SYN scan (-sS) sends a SYN, reads the SYN-ACK to verify the port is open, and immediately transmits an RST packet without sending the final ACK. This "half-open" scan is fast and historic logging engines only recorded completed connections.

Practice Drill 02.1 · Half-Open Scans

In a Wireshark capture, you see a host send a SYN packet, the server reply with SYN-ACK, but no final ACK is ever returned. What are the two most likely explanations?

Reveal Solution
Explanation 1: Port Reconnaissance (SYN Stealth Scan): A security scanner like Nmap intentionally avoids sending the final ACK to keep connections half-open.
Explanation 2: Network Issue: Stateful firewall silently dropping outbound ACK packets, or high packet loss on the return route.
Practice Drill 02.2 · UDP Amplification

Why do attackers prefer UDP over TCP when performing DNS or NTP reflection DDoS amplification attacks?

Reveal Solution
Reason: Lack of Handshake & Source Verification: UDP is stateless and does not perform a 3-way handshake. An attacker can spoof the victim's IP as the source address. When the open resolver sends back a large DNS response, it floods the victim, amplifying attack traffic up to 50x–100x.
SEC // 03

IP Addressing & CIDR

An IPv4 address consists of 32 bits arranged in four 8-bit octets (0–255), separated by dots.

// IPV4_BINARY_REPRESENTATION
Decimal:     192    .    168    .     1     .     10
Binary:   11000000  .  10101000 .  00000001 .  00001010  (32 total bits)

Private vs. Public IPv4 Ranges (RFC 1918)

Range (RFC 1918) CIDR Block Total Addresses Typical Environment
10.0.0.0 – 10.255.255.255 10.0.0.0/8 16,777,216 Large enterprise networks, cloud VPCs
172.16.0.0 – 172.31.255.255 172.16.0.0/12 1,048,576 Corporate branches, Docker networks
192.168.0.0 – 192.168.255.255 192.168.0.0/16 65,536 Home networks, SOHO routers
127.0.0.0 – 127.255.255.255 127.0.0.0/8 16,777,216 Loopback (Localhost: 127.0.0.1)
169.254.0.0 – 169.254.255.255 169.254.0.0/16 65,536 APIPA (DHCP assignment failure) / AWS IMDS
Internal Pentest Reconnaissance Clue

When conducting internal network penetration tests, discovering 10.x.x.x or 172.16–31.x.x confirms you have breached the internal perimeter and are inside private infrastructure. Finding 169.254.169.254 is the AWS Instance Metadata Service (IMDS) — a primary target for SSRF credential theft.

CIDR Notation & Usable Host Calculation

The slash number (/24) denotes how many bits from the left represent the network prefix. The remaining bits belong to the host portion.

Formula: Usable Hosts = 2(32 - CIDR) - 2 (Subtracting Network ID and Broadcast Address).

CIDR Subnet Mask Host Bits (H) Total IPs (2H) Usable Hosts (2H - 2)
/24255.255.255.08256254
/25255.255.255.1287128126
/26255.255.255.19266462
/27255.255.255.22453230
/28255.255.255.24041614
/29255.255.255.248386
/30255.255.255.252242 (Point-to-point links)
/32255.255.255.255011 (Single host route)
Practice Drill 03.1 · Scope Verification

Is the IP address 172.28.104.12 a public or private IP?

Reveal Solution
Answer: Private — It resides within the RFC 1918 Class B range of 172.16.0.0/12 (172.16.0.0 through 172.31.255.255).
Practice Drill 03.2 · Host Calculation

How many usable host IP addresses are available on a /29 subnet?

Reveal Solution
Calculation: 32 - 29 = 3 host bits. 23 - 2 = 8 - 2 = 6 usable host addresses.
SEC // 04

Subnetting & CIDR — Worked Practice

The core mental math method to calculate Network Address, Broadcast Address, and Usable Ranges without relying on an online calculator.

5-Step Mental Subnetting Algorithm

  1. Identify the Interesting Octet: Determine which octet contains the split between network and host bits.
  2. Find the Subnet Mask Value: e.g., /26 = 2 bits on in 4th octet = 128 + 64 = 192.
  3. Calculate Block Size (Magic Number): Block Size = 256 - Mask Value (256 - 192 = 64).
  4. Count in Multiples of Block Size: 0, 64, 128, 192... to locate the subnet boundary containing the target IP.
  5. Derive Addresses:
    • Network ID: The base multiple.
    • Broadcast Address: Next block multiple minus 1.
    • Usable Range: Network ID + 1 through Broadcast - 1.
// WORKED_EXAMPLE_192.168.1.130_26
Worked Example: 192.168.1.130/26

1. Mask for /26 = 255.255.255.192 (Interesting octet is the 4th octet)
2. Block size = 256 - 192 = 64
3. Blocks: 0, 64, 128, 192...
   130 falls between 128 and 192 -> Network = 192.168.1.128

Results:
  Network Address:    192.168.1.128
  First Usable IP:    192.168.1.129
  Last Usable IP:     192.168.1.190
  Broadcast Address:  192.168.1.191 (192 - 1)
Practice Drill 04.1 · Subnet Boundaries

Find the network address, broadcast address, and usable host range for 10.0.0.75/28.

Reveal Solution
1. Mask for /28: 255.255.255.240
2. Block Size: 256 - 240 = 16
3. Blocks: 0, 16, 32, 48, 64, 80... 75 falls between 64 and 80.
Network Address: 10.0.0.64
Usable Host Range: 10.0.0.65 – 10.0.0.78
Broadcast Address: 10.0.0.79
Practice Drill 04.2 · Same Subnet Check

Are hosts 192.168.10.60/28 and 192.168.10.68/28 on the same subnet?

Reveal Solution
Block Size: 16. Blocks are 0, 16, 32, 48, 64, 80...
Host 1 (.60): Lies in subnet 192.168.10.48/28 (range: .49 to .62).
Host 2 (.68): Lies in subnet 192.168.10.64/28 (range: .65 to .78).
Result: No, different subnets. They require a router to communicate.
Practice Drill 04.3 · Subnet Partitioning

You are assigned 192.168.5.0/24 and instructed to split it into 4 equal subnets for SecOps, Engineering, HR, and Management. What is the new CIDR and what are the 4 subnets?

Reveal Solution
Borrow Bits: To create 4 subnets, borrow 2 bits (22 = 4) -> New CIDR = /26.
Block Size: 256 - 192 = 64.
Subnet 1: 192.168.5.0/26 (Usable: .1 to .62)
Subnet 2: 192.168.5.64/26 (Usable: .65 to .126)
Subnet 3: 192.168.5.128/26 (Usable: .129 to .190)
Subnet 4: 192.168.5.192/26 (Usable: .193 to .254)
Practice Drill 04.4 · Class B Split

A host has IP 172.16.14.200 with mask 255.255.240.0. What CIDR is that, and what is the network address?

Reveal Solution
CIDR: 255.255.240.0 has 4 bits in 3rd octet = 16 + 4 = /20.
Block Size: 256 - 240 = 16 in 3rd octet. Blocks: 0, 16, 32... 14 falls between 0 and 16.
Network Address: 172.16.0.0/20
SEC // 05

NAT & DHCP

The two mechanisms powering LAN connectivity: NAT allows thousands of private IP endpoints to share public internet routes, while DHCP assigns IP configurations dynamically.

NAT Flavors

NAT Type Mapping Relationship Use Case
Static NAT 1 Private IP ↔ 1 Fixed Public IP Exposing internal web/mail servers publicly
Dynamic NAT Many Private IPs ↔ Pool of Public IPs Temporary public IP mapping on demand
PAT (NAT Overload) Thousands of Private IPs ↔ 1 Public IP (Unique Ports) Standard residential and enterprise office egress

The DHCP DORA Handshake

// DHCP_DORA_SEQUENCE
Client (0.0.0.0:68)                               DHCP Server (255.255.255.255:67)
  |                                                                   |
  | -------- 1. DHCP Discover (Layer 2 & 3 Broadcast) --------------> | "Does any server have an IP for me?"
  |                                                                   |
  | <------- 2. DHCP Offer (Unicast / Broadcast) -------------------- | "You can lease 192.168.1.50 with /24"
  |                                                                   |
  | -------- 3. DHCP Request (Broadcast confirmation) --------------> | "I accept 192.168.1.50 from Server A"
  |                                                                   |
  | <------- 4. DHCP Ack (Final Acknowledgement) -------------------- | "Confirmed! Lease valid for 24 hours."
Practice Drill 05.1 · Rogue DHCP MITM

An attacker connected to a corporate Wi-Fi network spawns a rogue DHCP server that replies to DHCP Discover broadcasts faster than the genuine router, assigning the attacker's laptop as the Default Gateway and DNS. What is this attack called and what does it accomplish?

Reveal Solution
Attack Name: Rogue DHCP Server / DHCP Spoofing Attack.
Impact: Complete Man-in-the-Middle (MITM). All outbound user web traffic and DNS queries route directly through the attacker's machine for packet interception and credential harvesting.
Practice Drill 05.2 · PAT Scalability

A company has 300 internal employee laptops but only owns 5 public IP addresses. How is this possible?

Reveal Solution
Answer: PAT (Port Address Translation / NAT Overload) — All 300 private IPs share the public IP pool, differentiated by unique source port numbers in the router's state translation table.
SEC // 06

Core Protocols Matrix

Memorize the port number, transport layer protocol (TCP/UDP), primary purpose, and plaintext vulnerability status for each foundational protocol.

Protocol Port Transport Purpose Security State
DNS 53 UDP (TCP for large zones) Domain Name to IP address resolution Plaintext
DHCP 67 / 68 UDP Automatic IP addressing & configuration Plaintext
HTTP 80 TCP Unencrypted Hypertext Web Traffic Plaintext
HTTPS 443 TCP TLS/SSL Encrypted Web Traffic Encrypted
SSH 22 TCP Encrypted remote shell administration Encrypted
FTP 20 / 21 TCP File transfer (Control on 21, Data on 20) Plaintext
SMTP 25, 587 TCP Email routing and client submission STARTTLS Opt

DNS Resolution Flow (Recursive Query Hierarchy)

// RECURSIVE_DNS_RESOLUTION_TRACE
1. Client requests "sub.example.com" -> Checks local OS DNS cache & /etc/hosts
2. Queries Recursive Resolver (e.g., 1.1.1.1, 8.8.8.8, or ISP)
3. Resolver queries Root Nameserver (".") -> Root returns .com TLD Server IP
4. Resolver queries .com TLD Nameserver -> TLD returns Authoritative NS for example.com
5. Resolver queries Authoritative NS for example.com -> Receives A Record (93.184.216.34)
6. Resolver caches record with TTL and returns answer to Client
Practice Drill 06.1 · Sniffing Cleartext

During packet inspection, you notice an employee accessing a payroll site over port 80 and sending a POST request with authentication parameters. What is the vulnerability?

Reveal Solution
Vulnerability: Plaintext Credential Transmission over HTTP (CWE-319).
Impact: Any passive listener on the local subnet or network hop can read the username and cleartext password directly out of the TCP packet payload using Wireshark or tcpdump. The service must enforce HTTPS on port 443 with HSTS headers.
Practice Drill 06.2 · Port Mapping

Match each scenario to a protocol: (a) A sysadmin remotely manages a Linux server, (b) A mail client sends a message to a recipient, (c) A browser resolves "google.com" to an IP.

Reveal Solution
(a) SSH (Port 22 / TCP) — Encrypted remote management.
(b) SMTP (Port 25 / 587 TCP) — Mail transfer agent submission.
(c) DNS (Port 53 / UDP) — Domain resolution.
Practice Drill 06.3 · Transport Selection

Why does DNS predominantly operate over UDP instead of TCP?

Reveal Solution
Answer: DNS queries are small, fast, and high-volume. Avoiding the 3-way handshake reduces latency drastically. TCP is only used as a fallback for large DNSSEC zone transfers or replies exceeding 512 bytes.
SEC // 07

Routing, ARP & VLANs

Switches move frames within a local broadcast domain via MAC addresses. Routers forward packets between subnets using IP routing tables. ARP bridges the two.

ARP (Address Resolution Protocol) Mechanism

// ARP_RESOLUTION_CYCLE
Host A (192.168.1.10) wants to send frame to Host B (192.168.1.1)

1. ARP Request (Broadcast):
   "Who has 192.168.1.1? Tell 192.168.1.10 (MAC: AA:AA:AA:AA:AA:AA)"
   Destination MAC: FF:FF:FF:FF:FF:FF (Every device on the switch receives this)

2. ARP Reply (Unicast):
   "192.168.1.1 is at BB:BB:BB:BB:BB:BB"
   Host A saves (192.168.1.1 -> BB:BB:BB:BB:BB:BB) in its local ARP cache table.
Attack Spotlight: ARP Poisoning / Spoofing

ARP is completely stateless and unauthenticated. An attacker can send unsolicited gratuitous ARP replies claiming "192.168.1.1 (Gateway) is at Attacker-MAC". All local endpoints overwrite their ARP tables, routing their traffic directly through the attacker before forwarding it to the genuine router.

Simplified Routing Table Lookup

Destination Prefix Next Hop Interface
192.168.1.0/24 Directly Connected eth0
10.0.0.0/8 192.168.1.254 eth0
0.0.0.0/0 (Default Gateway) 203.0.113.1 eth1 (WAN)
Practice Drill 07.1 · Inter-VLAN Routing

A security analyst is plugged into a switch port on VLAN 10 (Engineering) and needs to scan a database server on VLAN 30 (Production Database) in the same physical datacenter rack. Why can't the Layer-2 switch facilitate this alone?

Reveal Solution
Reason: VLANs create isolated Layer-2 broadcast domains. A standard switch only forwards frames within the same VLAN ID. Inter-VLAN communication requires a Layer-3 Router or Multilayer Switch to perform IP packet routing and apply Access Control Lists (ACLs).
Practice Drill 07.2 · Unsolicited ARP Replies

In Wireshark you notice one machine sending a flood of unsolicited ARP replies claiming to be the default gateway to multiple hosts that never asked. What is happening and what is the attacker's likely next move?

Reveal Solution
Diagnosis: ARP Cache Poisoning / MITM Attack.
Next Move: The attacker will sniff plaintext credentials, session tokens, or perform SSL stripping on the hijacked traffic.
SEC // 08

Wireshark — Reading Packets Live

Everything in networking is abstract theory until you inspect raw bytes on the wire. Wireshark decodes and visualizes packets layer by layer.

Essential Wireshark Display Filters (1-Click Copy)

dns

Isolate standard DNS queries and response records.

http.request.method == "POST"

Catch form data submissions and API payloads in plaintext.

tcp.flags.syn == 1 && tcp.flags.ack == 0

Spot port scanning signatures and SYN flood attempts.

arp

Filter ARP requests/replies to detect ARP spoofing.

frame contains "password"

Search raw payload bytes for unencrypted credentials.

tcp.port == 22

Monitor SSH management sessions and brute force attempts.

Practice Drill 08.1 · Display Filter Syntax

You want to isolate every TCP SYN packet (without the ACK flag) going to port 22 across an entire subnet to spot someone port-scanning SSH. Write the Wireshark display filter.

Reveal Solution
Filter: tcp.port == 22 && tcp.flags.syn == 1 && tcp.flags.ack == 0
Practice Drill 08.2 · Spoofing Signature

You suspect ARP spoofing on your local network. What single filter narrows the capture down, and what specifically would you look for once filtered?

Reveal Solution
Filter: arp
Indicators: Look for duplicate IP addresses claimed by different MAC addresses, or an abnormally high volume of unsolicited ARP replies without preceding requests.
SEC // 09

7-Day Mastery Checklist

Check these off as you complete your daily drills. Your progress is automatically saved in your browser's local storage.

Phase 01 Completion Progress 0 of 11 Completed (0%)
Next in Roadmap

Phase 02 · Linux Internals & Scripting

Filesystem permissions, SUID/SGID exploitation, process forensics (/proc), and automated Bash tooling.

Explore 10-Phase Pipeline