Skip to content

Instantly share code, notes, and snippets.

@SomeoneWeird
Last active August 29, 2015 14:19
Show Gist options
  • Save SomeoneWeird/bcdea0a99855a5aace84 to your computer and use it in GitHub Desktop.
Save SomeoneWeird/bcdea0a99855a5aace84 to your computer and use it in GitHub Desktop.
var frida = require('frida');
var script = `
recv('getModules', function() {
var modules = [];
Process.enumerateModules({
onMatch: function(module) {
modules.push(module);
},
onComplete: function() {
send({
name: "getModules",
data: modules
});
}
});
});
recv('getExports', function(data) {
console.log(JSON.stringify(data));
});
`;
frida.attach(process.argv[2]).then(function(session) {
session.createScript(script).then(function(script) {
script.events.listen("message", function(message) {
var { name, data } = message.payload;
if(name === "getModules") {
console.log("Got", data.length, "modules");
// we have modules, try and get exports for 2 random ones
var one = data[Math.floor(Math.random()*data.length)];
var two = data[Math.floor(Math.random()*data.length)];
console.log("Trying", one.name, "&", two.name);
[ one, two ].forEach(function(mod) {
script.postMessage({
type: "getExports",
payload: {
name: mod.name
}
});
});
} else {
console.log(name, data);
}
});
script.load().then(function() {
console.log("loaded");
script.postMessage({
type: "getModules"
});
}).catch(err);
}).catch(err);
}).catch(err);
function err(e) {
console.log(e);
}
➜ ex sudo babel-node test hello
loaded
Got 42 modules
Trying libsystem_network.dylib & libdyld.dylib
{"type":"getExports","payload":{"name":"libsystem_network.dylib"}}
➜ ex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment