API¶
-
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.ReversePythonConnectionpayload viaPyrasiteIPC.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.ReversePythonConnectionpayload, viaPyrasiteIPC.send(data)()andPyrasiteIPC.recv(data)().
The
PyrasiteIPCis subclassed bypyrasite.tools.gui.Processas well aspyrasite.reverse.ReverseConnection.-
cmd(cmd)¶ Send a python command to exec in the process and return the output
-
connect()¶ Setup a communication socket with the process by injecting a reverse subshell and having it connect back to us.
-
create_payload()¶ Write out a reverse python connection payload with a custom port
-
inject()¶ Inject the payload into the process.
-
listen()¶ Listen on a random port
-
recv()¶ Receive a command from a given socket
-
recv_bytes(n)¶ Receive n bytes from a socket
-
send(data)¶ Send arbitrary data to the process via self.sock
-
wait()¶ Wait for the injected payload to connect back to us
- Injection of the
-
class
pyrasite.ReverseConnection(host=None, port=None)¶ A payload that connects to a given host:port and receives commands
-
on_command(cmd)¶ Called when the host sends us a command
-
on_connect()¶ 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.