Added JS support (#992)

* Added JS support

* Added some documentation

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
WorksButNotTested
2021-06-24 18:46:08 +01:00
committed by GitHub
parent 4057134d3c
commit f348a35ec6
69 changed files with 1432 additions and 277 deletions

View File

@ -2,10 +2,11 @@
#include <sys/shm.h>
#include <sys/mman.h>
#include "frida-gum.h"
#include "frida-gumjs.h"
#include "debug.h"
#include "intercept.h"
#include "prefetch.h"
#include "stalker.h"
@ -20,9 +21,10 @@ typedef struct {
} prefetch_data_t;
static prefetch_data_t *prefetch_data = NULL;
gboolean prefetch_enable = TRUE;
static int prefetch_shm_id = -1;
static prefetch_data_t *prefetch_data = NULL;
static int prefetch_shm_id = -1;
/*
* We do this from the transformer since we need one anyway for coverage, this
@ -72,14 +74,33 @@ void prefetch_read(void) {
}
void prefetch_config(void) {
prefetch_enable = (getenv("AFL_FRIDA_INST_NO_PREFETCH") == NULL);
}
static int prefetch_on_fork(void) {
prefetch_read();
return fork();
}
static void prefetch_hook_fork(void) {
void *fork_addr =
GSIZE_TO_POINTER(gum_module_find_export_by_name(NULL, "fork"));
intercept_hook(fork_addr, prefetch_on_fork, NULL);
}
void prefetch_init(void) {
g_assert_cmpint(sizeof(prefetch_data_t), ==, PREFETCH_SIZE);
gboolean prefetch = (getenv("AFL_FRIDA_INST_NO_PREFETCH") == NULL);
OKF("Instrumentation - prefetch [%c]", prefetch_enable ? 'X' : ' ');
OKF("Instrumentation - prefetch [%c]", prefetch ? 'X' : ' ');
if (!prefetch) { return; }
if (!prefetch_enable) { return; }
/*
* Make our shared memory, we can attach before we fork, just like AFL does
* with the coverage bitmap region and fork will take care of ensuring both
@ -108,5 +129,7 @@ void prefetch_init(void) {
/* Clear it, not sure it's necessary, just seems like good practice */
memset(prefetch_data, '\0', sizeof(prefetch_data_t));
prefetch_hook_fork();
}