From d77d9d5f31f1b60de1bbd502afa1cb8b6e5915f7 Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Wed, 21 Dec 2022 19:23:57 +0900 Subject: [PATCH] Frida: Make stalker.exclude() configurable from command line arguments (#956) * remove exclude on windows * linux x86_64 * option --- libafl/src/bolts/cli.rs | 7 +++++++ libafl_frida/src/executor.rs | 15 +++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libafl/src/bolts/cli.rs b/libafl/src/bolts/cli.rs index e475874d80..87be0fa296 100644 --- a/libafl/src/bolts/cli.rs +++ b/libafl/src/bolts/cli.rs @@ -236,6 +236,13 @@ pub struct FuzzerOptions { #[arg(long, help_heading = "Frida Options")] pub drcov: bool, + /// disable stalker.exclude() if true + /// It's better to disable this on windows or your harness uses c++ exception handling + /// See https://github.com/AFLplusplus/LibAFL/issues/830 + #[cfg(feature = "frida_cli")] + #[arg(long, help_heading = "Frida Options")] + pub disable_excludes: bool, + /// locations which will not be instrumented for ASAN or coverage purposes (ex: mod_name@0x12345) #[cfg(feature = "frida_cli")] #[arg(short = 'D', long, help_heading = "Frida Options", value_parser = parse_instrumentation_location)] diff --git a/libafl_frida/src/executor.rs b/libafl_frida/src/executor.rs index 0c95398efd..79f1f906d5 100644 --- a/libafl_frida/src/executor.rs +++ b/libafl_frida/src/executor.rs @@ -172,12 +172,15 @@ where break; } } - for range in ranges.gaps(&(0..usize::MAX)) { - println!("excluding range: {:x}-{:x}", range.start, range.end); - stalker.exclude(&MemoryRange::new( - NativePointer(range.start as *mut c_void), - range.end - range.start, - )); + + if !helper.options().disable_excludes { + for range in ranges.gaps(&(0..usize::MAX)) { + println!("excluding range: {:x}-{:x}", range.start, range.end); + stalker.exclude(&MemoryRange::new( + NativePointer(range.start as *mut c_void), + range.end - range.start, + )); + } } #[cfg(windows)]