Created
January 6, 2017 07:36
-
-
Save riverar/687a272c315a53906461c4d52d444bb0 to your computer and use it in GitHub Desktop.
Frida + VSCode Example (app.js)
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
#!/usr/bin/env node | |
'use strict' | |
const co = require('co') | |
const frida = require('frida') | |
const fs = require('fs-promise') | |
const path = require('path') | |
const sleep = require('co-sleep'); | |
const pkg = require('./package.json') | |
const processName = process.argv[2] | |
if (typeof processName != 'string') { | |
console.log('Usage: ... <process name>') | |
return | |
} | |
co(function* () { | |
const session = yield frida.attach(processName) | |
session.enableDebugger({ port: 6666 }) | |
const script = yield session.createScript((yield fs.readFile(require.resolve('./agent'))).toString(), { | |
"name": `${path.join(process.cwd(), 'agent')}` | |
}) | |
script.events.listen('message', (message, data) => console.log(' [i] %s', message)) | |
yield script.load() | |
if(process.argv.includes('debug')) { | |
console.log(' [*] Sleeping 5 seconds for debugger attach') | |
yield sleep(5000) | |
} | |
const agent = yield script.getExports() | |
yield agent.doSomethingInteresting() | |
yield [script.unload(), session.detach()] | |
console.log(' [*] Done.') | |
}).catch(err => { | |
console.error(' %s', err.stack) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment