Cyber Services / All lessons / CEH — Ethical Hacking / Learn DDOS Attack

Learn DDOS Attack

Module 58 of 130 · 14 min read · Free to read

MODULES ↓ Command blocks have a COPY button

Comprehensive guide for Certified Ethical Hacker students covering attack vectors, tools, mitigation strategies, and ethical practices

LEGAL & ETHICAL WARNING: Launching DDoS attacks, or even possessing DDoS tools with malicious intent, is illegal in almost all jurisdictions. All information, tool mentions, and commands presented here are strictly for educational and defensive understanding ONLY within controlled, isolated lab environments. Never target any system without explicit, written authorization.

I. Understanding Denial-of-Service (DoS vs. DDoS)

Core Concept: The goal is to make a target system (server, network device, application) unavailable to legitimate users by overwhelming its resources or exploiting vulnerabilities that cause it to crash or become unresponsive.
  • Denial-of-Service (DoS): Attack originates from a single source. Easier to identify and block the offending IP address.
  • Distributed Denial-of-Service (DDoS): Attack originates from multiple, distributed sources (often thousands or millions of compromised devices called a botnet). This makes mitigation significantly harder as there isn't a single source IP to block.

Why DDoS Matters for CEH:

  • Direct Impact: Causes significant disruption, financial loss, and reputational damage to organizations.
  • Smokescreen: Can be used to distract security teams while other malicious activities (e.g., data exfiltration, malware injection) occur.
  • Understanding Infrastructure Limits: Assessing an organization's resilience requires understanding DDoS vectors and mitigation capacity.
  • Defense Strategy: Knowing attack methods is crucial for designing and implementing effective defenses.

II. The DDoS Attack Lifecycle

Understanding the typical stages helps in identifying potential points for detection and prevention:

  1. Target Identification & Reconnaissance: Attacker identifies a victim and gathers information about their infrastructure (IP ranges, services, potential weaknesses).
  2. Botnet Assembly/Rental: Attacker uses their own botnet or rents time on an existing one via illegal "DDoS-for-Hire" (Booter/Stresser) services. Bots are often compromised IoT devices, PCs, or servers.
  3. C&C Communication: The attacker (Botmaster/Herder) issues commands to the bots via a Command and Control (C&C) server or network (e.g., using IRC, HTTP/S, P2P protocols).
  4. Attack Launch: Bots receive instructions (target IP, port, attack type, duration) and simultaneously flood the target with malicious traffic.
  5. Impact & Persistence: The target's resources are overwhelmed, leading to service degradation or complete outage. Attacks may persist or change vectors.

III. Major DDoS Attack Categories & Vectors

Attacks are often categorized by the layer of the network stack they target or their primary goal.

Category Target Layer (OSI) Primary Goal Typical Characteristics Common Examples
Application Layer Attacks Layer 7 (Application) Exhaust Server Resources (CPU, Memory, Workers) Looks like legitimate traffic (harder to detect), lower bandwidth, targets application logic/flaws. Measured in Requests Per Second (RPS). HTTP Floods (GET/POST), Slowloris, R.U.D.Y., Application Exploits (SQLi leading to resource exhaustion), API Abuse, some DNS Query Floods.
Protocol Attacks Layer 3 (Network) / Layer 4 (Transport) Consume Server/Firewall State Tables or Exploit Protocol Weaknesses Medium bandwidth, targets stateful devices (firewalls, load balancers), exploits TCP/IP flaws. Measured in Packets Per Second (PPS). SYN Flood, ACK Flood, Fragmentation Attacks (Teardrop - largely historical), Ping of Death (historical).
Volumetric Attacks Layer 3 (Network) / Layer 4 (Transport) Saturate Network Bandwidth High bandwidth (Gbps/Tbps), aims to clog the network pipe, often uses amplification/reflection. Measured in Bits Per Second (BPS). UDP Flood, ICMP Flood (Ping Flood), Amplification/Reflection Attacks (DNS, NTP, SSDP, Memcached, Chargen).

A. Application Layer Attacks (Layer 7) - In Detail

Goal: Overwhelm Application/Server Logic

  • HTTP Flood: Bombarding a web server with excessive legitimate-looking HTTP GET or POST requests. Can target computationally expensive operations (e.g., database lookups, complex searches).

    Mitigation often involves WAFs with rate limiting, CAPTCHAs, behavioral analysis, and IP reputation.

  • Slowloris & Variants (e.g., Slow POST, R.U.D.Y.): Attacker opens many connections and keeps them alive by sending data very slowly or in incomplete fragments. This ties up server connection slots, preventing legitimate users from connecting. Low bandwidth, high impact on connection tables.

    Mitigation includes limiting connection duration, increasing max connections (carefully), specific server module configurations (e.g., mod_reqtimeout for Apache), and WAFs that detect slow patterns.

  • API Abuse: Flooding application programming interfaces (APIs) with excessive or malformed requests, consuming backend resources.
  • Database Connection Exhaustion: Exploiting application logic (sometimes via SQLi) to force the application to open excessive database connections, exhausting the pool.

B. Protocol Attacks (State Exhaustion) - In Detail

Goal: Consume Resources of Stateful Devices

  • SYN Flood: Exploits the TCP three-way handshake. Attacker sends many SYN packets (often with spoofed source IPs) but never sends the final ACK. The server keeps half-open connections waiting, filling its connection state table (SYN backlog queue) and preventing legitimate connections.
    # Conceptual Example (hping3 - Educational Use ONLY)
    sudo hping3 --syn --flood --rand-source -p 80 TARGET_IP

    Mitigation: SYN Cookies (server responds with cryptographic cookie instead of storing state), increasing backlog queue size, firewall SYN rate limiting, RST cookies.

  • ACK Flood / ACK & PUSH Flood: Floods the target with TCP ACK or PUSH-ACK packets that don't belong to any existing connection. Forces the server/firewall to check its state table for each packet, consuming CPU resources.
  • Fragmentation Attacks (e.g., Teardrop - Largely Historical): Sends fragmented IP packets with overlapping offsets or invalid information, potentially crashing older systems trying to reassemble them. Modern systems are generally resilient.

C. Volumetric Attacks (Bandwidth Saturation) - In Detail

Goal: Clog the Network Pipe

  • UDP Flood: Floods the target with UDP packets, typically aimed at random ports. The server checks for applications listening on those ports, consumes resources replying with ICMP "Destination Unreachable" messages (if not firewalled), and saturates bandwidth.
    # Conceptual Example (hping3 - Educational Use ONLY)
    sudo hping3 --udp --flood --rand-source -p 53 TARGET_IP
  • ICMP Flood (Ping Flood): Overwhelms the target with ICMP Echo Request (ping) packets. The target consumes resources processing requests and bandwidth sending Echo Replies.
    # Conceptual Example (hping3 - Educational Use ONLY)
    # -i u1000 = send every 1000 microseconds (very fast)
    sudo hping3 --icmp --flood -i u1000 TARGET_IP
  • Amplification / Reflection Attacks: Exploits protocols that send a larger response than the initial request, using publicly accessible servers (like DNS resolvers, NTP servers) as intermediaries.
    1. Attacker sends small query packets to multiple Amplifier servers, spoofing the source IP address to be the victim's IP.
    2. Amplifier servers send large response packets to the victim (the spoofed source).
    3. Result: Victim is flooded with unwanted traffic amplified many times over the attacker's original bandwidth.

    Common Amplifiers & Factors (Approximate): DNS (~28-54x), NTP (monlist command, ~556x - often disabled now), SSDP (~30x), Memcached (~10,000-50,000x!), Chargen (~358x - rare now).

    Mitigation: BCP38/uRPF (preventing IP spoofing at ISP level), firewalling unnecessary UDP ports, rate limiting responses from potentially abused services, using DDoS mitigation services that absorb amplified traffic.

IV. Botnets: The Engine of DDoS

