about summary refs log tree commit diff
path: root/frida_mode/test/js/fuzz.js
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-11-18 17:08:39 +0000
committerYour Name <you@example.com>2021-11-18 17:08:39 +0000
commit3b9545854fdfb5be111a9891675882c187801fb0 (patch)
tree61ea30b59b7b025a0e27dda061a091940897866d /frida_mode/test/js/fuzz.js
parente131d0fc55ddc34e2a59c13b3bb24f4bc559301b (diff)
downloadafl++-3b9545854fdfb5be111a9891675882c187801fb0.tar.gz
Added test of JS hooking LLVMFuzzerTestOneInput
Diffstat (limited to 'frida_mode/test/js/fuzz.js')
-rw-r--r--frida_mode/test/js/fuzz.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/frida_mode/test/js/fuzz.js b/frida_mode/test/js/fuzz.js
new file mode 100644
index 00000000..24eca2b6
--- /dev/null
+++ b/frida_mode/test/js/fuzz.js
@@ -0,0 +1,41 @@
+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 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 My_LLVMFuzzerTestOneInput(char *buf, int len) {
+
+      LLVMFuzzerTestOneInput(__afl_fuzz_ptr, *__afl_fuzz_len);
+
+    }
+    `,
+    {
+        LLVMFuzzerTestOneInput: LLVMFuzzerTestOneInput,
+        __afl_fuzz_ptr: Afl.getAflFuzzPtr(),
+        __afl_fuzz_len: Afl.getAflFuzzLen()
+    });
+
+Afl.setEntryPoint(cm.My_LLVMFuzzerTestOneInput);
+Afl.setPersistentAddress(cm.My_LLVMFuzzerTestOneInput);
+Afl.setInMemoryFuzzing();
+Interceptor.replace(LLVMFuzzerTestOneInput, cm.My_LLVMFuzzerTestOneInput);
+Afl.print("done");
+Afl.done();