NETWORK ATTACKS
TCP/IP internals · Scanning · Wireshark · ARP poisoning · MITM · Protocol attacks · Evasion · DoS · Pivoting
Network Fundamentals for Attackers
- The OSI layer an attack targets determines which tools detect it and which defenses apply - always identify the layer first
- Every TCP/IP header field is attack surface: spoof src IP for amplification, manipulate TTL for OS fingerprinting, abuse flags for firewall bypass
- SYN flood works by exhausting the server connection backlog before handshakes complete - SYN cookies mitigate this without memory allocation
- IPv6 is frequently less monitored than IPv4 on dual-stack networks - NDP (Neighbor Discovery) is the ARP equivalent and equally unauthenticated
- DNS has no authentication by default - every step in the resolution chain is a potential interception or poisoning point
Before launching any network attack you need to understand the infrastructure you are attacking. Every tool, every technique, and every defense maps to a specific layer of the network stack. This chapter builds that mental model from the ground up.
When you send a parcel to your people up at the shamba, it does not teleport there. You wrap the gift, a counter clerk seals it in a sack and writes the destination, a sorting office decides the route, and finally a rider carries it the last stretch to the gate. Each stage only handles its own layer of wrapping and passes it to the next — and at the far end the wrapping comes off in reverse. The network's seven layers work exactly like that chain, and an attacker can tamper at any single stage along the way.
OSI Model - Attacker Perspective
The OSI (Open Systems Interconnection) model has 7 layers. Each layer has its own protocols, vulnerabilities, and attack tools. Knowing which layer you are operating at tells you which defenses apply and which tools to reach for.
TCP/IP Model and Header Attack Surface
In practice attackers think in the TCP/IP model (4 layers). Every header field is a potential attack vector - either to spoof, manipulate, or exploit.
TCP 3-Way Handshake and Attack Opportunities
The TCP handshake is how two computers agree to start a conversation. Think of it like knocking on a door (SYN), getting an answer (SYN-ACK), and confirming you heard them (ACK). Attackers can abuse each step.
Phase 1 - SYN (Client to Server):
Client sends: SYN, seq=X
Server allocates memory, stores half-open connection
ATTACK: SYN flood - send millions of SYNs from spoofed IPs
Server fills backlog queue, legitimate connections rejected
Phase 2 - SYN-ACK (Server to Client):
Server sends: SYN+ACK, seq=Y, ack=X+1
ATTACK: SYN-ACK reflection - spoof src IP to victim
Server floods victim with SYN-ACKs (amplification ~1.4x)
Phase 3 - ACK (Client to Server):
Client sends: ACK, ack=Y+1
Connection ESTABLISHED - both sides enter ESTABLISHED state
ATTACK: If seq numbers predictable, inject ACK with correct seq
= TCP session hijacking (historical, modern OS randomizes)
Half-Open Scan (nmap -sS):
Client sends SYN
If port OPEN: server sends SYN-ACK -> client sends RST (never ACKs)
If port CLOSED: server sends RST immediately
Advantage: never completes handshake, harder to log
SYN Cookie Defense (linux default):
Server encodes connection state in SYN-ACK sequence number
No memory allocated until final ACK received
Defeats SYN flood - check: sysctl net.ipv4.tcp_syncookiesIPv4 Addressing - CIDR, RFC1918, Broadcast
PRIVATE RANGES (RFC 1918) - not routable on internet:
10.0.0.0/8 (10.0.0.0 - 10.255.255.255) Class A
172.16.0.0/12 (172.16.0.0 - 172.31.255.255) Class B
192.168.0.0/16 (192.168.0.0 - 192.168.255.255) Class C
SPECIAL ADDRESSES:
127.0.0.0/8 Loopback (localhost = 127.0.0.1)
169.254.0.0/16 APIPA / link-local (no DHCP assigned)
0.0.0.0/0 Default route (all traffic)
255.255.255.255 Limited broadcast (layer 2 only)
x.x.x.255 Directed broadcast for subnet (Smurf attack)
CIDR NOTATION:
/24 = 256 hosts (mask 255.255.255.0) - typical LAN
/16 = 65536 hosts - corporate network
/8 = 16M hosts - class A
/32 = single host - specific target
/30 = 4 addresses, 2 usable - point-to-point links
CIDR QUICK MATH:
192.168.1.100/24
Network: 192.168.1.0
Broadcast: 192.168.1.255
Hosts: .1 through .254
SUBNET ENUMERATION:
ipcalc 192.168.1.100/24 # show network details
nmap -sn 192.168.1.0/24 # ping scan entire subnetIPv6 Fundamentals and Attack Surface
IPv6 is increasingly common and introduces new attack surface. Many networks run dual-stack (IPv4 + IPv6) and IPv6 is often less monitored than IPv4.
ADDRESS TYPES: ::1/128 Loopback fe80::/10 Link-local (auto-assigned, every interface) fc00::/7 Unique local (RFC4193, like RFC1918) 2000::/3 Global unicast (routable internet) ff02::1 All-nodes multicast (replaces broadcast) ff02::2 All-routers multicast ff02::1:ff00::/104 Solicited-node multicast (for NDP) NEIGHBOR DISCOVERY PROTOCOL (NDP) replaces ARP: ICMPv6 Type 133 - Router Solicitation (host asks for router) ICMPv6 Type 134 - Router Advertisement (router announces self) ICMPv6 Type 135 - Neighbor Solicitation (who has this IPv6?) ICMPv6 Type 136 - Neighbor Advertisement (I have this IPv6) ARP SPOOFING EQUIVALENT: Neighbor Advertisement spoofing Send fake NA claiming your MAC for target IPv6 addr SLAAC (Stateless Address Autoconfiguration): Host receives RA (Router Advertisement) Generates address from prefix + interface MAC (EUI-64) ATTACK: Send rogue RAs via flood6 or fake_router6 Tools: thc-ipv6 toolkit, mitm6 IPv6 ATTACKS: mitm6 - Spoof DHCPv6 + DNS to capture NTLMv2 hashes flood6 - RA flood to disrupt routing alive6 - IPv6 host discovery parasite6 - NDP spoofing (ARP poison equivalent) redir6 - ICMPv6 redirect attack DUAL-STACK GOTCHA: Many firewalls filter IPv4 but allow IPv6 freely Always check for IPv6 on targets: nmap -6 fe80::1%eth0
DNS Resolution Process and Attack Surface
RESOLUTION CHAIN:
1. Browser cache
2. OS resolver cache (/etc/hosts first)
3. Recursive resolver (your ISP or 8.8.8.8)
4. Root nameservers (13 root servers, anycast)
5. TLD nameservers (.com, .net, .org)
6. Authoritative nameserver (final answer)
ATTACK SURFACES:
Step 2: /etc/hosts poisoning (local access required)
Step 3: DNS cache poisoning (Kaminsky attack)
Flood resolver with fake responses
If txid matches before real response -> cached
Step 5-6: Zone transfer (AXFR) from misconfigured NS
Any step: DNS interception (MITM + bettercap dns.spoof)
Any step: DNS tunneling (data exfil via DNS queries)
RECORD TYPES (know these for recon):
A - IPv4 address
AAAA - IPv6 address
CNAME - Canonical name (alias)
MX - Mail exchanger (priority + hostname)
NS - Nameserver for domain
TXT - Text records (SPF, DKIM, DMARC, juicy info)
PTR - Reverse lookup (IP -> hostname)
SOA - Start of Authority (zone serial, TTL defaults)
SRV - Service location records (_ldap._tcp, _kerberos._tcp)
DNS SECURITY MECHANISMS (and why they often fail):
DNSSEC - signs records with crypto, rarely deployed
DoH - DNS over HTTPS (hides queries, bypasses filters)
DoT - DNS over TLS port 853
RPKI - BGP route origin validationCommon Ports and Services Reference
WELL-KNOWN PORTS (0-1023): 20/21 FTP (data/control) - often anonymous, cleartext creds 22 SSH - brute force, key attacks, tunneling 23 Telnet - fully cleartext, legacy systems 25 SMTP - open relay, user enum, mail injection 53 DNS - zone transfer, amplification, tunneling 67/68 DHCP - rogue server, starvation 69 TFTP - unauthenticated file transfer 80 HTTP - web attacks, enumeration 88 Kerberos - AS-REQ brute force, ticket attacks 110 POP3 - cleartext email retrieval 111 RPC portmapper - NFS enumeration 119 NNTP 123 NTP - monlist amplification attack (556x) 135 MSRPC - Windows RPC endpoint mapper 137-139 NetBIOS - LLMNR/NBT-NS poisoning with Responder 143 IMAP 161/162 SNMP - community string brute, MIB dump, write access 389 LDAP - anonymous bind, injection, AD enumeration 443 HTTPS 445 SMB - EternalBlue, SMB relay, share enumeration 465 SMTPS 514 Syslog 515 LPD (printer) 546/547 DHCPv6 587 SMTP submission 636 LDAPS 993 IMAPS 995 POP3S REGISTERED PORTS (1024-49151): 1080 SOCKS proxy 1433 MSSQL - credential attacks, xp_cmdshell RCE 1521 Oracle DB 2049 NFS - exposed share mounting, root squash bypass 3268 LDAP Global Catalog 3306 MySQL - credential attacks, UDF injection 3389 RDP - BlueKeep, credential spray, NLA bypass 4444 Metasploit default handler 5432 PostgreSQL 5900 VNC - weak passwords, unencrypted 5985/5986 WinRM - lateral movement, PowerShell remoting 6379 Redis - unauthenticated RCE via config rewrite 6443 Kubernetes API 8080 HTTP alternate / proxy 8443 HTTPS alternate 8888 Jupyter Notebook - often unauthenticated 9200 Elasticsearch - unauthenticated HTTP API 11211 Memcached - UDP amplification (51000x), info disclosure 27017 MongoDB - unauthenticated access, data exfil
Network Topology - Trust Zones and Segmentation
TYPICAL ENTERPRISE NETWORK ZONES:
Internet (untrusted)
|
[Perimeter Firewall]
|
DMZ (semi-trusted) - web servers, mail, DNS, VPN gateway
|
[Internal Firewall]
|
Internal LAN (trusted)
|-- Corporate VLAN (workstations)
|-- Server VLAN (file, print, app servers)
|-- Management VLAN (network gear, OOB)
|-- Guest VLAN (isolated internet only)
|-- Production VLAN (databases, critical systems)
ATTACK PATH IMPLICATIONS:
External attacker:
1. Compromise DMZ host (webshell, vuln service)
2. Pivot to internal LAN (tunnel through DMZ host)
3. Enumerate internal network
4. Lateral movement to server VLAN
5. Escalate to domain admin
6. Access production VLAN / databases
VLAN SEGMENTATION BYPASS:
VLAN hopping (Chapter 4) breaks L2 segmentation
Misconfigured trunk ports expose all VLANs
Dual-homed servers bridge VLANs
FLAT NETWORK (no segmentation):
Attacker on any workstation can reach:
- Domain controllers
- Database servers
- Backup servers
= Disaster (but very common in SMBs)Firewalls, IDS/IPS - Types and Evasion Fundamentals
FIREWALL TYPES:
Packet filter (L3/L4):
- Stateless, checks src/dst IP + port + protocol
- Simple ACLs, cheap, fast
- Bypass: use allowed ports (80/443/53), fragment packets
Stateful inspection (L4):
- Tracks TCP connection state
- Blocks packets not part of established session
- Bypass: inject into established sessions
Application layer (L7 / proxy):
- Understands HTTP, DNS, FTP content
- Detects protocol anomalies
- Bypass: encode payloads, use valid-looking HTTP
NGFW (Next-Gen Firewall):
- App ID, user ID, threat intelligence feeds
- SSL inspection (MITM your HTTPS)
- Bypass: CDN fronting, encrypted C2, valid TLS certs
IDS vs IPS:
IDS (Intrusion Detection System):
- Passive monitor, generates alerts only
- Does NOT block traffic
- Signature-based: known attack patterns
- Behavioral: anomaly from baseline
IPS (Intrusion Prevention System):
- Inline, actively blocks malicious traffic
- False positive risk = legitimate traffic dropped
- Evasion = IDS/IPS evasion
EVASION FUNDAMENTALS (details in Chapter 6):
Fragmentation: reassembly required before inspection
Slow timing: evade rate-based detection
Encoding: base64, hex, ROT13 in payloads
Protocol confusion: tunneling HTTP inside DNS
Decoy traffic: blend attack with legitimate patternsProxies, Load Balancers, NAT
NAT (Network Address Translation):
Hides internal IPs behind single public IP
Impact on attacker:
- Scanning from internet sees only public IP
- Cannot directly reach internal hosts
- Bypass: SSRF from internal service, VPN misconfiguration
REVERSE PROXY / LOAD BALANCER:
Cloudflare, nginx, HAProxy in front of web servers
Impact:
- Real server IP hidden behind proxy IP
- WAF (Web Application Firewall) often present
- Find real IP via: SSL cert history, DNS history,
Shodan searches, email headers from app, subdomains
- Tools: censys, shodan, viewdns.info, securitytrails
FORWARD PROXY:
Transparent: intercepts all outbound traffic (MITM-able)
Explicit: clients configured to use proxy
Impact on attacker:
- All outbound connections go through proxy
- Non-HTTP protocols may be blocked
- But CONNECT method allows TCP tunneling over HTTP!
- HTTPTunnel, chisel, and others exploit this
CONTENT DELIVERY NETWORK (CDN):
Traffic flows through CDN edge nodes globally
Provides DDoS mitigation (absorbs volume attacks)
SSL termination at CDN edge
For attackers: CDN fronting (hide C2 behind CDN)- The OSI layer an attack targets determines which tools detect it and which defenses apply - always identify the layer first
- Every TCP/IP header field is attack surface: spoof src IP for amplification, manipulate TTL for OS fingerprinting, abuse flags for firewall bypass
- SYN flood works by exhausting the server connection backlog before handshakes complete - SYN cookies mitigate this without memory allocation
- IPv6 is frequently less monitored than IPv4 on dual-stack networks - NDP (Neighbor Discovery) is the ARP equivalent and equally unauthenticated
- DNS has no authentication by default - every step in the resolution chain is a potential interception or poisoning point