Overview
TCP Flood is a Layer 4 (transport layer) denial of service attack that floods a target with TCP connections and random data packets. Unlike HTTP attacks that target application logic, TCP Flood attacks the network layer by exhausting connection tables, bandwidth, and firewall resources.This attack operates at the TCP level and works against any TCP service, not just HTTP servers.
How it works
The TCP Flood attack executes the following sequence:- Connection Establishment: Opens TCP connection to target host:port
- Random Payload Generation: Creates buffer of cryptographically random bytes
- Initial Burst: Sends first payload packet with 2-second write deadline
- Additional Bursts: Sends 1-4 additional random payloads in rapid succession
- Connection Close: Closes connection immediately after bursts
- Repeat: Each thread continuously opens new connections
Attack pattern
When to use
TCP Flood is effective for:- Firewall stress testing: Test firewall’s connection tracking capacity
- Load balancer testing: Verify load balancer handles connection churn
- Network infrastructure testing: Stress test routers, switches, and network appliances
- Non-HTTP services: Attack game servers, databases, or any TCP service
- Connection table exhaustion: Fill up server’s connection tracking table
- Bandwidth saturation: Consume upstream/downstream bandwidth
Usage
Basic TCP Flood attack:Parameters
Target in format
tcp://hostname:port or hostname:port. Protocol can be omitted.Attack duration in seconds
Delay between connection attempts in milliseconds per thread
Size of random payload per burst. Defaults to 512 bytes if not specified or ≤ 0.
Number of concurrent attack threads (0 = number of CPU cores)
Show detailed logs for each connection attempt
Allow running without proxies (exposes your IP)
Expected behavior
Console output
Standard mode:Network behavior
- Connection lifecycle: Connect → Send bursts → Close (short-lived)
- Payload randomness: Uses
crypto/randfor unpredictable data - Burst count: 1-4 additional bursts per connection (random)
- Write timeout: 2 seconds per send operation
- Total data sent:
packet-size * (1 + burst_count)bytes per connection
Technical implementation
Implementation details frominternal/attacks/tcp/flood.go:17-55:
- Dialer: Uses
DialedTCPClientfrominternal/netutil - Randomness: Cryptographically secure random via
crypto/rand - Error handling: Silently ignores connection and write errors
- Burst calculation:
min(3, 1 + randIntn(3))= 1-4 bursts - Proxy support: Routes through SOCKS/HTTP proxies when available
- Context awareness: Respects cancellation signals
Code flow
Performance characteristics
Throughput optimization
Throughput optimization
- Lower delay = more connections per second
- More threads = higher aggregate connection rate
- Larger packet-size = more bandwidth consumed per connection
- More proxies = better distribution and harder to block
- Connections/sec: ~320 (32 threads × 10 conn/sec)
- Bandwidth: ~1.3-1.6 MB/sec (accounting for bursts)
Resource usage
Resource usage
- CPU: Low (mainly network I/O wait)
- Memory: ~4KB per thread for buffers
- Network: Depends on packet-size and delay
- File descriptors: One per active connection (short-lived)
Proxy considerations
Proxy considerations
- SOCKS5: Recommended for TCP proxying
- HTTP CONNECT: Also supported
- Proxy overhead: ~100-200ms additional latency
- Proxy health: Failed proxies are silently skipped
Attack effectiveness factors
Target vulnerabilities
- Vulnerable targets
- Resistant targets
- Servers without connection rate limiting
- Services with small connection tables
- Unoptimized firewalls/NAT devices
- Bandwidth-constrained networks
- Applications that process random data
Maximizing impact
Scale threads appropriately
Use 16-64 threads for most targets. Higher thread counts may saturate your own network.
Adjust packet size
- Small (128-512 bytes): More connections, less bandwidth
- Large (2048-4096 bytes): Fewer connections, more bandwidth
Defense mechanisms
If you’re protecting against TCP Flood attacks:- SYN cookies: Enable at OS level to mitigate SYN floods
- Connection rate limiting: Limit new connections per IP per second
- Connection table tuning: Increase
nf_conntrack_maxon Linux - Firewall rules: Drop packets from known malicious sources
- TCP timeout reduction: Lower
tcp_fin_timeoutto free resources faster - DDoS mitigation: Use services like Cloudflare, AWS Shield, or Arbor
Example iptables rules
Target examples
HTTP/HTTPS servers
Game servers
Database servers
Custom services
Related attack methods
HTTP Flood
Layer 7 HTTP request flood
Minecraft Ping
Specialized Minecraft server attack