How to use the rpyc.core.brine.dump function in rpyc

To help you get started, we’ve selected a few rpyc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krintoxi / NoobSec-Toolkit / NoobSecToolkit / scripts / sshbackdoors / rpyc / core / protocol.py View on Github external
def _send(self, msg, seq, args):
        data = brine.dump((msg, seq, args))
        self._sendlock.acquire()
        try:
            self._channel.send(data)
        finally:
            self._sendlock.release()
    def _send_request(self, handler, args):
github krintoxi / NoobSec-Toolkit / NoobSecToolkit / scripts / sshbackdoors / rpyc / utils / registry.py View on Github external
def register(self, aliases, port, interface = ""):
        self.logger.info("registering on %s:%s", self.ip, self.port)
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.bind((interface, 0))
        sock.settimeout(self.timeout)
        data = brine.dump(("RPYC", "REGISTER", (aliases, port)))

        try:
            try:
                sock.connect((self.ip, self.port))
                sock.send(data)
            except (socket.error, socket.timeout):
                self.logger.warn("could not connect to registry")
                return False
            try:
                data = sock.recv(MAX_DGRAM_SIZE)
            except socket.timeout:
                self.logger.warn("registry did not acknowledge")
                return False
            try:
                reply = brine.load(data)
            except Exception:
github tomerfiliba / rpyc / rpyc / utils / registry.py View on Github external
def discover(self, name):
        sock = socket.socket(self.sock_family, socket.SOCK_DGRAM)

        with closing(sock):
            if self.bcast:
                sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)
            data = brine.dump(("RPYC", "QUERY", (name,)))
            sock.sendto(data, (self.ip, self.port))
            sock.settimeout(self.timeout)

            try:
                data, _ = sock.recvfrom(MAX_DGRAM_SIZE)
            except (socket.error, socket.timeout):
                servers = ()
            else:
                servers = brine.load(data)
        return servers
github Kkevsterrr / backdoorme / backdoors / shell / __pupy / rpyc / utils / registry.py View on Github external
def discover(self, name):
        sock = socket.socket(self.sock_family, socket.SOCK_DGRAM)

        try:
            if self.bcast:
                sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)
            data = brine.dump(("RPYC", "QUERY", (name,)))
            sock.sendto(data, (self.ip, self.port))
            sock.settimeout(self.timeout)

            try:
                data, _ = sock.recvfrom(MAX_DGRAM_SIZE)
            except (socket.error, socket.timeout):
                servers = ()
            else:
                servers = brine.load(data)
        finally:
            sock.close()
        return servers
github tomerfiliba / rpyc / rpyc / utils / registry.py View on Github external
def unregister(self, port):
        self.logger.info("unregistering from %s:%s", self.ip, self.port)
        sock = socket.socket(self.sock_family, socket.SOCK_DGRAM)
        with closing(sock):
            if self.bcast:
                sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)
            data = brine.dump(("RPYC", "UNREGISTER", (port,)))
            sock.sendto(data, (self.ip, self.port))
github Digital-Structures / ghpythonremote / ghpythonremote / monkey.py View on Github external
rpyc.lib.get_methods(
                    rpyc.core.netref.LOCAL_ATTRS, self._local_objects[id_pack]
                )
            )

    # TODO: Remove that when ghpythonlib.components.__namedtuple.__getattr__ is fixed
    rpyc.core.protocol.Connection._handle_inspect = _handle_inspect

    if sys.version_info < (2, 7, 5):

        def dump(obj):
            stream = []
            rpyc.core.brine._dump(obj, stream)
            return b"".join(map(bytes, stream))

        rpyc.core.brine.dump = dump

        import socket
        def write(self, data):
            try:
                while data:
                    count = self.sock.send(buffer(data[:self.MAX_IO_CHUNK]))
                    data = data[count:]
            except socket.error:
                ex = sys.exc_info()[1]
                self.close()
                raise EOFError(ex)

        rpyc.core.stream.SocketStream.write = write
else:
    # This is only needed if the local is CPython and the remote is IronPython, doesn't
    # really hurt otherwise