-
Notifications
You must be signed in to change notification settings - Fork 30
/
margerine.js
95 lines (83 loc) · 2.92 KB
/
margerine.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env node
const yargs = require('yargs')
const chalk = require('chalk')
/* we use Sentry to help debug in case of errors in the obfuscated build and basic analytics */
const Sentry = require("@sentry/node");
const Tracing = require("@sentry/tracing");
Sentry.init({
dsn: "https://[email protected]/6247631",
tracesSampleRate: 1.0,
});
const { lock, unlock, doShell, doReboot} = require("./src/exploit")
const { wrapSentry, getDevice, waitDevice } = require("./src/utils")
const constants = require("./src/constants")
const argv = yargs
.command('unlock [serialport]', 'unlock device and enable adb', (yargs) => {
return yargs
.positional('serialport', {
describe: '(optional) serial port to connect to'
})
}, (argv) => {
wrapSentry("unlock", async () => {
console.log(chalk.hex("#0057b7")("margerine - brought to you with love by the fpv.wtf team"))
console.log(chalk.hex("#ffd700")("special thanks to @tmbinc, @bin4ry, @jaanuke and @funnel\n"))
return await getDevice(argv.serialport)
.then(unlock)
.then(() => {
console.log("\ndevice should be unlocked, try 'adb devices'")
console.log("please consider donating: https://github.com/fpv-wtf/margerine#support-the-effort")
})
.catch((error)=>{
console.error("couldn't do the magic. please read the notes in README.md, restart your device and try again")
throw error
})
})
})
.command('lock [serialport]', 'disable startup patches', (yargs) => {
return yargs
.positional('serialport', {
describe: '(optional) serial port to connect to'
})
}, (argv) => {
wrapSentry("lock", () => {
return getDevice(argv.serialport)
.then(lock)
.then(() => {
console.log("\nstartup patches should be disabled, assistant should be happy now")
})
})
})
.command('shell <command> [port]', 'execute a command on rooted device, once per reboot', (yargs) => {
return yargs
.positional('command', {
describe: 'command to execute'
})
.positional('serialport', {
describe: '(optional) serial port to connect to'
})
}, (argv) => {
return getDevice(argv.serialport).then((path) => {
doShell(path, argv.command)
})
})
.command('reboot [port]', 'reboot a connected device', (yargs) => {
return yargs
.positional('serialport', {
describe: '(optional) serial port to connect to'
})
}, (argv) => {
return getDevice(argv.serialport).then((path) => {
doReboot(path)
})
})
.command('wait', 'wait for a DJI serial device to appear (only works if the serial port can be auto detected)', (yargs) => {
return yargs
}, (argv) => {
console.log("waiting for DJI serial device")
return waitDevice(10000).then(() => {
console.log("DJI serial device detected")
process.exit(0)
})
})
.demandCommand()
.argv