aboutsummaryrefslogtreecommitdiff
path: root/frida_mode/src/persistent
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2022-01-11 12:20:35 +0100
committerGitHub <noreply@github.com>2022-01-11 12:20:35 +0100
commit10dae419d6e3ebc38f53840c5abfe98e9c901217 (patch)
tree352576e19c8a504c40ea58dbb141056762901a69 /frida_mode/src/persistent
parent74a8f145e09d0361d8f576eb3f2e8881b6116f18 (diff)
parentd2715336a54635bb6e617a2e739c0ad5fe51d28d (diff)
downloadafl++-10dae419d6e3ebc38f53840c5abfe98e9c901217.tar.gz
Merge pull request #1236 from AFLplusplus/dev
push to stable
Diffstat (limited to 'frida_mode/src/persistent')
-rw-r--r--frida_mode/src/persistent/persistent.c15
-rw-r--r--frida_mode/src/persistent/persistent_arm64.c17
-rw-r--r--frida_mode/src/persistent/persistent_x64.c10
-rw-r--r--frida_mode/src/persistent/persistent_x86.c10
4 files changed, 36 insertions, 16 deletions
diff --git a/frida_mode/src/persistent/persistent.c b/frida_mode/src/persistent/persistent.c
index 817d9925..7fd7d351 100644
--- a/frida_mode/src/persistent/persistent.c
+++ b/frida_mode/src/persistent/persistent.c
@@ -72,13 +72,16 @@ void persistent_config(void) {
void persistent_init(void) {
- FOKF("Instrumentation - persistent mode [%c] (0x%016" G_GINT64_MODIFIER "X)",
+ FOKF(cBLU "Instrumentation" cRST " - " cGRN "persistent mode:" cYEL
+ " [%c] (0x%016" G_GINT64_MODIFIER "X)",
persistent_start == 0 ? ' ' : 'X', persistent_start);
- FOKF("Instrumentation - persistent count [%c] (%" G_GINT64_MODIFIER "d)",
+ FOKF(cBLU "Instrumentation" cRST " - " cGRN "persistent count:" cYEL
+ " [%c] (%" G_GINT64_MODIFIER "d)",
persistent_start == 0 ? ' ' : 'X', persistent_count);
- FOKF("Instrumentation - hook [%s]", hook_name);
+ FOKF(cBLU "Instrumentation" cRST " - " cGRN "hook:" cYEL " [%s]", hook_name);
- FOKF("Instrumentation - persistent ret [%c] (0x%016" G_GINT64_MODIFIER "X)",
+ FOKF(cBLU "Instrumentation" cRST " - " cGRN "persistent ret:" cYEL
+ " [%c] (0x%016" G_GINT64_MODIFIER "X)",
persistent_ret == 0 ? ' ' : 'X', persistent_ret);
if (persistent_hook != NULL) { __afl_sharedmem_fuzzing = 1; }
@@ -87,7 +90,7 @@ void persistent_init(void) {
void persistent_prologue(GumStalkerOutput *output) {
- FOKF("AFL_FRIDA_PERSISTENT_ADDR reached");
+ FVERBOSE("AFL_FRIDA_PERSISTENT_ADDR reached");
entry_compiled = TRUE;
ranges_exclude();
stalker_trust();
@@ -97,7 +100,7 @@ void persistent_prologue(GumStalkerOutput *output) {
void persistent_epilogue(GumStalkerOutput *output) {
- FOKF("AFL_FRIDA_PERSISTENT_RET reached");
+ FVERBOSE("AFL_FRIDA_PERSISTENT_RET reached");
persistent_epilogue_arch(output);
}
diff --git a/frida_mode/src/persistent/persistent_arm64.c b/frida_mode/src/persistent/persistent_arm64.c
index c9159ca1..16ecf39c 100644
--- a/frida_mode/src/persistent/persistent_arm64.c
+++ b/frida_mode/src/persistent/persistent_arm64.c
@@ -89,7 +89,7 @@ static void instrument_persitent_save_regs(GumArm64Writer * cw,
/* LR (x30) */
gum_arm64_writer_put_str_reg_reg_offset(cw, ARM64_REG_X30, ARM64_REG_X0,
- offsetof(GumCpuContext, x[30]));
+ offsetof(GumCpuContext, lr));
/* PC & Adjusted SP (31) */
gum_arm64_writer_put_ldr_reg_address(cw, ARM64_REG_X2,
@@ -189,7 +189,7 @@ static void instrument_persitent_restore_regs(GumArm64Writer * cw,
/* LR (x30) */
gum_arm64_writer_put_ldr_reg_reg_offset(cw, ARM64_REG_X30, ARM64_REG_X0,
- offsetof(GumCpuContext, x[30]));
+ offsetof(GumCpuContext, lr));
/* Adjusted SP (31) (use x1 as clobber)*/
gum_arm64_writer_put_ldr_reg_reg_offset(cw, ARM64_REG_X1, ARM64_REG_X0,
@@ -236,7 +236,13 @@ static void instrument_exit(GumArm64Writer *cw) {
static int instrument_afl_persistent_loop_func(void) {
int ret = __afl_persistent_loop(persistent_count);
- instrument_previous_pc = instrument_hash_zero;
+ if (instrument_previous_pc_addr == NULL) {
+
+ FATAL("instrument_previous_pc_addr uninitialized");
+
+ }
+
+ *instrument_previous_pc_addr = instrument_hash_zero;
return ret;
}
@@ -264,8 +270,7 @@ static void persistent_prologue_hook(GumArm64Writer * cw,
gum_arm64_writer_put_ldr_reg_reg_offset(cw, ARM64_REG_X2, ARM64_REG_X2, 0);
gum_arm64_writer_put_ldr_reg_reg_offset(cw, ARM64_REG_X2, ARM64_REG_X2, 0);
- gum_arm64_writer_put_and_reg_reg_imm(cw, ARM64_REG_X2, ARM64_REG_X2,
- G_MAXULONG);
+ gum_arm64_writer_put_mov_reg_reg(cw, ARM64_REG_W2, ARM64_REG_W2);
gum_arm64_writer_put_ldr_reg_address(cw, ARM64_REG_X1,
GUM_ADDRESS(&__afl_fuzz_ptr));
@@ -324,7 +329,7 @@ void persistent_prologue_arch(GumStalkerOutput *output) {
gconstpointer loop = cw->code + 1;
- FOKF("Persistent loop reached");
+ FVERBOSE("Persistent loop reached");
instrument_persitent_save_regs(cw, &saved_regs);
diff --git a/frida_mode/src/persistent/persistent_x64.c b/frida_mode/src/persistent/persistent_x64.c
index 8cbde633..56141787 100644
--- a/frida_mode/src/persistent/persistent_x64.c
+++ b/frida_mode/src/persistent/persistent_x64.c
@@ -173,7 +173,13 @@ static void instrument_exit(GumX86Writer *cw) {
static int instrument_afl_persistent_loop_func(void) {
int ret = __afl_persistent_loop(persistent_count);
- instrument_previous_pc = instrument_hash_zero;
+ if (instrument_previous_pc_addr == NULL) {
+
+ FATAL("instrument_previous_pc_addr uninitialized");
+
+ }
+
+ *instrument_previous_pc_addr = instrument_hash_zero;
return ret;
}
@@ -269,7 +275,7 @@ void persistent_prologue_arch(GumStalkerOutput *output) {
gconstpointer loop = cw->code + 1;
- FOKF("Persistent loop reached");
+ FVERBOSE("Persistent loop reached");
/* Pop the return value */
gum_x86_writer_put_lea_reg_reg_offset(cw, GUM_REG_RSP, GUM_REG_RSP, 8);
diff --git a/frida_mode/src/persistent/persistent_x86.c b/frida_mode/src/persistent/persistent_x86.c
index 5425b01b..76c25334 100644
--- a/frida_mode/src/persistent/persistent_x86.c
+++ b/frida_mode/src/persistent/persistent_x86.c
@@ -130,7 +130,13 @@ static void instrument_exit(GumX86Writer *cw) {
static int instrument_afl_persistent_loop_func(void) {
int ret = __afl_persistent_loop(persistent_count);
- instrument_previous_pc = instrument_hash_zero;
+ if (instrument_previous_pc_addr == NULL) {
+
+ FATAL("instrument_previous_pc_addr uninitialized");
+
+ }
+
+ *instrument_previous_pc_addr = instrument_hash_zero;
return ret;
}
@@ -210,7 +216,7 @@ void persistent_prologue_arch(GumStalkerOutput *output) {
gconstpointer loop = cw->code + 1;
- FOKF("Persistent loop reached");
+ FVERBOSE("Persistent loop reached");
/* Pop the return value */
gum_x86_writer_put_lea_reg_reg_offset(cw, GUM_REG_ESP, GUM_REG_ESP, 4);