Exemplo n.º 1
0
 def setBaseLine(self):
     ''' get a baseline for a bad request '''
     try:
         print "\nSetting baseline ...",
         """
             numbers are valid characters in a domain,
             assuming no one would set the below domain
             as a given vhost of a server (even though that
             would be interesting) ...
             therefore we assume this will produce a 
             "vhost does not exist on this server" response
             TODO: form a large random number to replace the static one below
         """
         http_data = funcs.constructRequest(verb="GET", target="314159265358979323846264338327950288." + self.domain + "." + self.tld, resource="/")
         c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         c.connect((self.ipAddress, self.port))
         c.send(http_data)
         data = c.recv(1024*5)
         c.close()
         if debug:
             print http_data
             print data
         
         self.baseline = funcs.stripheader(data,self.includeinbaseline)
         print self.baseline
     except:
         print "\nError connecting, cleaning up\n\n"
         # kill tor sockets we spun up
         if anonimize:
             '''
             for p in sc.getTorPids():
                 funcs.killPid(ppid=p)
             '''
             for dir,_,_ in os.walk(sc.getDataDir()):
                 pidHandle = glob.glob(os.path.join(dir,'tor*.pid'))
                 if pidHandle:
                     funcs.killPid(ppid=int(open(pidHandle[0]).readline()))
             print
         slow_ddos_tor.killThreads()
         print
         sys.exit(0)
Exemplo n.º 2
0
    def run(self):
        while True:
            c = None
            '''
                grabs host from queue
                will cause exception if there are no items in queue
                and more then 10 sec have passed, 
                this will break out of while loop
            '''
            host = self.queue.get()
            if debug:
                print "Trying Host: %s" % host
            try:
                '''
                    rand sleep and then some socket
                    choice randomness with the Tor
                    sockets
                '''
                time.sleep(choice(range(1,30)))
                if anonimize:
                    if funcs.getRandBool() == True:
                        c = sc.setSocksProx()
                    else:
                        c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                else:
                    c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    
                if not c:
                    c = sc.setSocksProx()
                    if not c:
                        c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

                # connect to the socket 
                c.connect((self.ipAddress, int(self.port)))
                # request line
                http_data = funcs.constructRequest(target=host, resource="/")
                c.send(http_data)
                data = c.recv(1024*5)
                c.close()
                response_code = data.split(" ")[1]
                
                if debug:    
                    print "Host target: " + host
                    print http_data
                    print data
                    print "Response Code:" + response_code   
                    print "Baseline Hash: %s" % self.baseline
                    print "Current Hash: %s" % funcs.stripheader(data,self.includeinbaseline)
                
                if funcs.stripheader(data,self.includeinbaseline) != self.baseline:
                    if debug:
                        print "I think this exists: %s" % host
                        print data
                    if host not in self.foundvhosts:
                        self.foundvhosts.append(host)

                val = self.counter.add(1)
                if val % self.counter.getOutPoint() == 0:
                    print "Tested %s vhosts, last checked: '%s' - %s %s" % (str(val),host, 
                                                                            '-'.join(funcs.getTimeStamp().split('.')[0:3]),
                                                                            ':'.join(funcs.getTimeStamp().split('.')[3:]))
            except socket.error, err:
                if c:
                    c.close()
                if debug:
                    print err
                    print "failed for host %s" % host
                failedHosts.append(host)
            except IndexError, err:
                if c:
                    c.close()
                if debug:
                    print err
                    print "failed for host %s" % host
                failedHosts.append(host)