shared mem input for qemu persistent hook

This commit is contained in:
Andrea Fioraldi
2020-06-03 09:57:44 +02:00
parent 304a72c1ff
commit 9962de1a4c
5 changed files with 96 additions and 19 deletions

View File

@ -35,16 +35,25 @@ 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;
}