process_inject <target> <dylib> [flags]<target>: Can be one of:- Process ID of the target process (for direct injection)
- Process name (when using -name flag)
- Application bundle path (when using -spawn flag)
<dylib>: The full path to the dynamic library (dylib) to inject.[flags]: Optional flags for different injection modes.
-name: Use the process name instead of process ID to identify the target (for existing processes).-spawn: Spawn a new process from the specified application bundle and inject the dylib.
- Inject into an already running process by PID:
process_inject 1234 "/path/to/library.dylib"- Inject into an already running process by name:
process_inject "Safari" "/path/to/library.dylib" -name- Spawn a new process and inject (spawn mode):
process_inject "/Applications/Calculator.app/Contents/MacOS/Calculator" "/path/to/library.dylib" -spawnNote: Injecting into root processes requires root privileges
sudo codesign -f -s - --all-architectures --deep --entitlements "process_inject.entitlements" process_inject
Thanks to these projects for their inspiring idea and code!