Python · SQL · Web Dev · Java · AI/ML tracks launching soon — your one platform for all of IT

Network Attacks

From ARP spoofing to BGP hijacking, from SYN floods to SSL stripping: how attacks exploit protocol design, and what defenders can do about it.

30–42 min May 2026
Chapter 1

The Attacker's Advantage: Protocols Built on Trust

1988. Cornell graduate student Robert Morris launches the first major internet worm. It exploits sendmail, fingerd, and rsh — all protocols that trusted each other by hostname. No authentication, no authorization, just a hostname check. The worm infects 6,000 machines — 10% of the internet. Morris is convicted under the Computer Fraud and Abuse Act. The lesson the internet took 30 years to learn: trust must be earned, not assumed.

Most networking protocols were designed in an era when the internet was a small, trusted research network. The foundational assumptions — that routers won't lie, that DNS responses are honest, that ARP is reliable, that source IPs are authentic — were reasonable in 1981 but catastrophically wrong in 2026.

Network attacks exploit the gap between protocol design assumptions and deployment reality. Understanding these attacks is not about learning to cause harm — it is about understanding why security controls work, where they fail, and how to build systems that survive hostile environments.

WARN: This module covers attack techniques for defensive and educational purposes. Understanding how attacks work is essential for designing effective defenses, conducting authorized penetration tests, and passing security certifications (CISSP, CEH, OSCP). Do not use this knowledge to attack systems you do not own or do not have explicit written permission to test.
WOW: The original TCP specification (RFC 793, 1981) contains no mention of security. IP (RFC 791) was designed to route packets to their destination, not to verify they came from where they claim. ARP (RFC 826, 1982) explicitly states it has no authentication mechanism. These were not oversights — they were deliberate tradeoffs for simplicity in a trusted environment. The problem is that the environment changed.

Chapter 2

Reconnaissance: Know Your Target

Sun Tzu wrote: "Know your enemy and know yourself; in a hundred battles you will never be defeated." Every real attack begins with reconnaissance — gathering information about the target network, its services, its topology, and its vulnerabilities. Defenders who understand reconnaissance techniques can detect them in progress and reduce information leakage.

Port Scanning

Port scanning determines which TCP/UDP ports are open on a host. Each open port reveals a running service — each service has a version, each version has known vulnerabilities. Nmap is the canonical tool:

# TCP SYN scan (half-open, stealthy — no full connection)
nmap -sS -p 1-65535 192.168.1.0/24

# Version detection (-sV) + OS fingerprinting (-O)
nmap -sV -O 192.168.1.1

# Aggressive scan (all detection, scripts, traceroute)
nmap -A 192.168.1.1

# UDP scan (slower, requires root)
nmap -sU -p 53,123,161,500 192.168.1.1

# Timing: -T0 (paranoid, slow) to -T5 (insane, noisy)
nmap -T2 -sS 10.0.0.0/24   # quieter scan

# Detect scan with IDS: Suricata rule
# alert tcp any any -> $HOME_NET any (msg:"Port Scan detected"; flags:S; threshold: type both, track by_src, count 10, seconds 60; sid:1001)

Network Enumeration

Beyond port scanning, attackers enumerate:

DNS enumeration: zone transfers, brute-force subdomain discovery, reverse DNS for IP ranges. Tools: dig axfr, dnsenum, Subfinder.

SNMP enumeration: if SNMP community strings are guessable, the entire device configuration is exposed.

Banner grabbing: connecting to services and reading their version banners. SSH, HTTP headers, FTP 220 banners all reveal software versions.

OSINT: Shodan/Censys for internet-exposed services, Whois for domain registration, BGP routing tables for IP ownership.

Defense Against Reconnaissance

Reduce information leakage: suppress banner messages (no SSH version in banner, no Server: header in HTTP, no SMTP banner revealing MTA version). Block SNMP from internet. Disable DNS zone transfers. Deploy honeypot ports — any connection to a non-running service triggers an alert.


Chapter 3

Layer 2 Attacks: Poisoning the Local Network

