Three network-level attacks

Each attack below runs on a small working model. Start the attack, then turn on a defense and run it again. A guide next to each model says which button to press, and a panel under it explains each step.

Kelompok 4 / Cybersecurity, semester 5 / Module 07, part 2 (slides 37 to 81) / EC-Council EHE v2

Choose a platformTime
#AttackWhat it abusesSlidesModel

Kelompok 4's topics from the Week 10 activity sheet: slide 9, Mekanisme Serangan TCP SYN Flood (platform 1); slide 16, Siklus Infeksi & DGA Botnet (Mirai Case) (platform 2); slide 29, Proses 3 Fase Pembajakan Sesi TCP (platform 3). The sheet counts slides from the start of part 2, so these are numbered 45, 52 and 65 on the slides themselves, which is the numbering used below.

Dotted words open a short definition with its source. The models run only inside this page: no real traffic, and every address and domain comes from ranges reserved for documentation.

Platform 1: TCP SYN flood

Filling a server's waiting list with connections that never finish

Slides 44 to 46

Every TCP connection opens with a . The server sets aside memory for the connection, a , as soon as the first packet arrives, before it knows the sender is real. A SYN flood sends thousands of first packets from addresses. Each leaves a connection waiting for an answer that never comes, until the is full and real users are turned away.

Model 1: the server's waiting list

The black board is the server's SYN queue. Each row is one half-open connection, and each one uses memory on the server. Real users are shown in blue so you can tell them apart. The server itself cannot. The clock runs 5× faster, and the queue is cut to 8 rows so you can watch each one.

  1. SYN spoofing
  2. SYN/ACK orphaned
  3. Queue overflow
  4. Denial of service
Real user192.0.2.23 Attackerfake source IPs Server:80 spoofed sources, offline
Server 192.0.2.80:80SYN queue
SlotFromStateHold
Announcement

Your move

SYN cookies

            

Normal handshake vs SYN flood

PacketNormal connectionSYN flood
1. SYNFrom the real client, seq=100From the attacker, with a fake source address
2. SYN/ACKServer reserves a slot, replies seq=300 ack=101 to the clientServer reserves a slot, replies to an address that is offline RFC 4987 §2.2
3. ACKArrives with seq=101 ack=301; slot freed within millisecondsNever arrives; Linux keeps retrying for about 63 s by default kernel docs, 4.4BSD-derived systems up to 511 s RFC 4987 §2.2
ResultConnection ESTABLISHED, user servedQueue full, new SYNs dropped, real users time out

Why the fake addresses must be offlineIf a spoofed address belonged to a live machine, that machine would answer the unexpected SYN/ACK with a , and the server would free the slot at once RFC 4987 §2.2.

Defenses, and what each one costs

DefenseWhat it doesThe catchIn the model
Encodes the connection into the SYN/ACK sequence number and stores nothing until a valid ACK comes backSome TCP options do not fit in the cookie RFC 4987 §3.6. Linux treats it as a fallback for when the queue overflows kernel docsSYN cookies switch
Bigger backlogHolds more half-open connectionsOnly buys time, because a faster flood fills it again §3.2Queue size
Fewer SYN/ACK retriesFrees each slot soonerHelps only against slow floods, and slow real clients may fail §3.3SYN/ACK retries
SYN cacheKeeps a small record per SYN and builds the full TCB only after the final ACKIn tests, real connections took about 15% longer to set up while under attack §3.5Not modeled
FilteringNetworks drop packets whose source address is forgedWorks only where deployed; a botnet does not need spoofing §3.1Not modeled
Firewall or proxyA middlebox completes the handshake and passes on only finished connectionsMoves the load onto the middlebox §3.8Not modeled

Spotting it on a serverCount half-open connections with netstat -an | grep SYN_RECV | wc -l; the model's board footer shows the same count. The slide treats more than 100 as an early sign of a SYN flood (slide 58). On Linux each SYN_RECV entry costs about 304 bytes of memory kernel docs.

Finding who is sendingSlide 58's second command counts connections per source address: netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n. Against a spoofed flood it finds nothing useful, because every SYN carries a different fake address, so each one appears once, as on the model's board. It helps against a botnet that floods from its real addresses, where a few sources show up hundreds of times.

Platform 2: Mirai botnet and the DGA

How cameras and routers with factory passwords became one remote-controlled botnet

Slides 51 and 52

In 2016 Mirai took over about 600,000 cameras, video recorders and routers at its peak Antonakakis §4.2, just by logging in over with factory-default passwords. The infected devices formed a that flooded targets on orders from a server. The bots only find victims; a separate loader server does the infecting §2.

Slide 52 puts Mirai and DGA together. They came at different times.The 2016 Mirai reached its C2 through domain names written into its code, and researchers pulled 67 of them out of the binaries §3.3. A appeared later in one short-lived variant, used only when those hardcoded domains failed to resolve Netlab, Dec 2016. The two models below keep them apart.

Two numbers that differ from slide 52The slide gives about 60 default logins and "millions" of devices. The Mirai source code holds 62 username and password pairs, and the measured peak was about 600,000 devices at once Antonakakis §2, §4.2. The slide also describes DGAs that make thousands of names a day; that is true of DGAs in general, while the Mirai variant made one Netlab.

Model 2: the infection loop

The red loop line is one infection, stop by stop, as described in the Mirai paper §2. Below it is a neighborhood of 24 devices. Device .10 is already a bot, and the rest of the internet is scanning too.

ScanBrute-forceReport LoadLock inAwait orders TCP 23, 232310 of 62 pairsIP + login push buildhide in RAMC2, then scan
Factory-default passwordOwner's own passwordInfected (bot)
Scan logNewest on top
TargetEvent
Announcement

Your move

Model 3: how bots find their C2

Compare a fixed C2 address with a . Each day the bot and the operator run the same function on the date and get the same list of names. The operator registers one; the rest return . This is a teaching formula with reserved test domains, not Mirai's real algorithm, and it makes 5 names a day where the Mirai variant made 1 Netlab.

C2 lookupsDay
DomainAnswer

          
Announcement

Your move

Hardcoded C2 vs DGA

Hardcoded C2 (Mirai, 2016)DGA (later variant)
Where the address comes fromWritten into the malwareComputed each day from the date and a shared seed
To cut the bots offTake down one domainBeat every future domain
Defender's movePull the names from the binary and block or themReverse the algorithm, register names ahead, watch for bursts of NXDOMAIN ATT&CK T1568.002
Weak spotA single point of failureThe algorithm can be recovered, and the failed lookups are noisy

How big it got

DateEvent
1 Aug 2016First scan; 64,500 devices infected within 20 hours §4.1
21 Sep 2016623 Gbps attack on the Krebs on Security blog §6.3
30 Sep 2016Source code published; copycat variants follow §5.2
21 Oct 2016Attack on DNS provider Dyn disrupts Amazon, GitHub, Netflix, Twitter and others. It included SYN floods on port 53, the attack from platform 1 §6.3
End of Nov 2016Peak of about 600,000 infected devices §4.2
9 Dec 2016A variant with a DGA is reported, spreading through ports 7547 and 5555 Netlab

DefenseChanging default passwords and turning off Telnet stops the infection at the source. A reboot alone clears the malware from RAM, but an unchanged device is found and infected again CISA TA16-288A. Against a DGA, flag machines with many NXDOMAIN answers and sinkhole the predicted names ATT&CK T1568.002.

Spotting an infected deviceA bot scans for the next victim, so on your own network a camera or router that suddenly opens many outbound connections to TCP 23 and 2323 is probably infected Antonakakis §2. Block outbound Telnet from IoT devices at the firewall, so an infected one cannot recruit others.

Platform 3: TCP session hijacking in 3 phases

Taking over a live connection by forging the numbers it trusts

Slides 63 to 66

