Exemple #1
0
    def dispatch_data(self, data_received, addr):
        host, port = addr[0], addr[1]
        if addr not in self.clients:
            logging.info("new client connected : %s:%s" % (host, port))
            config = dict(self.protocol_config,
                          credentials=None,
                          connid="%s:%d" % (host, port))
            if self.authenticator:
                try:
                    sock, credentials = self.authenticator(data_received)
                    config["credentials"] = credentials
                except AuthenticationError:
                    logging.info("failed to authenticate, rejecting data")
                    raise
            self.clients[addr] = self.stream_class((self.sock, addr),
                                                   self.transport_class,
                                                   self.transport_kwargs,
                                                   client_side=False)

            t = PupyConnectionThread(self.pupy_srv,
                                     self.service,
                                     Channel(self.clients[addr]),
                                     config=config)
            t.daemon = True
            t.start()
        with self.clients[addr].downstream_lock:
            self.clients[addr].buf_in.write(data_received)
            self.clients[addr].transport.downstream_recv(
                self.clients[addr].buf_in)
Exemple #2
0
    def new(self, addr, ckcp):
        logging.info("new client connected: " + addr)

        host, port = addr.rsplit(':', 1)
        port = int(port)

        config = dict(self.protocol_config, credentials=None, connid=addr)

        client = self.stream((
            self.sock,
            (host, port),
            ckcp,
        ),
                             self.transport,
                             self.transport_kwargs,
                             client_side=False,
                             close_cb=self.on_close,
                             lsi=self.LONG_SLEEP_INTERRUPT_TIMEOUT)

        logging.debug('Request pings: %s', client.KEEP_ALIVE_REQUIRED
                      or self.ping_interval)

        connthread = PupyConnectionThread(self.pupy_srv,
                                          self.service,
                                          PupyChannel(client),
                                          ping=client.KEEP_ALIVE_REQUIRED
                                          or self.ping_interval,
                                          timeout=self.ping_timeout,
                                          config=config)
        connthread.start()
        return connthread.connection
Exemple #3
0
    def dispatch_data(self, data_received, addr):
        host, port=addr[0], addr[1]
        if addr not in self.clients:
            logging.info("new client connected : %s:%s"%(host, port))
            config = dict(self.protocol_config, credentials=None, connid="%s:%d"%(host, port))
            if self.authenticator:
                try:
                    sock, credentials = self.authenticator(data_received)
                    config["credentials"]=credentials
                except AuthenticationError:
                    logging.info("failed to authenticate, rejecting data")
                    raise
            self.clients[addr] = self.stream_class(
                (self.sock, addr), self.transport_class, self.transport_kwargs, client_side=False
            )

            t = PupyConnectionThread(
                self.pupy_srv,
                self.service,
                Channel(self.clients[addr]),
                ping=self.ping_interval,
                timeout=self.ping_timeout,
                config=config
            )
            t.daemon=True
            t.start()
        with self.clients[addr].downstream_lock:
            self.clients[addr].buf_in.write(data_received)
            self.clients[addr].transport.downstream_recv(self.clients[addr].buf_in)
Exemple #4
0
    def connect_on_client(self, launcher_args):
        """ connect on a client that would be running a bind payload """
        launcher = network.conf.launchers["connect"](
            connect_on_bind_payload=True)
        try:
            launcher.parse_args(shlex.split(launcher_args))
        except LauncherError as e:
            launcher.arg_parser.print_usage()
            return

        try:
            stream = launcher.iterate().next()
        except socket.error as e:
            self.handler.display_error(
                "Couldn't connect to pupy: {}".format(e))
            return

        self.handler.display_success("Connected. Starting session")
        bgsrv = PupyConnectionThread(self,
                                     PupyBindService,
                                     rpyc.Channel(stream),
                                     config={'connid': launcher.args.host})
        bgsrv.start()
Exemple #5
0
    def connect_on_client(self, launcher_args):
        """ connect on a client that would be running a bind payload """
        launcher=network.conf.launchers["connect"](connect_on_bind_payload=True)
        try:
            launcher.parse_args(shlex.split(launcher_args))
        except LauncherError as e:
            launcher.arg_parser.print_usage()
            return

        try:
            stream=launcher.iterate().next()
        except socket.error as e:
            self.handler.display_error("Couldn't connect to pupy: {}".format(e))
            return

        self.handler.display_success("Connected. Starting session")
        bgsrv=PupyConnectionThread(
            self,
            PupyBindService,
            rpyc.Channel(stream),
            config={
                'connid': launcher.args.host
            })
        bgsrv.start()