# Guide on DoS & DDoS

Complete Guide on DoS & DDoS Attacks (For Educational & Defensive Purposes Only)&#x20;

<figure><img src="/files/9C0un7D3lKTR2ksfjpW9" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
Disclaimer: This guide is meant for educational purposes only to understand how attacks work and how to defend against them. Unauthorized attacks on real systems are illegal.
{% endhint %}

## 1. Understanding DoS & DDoS&#x20;

**1.1 What is a DoS Attack?**&#x20;

A Denial-of-Service (DoS) attack is when an attacker floods a target system (server, website, or network) with too much traffic or resource requests, making it slow or completely unavailable.

**1.2 What is a DDoS Attack?**&#x20;

A Distributed Denial-of-Service (DDoS) attack is a more powerful version of DoS because it uses multiple machines (botnets or compromised systems) to flood the target.

## 2. Requirements for DoS/DDoS Attacks&#x20;

To simulate or test DoS/DDoS (on legal test environments), you’ll need:

**A. Tools for DoS:**

* hping3 (TCP/UDP flood)&#x20;
* LOIC (Low Orbit Ion Cannon)&#x20;
* HOIC (High Orbit Ion Cannon)&#x20;
* Slowloris (HTTP exhaustion attack)&#x20;
* GoldenEye (HTTP DoS attack)&#x20;
* Xerxes (Layer 7 attack used by Anonymous)&#x20;

**B. Tools for DDoS:**

* Metasploit Auxiliary Modules&#x20;
* Mirai Botnet (for IoT-based attacks, research purpose only)&#x20;
* Botnets (controlled through C2 servers, not recommended for ethical use)&#x20;
* Stresser/Booter Services (many are illegal but exist on the dark web)&#x20;

**C. System Setup:**

* A Linux system (Kali, Parrot, or Ubuntu)&#x20;
* A test server (self-hosted or legal target like a CTF challenge)&#x20;
* VPN or proxy chains (for anonymity if testing in a closed environment)&#x20;

## 3. How DoS/DDoS Attacks Are Done (A to Z Guide)&#x20;

**Step 1:** Selecting a Target Targets can be web servers, APIs, networks, or applications. In real-world scenarios, attackers often scan websites using reconnaissance tools (Nmap, Shodan, etc.) to find weak targets.&#x20;

**Step 2:** Choosing the Right Attack.

## 3. Types of DoS/DDoS attacks:

🔹 **Layer 3 (Network Layer Attacks):**

* **SYN Flood:** Overloads a server’s connection requests.&#x20;
* **UDP Flood:** Sends a large number of UDP packets to exhaust server resources.&#x20;
* **ICMP Flood (Ping Flood)**: Overwhelms a target with ping requests.&#x20;

🔹 **Layer 4 (Transport Layer Attacks)**&#x20;

* **hping3 UDP/TCP flood:** Sends thousands of packets per second.&#x20;
* **ACK Flood**: Disrupts firewalls by flooding acknowledgment packets.&#x20;

🔹 **Layer 7 (Application Layer Attacks)**&#x20;

* **Slowloris Attack:** Opens multiple HTTP connections and never closes them.&#x20;
* **HTTP POST/GET Flood:** Sends thousands of fake HTTP requests to overwhelm a web server.&#x20;

## 4. Practical Attack Demonstration:

**4.1 DoS Attack Using hping3:** `hping3 -S --flood -V -p 80 <target_ip>`

**📌 Explanation:**

1. **-S** → Sends SYN packets.&#x20;
2. **--flood** → Sends packets as fast as possible.&#x20;
3. **-V** → Verbose mode (shows output).&#x20;
4. **-p 80** → Targets port 80 (HTTP).&#x20;

**🔥 Impact:**&#x20;

* This attack overwhelms the target’s web server, making it slow or unresponsive.

**4.2 DDoS Attack Using LOIC (Windows/Linux)**&#x20;

1. Download LOIC (Low Orbit Ion Cannon).&#x20;
2. Enter the Target IP or website URL.&#x20;
3. Select Attack Mode (TCP, UDP, or HTTP flood).&#x20;
4. Set Thread Count (Higher = More powerful attack).&#x20;
5. Start Attack.&#x20;

**🔥 Impact:**&#x20;

* If multiple users launch LOIC on the same target, it acts as a DDoS attack (easier to track, though).

**4.3 Slowloris Attack (Layer 7 DoS):**&#x20;

`git clone https://github.com/gkbrk/slowloris.git`&#x20;

`cd slowloris`&#x20;

`python3 slowloris.py --sockets 500`&#x20;

**📌 Explanation:**

This script opens many half-connections to the target and never closes them. The server crashes because it runs out of connections.&#x20;

**🔥 Impact:**&#x20;

* Works best against Apache, Nginx, and IIS servers.

**4.4 DDoS Using a Botnet (Mirai Example)**&#x20;

1. Compromise IoT devices (Cameras, Routers, etc.).&#x20;
2. Inject malware to turn them into bots.&#x20;
3. Send commands from a C2 Server to launch DDoS floods.&#x20;
4. Target gets hit from thousands of infected machines.&#x20;

**🔥 Impact:**&#x20;

* This is the most powerful form of DDoS, often used in real-world cyberattacks.

## 5. Defending Against DoS/DDoS&#x20;

If you're hosting a website or server, you can prevent DoS/DDoS attacks using:

🔹 Firewall Rules: Block unusual traffic patterns.&#x20;

🔹 Rate Limiting: Limits the number of requests per second from a single IP.&#x20;

🔹 Cloudflare or AWS Shield: Protects against Layer 7 attacks.&#x20;

🔹 Intrusion Detection Systems (IDS): Detects attack patterns.&#x20;

🔹 Blackhole Routing: Drops traffic when a DDoS is detected.&#x20;

🔹 Using CDN Services: Like Cloudflare, Akamai, or Fastly to absorb DDoS.

## 6. Ethical Usage & Legal Considerations&#x20;

**✅ When DoS/DDoS is Legal:**

* Testing your own server.&#x20;
* Testing inside a controlled lab environment.&#x20;
* With written permission from an organization.&#x20;

**❌ When DoS/DDoS is Illegal:**

* Attacking someone else's server without consent.&#x20;
* Disrupting government, banking, or public services.&#x20;
* Using botnets to attack websites.&#x20;

{% hint style="info" %}
💡 **Consequences:** Unauthorized DoS/DDoS attacks can lead to prison time (5-20 years), huge fines, and lifetime bans from using the internet in some countries.
{% endhint %}

## 7. Conclusions

1. DoS = Single machine attack.&#x20;
2. DDoS = Multiple machines (botnets).&#x20;
3. Attacks can be done using SYN Floods, UDP Floods, HTTP Floods, Slowloris, etc.&#x20;
4. Defenses include firewalls, rate limiting, CDNs, and DDoS protection services.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bst04s.gitbook.io/hack-by-steps/pentesting/network/guide-on-dos-and-ddos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