Botnet Fundamentals: A network of compromised devices (bots) controlled remotely by an attacker (Botmaster/Herder) via a Command & Control (C&C) infrastructure.
  • Bot Types: Compromised PCs, servers, mobile devices, and increasingly, Internet of Things (IoT) devices (cameras, routers, DVRs, smart appliances).
  • Why IoT is a Major Source: Weak default credentials, lack of patching mechanisms, large attack surface, often "always-on". (e.g., Mirai Botnet).
  • C&C Mechanisms: Centralized (e.g., single web server, IRC channel - easier to take down) or Decentralized (P2P - more resilient). Communication often encrypted or uses common protocols (HTTP/S) to blend in.
  • Recruitment: Malware distribution via phishing, exploit kits, brute-forcing weak credentials, exploiting vulnerabilities.
  • DDoS-for-Hire (Booters/Stressers): Illegal online services allowing anyone to rent botnet time to launch DDoS attacks, often marketed deceptively as "network stress testing tools".

V. DDoS Mitigation Strategies: A Layered Defense

Effective DDoS defense requires a multi-layered approach, combining proactive prevention and reactive response.

1. Preparation & Prevention (Proactive)

  • Infrastructure Hardening: Patch systems promptly, disable unused services/ports, use strong authentication, implement network segmentation.
  • Network Design: Sufficient bandwidth overhead, redundant network paths.
  • Ingress/Egress Filtering (BCP38/uRPF): ISPs implement checks to prevent traffic with spoofed source IPs from entering/leaving their network. Essential for stopping reflection attacks at the source.
  • Firewall/ACL Configuration: Block known bad IPs/ranges, restrict access to management ports, implement basic rate limiting (though stateful firewalls can be overwhelmed by protocol attacks).
  • SYN Cookies: Server-level defense against SYN floods.
  • Web Application Firewall (WAF): Crucial for Layer 7 protection. Can filter malicious HTTP requests, rate limit specific URLs, enforce security policies, challenge suspicious clients (CAPTCHA, JavaScript challenges).
  • Content Delivery Network (CDN): Distributes website content geographically closer to users. Can absorb large amounts of volumetric traffic at their edge, cache content (reducing origin load), and often include WAF features.

2. Detection & Analysis

  • Traffic Monitoring & Baselining: Establish normal traffic patterns (volume, types, sources). Use tools like NetFlow, sFlow, IPFIX collectors, and network monitoring systems (NMS) to analyze traffic flows.
    # Simple real-time interface monitoring on Linux (Install with: sudo apt install nload)
    nload

    Look for sudden, unexplainable spikes in bandwidth (BPS), packets (PPS), or requests (RPS); unusual traffic types or port usage; traffic skewed towards specific IPs.

  • Anomaly Detection Systems: Use statistical or machine learning techniques to automatically identify deviations from the baseline.
  • Intrusion Detection/Prevention Systems (IDS/IPS): Can detect known attack signatures, but may struggle with zero-day or encrypted L7 attacks.
  • SIEM Integration: Correlate logs from firewalls, servers, WAFs, load balancers to get a holistic view of a potential attack.

3. Response & Mitigation (Reactive)

  • Rate Limiting: Dynamically restrict the number of connections or requests allowed from a single IP or subnet during an attack. Can be applied at firewall, load balancer, WAF, or server level.
  • IP Address Filtering/Blocking: Block attacking source IPs identified during analysis. Can be manual or automated based on reputation lists or anomaly detection.
  • Geo-Blocking: Block traffic from entire countries or regions unlikely to contain legitimate users.
  • Challenge-Response Tests: Use techniques like CAPTCHAs or JavaScript challenges (often via WAF/CDN) to filter out simple bots during L7 attacks.
  • Traffic Scrubbing Centers / Cloud Mitigation Services: Specialized services (e.g., Cloudflare, Akamai, AWS Shield, Azure DDoS Protection) designed to handle massive DDoS attacks.
    • Traffic is rerouted (via BGP or DNS) to the provider's global network.
    • Malicious traffic is filtered ("scrubbed") using sophisticated techniques (packet inspection, behavioral analysis, threat intelligence).
    • Clean traffic is forwarded back to the origin infrastructure.

    This is often the only effective defense against large-scale volumetric attacks.

  • Null Routing / Blackholing: (ISP-level or self-managed) Directing all traffic destined for the target IP address into a "black hole," effectively dropping it. Stops the attack but makes the service completely unavailable. Usually a last resort.
  • Incident Response Plan (IRP): Have a pre-defined plan detailing steps to take, contacts (ISP, mitigation provider), communication strategies, and escalation procedures during an attack.

VI. DDoS Tools: Understanding the Landscape (Educational Context ONLY)

