greenhouse.backdoor – Interpreter On A Socket

These functions enable running an additional server in greenhouse server processes, which accepts connections and runs interactive python interpreters on them, enabling entirely flexible and ad-hoc server administration at runtime.

Warning

backdoors are a gaping security hole

Make certain that you use "127.0.0.1" as the host on which to listen for connections so that it will only accept connection requests made locally. If you must connect to it from another machine, at least make sure it is behind a firewall that will block the backdoor port.

greenhouse.backdoor.run_backdoor(address, namespace=None)

start a server that runs python interpreters on connections made to it

Note

this function blocks effectively indefinitely – it runs the listening socket loop in the current greenlet. to keep the current greenlet free, schedule this function.

Parameters:
  • address (tuple) – the address on which to listen for backdoor connections, in the form of a two-tuple (host, port)
  • namespace (dict or None) – the local namespace dict for the interpreter, or None to have each connection create its own empty namespace
greenhouse.backdoor.backdoor_handler(clientsock, namespace=None)

start an interactive python interpreter on an existing connection

Note

this function will block for as long as the connection remains alive.

Parameters:
  • sock (Socket) – the socket on which to serve the interpreter
  • namespace (dict or None) – the local namespace dict for the interpreter, or None to have the function create its own empty namespace

Previous topic

greenhouse.emulation – Faking Out Third Parties

This Page