mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-03-21 18:04:10 -05:00
Add an option to run adb root and add a warning if the setup script is not running as root
This commit is contained in:
parent
25246be4b5
commit
c7948ded9e
|
|
@ -37,6 +37,10 @@ export function builder(yargs: Argv<ParentArguments>) {
|
|||
}).option('adb-path', {
|
||||
describe: 'Path to the adb executable',
|
||||
type: 'string',
|
||||
}).option('adb-root', {
|
||||
describe: 'Run `adb root` to restart adbd as root',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
}).option('frida-server-path', {
|
||||
describe: 'Path to the frida-server executable on the device',
|
||||
type: 'string',
|
||||
|
|
@ -553,6 +557,13 @@ const setup_script = (options: {
|
|||
start_method: StartMethod;
|
||||
}) => `#!/system/bin/sh
|
||||
|
||||
if [ "\`id -u\`" != "0" ]; then
|
||||
echo ""
|
||||
echo "-- Not running as root, this will not work --"
|
||||
echo "Use --adb-root to restart adbd as root (or run adb root manually) or use --exec-command to specify a su-like command to escalate to root."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Ensure frida-server is running
|
||||
echo "Running frida-server"
|
||||
killall ${JSON.stringify(path.basename(options.frida_server_path))}
|
||||
|
|
@ -583,12 +594,16 @@ fi
|
|||
|
||||
echo "Acquiring wake lock"
|
||||
echo androidzncaapiserver > /sys/power/wake_lock
|
||||
|
||||
exit 0
|
||||
`;
|
||||
|
||||
const shutdown_script = `#!/system/bin/sh
|
||||
|
||||
echo "Releasing wake lock"
|
||||
echo androidzncaapiserver > /sys/power/wake_unlock
|
||||
|
||||
exit 0
|
||||
`;
|
||||
|
||||
async function setup(argv: ArgumentsCamelCase<Arguments>, start_method: StartMethod) {
|
||||
|
|
@ -633,6 +648,14 @@ async function attach(argv: ArgumentsCamelCase<Arguments>, start_method: StartMe
|
|||
const frida = await import('frida');
|
||||
type Session = import('frida').Session;
|
||||
|
||||
if (argv.adbRoot) {
|
||||
debug('Restarting adbd as root');
|
||||
|
||||
execAdb([
|
||||
'root',
|
||||
], argv.adbPath, argv.device);
|
||||
}
|
||||
|
||||
debug('Running scripts');
|
||||
execScript(argv.device, '/data/local/tmp/android-znca-api-server-setup.sh', argv.execCommand, argv.adbPath);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user