Skip to content

Commit 03dd5a7

Browse files
committed
feat: inject into plugins only
this could be helpful in the case you'll inject your own fix into the main binary only, as all other injectors do
1 parent 2e6924e commit 03dd5a7

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ ipapatch only has 1 external dependency: the `zip` command. ipapatch actually co
1313
# usage
1414
```bash
1515
$ ipapatch --help
16-
usage: ipapatch [-h/--help] --input <path> [--output <path] [--dylib <path>] [--inplace] [--noconfirm] [--version]
16+
usage: ipapatch [-h/--help] --input <path> [--output <path] [--dylib <path>] [--inplace] [--noconfirm] [--plugins-only] [--version]
1717

1818
flags:
1919
--input path the path to the ipa file to patch
2020
--output path the path to the patched ipa file to create
2121
--dylib path the path to the dylib to use instead of the embedded zxPluginsInject
2222
--inplace takes priority over --output, use this to overwrite the input file
2323
--noconfirm skip interactive confirmation when not using --inplace, overwriting a file that already exists, etc
24+
--plugins-only only inject into plugin binaries (not the main executable)
2425

2526
info:
2627
-h, --help show usage and exit

cmd.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,31 @@ import (
77
"go.uber.org/zap/zapcore"
88
)
99

10-
const helpText = `usage: ipapatch [-h/--help] --input <path> [--output <path] [--dylib <path>] [--inplace] [--noconfirm] [--version]
10+
const helpText = `usage: ipapatch [-h/--help] --input <path> [--output <path] [--dylib <path>] [--inplace] [--noconfirm] [--plugins-only] [--version]
1111
1212
flags:
1313
--input path the path to the ipa file to patch
1414
--output path the path to the patched ipa file to create
1515
--dylib path the path to the dylib to use instead of the embedded zxPluginsInject
1616
--inplace takes priority over --output, use this to overwrite the input file
1717
--noconfirm skip interactive confirmation when not using --inplace, overwriting a file that already exists, etc
18+
--plugins-only only inject into plugin binaries (not the main executable)
1819
1920
info:
2021
-h, --help show usage and exit
2122
--version show version and exit`
2223

2324
type Args struct {
24-
Input string `arg:"--input,required"`
25-
Output string `arg:"--output"`
26-
Dylib string `arg:"--dylib"`
27-
InPlace bool `arg:"--inplace"`
28-
NoConfirm bool `arg:"--noconfirm"`
25+
Input string `arg:"--input,required"`
26+
Output string `arg:"--output"`
27+
Dylib string `arg:"--dylib"`
28+
InPlace bool `arg:"--inplace"`
29+
NoConfirm bool `arg:"--noconfirm"`
30+
PluginsOnly bool `arg:"--plugins-only"`
2931
}
3032

3133
func (Args) Version() string {
32-
return "ipapatch v1.1.0"
34+
return "ipapatch v1.1.1"
3335
}
3436

3537
func AskInteractively(question string) bool {

ipa.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func injectAll(args Args, tmpdir string) (map[string]string, error) {
2424
}
2525
defer z.Close()
2626

27-
plists, err := findPlists(z.File)
27+
plists, err := findPlists(z.File, args.PluginsOnly)
2828
if err != nil {
2929
return nil, err
3030
}
@@ -60,18 +60,22 @@ func injectAll(args Args, tmpdir string) (map[string]string, error) {
6060
return paths, nil
6161
}
6262

63-
func findPlists(files []*zip.File) (plists []string, err error) {
63+
func findPlists(files []*zip.File, pluginsOnly bool) (plists []string, err error) {
6464
plists = make([]string, 0, 10)
6565

6666
for _, f := range files {
67-
if !(strings.HasSuffix(f.Name, ".app/Info.plist") || strings.HasSuffix(f.Name, ".appex/Info.plist")) {
67+
if !pluginsOnly && strings.HasSuffix(f.Name, ".app/Info.plist") {
68+
plists = append(plists, f.Name)
69+
continue
70+
}
71+
if strings.HasSuffix(f.Name, ".appex/Info.plist") {
72+
plists = append(plists, f.Name)
6873
continue
6974
}
7075
if strings.Contains(f.Name, ".app/Watch") || strings.Contains(f.Name, ".app/WatchKit") || strings.Contains(f.Name, ".app/com.apple.WatchPlaceholder") {
7176
logger.Infof("found watch app at '%s', you might want to remove that", filepath.Dir(f.Name))
7277
continue
7378
}
74-
plists = append(plists, f.Name)
7579
}
7680

7781
if len(plists) == 0 {

0 commit comments

Comments
 (0)