The idea here is to organize multiple agent scripts into modules that can be combined into an aggregated agent.
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.
The idea here is to organize multiple agent scripts into modules that can be combined into an aggregated agent.
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 passe 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 () { | |
| return Frida.version === '8.0.0' | |
| } |
| module.exports = { | |
| agents: [ | |
| require('./agent1.js'), | |
| require('./agent2.js') | |
| ] | |
| } |