google / honggfuzz

Security oriented software fuzzer. Supports evolutionary, feedback-driven fuzzing based on code coverage (SW and HW based)
https://honggfuzz.dev
Apache License 2.0
3.04k stars 511 forks source link

honggfuzz does not support file as input? #474

Closed fr0zenrain closed 1 year ago

fr0zenrain commented 1 year ago

my host is WSL2,I found file input seems not work.thanks!

#include "stdio.h"

int main(int argc, char* argv[]){
        char buf[1024]={0};
        FILE* fp = fopen(argv[1],"rb");
        if(fp == 0) return -1
        fread(buf,1,1024,fp);
        fclose(fp);
        return 0;
}

honggfuzz -i seed -x -- ./test FILE [2022-10-19T16:20:38+0800][E][32377] cmdlineVerify():243 You must specify 'FILE' if the -s (stdin fuzzing) or --persistent options are not set

my target is complex, so i don't want change my target to stdin as input.

robertswiecki commented 1 year ago

Are you using ___FILE___, with three underscores (_)?

$ cat a.c 
#include "stdio.h"

int main(int argc, char* argv[]){
        char buf[1024]={0};
        FILE* fp = fopen(argv[1],"rb");
        if(fp == 0) return -1;
        fread(buf,1,1024,fp);
        fclose(fp);
        return 0;
}

$ honggfuzz -i corpus/ -x -- ./a ___FILE___
...
------------------------[  0 days 00 hrs 00 mins 01 secs ]----------------------
  Iterations : 1,738 [1.74k]
        Mode : Static
      Target : ./a ___FILE___
     Threads : 16, CPUs: 32, CPU%: 389% [12%/CPU]
       Speed : 3,960/sec [avg: 1,738]
     Crashes : 0 [unique: 0, blocklist: 0, verified: 0]
    Timeouts : 0 [1 sec]
 Corpus Size : 0, max: 8,192 bytes, init: 6 files
  Cov Update : 0 days 00 hrs 00 mins 01 secs ago
    Coverage : [none]
---------------------------------- [ LOGS ] ------------------/ honggfuzz 2.5 /-
Launched new fuzzing thread, no. #5
Launched new fuzzing thread, no. #14
Launched new fuzzing thread, no. #7
fr0zenrain commented 1 year ago

thanks! i miss two '_'.