EXTREME WARNING & ETHICAL OBLIGATION: Possession or use of DDoS tools against any system without explicit, written authorization is ILLEGAL and UNETHICAL. The tools and commands listed below are discussed and shown solely for educational purposes within a secure, isolated, and authorized lab environment. The goal is to understand potential attacker methods, recognize attack signatures, and appreciate the necessity of robust defenses. NEVER attempt to download, install, or execute these tools or commands against any target you do not own and have explicit permission to test within your isolated lab. Downloading code from untrusted sources carries significant malware risk. You are responsible for any misuse.

Understanding the types of tools used in DDoS attacks helps defenders anticipate threats. They fall into several categories:

1. Historical / Basic Flood Tools (Primarily for Conceptual Understanding)

  • LOIC (Low Orbit Ion Cannon):
    • Function: Simple, open-source TCP/UDP/HTTP flooder.
    • Relevance: Historically significant. Demonstrates basic flooding.
    • Limitations: Very "noisy," easily detected, directly exposes the user's IP.
    • CEH Takeaway: Understand the concept of basic flooding attacks and recognize LOIC's limitations.
    • Example Setup/Execution (Conceptual - Lab Environment Only - DO NOT Execute Without Permission!):
      # Note: Obtaining LOIC requires finding a source. Be extremely cautious.
      # Example assumes a Linux executable named LOIC.exe (uncommon, often Windows)
      chmod +x LOIC.exe
      ./LOIC.exe # This would typically launch a GUI or CLI interface

      This illustrates making a downloaded file executable and running it. The specific steps depend heavily on the version and operating system.

  • HOIC (High Orbit Ion Cannon):
    • Function: Successor to LOIC, using HTTP floods with "booster" scripts. Targets multiple domains.
    • Relevance: Shows evolution towards application-layer flooding.
    • Limitations: Still relatively easy to detect.
    • Example Download (Conceptual - Lab Environment Only - DO NOT Execute Without Permission!):
      # Example using git to clone a repository (Repository might be defunct or unsafe)
      git clone https://github.com/HyunsooKim01/HOIC
      cd HOIC
      # Further steps would involve running the specific HOIC executable/script

      This shows how code might be obtained from a repository. Requires extreme caution regarding the source.

  • XOIC (eXtended Orbit Ion Cannon):
    • Function: Another variant often based on LOIC/HOIC principles (TCP/UDP/HTTP/ICMP modes).
    • Relevance: Demonstrates variations on the basic flooding theme.
    • Limitations: Shares fundamental weaknesses regarding detection and traceability.
    • Example Installation (Conceptual - Lab Environment Only - DO NOT USE Without Permission!):
      # Assumes a Debian/Ubuntu based system like Kali. 'pkg' might be for Termux/Android.
      # The commands below might not work directly or install the intended tool safely.
      sudo apt install python git -y # Install prerequisites
      git clone https://github.com/StormRLS/XOIC # Repository might be defunct/unsafe
      cd XOIC
      # Execution would typically involve running a python script, e.g., python xoic.py

      Illustrates typical steps: updating system, installing dependencies (python, git), cloning repository, changing directory. Actual execution varies.

2. Specific Protocol Attack Tools / Scripts

  • aSYNcrone:
    • Function: Tool specifically designed for launching SYN flood attacks.
    • Relevance: Demonstrates a tool focused on Layer 4 state exhaustion.
    • Limitations: Effectiveness depends on target's SYN flood defenses.
    • Example Installation & Execution (Conceptual - Lab Environment Only - DO NOT USE Without Permission!):
      sudo apt install gcc git -y # Install compiler and git
      git clone https://github.com/fatihsnsy/aSYNcrone.git # Repo might be defunct/unsafe
      cd aSYNcrone
      gcc aSYNcrone.c -o aSYNcrone -lpthread -O2 # Compile the C code
      # Example execution syntax (DO NOT RUN against unauthorized targets)
      # ./aSYNcrone    
      ./aSYNcrone 12345 192.168.1.100 80 10 # Example only

      Shows C code compilation using gcc after cloning. The execution command requires specific parameters.

  • DDoS-Ripper:
    • Function: Script-based tool for basic floods.
    • Relevance: Highlights ease of creating basic attack scripts.
    • Limitations: Lacks sophistication, easily blocked. Risky source.
    • Example Installation & Execution (Conceptual - Lab Environment Only - DO NOT USE Without Permission!):
      sudo apt install git python3 -y # Install prerequisites
      git clone https://github.com/palahsu/DDoS-Ripper.git # Repo might be defunct/unsafe
      cd DDoS-Ripper
      # Execution - Requires interaction after running the script
      python3 DRipper.py # Or potentially python2 DRipper.py if it's an older script

      Demonstrates cloning and running a Python script. The script likely prompts for target information.

