/pypatch

Inject arbitrary code into any running python interpreter

Primary LanguageGoGNU General Public License v3.0GPL-3.0

logo

PyPatch

Inject arbitrary code into any running python interpreter

Supports all configurations of PyInstaller and PyArmor


Overview

pypatch includes:

Usage

  • Write the payload you want to inject in inject.py
  • Compile a DLL with the payload with make dll
  • Compile an injector (in cmd/injector) with your program and dll paths

Example

program.py obfuscated with pyarmor 8.4.2 and packed with pyinstaller 6.1.0

import time

def main():
  while True:
    print("Working")
    time.sleep(1)

if __name__ == "__main__":
  main()

logo

Injecting inject.py with pypatch executor before startup

import os
print("Hello from inject.py!")
print = lambda *args, **kwargs: os.write(1, b"Boo!\n")

logo


Contributing

Contributions are welcome!

License

Distributed under the GNU GPL v3.0 License. See LICENSE for more information.