Skip to content

Instantly share code, notes, and snippets.

@dweinstein
Last active October 9, 2016 15:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dweinstein/ece2110f51bcdf9a331d98c0bb1ca2cd to your computer and use it in GitHub Desktop.
Save dweinstein/ece2110f51bcdf9a331d98c0bb1ca2cd to your computer and use it in GitHub Desktop.
Template for organizing Frida agents. Should make it easier for community to be able to reuse code. Example device side agents and how to potentially organize them.

SUMMARY

The idea here is to organize multiple agent scripts into modules that can be combined into an aggregated agent.

frida agents generally live under e.g., an ./lib/agents directory in a top level project.

TODO

For each agent script we need a top level runner and then we use frida-compile to build into a single agent script that we can load.

'use strict'
module.exports = {
enable: enable,
test: test, // tests for whether our agent should be enabled
description: 'This script will dump the methods of the class name passed in'
}
function enable (opts) {
// pass the className via an option to the agent
// in this case we assume opts holds the options for all agent scripts rather
// than just this specific script this is a design decision that can be tweaked.
if (opts.agent1.className) {
console.log(ObjC.classes[opts.agent1.className].$methods)
}
}
/// the test will be called to make sure we should enable the agent.
function test (opts) {
return ObjC.available && typeof opts.agent1.className !== 'undefined'
}
'use strict'
module.exports = {
enable: enable,
test: test, // tests for whether our agent should be enabled
description: 'description here'
}
function enable (opts) {
if (opts.thing) {
// do something different here
}
}
/// only enable if we're using Frida version 8.0.0...
function test (opts) {
return Frida.version === '8.0.0'
}
module.exports = {
agents: [
require('./agent1.js'),
require('./agent2.js')
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment