aboutsummaryrefslogtreecommitdiff
path: root/unicorn_mode
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2021-10-12 23:46:47 +0200
committerDominik Maier <domenukk@gmail.com>2021-10-12 23:48:01 +0200
commite0c052cad70b5cf2c86e1bda1d279a2ac1440077 (patch)
tree591ec153d13329bf3ec8976ccf7446ded8209525 /unicorn_mode
parentea05d4ed134f69fc8df12c27c4fa633aea45484b (diff)
downloadAFLplusplus-e0c052cad70b5cf2c86e1bda1d279a2ac1440077.tar.gz
unicornafl bindings improved
Diffstat (limited to 'unicorn_mode')
-rw-r--r--unicorn_mode/UNICORNAFL_VERSION2
-rw-r--r--unicorn_mode/samples/speedtest/rust/src/main.rs23
m---------unicorn_mode/unicornafl0
3 files changed, 11 insertions, 14 deletions
diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION
index cbca63e5..e76da957 100644
--- a/unicorn_mode/UNICORNAFL_VERSION
+++ b/unicorn_mode/UNICORNAFL_VERSION
@@ -1 +1 @@
-f1c853648a74b0157d233a2ef9f1693cfee78c11
+d06e3d5113dd96799a765a6514f7f5c45f071ca3
diff --git a/unicorn_mode/samples/speedtest/rust/src/main.rs b/unicorn_mode/samples/speedtest/rust/src/main.rs
index 77356a67..89e10833 100644
--- a/unicorn_mode/samples/speedtest/rust/src/main.rs
+++ b/unicorn_mode/samples/speedtest/rust/src/main.rs
@@ -12,11 +12,11 @@ use std::{
use unicornafl::{
unicorn_const::{uc_error, Arch, Mode, Permission},
- RegisterX86::{self, *},
- Unicorn, UnicornHandle,
+ RegisterX86::*,
+ Unicorn,
};
-const BINARY: &str = &"../target";
+const BINARY: &str = "../target";
// Memory map for the code to be tested
// Arbitrary address where code to test will be loaded
@@ -47,7 +47,7 @@ fn read_file(filename: &str) -> Result<Vec<u8>, io::Error> {
fn parse_locs(loc_name: &str) -> Result<Vec<u64>, io::Error> {
let contents = &read_file(&format!("../target.offsets.{}", loc_name))?;
//println!("Read: {:?}", contents);
- Ok(str_from_u8_unchecked(&contents)
+ Ok(str_from_u8_unchecked(contents)
.split('\n')
.map(|x| {
//println!("Trying to convert {}", &x[2..]);
@@ -87,8 +87,7 @@ fn main() {
}
fn fuzz(input_file: &str) -> Result<(), uc_error> {
- let mut unicorn = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?;
- let mut uc: UnicornHandle<'_, _> = unicorn.borrow();
+ let mut uc = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?;
let binary =
read_file(BINARY).unwrap_or_else(|_| panic!("Could not read modem image: {}", BINARY));
@@ -133,7 +132,7 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> {
let already_allocated_malloc = already_allocated.clone();
// We use a very simple malloc/free stub here,
// that only works for exactly one allocation at a time.
- let hook_malloc = move |mut uc: UnicornHandle<'_, _>, addr: u64, size: u32| {
+ let hook_malloc = move |uc: &mut Unicorn<'_, _>, addr: u64, size: u32| {
if already_allocated_malloc.get() {
println!("Double malloc, not supported right now!");
abort();
@@ -154,7 +153,7 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> {
let already_allocated_free = already_allocated;
// No real free, just set the "used"-flag to false.
- let hook_free = move |mut uc: UnicornHandle<'_, _>, addr, size| {
+ let hook_free = move |uc: &mut Unicorn<'_, _>, addr, size| {
if already_allocated_free.get() {
println!("Double free detected. Real bug?");
abort();
@@ -177,7 +176,7 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> {
*/
// This is a fancy print function that we're just going to skip for fuzzing.
- let hook_magicfn = move |mut uc: UnicornHandle<'_, _>, addr, size| {
+ let hook_magicfn = move |uc: &mut Unicorn<'_, _>, addr, size| {
uc.reg_write(RIP, addr + size as u64).unwrap();
};
@@ -195,7 +194,7 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> {
}
let place_input_callback =
- |uc: &mut UnicornHandle<'_, _>, afl_input: &mut [u8], _persistent_round| {
+ |uc: &mut Unicorn<'_, _>, afl_input: &mut [u8], _persistent_round| {
// apply constraints to the mutated input
if afl_input.len() > INPUT_MAX as usize {
//println!("Skipping testcase with leng {}", afl_input.len());
@@ -209,9 +208,7 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> {
// return true if the last run should be counted as crash
let crash_validation_callback =
- |_uc: &mut UnicornHandle<'_, _>, result, _input: &[u8], _persistent_round| {
- result != uc_error::OK
- };
+ |_uc: &mut Unicorn<'_, _>, result, _input: &[u8], _persistent_round| result != uc_error::OK;
let end_addrs = parse_locs("main_ends").unwrap();
diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl
-Subproject c0e03d2c6b55a22025324f121746b41b1e756fb
+Subproject d06e3d5113dd96799a765a6514f7f5c45f071ca