mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-17 04:18:06 +00:00
optimin: add missing cmin options and auto create output dir
* Includes frida, unicorn modes * Automatically create the output directory if it does not already exist
This commit is contained in:
@ -32,7 +32,9 @@ Color Options:
|
|||||||
General options:
|
General options:
|
||||||
|
|
||||||
-C - Keep crashing inputs, reject everything else
|
-C - Keep crashing inputs, reject everything else
|
||||||
-Q - Use binary-only instrumentation
|
-O - Use binary-only instrumentation (FRIDA mode)
|
||||||
|
-Q - Use binary-only instrumentation (QEMU mode)
|
||||||
|
-U - Use unicorn-based instrumentation (unicorn mode)
|
||||||
-f - Include edge hit counts
|
-f - Include edge hit counts
|
||||||
-i dir - Input directory
|
-i dir - Input directory
|
||||||
-m megs - Memory limit for child process (default=none)
|
-m megs - Memory limit for child process (default=none)
|
||||||
|
@ -120,25 +120,34 @@ static cl::opt<std::string> CorpusDir("i", cl::desc("Input directory"),
|
|||||||
cl::value_desc("dir"), cl::Required);
|
cl::value_desc("dir"), cl::Required);
|
||||||
static cl::opt<std::string> OutputDir("o", cl::desc("Output directory"),
|
static cl::opt<std::string> OutputDir("o", cl::desc("Output directory"),
|
||||||
cl::value_desc("dir"), cl::Required);
|
cl::value_desc("dir"), cl::Required);
|
||||||
|
|
||||||
|
static cl::opt<bool> ShowProgBar("p", cl::desc("Display progress bar"));
|
||||||
static cl::opt<bool> EdgesOnly("f", cl::desc("Include edge hit counts"),
|
static cl::opt<bool> EdgesOnly("f", cl::desc("Include edge hit counts"),
|
||||||
cl::init(true));
|
cl::init(true));
|
||||||
static cl::opt<bool> ShowProgBar("p", cl::desc("Display progress bar"));
|
|
||||||
static cl::opt<std::string> WeightsFile("w", cl::desc("Weights file"),
|
static cl::opt<std::string> WeightsFile("w", cl::desc("Weights file"),
|
||||||
cl::value_desc("csv"));
|
cl::value_desc("csv"));
|
||||||
|
|
||||||
static cl::opt<std::string> TargetProg(cl::Positional,
|
static cl::opt<std::string> TargetProg(cl::Positional,
|
||||||
cl::desc("<target program>"),
|
cl::desc("<target program>"),
|
||||||
cl::Required);
|
cl::Required);
|
||||||
static cl::list<std::string> TargetArgs(cl::ConsumeAfter,
|
static cl::list<std::string> TargetArgs(cl::ConsumeAfter,
|
||||||
cl::desc("[target args...]"));
|
cl::desc("[target args...]"));
|
||||||
|
|
||||||
static cl::opt<std::string> MemLimit(
|
static cl::opt<std::string> MemLimit(
|
||||||
"m", cl::desc("Memory limit for child process (default=none)"),
|
"m", cl::desc("Memory limit for child process (default=none)"),
|
||||||
cl::value_desc("megs"), cl::init("none"));
|
cl::value_desc("megs"), cl::init("none"));
|
||||||
static cl::opt<std::string> Timeout(
|
static cl::opt<std::string> Timeout(
|
||||||
"t", cl::desc("Run time limit for child process (default=5000)"),
|
"t", cl::desc("Run time limit for child process (default=5000)"),
|
||||||
cl::value_desc("msec"), cl::init("4000"));
|
cl::value_desc("msec"), cl::init("4000"));
|
||||||
|
|
||||||
static cl::opt<bool> CrashMode(
|
static cl::opt<bool> CrashMode(
|
||||||
"C", cl::desc("Keep crashing inputs, reject everything else"));
|
"C", cl::desc("Keep crashing inputs, reject everything else"));
|
||||||
static cl::opt<bool> QemuMode("Q", cl::desc("Use binary-only instrumentation"));
|
static cl::opt<bool> FridaMode(
|
||||||
|
"O", cl::desc("Use binary-only instrumentation (FRIDA mode)"));
|
||||||
|
static cl::opt<bool> QemuMode(
|
||||||
|
"Q", cl::desc("Use binary-only instrumentation (QEMU mode)"));
|
||||||
|
static cl::opt<bool> UnicornMode(
|
||||||
|
"U", cl::desc("Use unicorn-based instrumentation (unicorn mode)"));
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
@ -184,7 +193,6 @@ static void GetWeights(const MemoryBuffer &MB, WeightsMap &Weights) {
|
|||||||
|
|
||||||
// Prepare afl-showmap arguments
|
// Prepare afl-showmap arguments
|
||||||
SmallVector<StringRef, 12> AFLShowmapArgs{
|
SmallVector<StringRef, 12> AFLShowmapArgs{
|
||||||
|
|
||||||
AFLShowmapPath, "-m", MemLimit, "-t", Timeout, "-q", "-o", OutputPath};
|
AFLShowmapPath, "-m", MemLimit, "-t", Timeout, "-q", "-o", OutputPath};
|
||||||
|
|
||||||
if (TargetArgsHasAtAt)
|
if (TargetArgsHasAtAt)
|
||||||
@ -192,8 +200,9 @@ static void GetWeights(const MemoryBuffer &MB, WeightsMap &Weights) {
|
|||||||
else
|
else
|
||||||
Redirects[/* stdin */ 0] = Seed;
|
Redirects[/* stdin */ 0] = Seed;
|
||||||
|
|
||||||
|
if (FridaMode) AFLShowmapArgs.push_back("-O");
|
||||||
if (QemuMode) AFLShowmapArgs.push_back("-Q");
|
if (QemuMode) AFLShowmapArgs.push_back("-Q");
|
||||||
if (CrashMode) AFLShowmapArgs.push_back("-C");
|
if (UnicornMode) AFLShowmapArgs.push_back("-U");
|
||||||
|
|
||||||
AFLShowmapArgs.append({"--", TargetProg});
|
AFLShowmapArgs.append({"--", TargetProg});
|
||||||
AFLShowmapArgs.append(TargetArgs.begin(), TargetArgs.end());
|
AFLShowmapArgs.append(TargetArgs.begin(), TargetArgs.end());
|
||||||
@ -269,9 +278,10 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
cl::ParseCommandLineOptions(argc, argv, "Optimal corpus minimizer");
|
cl::ParseCommandLineOptions(argc, argv, "Optimal corpus minimizer");
|
||||||
|
|
||||||
if (!sys::fs::is_directory(OutputDir)) {
|
if (EC = sys::fs::create_directory(OutputDir)) {
|
||||||
|
|
||||||
ErrMsg() << "Invalid output directory `" << OutputDir << "`\n";
|
ErrMsg() << "Invalid output directory `" << OutputDir
|
||||||
|
<< "`: " << EC.message() << '\n';
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user