Skip to content

Instantly share code, notes, and snippets.

@oleavr
Last active August 29, 2015 14:26
Show Gist options
  • Save oleavr/61bc5ca777f51cddfbc6 to your computer and use it in GitHub Desktop.
Save oleavr/61bc5ca777f51cddfbc6 to your computer and use it in GitHub Desktop.
RPC
#!/usr/bin/env iojs --harmony_arrow_functions
'use strict';
const co = require('co');
const frida = require('frida');
co(function *() {
const session = yield frida.attach('cat');
const script = yield session.createScript('(' +
agent.toString() + ').call(this);');
yield script.load();
const exports = yield script.getExports();
console.log(yield exports.add(2, 3));
console.log(yield exports.sub(5, 3));
yield session.detach();
});
function agent() {
'use strict';
rpc.exports = {
add(a, b) {
return a + b;
},
sub(a, b) {
return new Promise(resolve => {
setTimeout(() => {
resolve(a - b);
}, 100);
});
}
};
}
import frida
session = frida.attach("cat")
script = session.create_script("""\
'use strict';
rpc.exports = {
add(a, b) {
return a + b;
},
sub(a, b) {
return new Promise(resolve => {
setTimeout(() => {
resolve(a - b);
}, 100);
});
}
};
""")
script.load()
print(script.exports.add(2, 3))
print(script.exports.sub(5, 3))
session.detach()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment