Skip to content

Commit

Permalink
attempt to handle issue: FRIDA mode does NOT support multithreading A…
Browse files Browse the repository at this point in the history
  • Loading branch information
skirge committed Mar 15, 2024
1 parent 775861e commit 146a280
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions frida_mode/include/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "frida-gumjs.h"

extern guint64 entry_point;
extern guint64 other_func;
extern gboolean traceable;
extern gboolean entry_compiled;
extern gboolean entry_run;
Expand Down
2 changes: 2 additions & 0 deletions frida_mode/src/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
extern void __afl_manual_init();

guint64 entry_point = 0;
guint64 other_func = 0;
gboolean traceable = FALSE;
gboolean entry_compiled = FALSE;
gboolean entry_run = FALSE;
Expand Down Expand Up @@ -63,6 +64,7 @@ void entry_on_fork(void) {
void entry_config(void) {

entry_point = util_read_address("AFL_ENTRYPOINT", 0);
other_func = util_read_address("AFL_OTHER_FUNC", 0);
if (getenv("AFL_FRIDA_TRACEABLE") != NULL) { traceable = TRUE; }

}
Expand Down
12 changes: 12 additions & 0 deletions frida_mode/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ static void *on_entry(size_t a1, size_t a2, size_t a3, size_t a4, size_t a5,

}

static void *on_other(size_t a1, size_t a2, size_t a3, size_t a4, size_t a5,
size_t a6) {

intercept_unhook(GSIZE_TO_POINTER(other_func));
afl_frida_run();
entry_func_t entry = (entry_func_t)other_func;
return entry(a1, a2, a3, a4, a5, a6);

}
static int on_main(int argc, char **argv, char **envp) {

int ret;
Expand All @@ -287,6 +296,9 @@ static int on_main(int argc, char **argv, char **envp) {

}

if(other_func != 0 ) {
intercept_hook(GSIZE_TO_POINTER(other_func), on_other, NULL);
}
if (js_main_hook != NULL) {

ret = js_main_hook(argc, argv, envp);
Expand Down

0 comments on commit 146a280

Please sign in to comment.