def setTargetWithPort(self, relayIp, relayPort):
        if relayIp is not None and relayIp != '':
            if is_valid_ipv4_address(relayIp) or is_valid_ipv6_address(relayIp):
                if is_valid_port(relayPort):
                    self.hbExploit = HeartBleedExploit(relayIp, relayPort)
                    print "[+] Target %s with port %s setted." %(relayIp,relayPort)
                    return True
                else:
                    pluginException = PluginException(message='The port is Invalid ', trace="setTarget with args relayIp=%s , relayPort=%s" %(relayIp,relayPort), plugin="heartBleedPlugin", method="setTarget")
                    if self.runFromInterpreter:
                        showTrace(pluginException)
                        return
                    else:
                        raise pluginException

            else:
                pluginException = PluginException(message='IP Address is Invalid ', trace="setTarget with args relayIp=%s , relayPort=%s" %(relayIp,relayPort), plugin="heartBleedPlugin", method="setTarget")
                if self.runFromInterpreter:
                    showTrace(pluginException)
                    return
                else:
                    raise pluginException
        else:
            pluginException = PluginException(message='IP Address is None or empty. Invalid value', trace="setTarget with args relayIp=%s , relayPort=%s" %(relayIp,relayPort), plugin="heartBleedPlugin", method="setTarget")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                raise pluginException
Beispiel #2
0
 def setTarget(self, relayIp):
     if relayIp is not None and relayIp != '':
         if is_valid_ipv4_address(relayIp) or is_valid_ipv6_address(
                 relayIp):
             self.hbExploit = HeartBleedExploit(relayIp)
             print "[+] Target %s setted." % (relayIp)
             return True
         else:
             pluginException = PluginException(
                 message='IP Address is Invalid ',
                 trace="setTarget with args %s " % (relayIp),
                 plugin="heartBleedPlugin",
                 method="setTarget")
             if self.runFromInterpreter:
                 showTrace(pluginException)
                 return
             else:
                 raise pluginException
     else:
         pluginException = PluginException(
             message='IP Address is None or empty. Invalid value',
             trace="setTarget with args %s " % (relayIp),
             plugin="heartBleedPlugin",
             method="setTarget")
         if self.runFromInterpreter:
             showTrace(pluginException)
             return
         else:
             raise pluginException
