Exemplo n.º 1
0
    def connect(self):
        logger.debug("SSHClientTransportFactory.connect")

        tunnel = JAP_LOCAL.Tunnel(self.configuration)
        tunnel.connect(
            self.configuration["REMOTE_PROXY_SERVERS"][self.i]["ADDRESS"],
            self.configuration["REMOTE_PROXY_SERVERS"][self.i]["PORT"], self)
Exemplo n.º 2
0
    def connect(self):
        logger.debug("WSInputProtocol.connect")

        self.i = random.randrange(
            0, len(self.configuration["REMOTE_PROXY_SERVERS"]))

        if self.configuration["REMOTE_PROXY_SERVERS"][
                self.i]["TYPE"] == "HTTPS":
            factory = WSOutputProtocolFactory(
                self,
                "wss://" + str(self.configuration["REMOTE_PROXY_SERVERS"][
                    self.i]["ADDRESS"]) + ":" +
                str(self.configuration["REMOTE_PROXY_SERVERS"][self.i]
                    ["PORT"]),
                debug=False)
            factory.protocol = WSOutputProtocol

            if self.configuration["REMOTE_PROXY_SERVERS"][
                    self.i]["CERTIFICATE"]["AUTHENTICATION"]["FILE"] != "":
                contextFactory = ClientContextFactory(
                    self.configuration["REMOTE_PROXY_SERVERS"][
                        self.i]["CERTIFICATE"]["AUTHENTICATION"]["FILE"])
            else:
                contextFactory = ssl.ClientContextFactory()

            tunnel = JAP_LOCAL.Tunnel(self.configuration)
            tunnel.connect(
                self.configuration["REMOTE_PROXY_SERVERS"][self.i]["ADDRESS"],
                self.configuration["REMOTE_PROXY_SERVERS"][self.i]["PORT"],
                factory, contextFactory)
        else:
            factory = WSOutputProtocolFactory(
                self,
                "ws://" + str(self.configuration["REMOTE_PROXY_SERVERS"][
                    self.i]["ADDRESS"]) + ":" +
                str(self.configuration["REMOTE_PROXY_SERVERS"][self.i]
                    ["PORT"]),
                debug=False)
            factory.protocol = WSOutputProtocol

            tunnel = JAP_LOCAL.Tunnel(self.configuration)
            tunnel.connect(
                self.configuration["REMOTE_PROXY_SERVERS"][self.i]["ADDRESS"],
                self.configuration["REMOTE_PROXY_SERVERS"][self.i]["PORT"],
                factory)
Exemplo n.º 3
0
 def channelOpen(self, specificData):
     logger.debug("SSHChannel.channelOpen")
     
     self.connectionState = 1
     
     outputProtocolFactory = SSHOutputProtocolFactory(self)
     outputProtocolFactory.protocol = SSHOutputProtocol
     
     tunnel = JAP_LOCAL.Tunnel(self.avatar.configuration)
     tunnel.connect(self.remoteAddress, self.remotePort, outputProtocolFactory)
Exemplo n.º 4
0
    def processMessageState0(self):
        logger.debug("WSInputProtocol.processMessageState0")

        decoder = JAP_LOCAL.JSONDecoder()
        request = decoder.decode(self.message)

        authorized = False

        if len(self.configuration["REMOTE_PROXY_SERVER"]
               ["AUTHENTICATION"]) == 0:
            authorized = True

        if authorized == False:
            i = 0
            while i < len(self.configuration["REMOTE_PROXY_SERVER"]
                          ["AUTHENTICATION"]):
                if self.configuration["REMOTE_PROXY_SERVER"]["AUTHENTICATION"][
                        i]["USERNAME"] == request["REMOTE_PROXY_SERVER"][
                            "AUTHENTICATION"][
                                "USERNAME"] and self.configuration[
                                    "REMOTE_PROXY_SERVER"]["AUTHENTICATION"][
                                        i]["PASSWORD"] == request[
                                            "REMOTE_PROXY_SERVER"][
                                                "AUTHENTICATION"]["PASSWORD"]:
                    authorized = True
                    break

                i = i + 1

        if authorized == False:
            self.sendClose()

            return

        self.remoteAddress = request["REMOTE_ADDRESS"]
        self.remotePort = request["REMOTE_PORT"]

        logger.debug("WSInputProtocol.remoteAddress: " + self.remoteAddress)
        logger.debug("WSInputProtocol.remotePort: " + str(self.remotePort))

        outputProtocolFactory = WSOutputProtocolFactory(self)
        outputProtocolFactory.protocol = WSOutputProtocol

        tunnel = JAP_LOCAL.Tunnel(self.configuration)
        tunnel.connect(self.remoteAddress, self.remotePort,
                       outputProtocolFactory)