A Windows process injector written in Rust that can inject and execute Python scripts in running processes.
Note
This injector uses the pythonX.dll file that is already loaded on the process. It does not inject an additional Python DLL onto the process!
For detailed technical explanation, see the Technical Documentation.
Execute a Python command:
pyinjector.exe --pid <PID> --command "print('Hello from injected code!')"Inject a Python script file:
pyinjector.exe --pid <PID> --script script.pypyinjector.exe --pid 1234 --command "import ctypes; ctypes.windll.user32.MessageBoxW(0, 'Injected!', 'PyInjector', 0)"Create test.py:
import sys
import os
print(f"Python {sys.version} running in PID {os.getpid()}")Inject it:
pyinjector.exe --pid 1234 --script test.pycargo build --releaseInstall the Windows target:
rustup target add x86_64-pc-windows-gnuBuild for Windows:
cargo build --release --target x86_64-pc-windows-gnuI would like to thank Melih Kaan Yıldız for giving me the idea for pyinjector.