diff options
author | van Hauser <vh@thc.org> | 2020-06-09 19:25:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 19:25:09 +0200 |
commit | 12bdefe00e38cdc3dd8cb028eeac325ab2e94e16 (patch) | |
tree | 0d321d362a19ff19a4a98dcd1b9b72601945695f /examples/qemu_persistent_hook | |
parent | 748238d6ab4aeb7f34958d4c37c5ef200ad22463 (diff) | |
parent | 81829d132bebcb42c0e289bb5788b8f2b29c1599 (diff) | |
download | afl++-12bdefe00e38cdc3dd8cb028eeac325ab2e94e16.tar.gz |
Merge pull request #392 from AFLplusplus/dev
Push to master
Diffstat (limited to 'examples/qemu_persistent_hook')
-rw-r--r-- | examples/qemu_persistent_hook/read_into_rdi.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/examples/qemu_persistent_hook/read_into_rdi.c b/examples/qemu_persistent_hook/read_into_rdi.c index 6cf66ddf..bd6d3f45 100644 --- a/examples/qemu_persistent_hook/read_into_rdi.c +++ b/examples/qemu_persistent_hook/read_into_rdi.c @@ -1,6 +1,7 @@ #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) @@ -35,16 +36,26 @@ enum { }; -void afl_persistent_hook(uint64_t *regs, uint64_t guest_base) { +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("reading into %p\n", regs[R_EDI]); - size_t r = read(0, g2h(regs[R_EDI]), 1024); - regs[R_ESI] = r; - printf("read %ld bytes\n", r); + 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; } |