mirror of
https://github.com/rfc1036/whois.git
synced 2026-05-03 06:51:09 +00:00
Support american fuzzy lop
When built with AFL_MODE set to true, whois will use the first line of standard input as command line parameters and the rest as network input.
This commit is contained in:
parent
e143980234
commit
718ae61ae5
13
Makefile
13
Makefile
@ -96,6 +96,19 @@ tld_serv.h: tld_serv_list make_tld_serv.pl
|
||||
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
|
||||
|
||||
|
||||
4
utils.h
4
utils.h
@ -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))
|
||||
|
||||
21
whois.c
21
whois.c
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user