1. DoS (Denial of Service)¶
A DoS attack is carried out by a single source to exhaust system resources (CPU, memory, bandwidth) and disrupt normal operations.
Types of DoS Attacks:¶
- Volumetric Attacks β Flooding the target with excessive traffic (e.g., UDP flood, ICMP flood).
- Protocol Attacks β Exploiting weaknesses in network protocols (e.g., SYN flood, Ping of Death).
- Application Layer Attacks β Targeting web applications (e.g., HTTP Flood, Slowloris attack).
Example:¶
A hacker continuously sends ping requests (ICMP flood) to a web server, consuming its resources and causing it to crash.
2. DDoS (Distributed Denial of Service)¶
A DDoS attack is a large-scale attack performed using multiple compromised devices (botnet), making it harder to mitigate.
How it Works:¶
- The attacker infects multiple computers or IoT devices with malware.
- These devices (botnets) receive instructions to flood the target.
- The massive traffic volume overwhelms the system, causing downtime.
Types of DDoS Attacks:¶
- Volumetric Attacks β Large-scale traffic floods from multiple sources (e.g., DNS Amplification, NTP Amplification).
- Protocol Attacks β Exploiting vulnerabilities at the transport and network layers (e.g., SYN flood).
- Application Layer Attacks β Targeting application resources (e.g., HTTP GET/POST Flood).
Example:¶
A hacker uses a botnet of thousands of infected devices to flood an e-commerce website with HTTP requests, making it inaccessible.
Key Differences:¶
| Feature | DoS | DDoS |
|---|---|---|
| Attack Source | Single machine | Multiple machines (botnet) |
| Scale of Attack | Small to medium | Large-scale, more powerful |
| Complexity | Simple to detect & block | Harder to mitigate due to multiple sources |
| Mitigation | Firewall, rate limiting | DDoS protection services (Cloudflare, AWS Shield) |
How to Prevent DoS & DDoS Attacks¶
βοΈ Use a Web Application Firewall (WAF)
βοΈ Implement rate limiting and traffic filtering
βοΈ Use DDoS protection services (Cloudflare, Akamai, AWS Shield)
βοΈ Monitor network traffic for anomalous activity
βοΈ Deploy CDNs (Content Delivery Networks) to distribute traffic
π§ͺ DoS Attack Demonstration using hping3 (Educational Tutorial)¶
β οΈ Disclaimer: This tutorial is for educational purposes only. Never perform DoS attacks on public or unauthorized systems. Only test in isolated environments you control (e.g., VMs, Docker, local LAN).
π οΈ What Youβll Learn¶
-
How to simulate a basic SYN Flood Attack using
hping3 -
How the target machine reacts
-
How to monitor and optionally defend against it
π§° Requirements¶
| Role | System | Tools Needed |
|---|---|---|
| Attacker | VM or Host | hping3 |
| Target | VM or Host | Python / Netcat listener |
π§ Step 1: Set Up the Target Machine¶
πΉ Option A: Run a simple HTTP server¶
πΉ Option B: Use Netcat to open port 80¶
Keep this terminal open. It simulates a real server listening for connections.
π£ Step 2: Launch a SYN Flood from the Attacker Machine¶
β
Install hping3¶
Ubuntu/Debian:
Fedora/RHEL:
π₯ Run the Attack (SYN Flood)¶
Replace
TARGET_IPwith the IP address of your target machine.
β What each flag means:¶
-
-S: Sends SYN packets (like initiating a TCP handshake) -
--flood: Sends packets rapidly, as fast as possible -
-V: Enables verbose output -
-p 80: Sends packets to port 80
π Step 3: Observe Target Behavior¶
On the Target machine:¶
Or:
Youβll likely see a lot of SYN_RECV entries β these are half-open connections, indicating a SYN flood.
π What Happens?¶
-
The targetβs CPU/network may spike
-
Services on port 80 may slow down or become unresponsive
-
Youβre seeing a resource exhaustion attack in action
π‘οΈ Step 4: Mitigation (Optional)¶
πΈ Enable SYN Cookies¶
πΈ Apply Iptables Rate Limiting¶
sudo iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT
sudo iptables -A INPUT -p tcp --syn -j DROP
πΈ Monitor with iftop or tcpdump¶
π§ͺ Bonus: Use Docker for a Self-Contained Lab¶
Let me know if you want a Docker-based version of this demo (attacker and victim as separate containers). Super handy for safe, repeatable labs.
β Summary¶
| Step | Action |
|---|---|
| 1. Setup | Simple server on target (python3 -m http.server) |
| 2. Install | Install hping3 on attacker machine |
| 3. Launch | Run hping3 -S --flood -p 80 TARGET_IP |
| 4. Observe | Use netstat, ss, or htop on target |
| 5. Optional | Apply mitigation like SYN cookies / iptables |
π§ͺ DDoS Attack Simulation using hping3 (Educational Tutorial)¶
β οΈ Legal Notice: DDoS attacks are illegal on public infrastructure. This guide is strictly educational and must be run in a private network that you own β like a local lab, virtual machines, or Docker setup.
π― What Youβll Do¶
-
Set up 1 victim server and 2+ attacker systems (VMs, Docker, or even WSL)
-
Use
hping3on each attacker to simulate a coordinated SYN Flood -
Observe the impact on the victim machine
-
Learn about DDoS mitigation
π§° Requirements¶
| Machine | Role | Requirements |
|---|---|---|
| VM1 | Victim | Python or Netcat |
| VM2, VM3... | Attackers | hping3 installed |
Use VirtualBox, VMware, or Docker with separate IPs in a NAT/host-only network.
π§ Step 1: Set Up the Victim Server¶
On the victim machine (VM1):
Option A: Python HTTP Server¶
Option B: Netcat Listener¶
π Step 2: Prepare the Attackers¶
On each attacker machine (VM2, VM3, etc.), install hping3:
π₯ Step 3: Launch the DDoS (Simulated)¶
On each attacker, run the following command (change TARGET_IP to the IP of the victim):
Run this simultaneously from multiple attacker VMs to simulate a DDoS.
π Step 4: Observe the Attack¶
On the victim machine:¶
Run:
Or:
Youβll see a surge in SYN_RECV connections β this means multiple systems are overwhelming the target with TCP requests, simulating a Distributed SYN Flood.
π Optional: Monitor with iftop or tcpdump¶
Or:
Youβll see traffic flooding in from multiple attacker IPs.
π‘οΈ Step 5: Mitigation Techniques¶
π 1. Enable SYN Cookies¶
π 2. Rate Limit with Iptables¶
sudo iptables -A INPUT -p tcp --syn -m limit --limit 2/s --limit-burst 5 -j ACCEPT
sudo iptables -A INPUT -p tcp --syn -j DROP
π 3. Use Fail2Ban or TCPShield for dynamic banning (advanced)¶
β Summary¶
| Step | Description |
|---|---|
| Step 1 | Start web server on victim |
| Step 2 | Install hping3 on attackers |
| Step 3 | Run SYN flood from multiple attacker machines |
| Step 4 | Monitor victim with netstat, iftop, etc. |
| Step 5 | Try mitigations like iptables or SYN cookies |