aboutsummaryrefslogtreecommitdiff
path: root/frida_mode/test/persistent_ret
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-07-19 10:48:41 +0200
committervanhauser-thc <vh@thc.org>2021-07-19 10:48:41 +0200
commitcc57cc5f463e9b79980c2087d19b4a1e1360ec52 (patch)
tree69a89651deefc660b481e9c964f4cb97ab9073b6 /frida_mode/test/persistent_ret
parent3d1cc8ec57f0bf07d7834b652ec2db24e7914624 (diff)
parentc55f7af65700e3d11c368072d39ba6670efa477b (diff)
downloadafl++-cc57cc5f463e9b79980c2087d19b4a1e1360ec52.tar.gz
fix merge conflicts
Diffstat (limited to 'frida_mode/test/persistent_ret')
-rw-r--r--frida_mode/test/persistent_ret/test.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/frida_mode/test/persistent_ret/test.js b/frida_mode/test/persistent_ret/test.js
new file mode 100644
index 00000000..8adb45b2
--- /dev/null
+++ b/frida_mode/test/persistent_ret/test.js
@@ -0,0 +1,48 @@
+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}`);
+});
+
+if (name === 'testinstr') {
+ const persistent_addr = DebugSymbol.fromName('LLVMFuzzerTestOneInput').address;
+ Afl.print(`persistent_addr: ${persistent_addr}`);
+ Afl.setEntryPoint(persistent_addr);
+ Afl.setPersistentAddress(persistent_addr);
+ Afl.setInstrumentDebugFile("/dev/stdout");
+ Afl.setPersistentDebug();
+ Afl.setInstrumentNoOptimize();
+ Afl.setInstrumentEnableTracing();
+
+ const LLVMFuzzerTestOneInput = new NativeFunction(
+ persistent_addr,
+ 'void',
+ ['pointer', 'uint64'],
+ {traps: "all"});
+
+ const persistentHook = new NativeCallback(
+ (data, size) => {
+ const input = Afl.aflFuzzPtr.readPointer();
+ const len = Afl.aflFuzzLen.readPointer().readU32();
+ const hd = hexdump(input, {length: len, header: false, ansi: true});
+ Afl.print(`input: ${hd}`);
+ LLVMFuzzerTestOneInput(input, len);
+ },
+ 'void',
+ ['pointer', 'uint64']);
+
+ Afl.aflSharedMemFuzzing.writeInt(1);
+ Interceptor.replace(persistent_addr, persistentHook);
+ Interceptor.flush();
+}
+
+Afl.print("done");
+Afl.done();