DEV Community

Cover image for Inject code in Python process
petercour
petercour

Posted on

3

Inject code in Python process

Python is widely used for software development. By universities, companies and many more. So is Python an utopia that will solve all computer problems?

Did you know you can inject code into a running Python process? You can use Pyrasite for that. This needs Python 2.4 or higher.

You can watch a demo here: demo

It comes with several programs, including a shell

$ pyrasite-shell
Usage: pyrasite-shell <PID>
Enter fullscreen mode Exit fullscreen mode

So you can inject a payload

$ pyrasite <PID> payload.py
Enter fullscreen mode Exit fullscreen mode

You can find some example payloads here.

So if you have the process id , you can inject anything into the running program.

There's also a GUI. It lets you easily monitor, analyze, introspect, and alter running Python programs.

Related links:

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay