about summary refs log tree commit diff
path: root/examples/qemu_persistent_hook
diff options
context:
space:
mode:
authorrichinseattle@gmail.com <richinseattle@gmail.com>2021-03-18 01:37:40 -0700
committerrichinseattle@gmail.com <richinseattle@gmail.com>2021-03-18 01:37:40 -0700
commitc397becd81229d71b55acf89a31710bead3707aa (patch)
tree8306b59e88e22d7090fd786690227dacc99e24e3 /examples/qemu_persistent_hook
parent62508c3b446a893f0afead9a6d0546d53d588a13 (diff)
parent94312796f936ba1830b61432a0f958e192dd212f (diff)
downloadafl++-c397becd81229d71b55acf89a31710bead3707aa.tar.gz
Merge branch 'dev' of https://github.com/AFLplusplus/AFLplusplus into dev
Diffstat (limited to 'examples/qemu_persistent_hook')
-rw-r--r--examples/qemu_persistent_hook/README.md20
-rw-r--r--examples/qemu_persistent_hook/read_into_rdi.c61
-rw-r--r--examples/qemu_persistent_hook/test.c35
3 files changed, 0 insertions, 116 deletions
diff --git a/examples/qemu_persistent_hook/README.md b/examples/qemu_persistent_hook/README.md
deleted file mode 100644
index 3278b60c..00000000
--- a/examples/qemu_persistent_hook/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# QEMU persistent hook example
-
-Compile the test binary and the library:
-
-```
-gcc -no-pie test.c -o test
-gcc -fPIC -shared read_into_rdi.c -o read_into_rdi.so
-```
-
-Fuzz with:
-
-```
-export AFL_QEMU_PERSISTENT_ADDR=0x$(nm test | grep "T target_func" | awk '{print $1}')
-export AFL_QEMU_PERSISTENT_HOOK=./read_into_rdi.so
-
-mkdir in
-echo 0000 > in/in
-
-../../afl-fuzz -Q -i in -o out -- ./test
-```
diff --git a/examples/qemu_persistent_hook/read_into_rdi.c b/examples/qemu_persistent_hook/read_into_rdi.c
deleted file mode 100644
index bd6d3f45..00000000
--- a/examples/qemu_persistent_hook/read_into_rdi.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <stdint.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-#define g2h(x) ((void *)((unsigned long)(x) + guest_base))
-#define h2g(x) ((uint64_t)(x)-guest_base)
-
-enum {
-
-  R_EAX = 0,
-  R_ECX = 1,
-  R_EDX = 2,
-  R_EBX = 3,
-  R_ESP = 4,
-  R_EBP = 5,
-  R_ESI = 6,
-  R_EDI = 7,
-  R_R8 = 8,
-  R_R9 = 9,
-  R_R10 = 10,
-  R_R11 = 11,
-  R_R12 = 12,
-  R_R13 = 13,
-  R_R14 = 14,
-  R_R15 = 15,
-
-  R_AL = 0,
-  R_CL = 1,
-  R_DL = 2,
-  R_BL = 3,
-  R_AH = 4,
-  R_CH = 5,
-  R_DH = 6,
-  R_BH = 7,
-
-};
-
-void afl_persistent_hook(uint64_t *regs, uint64_t guest_base,
-                         uint8_t *input_buf, uint32_t input_len) {
-
-  // In this example the register RDI is pointing to the memory location
-  // of the target buffer, and the length of the input is in RSI.
-  // This can be seen with a debugger, e.g. gdb (and "disass main")
-
-  printf("placing input into %p\n", regs[R_EDI]);
-
-  if (input_len > 1024) input_len = 1024;
-  memcpy(g2h(regs[R_EDI]), input_buf, input_len);
-  regs[R_ESI] = input_len;
-
-}
-
-int afl_persistent_hook_init(void) {
-
-  // 1 for shared memory input (faster), 0 for normal input (you have to use
-  // read(), input_buf will be NULL)
-  return 1;
-
-}
-
diff --git a/examples/qemu_persistent_hook/test.c b/examples/qemu_persistent_hook/test.c
deleted file mode 100644
index afeff202..00000000
--- a/examples/qemu_persistent_hook/test.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdio.h>
-
-int target_func(unsigned char *buf, int size) {
-
-  printf("buffer:%p, size:%p\n", buf, size);
-  switch (buf[0]) {
-
-    case 1:
-      if (buf[1] == '\x44') { puts("a"); }
-      break;
-    case 0xff:
-      if (buf[2] == '\xff') {
-
-        if (buf[1] == '\x44') { puts("b"); }
-
-      }
-
-      break;
-    default:
-      break;
-
-  }
-
-  return 1;
-
-}
-
-char data[1024];
-
-int main() {
-
-  target_func(data, 1024);
-
-}
-