Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support report directory functionality for Grimoire #13

Closed
wants to merge 1 commit into from
Closed
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
34 changes: 33 additions & 1 deletion grimoire/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ pub fn libafl_main() {
.long("output")
.help("The directory to place finds in ('corpus')"),
)
.arg(
Arg::new("report")
.short('r')
.long("report")
.help("The directory to place dumped testcases ('corpus')"),
)
.arg(
Arg::new("tokens")
.short('x')
Expand Down Expand Up @@ -139,6 +145,19 @@ pub fn libafl_main() {
crashes.push("crashes");
out_dir.push("queue");

let report_dir = PathBuf::from(
res.get_one::<String>("report")
.expect("The --report parameter is missing")
.to_string(),
);
if fs::create_dir(&report_dir).is_err() {
println!("Report dir at {:?} already exists.", &report_dir);
if !report_dir.is_dir() {
println!("Report dir at {:?} is not a valid directory!", &report_dir);
return;
}
}

let in_dir = PathBuf::from(
res.get_one::<String>("in")
.expect("The --input parameter is missing")
Expand All @@ -159,7 +178,7 @@ pub fn libafl_main() {
.expect("Could not parse timeout in milliseconds"),
);

fuzz(in_dir, out_dir, crashes, tokens, timeout).expect("An error occurred while fuzzing");
fuzz(in_dir, out_dir, crashes, report_dir, tokens, timeout).expect("An error occurred while fuzzing");
}

fn run_testcases(filenames: &[&str]) {
Expand Down Expand Up @@ -196,6 +215,7 @@ fn fuzz(
in_dir: PathBuf,
corpus_dir: PathBuf,
objective_dir: PathBuf,
report_dir: PathBuf,
tokenfile: Option<PathBuf>,
timeout: Duration,
) -> Result<(), Error> {
Expand Down Expand Up @@ -381,7 +401,19 @@ fn fuzz(
3,
);

let fuzzbench = libafl::stages::DumpToDiskStage::new(
|input: &BytesInput, state: &StdState<_, _, _, _>| {
let target_bytes = input.target_bytes();
let bytes = target_bytes.as_slice().to_vec();
bytes
},
&report_dir.join("queue"),
&report_dir.join("crashes"),
)
.unwrap();

let mut stages = tuple_list!(
fuzzbench,
generalization,
tracing,
i2s,
Expand Down