Skip to content

Instantly share code, notes, and snippets.

@riverar
Created January 6, 2017 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riverar/687a272c315a53906461c4d52d444bb0 to your computer and use it in GitHub Desktop.
Save riverar/687a272c315a53906461c4d52d444bb0 to your computer and use it in GitHub Desktop.
Frida + VSCode Example (app.js)
#!/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