Last active
June 4, 2024 15:39
-
-
Save oleavr/6ecae99945ccba47427a to your computer and use it in GitHub Desktop.
Frida Node.js example
This file contains 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
var frida = require('frida'); | |
frida.attach('cat') | |
.then(function (session) { | |
console.log('attached:', session); | |
return session.createScript( | |
'function onMessage(message) {' + | |
'send({ name: "pong", payload: message });' + | |
'recv(onMessage);' + | |
'}' + | |
'recv(onMessage);' | |
); | |
}) | |
.then(function (script) { | |
console.log('script created:', script); | |
script.events.listen('message', function (message, data) { | |
console.log('message from script:', message, data); | |
}); | |
script.load() | |
.then(function () { | |
console.log('script loaded'); | |
setInterval(function () { | |
script.postMessage({ name: 'ping' }); | |
}, 1000); | |
}); | |
}) | |
.catch(function (error) { | |
console.log('error:', error.message); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment