diff options
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | utils.h | 4 | ||||
-rw-r--r-- | whois.c | 21 |
3 files changed, 38 insertions, 0 deletions
@@ -97,6 +97,19 @@ servers_charset.h: servers_charset_list make_servers_charset.pl $(PERL) make_servers_charset.pl < $< > $@ ############################################################################## +afl: + $(MAKE) whois \ + CC=afl-gcc AFL_HARDEN=1 \ + HAVE_LIBIDN=1 HAVE_ICONV=1 DEFS=-DAFL_MODE=1 + +afl2: + $(MAKE) whois \ + HAVE_LIBIDN=1 HAVE_ICONV=1 DEFS=-DAFL_MODE=1 + +afl-run: + nice afl-fuzz -i ../afl_in -o ../afl_out -- ./whois + +############################################################################## install: install-whois install-mkpasswd install-pos install-whois: whois @@ -9,6 +9,10 @@ #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__) +#ifndef AFL_MODE +# define AFL_MODE 0 +#endif + /* Portability macros */ #ifdef __GNUC__ # define NORETURN __attribute__((noreturn)) @@ -140,6 +140,20 @@ int main(int argc, char *argv[]) fstring = malloc(fstringlen + 1); *fstring = '\0'; + /* interface for American Fuzzy Lop */ + if (AFL_MODE) { + FILE *fp = fdopen(0, "r"); + char *buf = NULL; + size_t len = 0; + + /* read one line from stdin */ + if (getline(&buf, &len, fp) < 0) + err_sys("getline"); + fflush(fp); + /* and use it as command line arguments */ + argv = merge_args(buf, argv, &argc); + } + /* prepend options from environment */ argv = merge_args(getenv("WHOIS_OPTIONS"), argv, &argc); @@ -907,6 +921,13 @@ int openconn(const char *server, const char *port) struct sockaddr_in saddr; #endif + /* + * When using American Fuzzy Lop get the data from it using stdin + * instead of connecting to the actual whois server. + */ + if (AFL_MODE) + return (dup(0)); + alarm(60); #ifdef HAVE_GETADDRINFO |