Beispiel #3
0
    def startHTTPHiddenService(self,
                               serviceDir,
                               servicePort=8080,
                               hiddenserviceDir=None,
                               hiddenservicePort=80,
                               serviceInterface='127.0.0.1',
                               socksPort=9152,
                               orPort=9000):
        if is_valid_ipv4_address(
                serviceInterface) == False and is_valid_ipv6_address(
                    serviceInterface) == False:
            pluginException = PluginException(
                message=
                'The Service Interface is invalid. Try to use the default value without specify the parameter "serviceInterface" ',
                trace=
                "startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s"
                % (serviceDir, str(servicePort), hiddenserviceDir,
                   str(hiddenservicePort), serviceInterface, str(socksPort),
                   str(orPort)),
                plugin="maliciousHiddenServicePlugin",
                method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print '[-] The Service Interface is invalid. Try to use the default value without specify the parameter "serviceInterface". '
                raise pluginException

        if is_valid_port(hiddenservicePort) == False:
            pluginException = PluginException(
                message='The hidden service port is invalid.',
                trace=
                "startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s"
                % (serviceDir, str(servicePort), hiddenserviceDir,
                   str(hiddenservicePort), serviceInterface, str(socksPort),
                   str(orPort)),
                plugin="maliciousHiddenServicePlugin",
                method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The hidden service port is invalid. "
                raise pluginException

        if is_valid_port(socksPort) == False:
            pluginException = PluginException(
                message='The socks port is invalid.',
                trace=
                "startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s"
                % (serviceDir, str(servicePort), hiddenserviceDir,
                   str(hiddenservicePort), serviceInterface, str(socksPort),
                   str(orPort)),
                plugin="maliciousHiddenServicePlugin",
                method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The socks port is invalid. "
                raise pluginException

        if is_valid_port(orPort) == False:
            pluginException = PluginException(
                message='The OR port is invalid.',
                trace=
                "startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s"
                % (serviceDir, str(servicePort), hiddenserviceDir,
                   str(hiddenservicePort), serviceInterface, str(socksPort),
                   str(orPort)),
                plugin="maliciousHiddenServicePlugin",
                method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The OR port is invalid. "
                raise pluginException

        if is_valid_port(servicePort) == False:
            pluginException = PluginException(
                message='The Service port is invalid.',
                trace=
                "startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s"
                % (serviceDir, str(servicePort), hiddenserviceDir,
                   str(hiddenservicePort), serviceInterface, str(socksPort),
                   str(orPort)),
                plugin="maliciousHiddenServicePlugin",
                method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The Service port is invalid. "
                raise pluginException

        self.hiddenservicePort = hiddenservicePort
        config = txtorcon.TorConfig()
        config.SOCKSPort = socksPort
        config.ORPort = orPort
        if hiddenserviceDir is None:
            print "[+] HiddenServiceDir not specified... Generating a temporal file."
            hiddenserviceDir = self.__createTemporal()

        if os.path.exists(hiddenserviceDir) == False:
            print "[+] The HiddenServiceDir specified does not exists... Generating a temporal file."
            hiddenserviceDir = self.__createTemporal()

        if serviceDir is None or os.path.exists(serviceDir) == False:
            pluginException = PluginException(
                "The specified Server directory is not valid.",
                trace=
                "startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s"
                % (serviceDir, str(servicePort), hiddenserviceDir,
                   str(hiddenservicePort), serviceInterface, str(socksPort),
                   str(orPort)),
                plugin="maliciousHiddenServicePlugin",
                method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The specified Server directory is not valid. You must specify a valid directory where resources like HTML pages, images, CSS and stuff like that are located. The directory will be used to start a simple HTTP Server."
                raise pluginException

        config.HiddenServices = [
            txtorcon.HiddenService(config, hiddenserviceDir, [
                "%s %s:%s" %
                (str(hiddenservicePort), serviceInterface, str(servicePort))
            ])
        ]
        config.save()

        root = static.File(serviceDir)
        root.putChild("gatherUserInfo", GatherInformation())
        site = server.Site(root)
        hs_endpoint = TCP4ServerEndpoint(reactor,
                                         servicePort,
                                         interface=serviceInterface)
        hs_endpoint.listen(site)
        try:
            d = txtorcon.launch_tor(
                config,
                reactor,
                progress_updates=self.__updates,
            )
        except txtorcon.TorNotFound as torBinaryNotFound:
            print "[-] Tor binary not found in the system path. Using the property 'torExecutablePath' located in the config/config.py file."
            d = txtorcon.launch_tor(
                config,
                reactor,
                tor_binary=tortazoConfig.torExecutablePath,
                progress_updates=self.__updates,
            )

        d.addCallback(functools.partial(self.__setup_complete, config))
        d.addErrback(self.__setup_failed)
        reactor.run()
        return True
    def startHTTPHiddenService(self, serviceDir, servicePort=8080, hiddenserviceDir=None, hiddenservicePort=80, serviceInterface='127.0.0.1', socksPort=9152, orPort=9000):
        if is_valid_ipv4_address(serviceInterface) == False and is_valid_ipv6_address(serviceInterface) == False:
            pluginException = PluginException(message='The Service Interface is invalid. Try to use the default value without specify the parameter "serviceInterface" ',
                                  trace="startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s" %(serviceDir, str(servicePort), hiddenserviceDir, str(hiddenservicePort), serviceInterface, str(socksPort), str(orPort)),
                                  plugin="maliciousHiddenServicePlugin", method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print '[-] The Service Interface is invalid. Try to use the default value without specify the parameter "serviceInterface". '
                raise pluginException


        if is_valid_port(hiddenservicePort) == False:
            pluginException = PluginException(message='The hidden service port is invalid.', trace="startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s" %(serviceDir, str(servicePort), hiddenserviceDir, str(hiddenservicePort), serviceInterface, str(socksPort), str(orPort)), plugin="maliciousHiddenServicePlugin", method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The hidden service port is invalid. "
                raise pluginException

        if is_valid_port(socksPort) == False:
            pluginException = PluginException(message='The socks port is invalid.', trace="startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s" %(serviceDir, str(servicePort), hiddenserviceDir, str(hiddenservicePort), serviceInterface, str(socksPort), str(orPort)), plugin="maliciousHiddenServicePlugin", method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The socks port is invalid. "
                raise pluginException


        if is_valid_port(orPort) == False:
            pluginException = PluginException(message='The OR port is invalid.', trace="startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s" %(serviceDir, str(servicePort), hiddenserviceDir, str(hiddenservicePort), serviceInterface, str(socksPort), str(orPort)), plugin="maliciousHiddenServicePlugin", method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The OR port is invalid. "
                raise pluginException

        if is_valid_port(servicePort) == False:
            pluginException = PluginException(message='The Service port is invalid.', trace="startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s" %(serviceDir, str(servicePort), hiddenserviceDir, str(hiddenservicePort), serviceInterface, str(socksPort), str(orPort)), plugin="maliciousHiddenServicePlugin", method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return
            else:
                print "[-] The Service port is invalid. "
                raise pluginException



        self.hiddenservicePort = hiddenservicePort
        config = txtorcon.TorConfig()
        config.SOCKSPort = socksPort
        config.ORPort = orPort
        if hiddenserviceDir is None:
            print "[+] HiddenServiceDir not specified... Generating a temporal file."
            hiddenserviceDir = self.__createTemporal()

        if os.path.exists(hiddenserviceDir) == False:
            print "[+] The HiddenServiceDir specified does not exists... Generating a temporal file."
            hiddenserviceDir = self.__createTemporal()

        if serviceDir is None or os.path.exists(serviceDir) == False:
            pluginException = PluginException("The specified Server directory is not valid.", trace="startHTTPHiddenService with args serviceDir=%s , servicePort=%s , hiddenserviceDir=%s , hiddenservicePort=%s , serviceInterface=%s , socksPort=%s , orPort=%s" %(serviceDir,str(servicePort), hiddenserviceDir, str(hiddenservicePort), serviceInterface, str(socksPort) , str(orPort)), plugin="maliciousHiddenServicePlugin", method="startHTTPHiddenService")
            if self.runFromInterpreter:
                showTrace(pluginException)
                return 
            else:
                print "[-] The specified Server directory is not valid. You must specify a valid directory where resources like HTML pages, images, CSS and stuff like that are located. The directory will be used to start a simple HTTP Server."
                raise pluginException


        config.HiddenServices = [txtorcon.HiddenService(config, hiddenserviceDir, ["%s %s:%s" %(str(hiddenservicePort), serviceInterface, str(servicePort))] )]
        config.save()

        root = static.File(serviceDir)
        root.putChild("gatherUserInfo", GatherInformation())
        site = server.Site(root)
        hs_endpoint = TCP4ServerEndpoint(reactor, servicePort, interface=serviceInterface)
        hs_endpoint.listen(site)
        try:
            d = txtorcon.launch_tor(config, reactor, progress_updates=self.__updates, )
        except txtorcon.TorNotFound as torBinaryNotFound:
            print "[-] Tor binary not found in the system path. Using the property 'torExecutablePath' located in the config/config.py file."
            d = txtorcon.launch_tor(config, reactor, tor_binary=tortazoConfig.torExecutablePath, progress_updates=self.__updates, )

        d.addCallback(functools.partial(self.__setup_complete, config))
        d.addErrback(self.__setup_failed)
        reactor.run()
        return True