diff options
| author | Mason Reed <mason@vector35.com> | 2024-11-04 01:48:03 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2024-11-04 01:48:03 -0500 |
| commit | 7743af0603a2568ad28a1b152153eabce8c52dd7 (patch) | |
| tree | 082d2e33e321fa453c4b6230e679e89d87c19ef6 /plugins/warp/src/plugin | |
| parent | 393c7fb508b465b0cb096d46eaaefc08030e9fed (diff) | |
WARP: Misc formatting and remove useless apply command
Diffstat (limited to 'plugins/warp/src/plugin')
| -rw-r--r-- | plugins/warp/src/plugin/apply.rs | 82 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/find.rs | 2 |
2 files changed, 1 insertions, 83 deletions
diff --git a/plugins/warp/src/plugin/apply.rs b/plugins/warp/src/plugin/apply.rs deleted file mode 100644 index 78cb3be8..00000000 --- a/plugins/warp/src/plugin/apply.rs +++ /dev/null @@ -1,82 +0,0 @@ -use std::collections::HashMap; -use std::time::Instant; - -use crate::cache::cached_function_guid; -use crate::plugin::on_matched_function; -use binaryninja::binaryview::{BinaryView, BinaryViewExt}; -use binaryninja::command::Command; -use rayon::prelude::*; -use warp::signature::function::{Function, FunctionGUID}; - -pub struct ApplySignatureFile; - -// TODO: All this should do is insert data into the Matcher. this is leftover code. -impl Command for ApplySignatureFile { - fn action(&self, view: &BinaryView) { - // TODO: Start bulk modification - // TODO: view.begin_bulk_modify_symbols(); - let Some(file) = - binaryninja::interaction::get_open_filename_input("Apply Signature File", "*.sbin") - else { - return; - }; - - // TODO: signature files also need to store type information. - - let Ok(data) = std::fs::read(&file) else { - log::error!("Could not read signature file: {:?}", file); - return; - }; - - let Some(data) = warp::signature::Data::from_bytes(&data) else { - log::error!("Could not get data from signature file: {:?}", file); - return; - }; - - // TODO: Turn Vec<Function> to HashSet so that functions with the same symbol and type get eliminated. - let data_functions: HashMap<FunctionGUID, Vec<Function>> = - data.functions - .into_iter() - .fold(HashMap::new(), |mut acc, func| { - #[allow(clippy::unwrap_or_default)] - acc.entry(func.guid).or_insert_with(Vec::new).push(func); - acc - }); - - let background_task = binaryninja::backgroundtask::BackgroundTask::new( - format!("Applying signatures from {:?}", file), - true, - ) - .unwrap(); - - let funcs = view.functions(); - let start = Instant::now(); - - background_task - .set_progress_text(format!("Building {} patterns to lookup...", funcs.len())); - - // TODO: Redo this. - let single_matched = funcs - .par_iter() - .filter_map(|func| { - let llil = func.low_level_il_if_available()?; - let pattern = cached_function_guid(&func, &llil); - Some((func, data_functions.get(&pattern)?)) - }) - .filter(|(_, sig)| sig.len() == 1) - .collect::<Vec<_>>(); - - background_task.set_progress_text(format!("Applying {} matches...", single_matched.len())); - for (func, matched) in single_matched { - on_matched_function(&func, &matched[0]); - } - - log::info!("Signature application took {:?}", start.elapsed()); - - background_task.finish(); - } - - fn valid(&self, _view: &BinaryView) -> bool { - true - } -} diff --git a/plugins/warp/src/plugin/find.rs b/plugins/warp/src/plugin/find.rs index 3a14f7fb..7eb0ab38 100644 --- a/plugins/warp/src/plugin/find.rs +++ b/plugins/warp/src/plugin/find.rs @@ -47,7 +47,7 @@ impl Command for FindFunctionFromGUID { } else { for (func, _) in matched { log::info!("Match found at function... 0x{:0x}", func.start()); - } + } } background_task.finish(); |
