Skip to content

Instantly share code, notes, and snippets.

@oleavr
Created January 13, 2018 20:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oleavr/50536aedf68e06892d2e03961dc379ed to your computer and use it in GitHub Desktop.
Save oleavr/50536aedf68e06892d2e03961dc379ed to your computer and use it in GitHub Desktop.
Block recv() example
'use strict';
Interceptor.attach(ptr('0x103cdbf40'), {
onEnter: function (args) {
send({ type: 'need-input' });
var operation = recv(function (res) {
args[0] = ptr(res);
});
operation.wait();
}
});
import codecs
import frida
from frida.application import Reactor
import sys
import threading
done = threading.Event()
script = None
def wait_for_keypress(reactor):
done.wait()
reactor = Reactor(wait_for_keypress)
def send_value():
value = input("Enter a number: ")
script.post(value)
def on_message(message, data):
global reactor
print("on_message:", message)
if message["type"] == "send":
reactor.schedule(lambda: send_value())
session = frida.attach("hello")
with codecs.open("explore.js", "r", "utf-8") as f:
source = f.read()
script = session.create_script(source)
script.on("message", on_message)
script.load()
reactor.run()
#include <stdio.h>
#include <unistd.h>
static void f (int n)
{
printf ("Number: %d\n", n);
}
int main (int argc, char * argv[])
{
int n = 1;
printf ("f is at %p\n", f);
while (1)
{
f (n++);
sleep (1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment