How to use the rpyc.utils.helpers.restricted 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 n1nj4sec / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
def redirected_stdo(module, stdout=None, stderr=None):
    conn = module.client.conn
    if stdout is None:
        stdout = module.stdout
    if stderr is None:
        stderr = module.stdout

    hotpatch_oswrite(conn)
    orig_stdout = conn.modules.sys.stdout
    orig_stderr = conn.modules.sys.stderr
    try:
        conn.modules.sys.stdout = restricted(stdout,["softspace", "write", "flush"])
        conn.modules.sys.stderr = restricted(stderr,["softspace", "write", "flush"])
        yield
    finally:
        conn.modules.sys.stdout = orig_stdout
        conn.modules.sys.stderr = orig_stderr
github n1nj4sec / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
"""
    conn = module.client.conn
    orig_stdin = conn.modules.sys.stdin
    orig_stdout = conn.modules.sys.stdout
    orig_stderr = conn.modules.sys.stderr

    if stdout is None:
        stdout = module.stdout
    if stderr is None:
        stderr = module.stdout

    try:
        conn.modules.sys.stdin = restricted(sys.stdin, ["softspace", "write", "readline", "encoding", "close"])
        conn.modules.sys.stdout = restricted(stdout, ["softspace", "write", "readline", "encoding", "close", "flush"])
        conn.modules.sys.stderr = restricted(stderr, ["softspace", "write", "readline", "encoding", "close", "flush"])
        yield
    finally:
        conn.modules.sys.stdin = orig_stdin
        conn.modules.sys.stdout = orig_stdout
        conn.modules.sys.stderr = orig_stderr
github n1nj4sec / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
with redirected_stdio(conn):
            conn.modules.sys.stdout.write("hello\n")   # will be printed locally

    """
    conn = module.client.conn
    orig_stdin = conn.modules.sys.stdin
    orig_stdout = conn.modules.sys.stdout
    orig_stderr = conn.modules.sys.stderr

    if stdout is None:
        stdout = module.stdout
    if stderr is None:
        stderr = module.stdout

    try:
        conn.modules.sys.stdin = restricted(sys.stdin, ["softspace", "write", "readline", "encoding", "close"])
        conn.modules.sys.stdout = restricted(stdout, ["softspace", "write", "readline", "encoding", "close", "flush"])
        conn.modules.sys.stderr = restricted(stderr, ["softspace", "write", "readline", "encoding", "close", "flush"])
        yield
    finally:
        conn.modules.sys.stdin = orig_stdin
        conn.modules.sys.stdout = orig_stdout
        conn.modules.sys.stderr = orig_stderr
github krintoxi / NoobSec-Toolkit / NoobSecToolkit / scripts / sshbackdoors / backdoors / shell / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
Redirects the other party's ``stdin``, ``stdout`` and ``stderr`` to 
	those of the local party, so remote IO will occur locally.

	Example usage::
	
		with redirected_stdio(conn):
			conn.modules.sys.stdout.write("hello\n")   # will be printed locally
	
	"""
	orig_stdin = conn.modules.sys.stdin
	orig_stdout = conn.modules.sys.stdout
	orig_stderr = conn.modules.sys.stderr
	try:
		conn.modules.sys.stdin =restricted(sys.stdin, ["softspace", "write", "readline", "encoding", "close"])
		conn.modules.sys.stdout = restricted(sys.stdout, ["softspace", "write", "readline", "encoding", "close", "flush"])
		conn.modules.sys.stderr = restricted(sys.stderr, ["softspace", "write", "readline", "encoding", "close", "flush"])
		yield
	finally:
		conn.modules.sys.stdin = orig_stdin
		conn.modules.sys.stdout = orig_stdout
		conn.modules.sys.stderr = orig_stderr
github Kkevsterrr / backdoorme / backdoors / shell / __pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
Redirects the other party's ``stdin``, ``stdout`` and ``stderr`` to 
	those of the local party, so remote IO will occur locally.

	Example usage::
	
		with redirected_stdio(conn):
			conn.modules.sys.stdout.write("hello\n")   # will be printed locally
	
	"""
	orig_stdin = conn.modules.sys.stdin
	orig_stdout = conn.modules.sys.stdout
	orig_stderr = conn.modules.sys.stderr
	try:
		conn.modules.sys.stdin =restricted(sys.stdin, ["softspace", "write", "readline", "encoding", "close"])
		conn.modules.sys.stdout = restricted(sys.stdout, ["softspace", "write", "readline", "encoding", "close", "flush"])
		conn.modules.sys.stderr = restricted(sys.stderr, ["softspace", "write", "readline", "encoding", "close", "flush"])
		yield
	finally:
		conn.modules.sys.stdin = orig_stdin
		conn.modules.sys.stdout = orig_stdout
		conn.modules.sys.stderr = orig_stderr