Once a TCP connection is open, each end accepts any packet with the right addresses, ports and numbers. Nothing else proves who sent it. An attacker between client and server can read those numbers, knock the two ends out of step, then speak to the server as the client Joncheray 1995.

Model 4: hijack a Telnet session

The handshake is done: the client started at 100, the server at 300, the same numbers as slide 63. The three boards show what each side expects next. The server accepts a packet only if its SEQ equals the byte it expects next (inside its window) RFC 9293 §3.10.7.4.

  1. Track and sniff
  2. Desynchronize
  3. Inject
  4. ACK storm
Client192.0.2.23 Attacker, on the path Server:23 Telnet
Client
Next SEQ it sends
Next byte it expects
Attacker's copy
Client's next SEQ
Server's next SEQ
Server
Next byte it expects
Next SEQ it sends
Packet logNewest on top
PathSEQACKCarriesResult
Announcement

Your move

Protection on this connection

Two ways to desynchronizeThe model injects harmless null data (Telnet no-ops) into an open session, so the server's count jumps ahead of the client's. The other way, early desync, strikes during setup: the attacker resets the half-built connection with an and opens a new one with a different starting number Joncheray. Either way the result is the same state, and an follows.

Spotting itA network IDS sees what the packet log in the model shows: a sudden jump in a connection's sequence numbers (the "SEQ Jump" indicator on slide 80) and bursts of empty ACKs going back and forth between two hosts. The lab tool on slides 66 and 67, Hunt, does the same three phases on a real LAN: it lists active connections, resets or desynchronizes one, and injects into it.

Network-level vs application-level hijacking

Network-level (this model)Application-level
Layer3 and 4: IP and TCP7: HTTP and HTTPS
What is taken overThe TCP stream itselfThe session cookie or token
HowSniff SEQ/ACK, desynchronize, inject; RST tricksXSS, session fixation, sniffing cookies sent over plain HTTP
Works againstAny TCP applicationWeb applications
Main defenseEncrypt and authenticate packets (TLS, IPsec); unpredictable stop attackers off the path RFC 6528Cookie flags Secure, HttpOnly, SameSite, plus HSTS (slides 76 to 78)

The three attacks side by side

SYN floodMiraiTCP session hijack
Part of CIA hitAvailabilityAvailability, through the DDoS it launches; the devices themselves are taken overIntegrity and confidentiality
LayerTransport (TCP)Application (Telnet login) to recruit; its floods hit several layersNetwork and transport (IP, TCP)
What it abusesThe server stores state before the client is proven realFactory-default passwords on exposed TelnetTrust in any packet with the right IP, port and SEQ/ACK
Attacker needsA way to send many SYNs; spoofing hides the sourceInternet reach to devices with Telnet openA position on the path, or ISNs it can guess
Stages4 (slide 45)6-stop loop (paper §2)3 phases (slide 65)
Best defenseSYN cookies; filtering and scrubbing upstreamChange default passwords, close Telnet, patchEncryption with authentication: TLS, IPsec; random ISNs

Terms

