diff options
author | WorksButNotTested <62701594+WorksButNotTested@users.noreply.github.com> | 2021-06-25 22:14:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 23:14:27 +0200 |
commit | 6a3877dcd35d31eb79bebbc30ffe70ac0342743e (patch) | |
tree | f3ddccc0e1315a728fe5b12fdf10990f48f05298 /frida_mode/test/js/replace.js | |
parent | c88b98d1c91b37c1941483980161bd46cb03c4d5 (diff) | |
download | afl++-6a3877dcd35d31eb79bebbc30ffe70ac0342743e.tar.gz |
Improved FRIDA mode scripting support (#994)
Co-authored-by: Your Name <you@example.com>
Diffstat (limited to 'frida_mode/test/js/replace.js')
-rw-r--r-- | frida_mode/test/js/replace.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/frida_mode/test/js/replace.js b/frida_mode/test/js/replace.js new file mode 100644 index 00000000..4e1e7eb7 --- /dev/null +++ b/frida_mode/test/js/replace.js @@ -0,0 +1,43 @@ +Afl.print('******************'); +Afl.print('* AFL FRIDA MODE *'); +Afl.print('******************'); +Afl.print(''); + +Afl.print(`PID: ${Process.id}`); + +const name = Process.enumerateModules()[0].name; +Afl.print(`Name: ${name}`); + +new ModuleMap().values().forEach(m => { + Afl.print(`${m.base}-${m.base.add(m.size)} ${m.name}`); +}); + +const slow = DebugSymbol.fromName('slow').address; +Afl.print(`slow: ${slow}`); + +const LLVMFuzzerTestOneInput = DebugSymbol.fromName('LLVMFuzzerTestOneInput').address; +Afl.print(`LLVMFuzzerTestOneInput: ${LLVMFuzzerTestOneInput}`); + +const cm = new CModule(` + + extern unsigned char * __afl_fuzz_ptr; + extern unsigned int * __afl_fuzz_len; + extern void LLVMFuzzerTestOneInput(char *buf, int len); + + void slow(void) { + + LLVMFuzzerTestOneInput(__afl_fuzz_ptr, *__afl_fuzz_len); + } + `, + { + LLVMFuzzerTestOneInput: LLVMFuzzerTestOneInput, + __afl_fuzz_ptr: Afl.getAflFuzzPtr(), + __afl_fuzz_len: Afl.getAflFuzzLen() + }); + +Afl.setEntryPoint(cm.slow); +Afl.setPersistentAddress(cm.slow); +Afl.setInMemoryFuzzing(); +Interceptor.replace(slow, cm.slow); +Afl.print("done"); +Afl.done(); |