github n1nj4sec / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
ns = module.client.conn.namespace

    stdin = sys.stdin

    if stdout is None:
        stdout = module.stdout
    if stderr is None:
        stderr = module.stdout

    try:
        ns['redirect_stdio'](
            restricted(
                stdin, ['softspace', 'write', 'readline', 'encoding', 'close']),
            restricted(
                stdout, ['softspace', 'write', 'readline', 'encoding', 'close']),
            restricted(
                stderr, ['softspace', 'write', 'readline', 'encoding', 'close']))

        module.client.conn.register_remote_cleanup(ns['reset_stdio'])

        yield

    finally:
        ns['reset_stdio']()
        module.client.conn.unregister_remote_cleanup(ns['reset_stdio'])
github Kkevsterrr / backdoorme / backdoors / shell / __pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
r"""
	Redirects the other party's ``stdin``, ``stdout`` and ``stderr`` to 
	those of the local party, so remote IO will occur locally.

	Example usage::
	
		with redirected_stdio(conn):
			conn.modules.sys.stdout.write("hello\n")   # will be printed locally
	
	"""
	orig_stdin = conn.modules.sys.stdin
	orig_stdout = conn.modules.sys.stdout
	orig_stderr = conn.modules.sys.stderr
	try:
		conn.modules.sys.stdin =restricted(sys.stdin, ["softspace", "write", "readline", "encoding", "close"])
		conn.modules.sys.stdout = restricted(sys.stdout, ["softspace", "write", "readline", "encoding", "close", "flush"])
		conn.modules.sys.stderr = restricted(sys.stderr, ["softspace", "write", "readline", "encoding", "close", "flush"])
		yield
	finally:
		conn.modules.sys.stdin = orig_stdin
		conn.modules.sys.stdout = orig_stdout
		conn.modules.sys.stderr = orig_stderr
github n1nj4sec / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
def redirected_stdo(module, stdout=None, stderr=None):
    ns = module.client.conn.namespace
    if stdout is None:
        stdout = module.stdout
    if stderr is None:
        stderr = module.stdout

    try:
        ns['redirect_stdo'](
            restricted(
                stdout, ['softspace', 'write', 'flush']),
            restricted(
                stderr, ['softspace', 'write', 'flush']))

        module.client.conn.register_remote_cleanup(ns['reset_stdo'])

        yield

    finally:
        ns['reset_stdo']()
        module.client.conn.unregister_remote_cleanup(ns['reset_stdo'])
github Kkevsterrr / backdoorme / backdoors / shell / __pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
def redirected_stdio(conn):
	r"""
	Redirects the other party's ``stdin``, ``stdout`` and ``stderr`` to 
	those of the local party, so remote IO will occur locally.

	Example usage::
	
		with redirected_stdio(conn):
			conn.modules.sys.stdout.write("hello\n")   # will be printed locally
	
	"""
	orig_stdin = conn.modules.sys.stdin
	orig_stdout = conn.modules.sys.stdout
	orig_stderr = conn.modules.sys.stderr
	try:
		conn.modules.sys.stdin =restricted(sys.stdin, ["softspace", "write", "readline", "encoding", "close"])
		conn.modules.sys.stdout = restricted(sys.stdout, ["softspace", "write", "readline", "encoding", "close", "flush"])
		conn.modules.sys.stderr = restricted(sys.stderr, ["softspace", "write", "readline", "encoding", "close", "flush"])
		yield
	finally:
		conn.modules.sys.stdin = orig_stdin
		conn.modules.sys.stdout = orig_stdout
		conn.modules.sys.stderr = orig_stderr
github n1nj4sec / pupy / pupy / pupylib / utils / rpyc_utils.py View on Github external
conn.modules.sys.stdout.write("hello\n")   # will be printed locally

    """

    ns = module.client.conn.namespace

    stdin = sys.stdin

    if stdout is None:
        stdout = module.stdout
    if stderr is None:
        stderr = module.stdout

    try:
        ns['redirect_stdio'](
            restricted(
                stdin, ['softspace', 'write', 'readline', 'encoding', 'close']),
            restricted(
                stdout, ['softspace', 'write', 'readline', 'encoding', 'close']),
            restricted(
                stderr, ['softspace', 'write', 'readline', 'encoding', 'close']))

        module.client.conn.register_remote_cleanup(ns['reset_stdio'])

        yield

    finally:
        ns['reset_stdio']()
        module.client.conn.unregister_remote_cleanup(ns['reset_stdio'])