-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.ts
62 lines (56 loc) · 1.97 KB
/
cli.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
import process from 'process'
import { defineConfig, startHost } from ".";
import { program } from "commander";
program
.name("frida-host")
.description("Host scripts for Frida")
.version("1.0")
type ProgramOptions = {
target: string,
package: string,
attach: 'always' | 'try' | 'never',
retries: number,
delay: number,
spawn: boolean,
output: string,
device: 'usb' | 'local',
usb: boolean,
local: boolean
}
program
.argument("<script>", "Script to host")
.option("-p, --package <package>", "Target package name")
.option("-t, --target <target>", "Target process name")
.option("-a, --attach", "Never spawn the target app")
.option("-s, --spawn [pref]", "Spawn preference", "always")
.option("-r, --retries <retries>", "Number of retries", "15")
.option("-D, --delay <delay>", "Delay between each retry in ms", "1000")
.option("-o, --output <output>", "Output file")
.option("-d, --device <device>", "Device type")
.option("-u, --usb", "Use USB device")
.option("-l, --local", "Use local device")
.description("Host a script for Frida")
.action(async (script: string, options: ProgramOptions) => {
try {
const conf = defineConfig({
target: {
name: options.target,
package: options.package,
source: options.usb ? "usb" : options.local ? "local" : options.device ? options.device : "usb",
},
attachPreference: {
spawn: options.attach ? options.attach : options.spawn ? "always" : "try",
maxAttempts: options.retries,
delay: options.delay
},
output: options.output,
entryPoint: script
})
await startHost(conf)
} catch (e) {
console.error(e)
process.exit(1)
}
})
program.parse()