{"id":20325818,"url":"https://github.com/paradiseduo/inject","last_synced_at":"2025-04-05T11:04:41.915Z","repository":{"id":44722779,"uuid":"405085118","full_name":"paradiseduo/inject","owner":"paradiseduo","description":"Command Line Tool for interacting with MachO binaries on OSX/iOS","archived":false,"fork":false,"pushed_at":"2025-02-19T03:32:40.000Z","size":126,"stargazers_count":166,"open_issues_count":2,"forks_count":28,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T10:04:52.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paradiseduo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-10T13:10:13.000Z","updated_at":"2025-03-18T15:49:54.000Z","dependencies_parsed_at":"2024-11-14T19:41:55.488Z","dependency_job_id":"9770ee14-53d7-49ac-8c44-cab5201dfd70","html_url":"https://github.com/paradiseduo/inject","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradiseduo%2Finject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradiseduo%2Finject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradiseduo%2Finject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradiseduo%2Finject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paradiseduo","download_url":"https://codeload.github.com/paradiseduo/inject/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T19:41:49.550Z","updated_at":"2025-04-05T11:04:41.866Z","avatar_url":"https://github.com/paradiseduo.png","language":"Swift","readme":"# inject\n\ninject is a tool which interfaces with MachO binaries in order to insert load commands. Below is its help.\n```bash\n❯ ./inject -h\nOVERVIEW: inject v3.0.0\n\ninject is a tool which interfaces with MachO binaries in order to insert load commands.\n\nUSAGE: inject \u003cfile-path\u003e [--dylib \u003cdylib\u003e] [--cmd \u003ccmd\u003e] [--ipa] [--strip] [--aslr] [--remove] [--weak \u003cweak\u003e]\n\nARGUMENTS:\n  \u003cfile-path\u003e             The machO/ipa to inject.\n\nOPTIONS:\n  -d, --dylib \u003cdylib\u003e     The dylib to inject, please give me path.\n  -c, --cmd \u003ccmd\u003e         Specify which type of load command to use in INSTALL. Can be reexport for LC_REEXPORT_DYLIB, weak for LC_LOAD_WEAK_DYLIB, upward for LC_LOAD_UPWARD_DYLIB, or load for LC_LOAD_DYLIB. (default: LC_LOAD_DYLIB)\n  -i, --ipa               If inject into ipa, please set this flag. Default false mean is machO file path.\n  -s, --strip             Removes a code signature load command from the given binary.\n  -a, --aslr              Removes an ASLR flag from the macho header if it exists. This may render some executables unusable.\n  -r, --remove            Removes any LC_LOAD commands which point to a given payload from the target binary. This may render some executables unusable.\n  -w, --weak \u003cweak\u003e       Used with the STRIP command to weakly remove the signature. Without this, the code signature is replaced with null bytes on the binary and it's LOAD command is removed. (default: true)\n  --version               Show the version.\n  -h, --help              Show help information.\n```\n\n## Build\nbuild with xcode\n```bash\nopen Package.swift\ncommand + B\n```\n\nbuild with bash\n```bash\n❯ chmod +x build-macOS_x86.sh\n❯ ./build-macOS_x86.sh\n❯ chmod +x build-macOS_arm.sh\n❯ ./build-macOS_arm.sh\n```\n\n## Test\nTest for mac machO\n```bash\n❯ chmod +x test-mac-inject.sh\n❯ ./test-mac-inject.sh\n==========Build Start==========\nBuilding for production...\n[7/7] Linking inject\nBuild of product 'inject' complete! (9.10s)\nbuild in 12 seconds\n==========Build Finish==========\n\n==========Test Start==========\nBackup machO file ./inject_back\nInject @executable_path/testMac/libtestinject.dylib Finish\n==========Test otool==========\ninject:\n\t/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)\n\t/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3107.0.0)\n\t/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.101.0)\n\t/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)\n\t/usr/lib/swift/libswift_Concurrency.dylib (compatibility version 1.0.0, current version 0.0.0, weak)\n\t@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 0.0.0)\n\t@rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)\n\t@rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 228.0.13)\n\t@rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 49.0.0, weak)\n\t@rpath/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)\n\t@rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 10.0.0, weak)\n\t@rpath/libswiftXPC.dylib (compatibility version 1.0.0, current version 62.0.1, weak)\n\t@rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1.0.0)\n\t@executable_path/testMac/libtestinject.dylib (compatibility version 0.0.0, current version 0.0.0)\n==========Test Run==========\nlibtestinject.dylib inject success\nError: Missing expected argument '\u003cfile-path\u003e'\n\nOVERVIEW: inject v3.0.0\n\ninject is a tool which interfaces with MachO binaries in order to insert load commands.\n\nUSAGE: inject \u003cfile-path\u003e [--dylib \u003cdylib\u003e] [--cmd \u003ccmd\u003e] [--ipa] [--strip] [--aslr] [--remove] [--weak \u003cweak\u003e]\n\nARGUMENTS:\n  \u003cfile-path\u003e             The machO/ipa to inject.\n\nOPTIONS:\n  -d, --dylib \u003cdylib\u003e     The dylib to inject, please give me path.\n  -c, --cmd \u003ccmd\u003e         Specify which type of load command to use in INSTALL. Can be reexport for LC_REEXPORT_DYLIB, weak for LC_LOAD_WEAK_DYLIB, upward for LC_LOAD_UPWARD_DYLIB, or load for LC_LOAD_DYLIB. (default: LC_LOAD_DYLIB)\n  -i, --ipa               If inject into ipa, please set this flag. Default false mean is machO file path.\n  -s, --strip             Removes a code signature load command from the given binary.\n  -a, --aslr              Removes an ASLR flag from the macho header if it exists. This may render some executables unusable.\n  -r, --remove            Removes any LC_LOAD commands which point to a given payload from the target binary. This may render some executables unusable.\n  -w, --weak \u003cweak\u003e       Used with the STRIP command to weakly remove the signature. Without this, the code signature is replaced with null bytes on the binary and it's LOAD command is removed. (default: true)\n  --version               Show the version.\n  -h, --help              Show help information.\n\n==========Test Finish==========\n\n==========Clean Start==========\n==========Clean Finish==========\n==========Build Start==========\nBuilding for production...\n[6/6] Linking inject\nBuild of product 'inject' complete! (7.28s)\nbuild in 7 seconds\n==========Build Finish==========\n\n==========Test Start==========\nBackup machO file ./inject_arm64_back\nInject @executable_path/testMac/libtestinject.dylib Finish\ninject_arm64: replacing existing signature\n==========Test otool==========\ninject_arm64:\n\t/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1351.0.0)\n\t/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 3107.0.0)\n\t/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1800.101.0)\n\t/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)\n\t/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 0.0.0)\n\t/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)\n\t/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 228.0.13)\n\t/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 49.0.0, weak)\n\t/usr/lib/swift/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)\n\t/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 10.0.0, weak)\n\t/usr/lib/swift/libswiftXPC.dylib (compatibility version 1.0.0, current version 62.0.1, weak)\n\t@rpath/libswift_Concurrency.dylib (compatibility version 1.0.0, current version 0.0.0, weak)\n\t/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1.0.0)\n\t@executable_path/testMac/libtestinject.dylib (compatibility version 0.0.0, current version 0.0.0)\n==========Test Run==========\nlibtestinject.dylib inject success\nError: Missing expected argument '\u003cfile-path\u003e'\n\nOVERVIEW: inject v3.0.0\n\ninject is a tool which interfaces with MachO binaries in order to insert load commands.\n\nUSAGE: inject \u003cfile-path\u003e [--dylib \u003cdylib\u003e] [--cmd \u003ccmd\u003e] [--ipa] [--strip] [--aslr] [--remove] [--weak \u003cweak\u003e]\n\nARGUMENTS:\n  \u003cfile-path\u003e             The machO/ipa to inject.\n\nOPTIONS:\n  -d, --dylib \u003cdylib\u003e     The dylib to inject, please give me path.\n  -c, --cmd \u003ccmd\u003e         Specify which type of load command to use in INSTALL. Can be reexport for LC_REEXPORT_DYLIB, weak for LC_LOAD_WEAK_DYLIB, upward for LC_LOAD_UPWARD_DYLIB, or load for LC_LOAD_DYLIB. (default: LC_LOAD_DYLIB)\n  -i, --ipa               If inject into ipa, please set this flag. Default false mean is machO file path.\n  -s, --strip             Removes a code signature load command from the given binary.\n  -a, --aslr              Removes an ASLR flag from the macho header if it exists. This may render some executables unusable.\n  -r, --remove            Removes any LC_LOAD commands which point to a given payload from the target binary. This may render some executables unusable.\n  -w, --weak \u003cweak\u003e       Used with the STRIP command to weakly remove the signature. Without this, the code signature is replaced with null bytes on the binary and it's LOAD command is removed. (default: true)\n  --version               Show the version.\n  -h, --help              Show help information.\n\n==========Test Finish==========\n\n==========Clean Start==========\n==========Clean Finish==========\n```\nTest for iOS IPA\n```bash\n❯ chmod +x test-ios-inject.sh\n❯ ./test-ios-inject.sh\n==========Build Start==========\n[0/0] Build complete!\nbuild in 0 seconds\n==========Build Finish==========\n\n==========Test Start==========\nInject @executable_path/Inject/injectiOSFramework.framework/injectiOSFramework Finish\nInject @executable_path/testiOS/injectiOSFramework.framework finish, new IPA file is testiOS/app.ipa\nInject @executable_path/Inject/libinjectiOS.dylib Finish\nInject @executable_path/testiOS/libinjectiOS.dylib finish, new IPA file is testiOS/app.ipa\n==========Test Result==========\nPayload/TestLock.app/TestLock:\n\t/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1854.0.0)\n\t/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)\n\t/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)\n\t/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 1854.0.0)\n\t/System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 5067.3.107)\n\t@executable_path/Inject/injectiOSFramework.framework/injectiOSFramework (compatibility version 0.0.0, current version 0.0.0)\n\t@executable_path/Inject/libinjectiOS.dylib (compatibility version 0.0.0, current version 0.0.0)\n==========Test Finish==========\n\n==========Clean Start==========\n==========Clean Finish==========\n```\n\n## Use\n### Inject dylib for mac exec:\n```bash\n❯ ./inject testExec -d @executable_path/testMac/libtestinject.dylib\n```\n### Remove dylib for mac exec:\n```bash\n❯ ./inject testExec -d @executable_path/testMac/libtestinject.dylib --remove\n```\n\n### Inject dylib for ipa:\n```bash\n❯ ./inject testiOS/app.ipa -d  @executable_path/testiOS/libinjectiOS.dylib --ipa\n```\n### Inject Framework for ipa:\n```bash\n❯ ./inject testiOS/app.ipa -d  @executable_path/testiOS/injectiOSFramework.framework/injectiOSFramework --ipa\n```\nOR end with .framework\n```bash\n❯ ./inject testiOS/app.ipa -d  @executable_path/testiOS/injectiOSFramework.framework --ipa\n```\n\n## Use As Framework\n\nUse Injection.framework, See [ViewController.swift](https://github.com/paradiseduo/inject/blob/master/Injection/InjectTest/ViewController.swift)\n\n\n## Use as Swift Package\n\nPackage.swift:\n```swift\n// swift-tools-version: 5.7\n// The swift-tools-version declares the minimum version of Swift required to build this package.\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"Test\",\n    products: [\n        .executable(\n            name: \"Test\",\n            targets: [\"Test\"]),\n    ],\n    dependencies: [\n         .package(url: \"https://github.com/paradiseduo/inject\", from: \"1.0.0\"),\n    ],\n    targets: [\n        .target(\n            name: \"Test\",\n            dependencies: [.product(name: \"Injection\", package: \"inject\"),]),\n        .testTarget(\n            name: \"TestTests\",\n            dependencies: [\"Test\"]),\n    ]\n)\n```\n\nExample:\n\n```swift\nimport injection\n\nInject.injectMachO(machoPath: \"\", cmdType: LC_Type.LOAD_DYLIB, backup: false, injectPath: \"\") { result in\n    \n}\n```\n\n\n\n## Other\nYou should resign new .IPA file to run.\nJust use codesign:\n```bash\n❯ security find-identity -v -p codesigning\n1) xxxxx \"Apple Development: xxx xx (xxxxxxxxxx)\"\n     1 valid identities found\n❯ codesign -f -s \"xxxxx\" Payload/app.app\nPayload/app.app: replacing existing signature\n❯ codesign -f -s \"xxxxx\" Payload/app.app/Inject/libxxxxx.dylib\nPayload/app.app/Inject/libxxxxx.dylib: replacing existing signature\n```\n\n## License\n\nThis software is released under the GPL-3.0 license.\n\n\n\n## Stargazers over time\n\n[![Stargazers over time](https://starchart.cc/paradiseduo/inject.svg)](https://starchart.cc/paradiseduo/inject)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadiseduo%2Finject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparadiseduo%2Finject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadiseduo%2Finject/lists"}