Skip to content

Commit 3b580bc

Browse files
committed
updated afl++
1 parent 92f2288 commit 3b580bc

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

examples/emm/src/main.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::fs::File;
66
use std::io;
77
use std::io::Read;
88

9+
use unicornafl::unicorn_const::Mode;
910
use unicornafl::unicorn_const::{uc_error, Arch, Permission};
1011
use unicornafl::utils::*;
1112
use unicornafl::RegisterARM;
@@ -57,7 +58,7 @@ fn main() {
5758

5859
let aligned_size = align(modem_len);
5960

60-
let mut unicorn = init_emu_with_heap(Arch::ARM, 1048576 * 20, 0x90000000, false)
61+
let mut unicorn = init_emu_with_heap(Arch::ARM, Mode::THUMB, 1048576 * 20, 0x90000000, false)
6162
.expect("failed to create emulator instance");
6263
let mut emu = unicorn.borrow();
6364

@@ -553,7 +554,7 @@ fn main() {
553554
hook!(0x001e6a30, init);
554555
hook!(0x00489dfc, mcd_unpack);
555556

556-
let place_input_callback = |mut uc: Unicorn, afl_input: &mut [u8], _: i32| {
557+
let place_input_callback = |mut uc: &mut Unicorn, afl_input: &mut [u8], _: i32| {
557558
uc.mem_write(0x0A000000, &(afl_input.len() as u32).to_le_bytes())
558559
.expect("failed to write input_size");
559560
uc.mem_write(0x0A000000 + 8, &afl_input)
@@ -562,11 +563,9 @@ fn main() {
562563
};
563564

564565
let crash_validation_callback =
565-
|_uc: Unicorn, result: uc_error, _input: &[u8], _: i32| result != uc_error::OK;
566+
|_uc: &mut Unicorn, result: uc_error, _input: &[u8], _: i32| result != uc_error::OK;
566567

567-
// fuzz decoder for ATTACH ACCEPT messages
568-
emu.emu_start(0x001e6a31, 0x001e6c82, 0, 1)
569-
.expect("failed to kick off"); // start at offset 1 to run in thumb mode
568+
set_pc(&mut emu, 0x001e6a31).unwrap();
570569
let ret = emu.afl_fuzz(
571570
input_file,
572571
place_input_callback,

examples/errc/src/main.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::fs::File;
77
use std::io;
88
use std::io::Read;
99

10+
use unicornafl::unicorn_const::Mode;
1011
use unicornafl::{
1112
unicorn_const::{Arch, Permission},
1213
utils::*,
@@ -64,7 +65,7 @@ fn main() {
6465

6566
let aligned_size = align(modem_len);
6667

67-
let mut unicorn = init_emu_with_heap(Arch::ARM, 1048576 * 20, 0x90000000, false)
68+
let mut unicorn = init_emu_with_heap(Arch::ARM, Mode::THUMB, 1048576 * 20, 0x90000000, false)
6869
.expect("failed to create emulator instance");
6970
let mut emu = unicorn.borrow();
7071

@@ -641,7 +642,7 @@ fn main() {
641642
println!("heap: {:#010x?}", emu.get_data());
642643
}
643644

644-
let place_input_callback = |mut uc: Unicorn, afl_input: &mut [u8], _: i32| {
645+
let place_input_callback = |uc: &mut Unicorn, afl_input: &mut [u8], _: i32| {
645646
if afl_input.len() > 4096 {
646647
false
647648
} else {
@@ -654,13 +655,13 @@ fn main() {
654655
};
655656

656657
let crash_validation_callback =
657-
move |_uc: Unicorn, result: unicornafl::unicorn_const::uc_error, _input: &[u8], _: i32| {
658-
result != unicornafl::unicorn_const::uc_error::OK
659-
};
658+
move |_uc: &mut Unicorn,
659+
result: unicornafl::unicorn_const::uc_error,
660+
_input: &[u8],
661+
_: i32| { result != unicornafl::unicorn_const::uc_error::OK };
660662

661663
// fuzz ASN.1 decoders in ERRC handler
662-
emu.emu_start(0x1fe741, 0x001ff106, 0, 1)
663-
.expect("failed to kick off emulation"); // start at offset 1 to run in thumb mode
664+
set_pc(&mut emu, 0x1fe741).unwrap();
664665
let ret = emu.afl_fuzz(
665666
input_file,
666667
place_input_callback,

0 commit comments

Comments
 (0)