Created
January 12, 2021 17:41
-
-
Save keesj/dcf40e22fd8ff0fc84b49246a9e9e439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Execute a shell command and capture stdout until eof (run with node frida-shell-cmd.js) */ | |
const frida = require('frida'); | |
let device = null; | |
async function main() { | |
const deviceManager = frida.getDeviceManager(); | |
device = await deviceManager.addRemoteDevice('192.168.3.105'); | |
device.output.connect(onOutput); | |
console.log('[*] spawn()'); | |
const pid = await device.spawn('/bin/sh', { | |
argv: ['/bin/sh', '-c', 'ls /; sleep 2; echo done'], | |
cwd: '/', | |
stdio: 'pipe', | |
aslr: 'auto' | |
}); | |
console.log(`[*] attach(${pid})`); | |
const session = await device.attach(pid); | |
console.log('[*] enableChildGating()'); | |
console.log(`[*] resume(${pid})`); | |
await device.resume(pid); | |
} | |
function onOutput(pid, fd, data) { | |
let description; | |
if (data.length > 0) { | |
description = '"' + data.toString().replace(/\n/g, '\\n') + '"'; | |
} else { | |
description = '<EOF>'; | |
device.output.disconnect(onOutput); | |
} | |
console.log(`[*] onOutput(pid=${pid}, fd=${fd}, data=${description})`); | |
} | |
main() | |
.catch(e => { | |
console.error(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment