Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libafl_frida/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ frida-gum = { version = "0.4.0", git = "https://github.com/s1341/frida-rust", fe
frida-gum-sys = { version = "0.2.4", git = "https://github.com/s1341/frida-rust", features = [ "auto-download", "event-sink", "invocation-listener"] }
#frida-gum = { version = "0.4.0", path = "../../frida-rust/frida-gum", features = [ "auto-download", "backtrace", "event-sink", "invocation-listener"] }
#frida-gum-sys = { version = "0.2.4", path = "../../frida-rust/frida-gum-sys", features = [ "auto-download", "event-sink", "invocation-listener"] }
core_affinity = { version = "0.5", git = "https://github.com/s1341/core_affinity_rs" }
regex = "1.4"
dynasmrt = "1.0.1"
capstone = "0.8.0"
Expand Down
21 changes: 19 additions & 2 deletions libafl_frida/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ It can report coverage and, on supported architecutres, even reports memory acce

/// The frida address sanitizer runtime
pub mod asan_rt;
/// The `LibAFL` firda helper
/// The `LibAFL` frida helper
pub mod helper;
// for parsing asan cores
use libafl::utils::parse_core_bind_arg;
// for getting current core_id
use core_affinity;

/// A representation of the various Frida options
#[derive(Clone, Debug)]
Expand All @@ -31,6 +35,7 @@ impl FridaOptions {
#[must_use]
pub fn parse_env_options() -> Self {
let mut options = Self::default();
let mut asan_cores = None;

if let Ok(env_options) = std::env::var("LIBAFL_FRIDA_OPTIONS") {
for option in env_options.trim().split(':') {
Expand All @@ -40,7 +45,6 @@ impl FridaOptions {
match name {
"asan" => {
options.enable_asan = value.parse().unwrap();

#[cfg(not(target_arch = "aarch64"))]
if options.enable_asan {
panic!("ASAN is not currently supported on targets other than aarch64");
Expand All @@ -55,6 +59,9 @@ impl FridaOptions {
"asan-allocation-backtraces" => {
options.enable_asan_allocation_backtraces = value.parse().unwrap();
}
"asan-cores" => {
asan_cores = parse_core_bind_arg(value);
}
"instrument-suppress-locations" => {
options.instrument_suppress_locations = Some(
value
Expand Down Expand Up @@ -92,6 +99,16 @@ impl FridaOptions {
panic!("unknown FRIDA option: '{}'", option);
}
}
} // end of for loop
if options.enable_asan && asan_cores.is_some() {
let core_ids = core_affinity::get_core_ids().unwrap();
assert_eq!(
core_ids.len(),
1,
"Client should only be enabled on one core"
);
let core_id = core_ids[0].id;
options.enable_asan = asan_cores.unwrap().contains(&core_id);
}
}

Expand Down