Skip to content

Commit

Permalink
Fixed v2 Goggles rooting process, added wait subcommand, made reboots…
Browse files Browse the repository at this point in the history
… faster by removing most fixed timeouts, added pkg config for .exe builds
  • Loading branch information
j005u committed May 9, 2023
1 parent d039f16 commit defe680
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 1,209 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
tmp/
dist/
36 changes: 18 additions & 18 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Copyright (c) 2022 Joonas Trussmann <joonas@batman.ee>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
Copyright (c) 2022 Joonas Trussmann <joonas@batman.ee>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
53 changes: 26 additions & 27 deletions margerine.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

const { SerialPort } = require('serialport')
const yargs = require('yargs')
const chalk = require('chalk')

Expand All @@ -15,31 +14,10 @@ Sentry.init({
});


const { lock, unlock, doShell} = require("./src/exploit")
const { wrapSentry } = require("./src/utils")
const { lock, unlock, doShell, doReboot} = require("./src/exploit")
const { wrapSentry, getDevice, waitDevice } = require("./src/utils")
const constants = require("./src/constants")

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"))

async function getDevice(argv) {
if(argv.serialport) {
return argv.serialport
}
else {
return SerialPort.list()
.then(portInfos => {
var dji = portInfos.filter(pinfo => `${pinfo.vendorId}`.match(/2CA3/i))
if(!dji.length) {
console.log("no dji devices detected\nyou may wish to specify a COM port, see node margerine.js --help")
process.exit(1)
}
return dji[0].path
})
}
}


const argv = yargs
.command('unlock [serialport]', 'unlock device and enable adb', (yargs) => {
return yargs
Expand All @@ -48,7 +26,9 @@ const argv = yargs
})
}, (argv) => {
wrapSentry("unlock", async () => {
return await getDevice(argv)
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'")
Expand All @@ -68,7 +48,7 @@ const argv = yargs
})
}, (argv) => {
wrapSentry("lock", () => {
return getDevice(argv)
return getDevice(argv.serialport)
.then(lock)
.then(() => {
console.log("\nstartup patches should be disabled, assistant should be happy now")
Expand All @@ -85,10 +65,29 @@ const argv = yargs
describe: '(optional) serial port to connect to'
})
}, (argv) => {
return getDevice(argv).then((path) => {
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)
})
})



Expand Down
Loading

0 comments on commit defe680

Please sign in to comment.