3-way handshake
The three packets (SYN, SYN/ACK, ACK) that open a TCP connection before any data moves. RFC 9293 §3.5
TCB
Transmission Control Block: the record a host keeps in memory for each connection, holding its addresses, ports, sequence numbers and state. RFC 9293 §3.3.1
Half-open connection (SYN_RECV)
A connection the server has answered with SYN/ACK but that has not received the final ACK yet. RFC 4987 §2.2
Backlog (SYN queue)
The limit on how many half-open connections a listening port holds. When it is full, new SYNs are dropped. RFC 4987 §2.2
IP spoofing
Writing a false source address into a packet, so the replies go somewhere else. RFC 4987 §2.2
RST
A TCP flag that aborts a connection at once. A host sends it when a packet does not belong to any connection it knows. RFC 9293 §3.5.2
ISN
Initial Sequence Number: each side's starting count. It must be hard to predict, or an attacker off the path can guess it. RFC 6528 §3
SEQ and ACK numbers
SEQ numbers the bytes a side sends; ACK names the next byte it expects. A segment is accepted only if its SEQ falls inside the receiver's window. RFC 9293 §3.4
Botnet
A group of malware-infected devices controlled remotely as one. CISA TA16-288A
C2 (command and control)
The server an operator uses to send orders to infected devices. MITRE ATT&CK
Telnet
An old remote-login protocol that sends everything, passwords included, unencrypted. Mirai scanned for it on TCP ports 23 and 2323. Antonakakis §2
DGA
Domain Generation Algorithm: code that malware and its operator both run to compute the same changing list of C2 domain names, usually from the date. ATT&CK T1568.002
NXDOMAIN
The DNS answer that means the name does not exist. Many of them from one machine is a sign of a DGA at work. ATT&CK T1568.002
Sinkhole
Defenders take control of a C2 name and point it at their own server. Bots that connect there are cut off from the operator and reveal themselves. ATT&CK T1568.002
On-path attacker
Also called man-in-the-middle: an attacker on the route between two hosts, who can see their packets and send forged ones, such as someone on the same Wi-Fi or a compromised router. Joncheray
Desynchronized state
Both ends think the connection is open, but each one's SEQ falls outside what the other expects, so their own packets get rejected. Joncheray
ACK storm
Two desynchronized ends answering each other's unacceptable packets with ACKs, in a loop. The ACKs carry no data, so one lost packet ends it. Joncheray
TLS and IPsec ESP
TLS encrypts and authenticates the data inside a TCP connection; ESP does the same for whole IP payloads, TCP header included. Forged bytes fail their integrity checks. RFC 8446 RFC 4303

Sources

  1. Eddy, W. (ed.). Transmission Control Protocol (TCP). RFC 9293, IETF, Aug 2022. rfc-editor.org/rfc/rfc9293
  2. Eddy, W. TCP SYN Flooding Attacks and Common Mitigations. RFC 4987, IETF, Aug 2007. rfc-editor.org/rfc/rfc4987
  3. The Linux kernel documentation. IP sysctl (tcp_synack_retries, tcp_syncookies, tcp_max_syn_backlog). docs.kernel.org/networking/ip-sysctl.html
  4. Gont, F. and Bellovin, S. Defending against Sequence Number Attacks. RFC 6528, IETF, Feb 2012. rfc-editor.org/rfc/rfc6528
  5. Antonakakis, M. et al. Understanding the Mirai Botnet. 26th USENIX Security Symposium, 2017. usenix.org
  6. Liu, Y. Now Mirai Has DGA Feature Built in. 360 Netlab blog, 9 Dec 2016. blog.netlab.360.com
  7. US-CERT / CISA. Heightened DDoS Threat Posed by Mirai and Other Botnets. Alert TA16-288A, 14 Oct 2016. cisa.gov
  8. MITRE ATT&CK. Dynamic Resolution: Domain Generation Algorithms, T1568.002. attack.mitre.org
  9. Joncheray, L. A Simple Active Attack Against TCP. 5th USENIX UNIX Security Symposium, 1995. usenix.org
  10. Rescorla, E. The Transport Layer Security (TLS) Protocol Version 1.3. RFC 8446, IETF, Aug 2018. rfc-editor.org/rfc/rfc8446
  11. Kent, S. IP Encapsulating Security Payload (ESP). RFC 4303, IETF, Dec 2005. rfc-editor.org/rfc/rfc4303
  12. Arkko, J. et al. IPv4 Address Blocks Reserved for Documentation. RFC 5737, IETF, Jan 2010 (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24, used for every address in the models). rfc-editor.org/rfc/rfc5737
  13. Eastlake, D. and Panitz, A. Reserved Top Level DNS Names. RFC 2606, IETF, Jun 1999 (.example, .test, .invalid, used for every domain in the models). rfc-editor.org/rfc/rfc2606

Lecture material: EHE Cyber Module 07, Part 2, Network Level Attacks (slides 44 to 46, 51 and 52, 58, 63 to 67, 76 and 80).