3. Network Testing & Analysis Tools (Can be Misused)

  • hping3:
    • Function: Powerful command-line network packet crafting/analysis tool (Kali: sudo apt install hping3).
    • Relevance for CEH: Excellent for learning protocols, firewall testing, simulating flood components in a controlled lab.
    • Examples (Demonstration Purposes in Lab ONLY - NEVER use without permission!):
      # Simulate SYN Flood (requires root)
      sudo hping3 --syn --flood --rand-source -p 80 <LAB_TARGET_IP>
      
      # Simulate Ping Flood (requires root)
      sudo hping3 --icmp --flood -i u1000 <LAB_TARGET_IP>
      
      # Simulate UDP Flood (requires root)
      sudo hping3 --udp --flood --rand-source -p 53 <LAB_TARGET_IP>
      
      # Simulate conceptual Smurf component (requires root & specific network config)
      # Sending ICMP Echo to broadcast - DO NOT RUN ON PRODUCTION NETWORKS
      # sudo hping3 -1 --flood -a <VICTIM_IP> <BROADCAST_IP>
    • Caution: Use responsibly ONLY within authorized lab environments.
  • Slowhttptest:
    • Function: Tests server vulnerability to Slowloris-type attacks.
    • Relevance for CEH: Useful for defensive testing of web server configurations in a lab. (Kali: sudo apt install slowhttptest)
    • # Example: Test for slow headers vulnerability (Defensive lab testing ONLY)
      slowhttptest -c 1000 -H -g -o slowloris_results -i 10 -r 200 -t GET -u http://<LAB_TARGET_IP>/

4. Botnet Malware & Infrastructure

  • Examples: Mirai, Zeus, Gafgyt, etc.
  • Function: The actual malicious software and C&C infrastructure behind large-scale DDoS.
  • Relevance for CEH: Study malware analysis reports, C&C protocols, and infection vectors. Handling live malware requires specialized skills and secure environments.
CEH Focus Regarding Tools:
  • Recognize the signatures and traffic patterns these different tool types generate.
  • Understand the protocols being abused (HTTP, TCP, UDP, ICMP, DNS, NTP, etc.).
  • Know the corresponding mitigation techniques.
  • Focus on legitimate testing tools like hping3 or slowhttptest for defensive analysis within labs.
  • Do not waste time trying to master illegal attack tools. Understand them conceptually for defense.

VII. Legal and Ethical Imperatives

Non-Negotiable Rules for Ethical Hackers:
  • Authorization is Mandatory: Never conduct any form of DoS/DDoS testing or probing without explicit, written permission from the target system owner, clearly defining scope, duration, and allowed methods.
  • Legality: DDoS attacks violate laws like the Computer Fraud and Abuse Act (CFAA) in the US and similar legislation globally. Penalties can include hefty fines and imprisonment.
  • Collateral Damage: DDoS attacks can easily impact shared infrastructure or upstream providers, affecting innocent third parties. Avoid actions with potential unintended consequences.
  • Responsibility: Secure your own systems diligently to prevent them from becoming part of a botnet.
  • Focus on Defense: Your primary role as a CEH regarding DDoS is understanding the threat to better advise on, implement, and test defensive postures.

VIII. Conclusion

DDoS attacks represent a constant battle between attackers seeking disruption and defenders striving for availability. As aspiring CEH professionals, a deep understanding of attack vectors, the botnet ecosystem, and particularly the diverse array of mitigation techniques is crucial. Always prioritize learning defensive strategies and adhere strictly to legal and ethical boundaries. Your expertise should be used to build resilience, not cause harm.

Modules (130) ← CEH — Ethical Hacking