pyrasite.inject(pid, filename, verbose=False, gdb_prefix='')

Executes a file in a running Python process.

pyrasite.inspect(pid, address)

Return the value of an object in a given process at the specified address

class pyrasite.PyrasiteIPC(pid, reverse='ReversePythonConnection', timeout=5)

Pyrasite Inter-Python Communication.

This object is used in communicating to or from another Python process.

It can perform a variety of tasks:

  • Injection of the pyrasite.ReversePythonConnection payload via PyrasiteIPC.connect(), which causes the process to connect back to a port that we are listening on. The connection with the process is then available via self.sock.
  • Python code can then be executed in the process using PyrasiteIPC.cmd(). Both stdout and stderr are returned.
  • Low-level communication with the process, both reliably (via a length header) or unreliably (raw data, ideal for use with netcat) with a pyrasite.ReversePythonConnection payload, via PyrasiteIPC.send(data)() and PyrasiteIPC.recv(data)().

The PyrasiteIPC is subclassed by pyrasite.tools.gui.Process as well as pyrasite.reverse.ReverseConnection.


Send a python command to exec in the process and return the output


Setup a communication socket with the process by injecting a reverse subshell and having it connect back to us.


Write out a reverse python connection payload with a custom port


Inject the payload into the process.


Listen on a random port


Receive a command from a given socket


Receive n bytes from a socket


Send arbitrary data to the process via self.sock


Wait for the injected payload to connect back to us

class pyrasite.ReverseConnection(host=None, port=None)

A payload that connects to a given host:port and receives commands


Called when the host sends us a command


Called when we successfuly connect to self.host

class pyrasite.ReversePythonConnection(host=None, port=None)

A reverse Python connection payload.

Executes Python commands and returns the output.