An attacker sits in a coffee shop. They connect to the Wi-Fi. Their laptop sees 30 other devices on the /24 subnet — laptops, phones, tablets. They run bettercap, start ARP spoofing the gateway, and enable HTTP interception. Within 2 minutes, a bank employee connects to an internal app via HTTP. The credentials flow through the attacker's machine in plaintext. The employee never notices a thing — they're connected to the right network; it's just that every packet takes a detour.

ARP Spoofing in Detail

ARP (Address Resolution Protocol) maps IP addresses to MAC addresses within a broadcast domain. The protocol has no authentication — any host can claim any IP-to-MAC mapping. An attacker exploits this by sending unsolicited (gratuitous) ARP replies:

# Gratuitous ARP: "I am 192.168.1.1, MAC is AA:BB:CC:DD:EE:FF"
# Sent to broadcast — all hosts update their ARP caches

# Attacker runs:
arpspoof -i eth0 -t 192.168.1.50 192.168.1.1  # tell victim: gateway MAC = attacker
arpspoof -i eth0 -t 192.168.1.1 192.168.1.50  # tell gateway: victim MAC = attacker

# Enable forwarding so traffic actually reaches destination
sysctl -w net.ipv4.ip_forward=1

# Now run:
wireshark -i eth0   # capture all traffic between victim and gateway

MAC Flooding

A switch's CAM (Content Addressable Memory) table maps MAC addresses to switch ports. If an attacker floods the switch with frames from thousands of fake MAC addresses, the CAM table fills up. The switch falls back to flooding all frames to all ports — effectively becoming a hub. The attacker receives all traffic on the segment.

Defense: Port Security — limit the number of MAC addresses allowed per port. When exceeded, the port can shut down (err-disable) or drop the offending frames.

VLAN Hopping

VLAN hopping exploits trunk ports. An attacker sends double-tagged 802.1Q frames: an outer tag for the attacker's VLAN, an inner tag for the target VLAN. The first switch removes the outer tag and forwards on the trunk. The second switch sees the inner tag and delivers to the target VLAN. Defense: never use the native VLAN (VLAN 1) for user traffic; set a dedicated unused VLAN as the native VLAN on all trunks.

STP Attacks

Spanning Tree Protocol (STP) prevents Layer 2 loops by electing a root bridge and blocking redundant paths. An attacker can send STP BPDUs (Bridge Protocol Data Units) claiming to be the root bridge with the best priority. If the switch accepts it, the STP topology changes — potentially redirecting all traffic through the attacker's port. Defense: BPDU Guard on access ports (drops any received BPDU; error-disables the port).


Chapter 4

Layer 3 Attacks: Routing and IP-Level Manipulation

2010. China Telecom accidentally announces BGP routes for 37,000 IP prefixes belonging to US government agencies, military, and major internet services. Traffic for the Pentagon, NASDAQ, and many others was briefly routed through China. The word "accidentally" is disputed by some researchers. BGP has no mechanism to prevent this — any AS can announce any prefix, and the internet will route traffic toward it.

IP Source Address Spoofing

IP packets carry a source address field that can be set to any value. There is no verification by default. Attackers use spoofed source IPs for:

Amplification attacks: sending requests with victim's IP as source; servers send large responses to victim.

ACL bypass: spoofing a trusted IP to pass firewall rules that allow traffic from that address.

TCP blind injection: if an attacker can predict TCP sequence numbers, they can inject packets into a TCP session without being on-path.

BCP 38 (Network Ingress Filtering): ISPs should filter packets leaving their network with source IPs that don't belong to their customers. This prevents spoofing of external IPs from inside the network. ISPs that implement BCP 38 significantly reduce amplification attacks from their networks.

ICMP Redirect Attack

ICMP Redirect messages tell a host to use a different gateway for a specific destination. Legitimate use: routers telling hosts about a better route on the local segment. Attacker use: send forged ICMP Redirects to a host, redirecting all traffic through the attacker's IP. Defense: disable ICMP Redirect acceptance (Linux: net.ipv4.conf.all.accept_redirects=0).

BGP Route Hijacking

BGP (Border Gateway Protocol) is the internet's routing protocol. It operates on trust — each AS announces the prefixes it is authoritative for, and neighboring ASes propagate these announcements. There is no cryptographic verification of whether an AS legitimately owns the prefix it announces.

Attack: an AS announces a more-specific prefix (/24 versus the legitimate owner's /16). Internet routers prefer more-specific routes (longest prefix match), so traffic is redirected to the hijacking AS.

RPKI (Resource Public Key Infrastructure): Regional Internet Registries (ARIN, RIPE, etc.) sign Route Origin Authorizations (ROAs) — cryptographic statements that "AS 65001 is authorized to originate prefix 203.0.113.0/24." Routers with RPKI validation reject route announcements that conflict with ROAs. RPKI adoption reached 60%+ of internet routing by 2024.

Network Attack Explorer

Filter by category, click an attack to see how it works and how to defend against it.

Port Scanning
Transport (L4)
Low
ARP Spoofing / Poisoning
Data Link (L2)
High
DNS Cache Poisoning
Application (L7)
Critical
SYN Flood (TCP DoS)
Transport (L4)
High
SSL Stripping
Application (L7)
Critical
BGP Route Hijacking
Network (L3)
Critical
Network Lateral Movement
Multiple
Critical
SYN Flood (TCP DoS)
Layer: Transport (L4)Category: dos
Mechanism
Attacker sends millions of TCP SYN packets with spoofed source IPs. Server allocates state for each half-open connection (SYN-RECEIVED). The SYN backlog fills. Legitimate connections are rejected with RST or silently dropped. The forged IPs never complete the handshake.
Detection
High rate of SYN packets. Large number of half-open connections in netstat. Backlog queue full errors in kernel logs.
Mitigation
SYN cookies: no state allocated until SYN-ACK is acknowledged. Rate limiting SYN packets per IP. Upstream scrubbing services for volumetric attacks.
Real-World Example
SYN flood was one of the first DDoS techniques (1996). SYN cookies (Stevens 1994, deployed widely ~1998) largely solved it at the kernel level. Still used as a component of multi-vector DDoS.

Chapter 5

Man-in-the-Middle Attacks: The Complete Chain

MITM is not a single attack — it is a capability achieved by chaining multiple techniques. The attacker must first gain a network position (ARP spoof, rogue AP, compromised router), then intercept traffic (IP forwarding), then break the security layer protecting it (SSL strip, forge certificate, decode unencrypted protocol). Understanding each link in the chain reveals where defenses can break the chain.

TCP/IP Stack Attack Surface

Select a layer to see which attacks target it.

L1PhysicalEthernet PHY, Wi-Fi 802.11, Fiber
L2Data LinkARP, Ethernet, 802.1Q, STP
L3NetworkIP, ICMP, BGP, OSPF
L4TransportTCP, UDP, TLS handshake
L7ApplicationHTTP, DNS, SMTP, TLS
Layer 4Transport Attacks
SYN Flood
Half-open connections exhaust server backlog
UDP Flood
Amplified UDP traffic overwhelms bandwidth
TCP Session Hijacking
Inject packets into established TCP stream with correct seq nums
Port Scanning
Enumerate open services as reconnaissance

MITM Attack Chain

Click each phase to understand the technique and the defense.

Phase 2: ARP Spoofing
Attacker sends gratuitous ARP replies to victim: "I am the gateway (IP 192.168.1.1)." And to gateway: "I am the victim (IP 192.168.1.50)." Both update their ARP caches. Traffic flows attacker→gateway and vice versa.
TOOLS
arpspoofettercapbettercap
DEFENSE
Dynamic ARP Inspection (DAI). Static ARP entries. ARP monitoring (arpwatch).

MITM on Public Wi-Fi

Public Wi-Fi MITM is simpler: the attacker creates an access point with the same SSID as a popular network ("Starbucks_WiFi"). Devices that auto-connect to known SSIDs will connect to the rogue AP. The attacker's AP provides internet access (routing through legitimate network or LTE) while intercepting all traffic. Defense: always verify the AP's BSSID (MAC address) matches the expected AP. Use a VPN on all public Wi-Fi.

TLS and Certificate Pinning

TLS prevents MITM by requiring the server to present a certificate signed by a trusted CA. An MITM attacker cannot forge a legitimate certificate unless they have compromised a CA. Certificate pinning goes further: the application hardcodes specific certificate fingerprints or public keys, rejecting any certificate not matching the pin — even valid CA-issued ones.

Certificate pinning is used by mobile banking apps, corporate MDM systems, and high-security APIs. It defeats even corporate TLS inspection proxies (which present a CA-signed cert). The tradeoff: pinned certificates must be rotated with app updates.


Chapter 6

DNS Attacks: Redirecting the Internet's Phone Book

2008. Security researcher Dan Kaminsky discovers a fundamental flaw in DNS: the 16-bit transaction ID field gives only 65,536 possible values. An attacker can flood a DNS resolver with forged responses for all 65,536 transaction IDs in under a second. If the forged response arrives before the legitimate one, the resolver caches the malicious record. Every lookup for the poisoned domain goes to the attacker's server — phishing, credential theft, and malware delivery at scale. Kaminsky coordinated a global patch with DNS vendors before disclosure. It was the largest coordinated vulnerability disclosure in internet history.

DNS Cache Poisoning (Kaminsky Attack)

The Kaminsky attack works in three steps:

1. Ask the target DNS resolver to resolve a random subdomain of the target domain (e.g., xyz123.bank.com). The resolver has no cached answer.

2. Immediately flood the resolver with forged responses purporting to be from bank.com's authoritative name server. Each forged response tries a different transaction ID and source port. Because transaction IDs are only 16-bit and source ports were not randomized, 65,536 attempts suffices.

3. One forged response matches the transaction ID. The resolver caches the attacker's glue record as the NS server for bank.com. All future lookups for bank.com resolve to the attacker's IP.

DNS Hijacking

DNS hijacking modifies DNS resolution at a different layer:

Rogue DHCP server: attacker's DHCP server assigns their DNS server IP to clients.

Router compromise: attacker modifies router's DNS settings to redirect DNS queries to their server.

ISP DNS hijacking: some ISPs redirect NXDOMAIN responses to their search/advertising pages.

DNSSEC and DoH/DoT

DNSSEC adds digital signatures to DNS records. The chain of trust runs from the root zone through TLD to domain. A valid DNSSEC signature proves the record was created by the zone owner and hasn't been modified. DNSSEC prevents cache poisoning but not DNS traffic interception (the responses are still observable).

DNS over HTTPS (DoH) and DNS over TLS (DoT) encrypt DNS traffic, preventing observation and on-path modification. DoH additionally hides DNS queries from ISPs (queries go to port 443 mixed with HTTPS traffic). Cloudflare (1.1.1.1), Google (8.8.8.8), and NextDNS offer DoH/DoT resolvers.


Chapter 7

Denial of Service: Volumetric, Protocol, and Application

October 2016. Mirai botnet — a network of compromised IoT devices (cameras, DVRs, routers with default credentials) — launches a 1.2 Tbps DDoS attack against Dyn DNS, a major DNS provider. Large portions of the US internet go dark: Twitter, Reddit, GitHub, Netflix, Spotify. The entire attack infrastructure was IoT devices, each sending simple UDP floods. One botnet. 1.2 terabits per second. Critical infrastructure disrupted.

Volumetric Attacks

Volumetric attacks flood the target's network link with traffic, saturating bandwidth. The traffic doesn't need to be clever — it just needs to be more than the link can handle.

UDP Floods: send large volumes of UDP packets to random ports. Target sends ICMP Port Unreachable for each. The target's CPU and uplink are overwhelmed.

Amplification Attacks: exploit protocols that return large responses to small requests. The attacker spoofs the victim's IP as source. DNS (amplification factor: 50-100x), NTP monlist (100x), SSDP (30x), Memcached (50,000x). Attacker sends 1 Mbps, victim receives 100+ Mbps.

Protocol Attacks

Protocol attacks exploit weaknesses in protocol state machines:

SYN Flood: exhausts server connection table with half-open TCP connections. Defense: SYN cookies (no state allocated until handshake completes).

BGP Flapping: repeatedly withdrawing and announcing routes to cause route instability in BGP.

SSL/TLS Exhaustion: initiating many TLS handshakes without completing them; asymmetric CPU cost (server does more work than client per handshake).

Application Layer (L7) Attacks

Layer 7 attacks look like legitimate traffic but overwhelm application resources:

HTTP Flood: thousands of clients making valid HTTP GET/POST requests. Indistinguishable from legitimate traffic without rate limiting and behavioral analysis.

Slowloris: open many HTTP connections, send partial headers very slowly. Server holds connections open. Most servers have a connection limit — Slowloris fills it with near-zero bandwidth.

XML/JSON Bombs: send deeply nested XML ("billion laughs attack") or JSON that expands exponentially during parsing.

DDoS Mitigation

Anycast scrubbing: Cloudflare, Akamai, AWS Shield absorb attack traffic across their global networks before it reaches the customer.

Rate limiting: limit requests per IP per time window at the network or CDN edge.

BGP blackholing: route the victim IP to null — traffic is dropped at the ISP. The victim goes offline, but the upstream network is protected.

BCP 38: ISPs that filter spoofed source IPs prevent amplification attacks from their customers.


Chapter 8

TCP-Level Attacks: Session Hijacking and Blind Injection

TCP's sequence number mechanism was designed to reorder out-of-order packets, not as a security mechanism. In early TCP implementations, sequence numbers were predictable — they started at 0 or incremented by 64000 each second. An attacker who could predict the next sequence number could inject packets into an established TCP session without being on the network path. This class of attacks drove the randomization of TCP initial sequence numbers (ISNs) in the late 1990s.

TCP Session Hijacking

In session hijacking, an on-path attacker (after ARP spoofing) observes a TCP session and injects packets with the correct sequence numbers. The attacker can inject commands, steal session cookies, or terminate connections. Modern TLS prevents content injection, but the TCP connection itself can still be terminated by injecting a RST with the right sequence number (RST injection).

TCP Reset Injection

TCP RST (Reset) packets terminate a connection immediately. An attacker who can observe a TCP session (even briefly) can inject a RST with the correct sequence number, abruptly terminating it. The Great Firewall of China uses TCP RST injection to terminate connections to blocked content: rather than silently dropping packets, it sends RSTs to both endpoints, causing connections to fail immediately.

SYN Cookies: Defeating SYN Floods

SYN cookies encode session state in the TCP Initial Sequence Number (ISN) rather than in server memory. The server hashes the 5-tuple + timestamp + secret key to generate the ISN. No connection state is stored until the SYN-ACK is acknowledged. If the ACK arrives with the right ISN, the server recreates the connection state. No backlog = no resource exhaustion.

# Linux SYN cookies
sysctl net.ipv4.tcp_syncookies=1     # Enable SYN cookies
sysctl net.ipv4.tcp_max_syn_backlog  # SYN backlog size
sysctl net.ipv4.tcp_synack_retries   # Reduce retries under flood

# Verify SYN cookie usage:
netstat -s | grep "SYNCookies"

Chapter 9

Wireless Network Attacks

WEP (Wired Equivalent Privacy) was the original Wi-Fi encryption standard, mandatory in 802.11b. By 2001, researchers had broken it completely — an attacker could recover the WEP key from a captured traffic in minutes using passive monitoring. WEP was cryptographically flawed by design: the IV (initialization vector) was only 24 bits and was reused, allowing statistical recovery of the key. WPA (2003) and WPA2 (2004) replaced WEP. In 2022, WPA3 was mandated for new Wi-Fi devices.

Evil Twin Attack

An attacker creates a Wi-Fi network with the same SSID (network name) and higher signal strength than the legitimate AP. Devices configured to auto-connect to known SSIDs will associate with the stronger signal. The attacker provides internet connectivity (routing via LTE or the legitimate network), so victims don't notice. All plaintext traffic is captured; HTTPS is attempted to be stripped.

PMKID Attack (WPA2/WPA3)

The PMKID (Pairwise Master Key Identifier) is a hash derived from the PMK and BSSID, transmitted in the first EAPOL frame of the WPA2 4-way handshake. The attacker captures a single PMKID packet — without waiting for a client to authenticate. The PMKID can then be attacked offline: crack the WPA2 password with a dictionary attack. Tools: hcxdumptool + hashcat.

WPA3 Dragonfly and Side-Channel Attacks

WPA3 uses the Dragonfly key exchange (SAE - Simultaneous Authentication of Equals), which is resistant to offline dictionary attacks — the password is never transmitted. However, in 2019 researchers found timing side-channels and cache-based side-channels in some Dragonfly implementations (CVE-2019-9494, "Dragonblood"). These have been patched, but demonstrate that even modern protocols have implementation risks.


Chapter 10

Lateral Movement and Internal Network Attacks

2017. NotPetya spreads across Maersk, the world's largest shipping company, in 7 minutes. It needed only one initially compromised host with an unpatched SMB vulnerability (EternalBlue) plus credential extraction (Mimikatz pass-the-hash). No internet exposure was required — every Windows machine on the internal network was reachable via SMB. The result: 45,000 PCs and 4,000 servers wiped. 10 days of manual intervention to restore operations. $300 million in losses.

Pass-the-Hash

Windows NTLM authentication accepts a password hash (NTLM hash) directly — you don't need to crack the password, just capture and replay the hash. After extracting hashes from lsass.exe (local security authority) using Mimikatz, the attacker can authenticate to any system accepting NTLM with that user's hash, without ever knowing the plaintext password.

# Pass-the-hash with impacket (authorized red team only)
python psexec.py -hashes :NTLM_HASH_HERE Administrator@192.168.1.50
# Authenticates as Administrator without knowing the password

# Defense:
# 1. Credential Guard (Windows 10+): protects lsass in a hypervisor-isolated container
# 2. Disable NTLM: force Kerberos everywhere (requires domain)
# 3. Local admin passwords unique per machine (LAPS)
# 4. Privileged Access Workstations (PAW) for admin tasks

EternalBlue and SMB Exploitation

EternalBlue (CVE-2017-0144) is an NSA exploit for a buffer overflow in Windows SMBv1. It allows remote code execution without authentication on Windows XP through Server 2008 R2 (unpatched). WannaCry and NotPetya both used EternalBlue to spread laterally. The patch (MS17-010) was available for 2 months before WannaCry; millions of machines were unpatched.

Network Segmentation as Defense

If every machine can reach every other machine on port 445 (SMB), one compromised host leads to total network compromise. Network segmentation with firewall rules between segments limits lateral movement: servers can't reach client machines, production can't reach development, external DMZ can't reach internal.


Chapter 11

Defense in Depth: Building Layered Defenses

A medieval castle didn't rely on a single wall. It had a moat, an outer wall, a courtyard, an inner wall, and a keep. An attacker who breached the outer wall still faced three more defensive layers. Modern network security takes the same approach: no single control is sufficient, but multiple overlapping controls make compromise extremely difficult.

The Defense Layers

Perimeter: firewall, IPS, DDoS mitigation. Reduces attack surface exposed to the internet.

Network: VLAN segmentation, ACLs, DHCP snooping, DAI, port security. Limits blast radius within the network.

Host: OS hardening, endpoint protection, host-based firewall, patch management. Reduces vulnerability to exploitation.

Application: TLS, input validation, WAF, authentication. Protects the service itself.

Data: encryption at rest, DLP, access controls. Protects data even if other layers fail.

Detection: SIEM, IDS/IPS, NDR, honeypots. Identifies breaches that bypass preventive controls.

Response: incident response plan, forensics capability, backup/recovery. Limits damage when breaches occur.

Zero Trust Architecture

Zero Trust assumes breach: no device or user is trusted by default, even on the internal network. Every access request is authenticated, authorized, and continuously verified. Network location (inside vs. outside firewall) is not a trust indicator. This model eliminates the "trusted insider" assumption that makes lateral movement so easy.


Chapter 12

Intrusion Detection: Recognizing Attacks in Progress

Prevention is imperfect. Adversaries adapt. The security principle of "assume breach" drives the investment in detection: not "will they get in?" but "when they get in, how quickly will we know?" The mean time to detect a breach in 2023 was 204 days (IBM Cost of a Data Breach Report). That is 204 days of attacker-controlled access before anyone noticed.

Network-Based Detection

IDS/IPS: Intrusion Detection/Prevention Systems analyze traffic for attack signatures and anomalies. Signature-based detection catches known attacks; anomaly-based detection flags deviations from normal behavior. Suricata and Snort are leading open-source IDS engines.

NDR (Network Detection and Response): uses machine learning on flow data to detect C2 communication patterns, lateral movement, data exfiltration, and unusual protocol usage. Products: Darktrace, ExtraHop, Vectra.

Honeypots: decoy systems with no legitimate traffic. Any connection to a honeypot is by definition suspicious. Honeytokens (fake credentials, fake API keys) in monitoring can detect credential theft even before the attacker uses them.

SIEM and Log Correlation

Security Information and Event Management (SIEM) aggregates logs from all systems — firewalls, IDS, endpoints, servers, applications — and correlates events across them. A single failed login is noise; 1,000 failed logins across 50 accounts in 10 minutes is a brute-force attack. SIEM detects patterns that individual devices cannot see.


Chapter 13

Misconceptions About Network Attacks

MISCONCEPTION: "Encryption prevents MITM attacks." — Encryption prevents eavesdropping, not MITM. SSL stripping downgrades HTTPS to HTTP before encryption is established. A forged certificate (from a compromised or rogue CA) allows TLS inspection. Encryption protects content only if the client properly verifies the server's certificate against a trusted CA and refuses to connect on failure — many applications accept invalid certificates in development mode or ignore certificate errors.
MISCONCEPTION: "Firewalls prevent all network attacks." — Firewalls filter traffic based on IP, port, and sometimes protocol. They do not understand the content of allowed protocols. An attacker using port 443 (allowed HTTPS) for command-and-control is invisible to a basic firewall. SQL injection, XSS, and protocol-level attacks all pass through firewalls that permit the relevant ports. Firewalls are one layer; not the only layer.
MISCONCEPTION: "Attackers need to be on the local network for ARP spoofing." — ARP is a Layer 2 protocol limited to a broadcast domain — true. But an attacker inside the same VLAN (on the same switch) is sufficient. After a single client machine is compromised via phishing, the attacker has LAN access from that machine. Network segmentation limits which VLANs attackers can reach, but does not prevent ARP attacks within a VLAN.
MISCONCEPTION: "DDoS attacks are impossible to mitigate." — DDoS attacks are manageable with the right infrastructure. Anycast scrubbing networks (Cloudflare, Akamai) absorb even terabit-scale attacks across globally distributed PoPs. The architecture secret: distribute the absorption across enough surface area that no single point gets overwhelmed. 1 Tbps absorbed across 250 datacenters = 4 Gbps per datacenter.
MISCONCEPTION: "BGP hijacking only affects internet routing, not internal networks." — BGP is the internet's routing protocol, so BGP hijacking affects internet-connected traffic. But internal networks also use routing protocols (OSPF, EIGRP, IS-IS) that have similar trust issues without authentication. OSPF without MD5 authentication allows any host on the segment to inject false routes into the network's routing table.

Chapter 14

IQ Depth Check: Attack and Defense Mastery

Beginner
What is a Man-in-the-Middle attack and what enables it on a local network?
A Man-in-the-Middle (MITM) attack is when an attacker intercepts communications between two parties without either knowing. On a local network, it is typically enabled by ARP spoofing — sending fake ARP replies that cause victim devices to send their traffic to the attacker's MAC address instead of the legitimate gateway. The attacker forwards the traffic to the real gateway, making the connection appear normal while all traffic passes through them.
Intermediate
Explain SYN cookies and why they defeat SYN flood attacks.
A SYN flood exhausts a server's half-open connection table by sending millions of SYN packets from spoofed IPs that never complete the handshake. SYN cookies eliminate the need for per-connection state until the handshake completes. The server encodes session information (client IP, port, server port, timestamp) into the Initial Sequence Number (ISN) of the SYN-ACK using a cryptographic hash. If the client completes the handshake (sending ACK with ISN+1), the server decodes the cookie and recreates the connection state. Spoofed IPs never respond, so no state is ever created — the SYN flood consumes only CPU cycles to verify cookies, not memory for connection state.
Senior
How does RPKI prevent BGP route hijacking, and what are its limitations?
RPKI (Resource Public Key Infrastructure) allows IP address holders to create Route Origin Authorizations (ROAs) — cryptographic attestations that "AS N is authorized to originate prefix P/len with maximum prefix length L." These ROAs are signed with the IP block holder's key, validated by the RIR CA chain (IANA → Regional Internet Registries → resource holders). Routers with RPKI validation mark routes as Valid, Invalid (announced by an AS not in the ROA), or NotFound. Networks that deploy RPKI Origin Validation (ROV) reject or deprioritize Invalid routes. Limitations: (1) only validates origin AS, not the full AS path — AS path prepending attacks are not prevented; (2) only ~60-70% of internet routes have ROAs as of 2024; (3) BGPsec (full path validation) is not widely deployed due to performance overhead; (4) an attacker who can access a legitimate AS with valid ROAs can still misuse those announcements.
PhD
Describe the Kaminsky DNS cache poisoning attack mechanism and explain why source port randomization (the main patch) reduces but does not eliminate the attack surface.
The Kaminsky attack exploits the fact that DNS transaction IDs are only 16 bits (65,536 values). The attacker queries the target resolver for a random subdomain (forcing a fresh lookup). Simultaneously, they flood the resolver with forged authoritative responses for all 65,536 transaction IDs, all claiming a malicious NS record for the target domain. Before the real authoritative server responds (typically 50-100ms), the attacker has a high probability of matching the transaction ID. The fix (RFC 5452) adds source port randomization: instead of sending all DNS queries from a fixed port (53), the resolver uses a random ephemeral port. This adds ~16 bits of additional entropy (65,536 possible ports × 65,536 TXIDs = ~4 billion combinations), making brute-force much harder. However, it does not eliminate the attack because: (1) NAT devices often remap source ports, eliminating port entropy; (2) some firewalls and middleboxes restrict outgoing UDP source ports; (3) the Fragmentation-based DNS poisoning (FRAG16, 2020 CVE) exploits IP fragmentation to bypass port randomization by triggering fragmented DNS responses; (4) DNS-over-UDP fundamentally lacks authentication — DNSSEC's cryptographic signatures are the only complete solution, as they make forged responses detectable regardless of transaction ID entropy.

🎯 Key Takeaways

  • Network protocols were designed with trust assumptions that fail in adversarial environments: ARP has no auth, BGP has no origin verification, IP source addresses are unverifiable by default.
  • ARP spoofing poisons the ARP cache to redirect LAN traffic; defended by Dynamic ARP Inspection (DAI) + DHCP snooping binding table.
  • MAC flooding fills the CAM table to make a switch act like a hub; defended by port security (max MAC per port).
  • SYN flood exhausts the TCP backlog with half-open connections; defeated by SYN cookies (no state until handshake completes).
  • The Kaminsky attack exploits 16-bit DNS transaction ID entropy; partial mitigation: source port randomization; complete mitigation: DNSSEC.
  • BGP route hijacking redirects internet traffic via more-specific prefix announcements; RPKI Route Origin Validation rejects unauthorized prefix origins.
  • MITM chain: network position (ARP/rogue AP) → IP forwarding → intercept → SSL strip or forge cert. Broken by HSTS, certificate pinning, DAI.
  • DDoS mitigation: BCP38 (prevent spoofing), SYN cookies, rate limiting, anycast scrubbing (Cloudflare/Akamai), BGP blackholing.
  • Lateral movement (pass-the-hash, EternalBlue): defeated by network segmentation, unique local admin passwords (LAPS), Credential Guard, disabling NTLM.
  • Defense in depth: perimeter → network → host → application → data → detection → response; no single layer is sufficient.
Share

Discussion

0

Have a better approach? Found something outdated? Share it — your knowledge helps everyone learning here.

Continue with GitHub
Loading...