Created
January 13, 2018 20:01
-
-
Save oleavr/50536aedf68e06892d2e03961dc379ed to your computer and use it in GitHub Desktop.
Block recv() example
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
'use strict'; | |
Interceptor.attach(ptr('0x103cdbf40'), { | |
onEnter: function (args) { | |
send({ type: 'need-input' }); | |
var operation = recv(function (res) { | |
args[0] = ptr(res); | |
}); | |
operation.wait(); | |
} | |
}); |
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 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() |
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
#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