Labs / Network Attacks / Breaking in and flooding

Lab 3 of 4 · Breaking in and flooding

SYN flood: half-open connections and the host that shrugs them off

Spray forged half-open TCP connections at a booking server with hping3 and watch the SYN queue fill, then see why a modern kernel keeps serving.

Start this lab 4 steps

The idea

You're Hugo, on a signed engagement against Saltmarsh Ferries, working from the Kali box kali. Their whole business is the booking site on 10.0.1.10 — if it stops answering, the ferries stop selling seats.

A SYN flood abuses the TCP handshake: spray SYNs from forged sources and never send the final ACK, so the server fills with half-open connections waiting for a reply that never comes. It is the textbook denial-of-service — and this lab teaches the honest version of it: a modern server with SYN cookies on will keep serving right through a small single-box flood, so the real exposure is the host that has cookies off, and the network edge that should never have let a forged source out in the first place.

Each SYN-ACK goes to a stranger
Each SYN-ACK goes to a stranger

Steps

  1. The booking site, and one lone SYN

    First, the ground truth: the booking site answers, and a single SYN shows what the attack abuses. Book a seat as a customer, then send one crafted SYN with hping3 and read the reply.

    hping3 -S sends a lone SYN; the server answers SA (SYN-ACK) and waits for an ACK that a real client would send to finish the handshake. hping3 never sends it — that unfinished third step is the whole attack, multiplied.

    customer:~# curl -s -o /dev/null -w 'code=%{http_code}\n' --max-time 6 http://10.0.1.10/
    kali:~# sudo hping3 -S -p 80 -c 1 10.0.1.10
  2. The flood: half-open connections pile up

    Now the flood. Twelve senders on Kali, each spraying SYNs to port 80 from a forged source (10.0.1.101–10.0.1.112) Hugo does not own, none of them ever sending the ACK. The forged sources are the point: the server's SYN-ACK goes to an address that never asked and never replies, so each connection sits half-open. List the server's half-open connections while the flood runs.

    booking:~# ss -tn state syn-recv
  3. The server shrugs it off

    The flood is in full flow and the queue is full of forged half-open connections. So book a seat as a real customer right now, and read the kernel's own counter for why it still works.

    customer:~# curl -s -o /dev/null -w 'code=%{http_code}\n' --max-time 6 http://10.0.1.10/
    booking:~# nstat -az TcpExtSyncookiesSent
  4. Cut the forgery at the edge — and the fixes

    The flood only works because Hugo can forge its source. The durable network fix is anti-spoofing at the edge (BCP 38): a port may send only packets whose source is its own address. Put that filter on Kali, run the same flood, and watch what reaches the server.

    Then the defender's checklist, because no single control is the whole answer:

    • Keep SYN cookies on (net.ipv4.tcp_syncookies=1) on every host — the reason this server shrugged the flood off, and free.
    • Anti-spoofing at the edge (BCP 38 / uRPF, IP Source Guard per switch port) — a forged source never leaves the network it was faked on.
    • Upstream scrubbing for a real distributed flood no host can absorb — the volume is dropped before it reaches you.

    Running a flood against a system whose owner has not authorised you in writing is an offence under laws like the UK Computer Misuse Act and the United States' CFAA — the engagement letter is what makes it a test and not a crime.

    kali:~# sudo iptables -I OUTPUT ! -s 10.0.1.11 -j DROP
    customer:~# curl -s -o /dev/null -w 'code=%{http_code}\n' --max-time 6 http://10.0.1.10/

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab