Move to clap 3.0 (#447)

* move to clap 3.0

* fix cargo.toml

* update symcc to use clap3
This commit is contained in:
Dominik Maier 2022-01-04 23:53:12 +01:00 committed by GitHub
parent a1a6d5f478
commit 6d9763c51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 88 additions and 110 deletions

View File

@ -17,4 +17,4 @@ opt-level = 3
[dependencies] [dependencies]
libafl = { path = "../../libafl/" } libafl = { path = "../../libafl/" }
clap = { version = "3.0.0-rc.4", features = ["default"] } clap = { version = "3.0", features = ["default"] }

View File

@ -38,7 +38,7 @@ libc = "0.2"
libloading = "0.7" libloading = "0.7"
num-traits = "0.2.14" num-traits = "0.2.14"
rangemap = "0.1" rangemap = "0.1"
structopt = "0.3.25" clap = { version = "3.0", features = ["derive"] }
serde = "1.0" serde = "1.0"
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }

View File

@ -4,14 +4,13 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use frida_gum::Gum; use frida_gum::Gum;
use std::{ use std::{
env, env,
net::SocketAddr, net::SocketAddr,
path::{Path, PathBuf}, path::{Path, PathBuf},
time::Duration,
}; };
use structopt::StructOpt;
use libafl::{ use libafl::{
bolts::{ bolts::{
@ -56,7 +55,7 @@ use libafl_targets::cmplog::{CmpLogObserver, CMPLOG_MAP};
use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ERRORS}; use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ERRORS};
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt( #[clap(
name = "libafl_frida", name = "libafl_frida",
version = "0.1.0", version = "0.1.0",
about = "A frida-based binary-only libfuzzer-style fuzzer for with llmp-multithreading support", about = "A frida-based binary-only libfuzzer-style fuzzer for with llmp-multithreading support",
@ -64,7 +63,7 @@ use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ER
Dongjia Zhang <toka@aflplus.plus>, Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>" Dongjia Zhang <toka@aflplus.plus>, Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>"
)] )]
struct Opt { struct Opt {
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str = Cores::from_cmdline), parse(try_from_str = Cores::from_cmdline),
@ -73,8 +72,8 @@ struct Opt {
)] )]
cores: Cores, cores: Cores,
#[structopt( #[clap(
short = "p", short = 'p',
long, long,
help = "Choose the broker TCP port, default is 1337", help = "Choose the broker TCP port, default is 1337",
name = "PORT", name = "PORT",
@ -82,16 +81,16 @@ struct Opt {
)] )]
broker_port: u16, broker_port: u16,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short = "a", short = 'a',
long, long,
help = "Specify a remote broker", help = "Specify a remote broker",
name = "REMOTE" name = "REMOTE"
)] )]
remote_broker_addr: Option<SocketAddr>, remote_broker_addr: Option<SocketAddr>,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long, long,
@ -100,7 +99,7 @@ struct Opt {
)] )]
input: Vec<PathBuf>, input: Vec<PathBuf>,
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str), parse(try_from_str),
@ -110,7 +109,7 @@ struct Opt {
)] )]
output: PathBuf, output: PathBuf,
#[structopt( #[clap(
long, long,
help = "The configuration this fuzzer runs with, for multiprocessing", help = "The configuration this fuzzer runs with, for multiprocessing",
name = "CONF", name = "CONF",
@ -118,19 +117,19 @@ struct Opt {
)] )]
configuration: String, configuration: String,
#[structopt( #[clap(
long, long,
help = "The file to redirect stdout input to (/dev/null if unset)" help = "The file to redirect stdout input to (/dev/null if unset)"
)] )]
stdout_file: Option<String>, stdout_file: Option<String>,
#[structopt(help = "The harness")] #[clap(help = "The harness")]
harness: String, harness: String,
#[structopt(help = "The symbol name to look up and hook")] #[clap(help = "The symbol name to look up and hook")]
symbol: String, symbol: String,
#[structopt(help = "The modules to instrument, separated by colons")] #[clap(help = "The modules to instrument, separated by colons")]
modules_to_instrument: String, modules_to_instrument: String,
} }
@ -140,7 +139,7 @@ pub fn main() {
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();
let opt = Opt::from_args(); let opt = Opt::parse();
color_backtrace::install(); color_backtrace::install();
println!( println!(

View File

@ -24,7 +24,7 @@ libafl = { path = "../../libafl/" }
libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "sancov_cmplog", "libfuzzer"] } libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "sancov_cmplog", "libfuzzer"] }
# TODO Include it only when building cc # TODO Include it only when building cc
libafl_cc = { path = "../../libafl_cc/" } libafl_cc = { path = "../../libafl_cc/" }
clap = { version = "3.0.0-rc.4", features = ["default"] } clap = { version = "3.0", features = ["default"] }
nix = "0.23" nix = "0.23"
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }

View File

@ -14,5 +14,5 @@ debug = true
[dependencies] [dependencies]
libafl = { path = "../../libafl/" } libafl = { path = "../../libafl/" }
libafl_qemu = { path = "../../libafl_qemu/", features = ["x86_64"] } libafl_qemu = { path = "../../libafl_qemu/", features = ["x86_64"] }
clap = { version = "3.0.0-rc.4", features = ["default"] } clap = { version = "3.0", features = ["default"] }
nix = "0.23" nix = "0.23"

View File

@ -24,7 +24,7 @@ libafl = { path = "../../libafl/" }
libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "sancov_cmplog", "libfuzzer"] } libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "sancov_cmplog", "libfuzzer"] }
# TODO Include it only when building cc # TODO Include it only when building cc
libafl_cc = { path = "../../libafl_cc/" } libafl_cc = { path = "../../libafl_cc/" }
structopt = "0.3.25" clap = { version = "3.0", features = ["derive"] }
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }
[lib] [lib]

View File

@ -4,9 +4,9 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
use structopt::StructOpt;
use libafl::{ use libafl::{
bolts::{ bolts::{
@ -50,13 +50,13 @@ fn timeout_from_millis_str(time: &str) -> Result<Duration, Error> {
} }
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt( #[clap(
name = "generic_inmemory", name = "generic_inmemory",
about = "A generic libfuzzer-like fuzzer with llmp-multithreading support", about = "A generic libfuzzer-like fuzzer with llmp-multithreading support",
author = "Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>" author = "Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>"
)] )]
struct Opt { struct Opt {
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str = Cores::from_cmdline), parse(try_from_str = Cores::from_cmdline),
@ -65,24 +65,24 @@ struct Opt {
)] )]
cores: Cores, cores: Cores,
#[structopt( #[clap(
short = "p", short = 'p',
long, long,
help = "Choose the broker TCP port, default is 1337", help = "Choose the broker TCP port, default is 1337",
name = "PORT" name = "PORT"
)] )]
broker_port: u16, broker_port: u16,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short = "a", short = 'a',
long, long,
help = "Specify a remote broker", help = "Specify a remote broker",
name = "REMOTE" name = "REMOTE"
)] )]
remote_broker_addr: Option<SocketAddr>, remote_broker_addr: Option<SocketAddr>,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long, long,
@ -91,7 +91,7 @@ struct Opt {
)] )]
input: Vec<PathBuf>, input: Vec<PathBuf>,
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str), parse(try_from_str),
@ -101,7 +101,7 @@ struct Opt {
)] )]
output: PathBuf, output: PathBuf,
#[structopt( #[clap(
parse(try_from_str = timeout_from_millis_str), parse(try_from_str = timeout_from_millis_str),
short, short,
long, long,
@ -111,13 +111,13 @@ struct Opt {
)] )]
timeout: Duration, timeout: Duration,
#[structopt( #[clap(
parse(from_os_str), parse(from_os_str),
short = "x", short = 'x',
long, long,
help = "Feed the fuzzer with an user-specified list of tokens (often called \"dictionary\"", help = "Feed the fuzzer with an user-specified list of tokens (often called \"dictionary\"",
name = "TOKENS", name = "TOKENS",
multiple = true multiple_occurrences = true
)] )]
tokens: Vec<PathBuf>, tokens: Vec<PathBuf>,
} }
@ -131,7 +131,7 @@ pub fn libafl_main() {
let workdir = env::current_dir().unwrap(); let workdir = env::current_dir().unwrap();
let opt = Opt::from_args(); let opt = Opt::parse();
let cores = opt.cores; let cores = opt.cores;
let broker_port = opt.broker_port; let broker_port = opt.broker_port;

View File

@ -22,7 +22,7 @@ num_cpus = "1.0"
[dependencies] [dependencies]
libafl = { path = "../../libafl/" } libafl = { path = "../../libafl/" }
libafl_targets = { path = "../../libafl_targets/", features = ["pointer_maps", "sancov_cmplog", "libfuzzer"] } libafl_targets = { path = "../../libafl_targets/", features = ["pointer_maps", "sancov_cmplog", "libfuzzer"] }
clap = { version = "3.0.0-beta.4", features = ["default", "yaml"] } clap = { version = "3.0", features = ["default"] }
[lib] [lib]
name = "afl_atheris" name = "afl_atheris"

View File

@ -24,7 +24,7 @@ libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compressio
libafl_targets = { path = "../../libafl_targets/", features = ["libfuzzer"] } libafl_targets = { path = "../../libafl_targets/", features = ["libfuzzer"] }
# TODO Include it only when building cc # TODO Include it only when building cc
libafl_cc = { path = "../../libafl_cc/" } libafl_cc = { path = "../../libafl_cc/" }
structopt = "0.3.25" clap = { version = "3.0", features = ["derive"] }
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }
[lib] [lib]

View File

@ -6,9 +6,9 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
use structopt::StructOpt;
use libafl::{ use libafl::{
bolts::{ bolts::{
@ -47,13 +47,13 @@ fn timeout_from_millis_str(time: &str) -> Result<Duration, Error> {
} }
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt( #[clap(
name = "libfuzzer_libpng_ctx", name = "libfuzzer_libpng_ctx",
about = "A clone of libfuzzer using LibAFL for a libpng harness", about = "A clone of libfuzzer using LibAFL for a libpng harness",
author = "Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>" author = "Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>"
)] )]
struct Opt { struct Opt {
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str = Cores::from_cmdline), parse(try_from_str = Cores::from_cmdline),
@ -62,8 +62,8 @@ struct Opt {
)] )]
cores: Cores, cores: Cores,
#[structopt( #[clap(
short = "p", short = 'p',
long, long,
help = "Choose the broker TCP port, default is 1337", help = "Choose the broker TCP port, default is 1337",
name = "PORT", name = "PORT",
@ -71,16 +71,16 @@ struct Opt {
)] )]
broker_port: u16, broker_port: u16,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short = "a", short = 'a',
long, long,
help = "Specify a remote broker", help = "Specify a remote broker",
name = "REMOTE" name = "REMOTE"
)] )]
remote_broker_addr: Option<SocketAddr>, remote_broker_addr: Option<SocketAddr>,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long, long,
@ -89,7 +89,7 @@ struct Opt {
)] )]
input: Vec<PathBuf>, input: Vec<PathBuf>,
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str), parse(try_from_str),
@ -99,7 +99,7 @@ struct Opt {
)] )]
output: PathBuf, output: PathBuf,
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str = timeout_from_millis_str), parse(try_from_str = timeout_from_millis_str),
@ -110,7 +110,7 @@ struct Opt {
timeout: Duration, timeout: Duration,
/* /*
// The tokens are hardcoded in this example. // The tokens are hardcoded in this example.
#[structopt( #[clap(
parse(from_os_str), parse(from_os_str),
short = "x", short = "x",
long, long,
@ -127,7 +127,7 @@ pub fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();
let opt = Opt::from_args(); let opt = Opt::parse();
let broker_port = opt.broker_port; let broker_port = opt.broker_port;

View File

@ -24,7 +24,7 @@ libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compressio
libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "libfuzzer"] } libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "libfuzzer"] }
# TODO Include it only when building cc # TODO Include it only when building cc
libafl_cc = { path = "../../libafl_cc/" } libafl_cc = { path = "../../libafl_cc/" }
structopt = "0.3.25" clap = { version = "3.0", features = ["derive"] }
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }
[lib] [lib]

View File

@ -6,9 +6,9 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use core::time::Duration; use core::time::Duration;
use std::{env, net::SocketAddr, path::PathBuf}; use std::{env, net::SocketAddr, path::PathBuf};
use structopt::StructOpt;
use libafl::{ use libafl::{
bolts::{ bolts::{
@ -47,13 +47,13 @@ fn timeout_from_millis_str(time: &str) -> Result<Duration, Error> {
/// The commandline args this fuzzer accepts /// The commandline args this fuzzer accepts
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt( #[clap(
name = "libfuzzer_libpng_launcher", name = "libfuzzer_libpng_launcher",
about = "A libfuzzer-like fuzzer for libpng with llmp-multithreading support and a launcher", about = "A libfuzzer-like fuzzer for libpng with llmp-multithreading support and a launcher",
author = "Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>" author = "Andrea Fioraldi <andreafioraldi@gmail.com>, Dominik Maier <domenukk@gmail.com>"
)] )]
struct Opt { struct Opt {
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str = Cores::from_cmdline), parse(try_from_str = Cores::from_cmdline),
@ -62,8 +62,8 @@ struct Opt {
)] )]
cores: Cores, cores: Cores,
#[structopt( #[clap(
short = "p", short = 'p',
long, long,
help = "Choose the broker TCP port, default is 1337", help = "Choose the broker TCP port, default is 1337",
name = "PORT", name = "PORT",
@ -71,16 +71,16 @@ struct Opt {
)] )]
broker_port: u16, broker_port: u16,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short = "a", short = 'a',
long, long,
help = "Specify a remote broker", help = "Specify a remote broker",
name = "REMOTE" name = "REMOTE"
)] )]
remote_broker_addr: Option<SocketAddr>, remote_broker_addr: Option<SocketAddr>,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long, long,
@ -89,7 +89,7 @@ struct Opt {
)] )]
input: Vec<PathBuf>, input: Vec<PathBuf>,
#[structopt( #[clap(
short, short,
long, long,
parse(try_from_str), parse(try_from_str),
@ -99,7 +99,7 @@ struct Opt {
)] )]
output: PathBuf, output: PathBuf,
#[structopt( #[clap(
parse(try_from_str = timeout_from_millis_str), parse(try_from_str = timeout_from_millis_str),
short, short,
long, long,
@ -110,7 +110,7 @@ struct Opt {
timeout: Duration, timeout: Duration,
/* /*
/// This fuzzer has hard-coded tokens /// This fuzzer has hard-coded tokens
#[structopt( #[clap(
parse(from_os_str), parse(from_os_str),
short = "x", short = "x",
long, long,
@ -128,7 +128,7 @@ pub fn libafl_main() {
// Registry the metadata types used in this fuzzer // Registry the metadata types used in this fuzzer
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();
let opt = Opt::from_args(); let opt = Opt::parse();
let broker_port = opt.broker_port; let broker_port = opt.broker_port;
let cores = opt.cores; let cores = opt.cores;

View File

@ -18,7 +18,7 @@ debug = true
[dependencies] [dependencies]
libafl = { path = "../../../libafl/", features = ["concolic_mutation"] } libafl = { path = "../../../libafl/", features = ["concolic_mutation"] }
libafl_targets = { path = "../../../libafl_targets/", features = ["sancov_pcguard_edges", "sancov_cmplog", "libfuzzer"] } libafl_targets = { path = "../../../libafl_targets/", features = ["sancov_pcguard_edges", "sancov_cmplog", "libfuzzer"] }
structopt = "0.3.21" clap = { version = "3.0", features = ["derive"]}
mimalloc = { version = "*", default-features = false } mimalloc = { version = "*", default-features = false }
[build-dependencies] [build-dependencies]

View File

@ -4,6 +4,7 @@ use mimalloc::MiMalloc;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
use clap::{self, StructOpt};
use std::{env, path::PathBuf}; use std::{env, path::PathBuf};
use libafl::{ use libafl::{
@ -25,6 +26,7 @@ use libafl::{
feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback}, feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback},
fuzzer::{Fuzzer, StdFuzzer}, fuzzer::{Fuzzer, StdFuzzer},
inputs::{BytesInput, HasTargetBytes, Input}, inputs::{BytesInput, HasTargetBytes, Input},
monitors::MultiMonitor,
mutators::{ mutators::{
scheduled::{havoc_mutations, StdScheduledMutator}, scheduled::{havoc_mutations, StdScheduledMutator},
token_mutations::I2SRandReplace, token_mutations::I2SRandReplace,
@ -41,7 +43,6 @@ use libafl::{
StdMutationalStage, TracingStage, StdMutationalStage, TracingStage,
}, },
state::{HasCorpus, StdState}, state::{HasCorpus, StdState},
monitors::MultiMonitor,
Error, Error,
}; };
@ -50,12 +51,10 @@ use libafl_targets::{
MAX_EDGES_NUM, MAX_EDGES_NUM,
}; };
use structopt::StructOpt;
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
struct Opt { struct Opt {
/// This node should do concolic tracing + solving instead of traditional fuzzing /// This node should do concolic tracing + solving instead of traditional fuzzing
#[structopt(short, long)] #[clap(short, long)]
concolic: bool, concolic: bool,
} }
@ -64,7 +63,7 @@ pub fn main() {
// Needed only on no_std // Needed only on no_std
//RegistryBuilder::register::<Tokens>(); //RegistryBuilder::register::<Tokens>();
let opt = Opt::from_args(); let opt = Opt::parse();
println!( println!(
"Workdir: {:?}", "Workdir: {:?}",

View File

@ -237,6 +237,9 @@ impl From<TryFromIntError> for Error {
} }
} }
#[cfg(feature = "std")]
impl std::error::Error for Error {}
// TODO: no_std test // TODO: no_std test
#[cfg(feature = "std")] #[cfg(feature = "std")]
#[cfg(test)] #[cfg(test)]

@ -1 +1 @@
Subproject commit 45cde0269ae22aef4cca2e1fb98c3b24f7bb2984 Subproject commit 3133c0b37d3c498db9addf2331378c7c9cadbf10

View File

@ -8,4 +8,4 @@ authors = ["Julius Hohnerlein <julihoh@users.noreply.github.com>"]
[dependencies] [dependencies]
libafl = {path = "../../../libafl"} libafl = {path = "../../../libafl"}
structopt = "0.3.21" clap = { version = "3.0", features = ["derive"] }

View File

@ -2,6 +2,7 @@
//! It achieves this by running an instrumented target program with the necessary environment variables set. //! It achieves this by running an instrumented target program with the necessary environment variables set.
//! When the program has finished executing, it dumps the traced constraints to a file. //! When the program has finished executing, it dumps the traced constraints to a file.
use clap::{self, StructOpt};
use std::{ use std::{
ffi::OsString, ffi::OsString,
fs::File, fs::File,
@ -11,8 +12,6 @@ use std::{
string::ToString, string::ToString,
}; };
use structopt::StructOpt;
use libafl::{ use libafl::{
bolts::shmem::{ShMem, ShMemProvider, StdShMemProvider}, bolts::shmem::{ShMem, ShMemProvider, StdShMemProvider},
observers::concolic::{ observers::concolic::{
@ -22,44 +21,44 @@ use libafl::{
}; };
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt( #[clap(
name = "dump_constraints", name = "dump_constraints",
about = "Dump tool for concolic constraints." about = "Dump tool for concolic constraints."
)] )]
struct Opt { struct Opt {
/// Outputs plain text instead of binary /// Outputs plain text instead of binary
#[structopt(short, long)] #[clap(short, long)]
plain_text: bool, plain_text: bool,
/// Outputs coverage information to the given file /// Outputs coverage information to the given file
#[structopt(short, long)] #[clap(short, long)]
coverage_file: Option<PathBuf>, coverage_file: Option<PathBuf>,
/// Symbolizes only the given input file offsets. /// Symbolizes only the given input file offsets.
#[structopt(short, long)] #[clap(short, long)]
symbolize_offsets: Option<Vec<usize>>, symbolize_offsets: Option<Vec<usize>>,
/// Concretize all floating point operations. /// Concretize all floating point operations.
#[structopt(long)] #[clap(long)]
no_float: bool, no_float: bool,
/// Prune expressions from high-frequency code locations. /// Prune expressions from high-frequency code locations.
#[structopt(long)] #[clap(long)]
prune: bool, prune: bool,
/// Trace file path, "trace" by default. /// Trace file path, "trace" by default.
#[structopt(parse(from_os_str), short, long)] #[clap(parse(from_os_str), short, long)]
output: Option<PathBuf>, output: Option<PathBuf>,
/// Target program and arguments /// Target program and arguments
#[structopt(last = true)] #[clap(last = true)]
program: Vec<OsString>, program: Vec<OsString>,
} }
fn main() { fn main() {
const COVERAGE_MAP_SIZE: usize = 65536; const COVERAGE_MAP_SIZE: usize = 65536;
let opt = Opt::from_args(); let opt = Opt::parse();
let mut shmemprovider = StdShMemProvider::default(); let mut shmemprovider = StdShMemProvider::default();
let concolic_shmem = shmemprovider let concolic_shmem = shmemprovider

View File

@ -11,4 +11,4 @@ regex = "1"
postcard = "0.7" postcard = "0.7"
lazy_static = "1.4.0" lazy_static = "1.4.0"
libafl = { path = "../../../libafl" } libafl = { path = "../../../libafl" }
structopt = "0.3.25" clap = { version = "3.0", features = ["derive"] }

View File

@ -1,22 +0,0 @@
name: construct_automata
version: "0.1.0"
author: "Andrea Fioraldi <andreafioraldi@gmail.com>"
about: Generate a serialized Automaton using a json GNF grammar
args:
- grammar:
short: g
long: grammar-file
value_name: GRAMMAR
required: true
takes_value: true
- output:
short: o
long: output
value_name: OUTPUT
required: true
takes_value: true
- limit:
short: l
long: limit
value_name: LIMIT
takes_value: true

View File

@ -1,3 +1,4 @@
use clap::{self, StructOpt};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use serde_json::Value; use serde_json::Value;
@ -9,18 +10,17 @@ use std::{
path::PathBuf, path::PathBuf,
rc::Rc, rc::Rc,
}; };
use structopt::StructOpt;
use libafl::generators::gramatron::{Automaton, Trigger}; use libafl::generators::gramatron::{Automaton, Trigger};
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
#[structopt( #[clap(
name = "construct_automata", name = "construct_automata",
about = "Generate a serialized Automaton using a json GNF grammar", about = "Generate a serialized Automaton using a json GNF grammar",
author = "Andrea Fioraldi <andreafioraldi@gmail.com>" author = "Andrea Fioraldi <andreafioraldi@gmail.com>"
)] )]
struct Opt { struct Opt {
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long = "grammar-file", long = "grammar-file",
@ -29,7 +29,7 @@ struct Opt {
)] )]
grammar: PathBuf, grammar: PathBuf,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long, long,
@ -39,7 +39,7 @@ struct Opt {
)] )]
limit: usize, limit: usize,
#[structopt( #[clap(
parse(try_from_str), parse(try_from_str),
short, short,
long, long,
@ -305,7 +305,7 @@ fn postprocess(pda: &[Transition], stack_limit: usize) -> Automaton {
} }
fn main() { fn main() {
let opt = Opt::from_args(); let opt = Opt::parse();
let grammar_file = opt.grammar; let grammar_file = opt.grammar;
let output_file = opt.output; let output_file = opt.output;