Skip to content
dexvndPublic

About

Inject and run live Python code inside any running process.

Topics

Resources

Stars

9 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stitch

Inject and run live Python code inside any running process

Rust Platform egui

Stitch in action

Inspired by Pyinjector, Stitch lets you inject Python code to any running Python process and execute code inside it in real time. Pick a process, connect, and start injecting Python code.

What it does

Stitch finds Python processes running on your machine, attaches to one, and opens a live channel into it. From there you can execute any Python code and see the output immediately.

Features

  • Automatically finds running Python processes and shows which version they're using
  • Live code execution, output and tracebacks print straight to the target process's terminal
  • Inspector panel that slides out and lets you poke around the process, loaded modules, running threads with their stacks, and the live globals (functions, classes and variables as they are right now)
  • Bake any script into a standalone DLL that runs itself the moment it's injected, no Stitch needed on the other end
  • Script folder with support for custom .py files. Save with Ctrl+S, run with Ctrl+Enter
  • Create new scripts directly from the UI
  • No dependencies required on the target machine, Stitch uses the Python interpreter already running in the process

Installation

Grab the latest stitch.exe from the Releases page, or build it yourself from source.

Build from source

You'll need Rust installed.

git clone https://github.com/dexvnd/stitch.git
cd stitch
cargo build --release

The build script compiles the stub DLL and embeds it into stitch.exe automatically.

Usage

  1. Start a Python process (any script, app, or just python in a terminal)
  2. Launch stitch.exe
  3. Select the process from the list on the left and click Connect
  4. Type or load a script and click Execute

Once you're connected, open the Inspector on the right to see what's going on inside — modules, threads, globals. And if you'd rather have a script just run on its own, hit Build DLL to bake it into a DLL you can drop into any process however you like.

How it works

When you connect to a python process Stitch injects a small stub into the target process using the standard Windows loader API. The stub initialises the CPython runtime inside the target, connects back to Stitch over a named pipe. Reading code, executing it under the GIL, and sending the output back. The pipe stays open so you can keep sending code without reconnecting.

The whole thing is written in Rust. The stub is a cdylib target in the same workspace, compiled separately and the injection and UI are in the main binary.

Project structure

stitch/
├── src/
│   ├── main.rs        entry point
│   ├── app.rs         egui UI
│   ├── lib.rs         stub DLL
│   ├── python.rs      CPython API resolved at runtime
│   ├── pipe.rs        named pipe for communicating between exe and stub
│   ├── injector.rs    loads the stub into the target process
│   ├── builder.rs     bakes a script into a standalone injectable DLL
│   └── process.rs     enumerates and filters Python processes

Credits

Project idea and name by Body-Alhoha.

License

MIT — see LICENSE for details.


Built with Rust, egui, and windows-rs

About

Inject and run live Python code inside any running process.

Topics

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages