Last active
August 29, 2015 14:26
-
-
Save oleavr/61bc5ca777f51cddfbc6 to your computer and use it in GitHub Desktop.
RPC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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); | |
}); | |
} | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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