persistent hook example

This commit is contained in:
Andrea Fioraldi
2020-11-02 14:15:44 +01:00
parent 54ed02ef47
commit a260d34b49
6 changed files with 29 additions and 15 deletions

View File

@ -0,0 +1,6 @@
all:
$(CC) -no-pie test.c -o test
$(CC) -fPIC -shared read_into_rdi.c -o read_into_rdi.so
clean:
rm -rf in out test read_into_rdi.so

View File

@ -3,8 +3,7 @@
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
make
```
Fuzz with:

View File

@ -15,11 +15,11 @@ void afl_persistent_hook(struct x86_64_regs *regs,
// 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->rdi);
printf("Placing input into 0x%lx\n", regs->rdi);
if (input_len > 1024) input_len = 1024;
memcpy(g2h(regs->rdi), input_buf, input_len);
regs->rsi = input_len;
if (input_buf_len > 1024) input_buf_len = 1024;
memcpy(g2h(regs->rdi), input_buf, input_buf_len);
regs->rsi = input_buf_len;
#undef g2h
#undef h2g