Skip to main content

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:
  1. Connection Establishment: Opens TCP connection to target host:port
  2. Random Payload Generation: Creates buffer of cryptographically random bytes
  3. Initial Burst: Sends first payload packet with 2-second write deadline
  4. Additional Bursts: Sends 1-4 additional random payloads in rapid succession
  5. Connection Close: Closes connection immediately after bursts
  6. 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
This attack generates significant network traffic and can affect network infrastructure. Only use on networks you own or have permission to test.

Usage

Basic TCP Flood attack:
Attacking a game server:
High-intensity attack:

Parameters

string
required
Target in format tcp://hostname:port or hostname:port. Protocol can be omitted.
int
default:"60"
Attack duration in seconds
int
default:"500"
Delay between connection attempts in milliseconds per thread
int
default:"512"
Size of random payload per burst. Defaults to 512 bytes if not specified or ≤ 0.
int
default:"0"
Number of concurrent attack threads (0 = number of CPU cores)
boolean
default:"false"
Show detailed logs for each connection attempt
boolean
default:"false"
Allow running without proxies (exposes your IP)

Expected behavior

Console output

Standard mode:
Verbose mode:

Network behavior

  • Connection lifecycle: Connect → Send bursts → Close (short-lived)
  • Payload randomness: Uses crypto/rand for 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 from internal/attacks/tcp/flood.go:17-55:
  • Dialer: Uses DialedTCPClient from internal/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

  • 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
Example: 32 threads, 100ms delay, 1024-byte packets
  • Connections/sec: ~320 (32 threads × 10 conn/sec)
  • Bandwidth: ~1.3-1.6 MB/sec (accounting for bursts)
  • 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)
  • 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

  • Servers without connection rate limiting
  • Services with small connection tables
  • Unoptimized firewalls/NAT devices
  • Bandwidth-constrained networks
  • Applications that process random data

Maximizing impact

1

Tune delay for optimal rate

Start with 500ms, reduce to 50-100ms for high-rate attacks.
2

Scale threads appropriately

Use 16-64 threads for most targets. Higher thread counts may saturate your own network.
3

Adjust packet size

  • Small (128-512 bytes): More connections, less bandwidth
  • Large (2048-4096 bytes): Fewer connections, more bandwidth
4

Use quality proxies

SOCKS5 proxies with low latency and high bandwidth are ideal.

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_max on Linux
  • Firewall rules: Drop packets from known malicious sources
  • TCP timeout reduction: Lower tcp_fin_timeout to 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

HTTP Flood

Layer 7 HTTP request flood

Minecraft Ping

Specialized Minecraft server attack