Changeset 3635 for zzuf/trunk/src
- Timestamp:
- Aug 6, 2009, 11:17:00 PM (12 years ago)
- Location:
- zzuf/trunk/src
- Files:
-
- 1 added
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/Makefile.am
r2534 r3635 14 14 15 15 pkglib_LTLIBRARIES = libzzuf.la 16 libzzuf_la_SOURCES = libzzuf.c libzzuf.h $(COMMON) debug.c debug.h sys.c sys.h \ 16 libzzuf_la_SOURCES = libzzuf.c libzzuf.h $(COMMON) debug.c debug.h \ 17 sys.c sys.h network.c network.h \ 17 18 lib-fd.c lib-mem.c lib-signal.c lib-stream.c lib-load.h 18 19 libzzuf_la_CFLAGS = -DLIBZZUF -
zzuf/trunk/src/fd.c
r2584 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2006-200 7 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 36 36 #include "fd.h" 37 37 #include "fuzz.h" 38 #include "network.h" 38 39 #include "ranges.h" 39 40 … … 43 44 static int has_include = 0, has_exclude = 0; 44 45 #endif 45 46 /* Network port cherry picking */47 static int *ports = NULL;48 static int static_ports[512];49 46 50 47 /* File descriptor cherry picking */ … … 100 97 } 101 98 102 void _zz_ports(char const *portlist)103 {104 ports = _zz_allocrange(portlist, static_ports);105 }106 107 99 void _zz_list(char const *fdlist) 108 100 { … … 200 192 if(list != static_list) 201 193 free(list); 202 if(ports != static_ports)203 free(ports);204 194 } 205 195 … … 225 215 226 216 return 1; 227 }228 229 int _zz_portwatched(int port)230 {231 if(!ports)232 return 1;233 234 return _zz_isinrange(port, ports);235 217 } 236 218 -
zzuf/trunk/src/fd.h
r2584 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 27 27 28 28 extern int _zz_mustwatch(char const *); 29 extern int _zz_portwatched(int);30 29 extern int _zz_iswatched(int); 31 30 extern void _zz_register(int); -
zzuf/trunk/src/fuzz.h
r1858 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 20 20 extern void _zz_bytes(char const *); 21 21 extern void _zz_list(char const *); 22 extern void _zz_ports(char const *);23 22 extern void _zz_protect(char const *); 24 23 extern void _zz_refuse(char const *); -
zzuf/trunk/src/lib-fd.c
r3634 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2006 , 2007 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> 4 4 * 2007 Rémi Denis-Courmont <rdenis#simphalempin:com> 5 5 * 2007 Clément Stenac <zorglub#diwi:org> 6 6 * 2007 Dominik Kuhlen <dominik.kuhlen#gmit-gmbh:de> 7 * 2009 Corentin Delorme <codelorme@gmail.com> 7 8 * All Rights Reserved 8 9 * … … 352 353 LOADSYM(recv); 353 354 ret = ORIG(recv)(s, buf, len, flags); 354 if(!_zz_ready || !_zz_iswatched(s) || _zz_islocked(s) || !_zz_isactive(s)) 355 if(!_zz_ready || !_zz_iswatched(s) || !_zz_hostwatched(s) 356 || _zz_islocked(s) || !_zz_isactive(s)) 355 357 return ret; 356 358 … … 385 387 LOADSYM(recvfrom); 386 388 ret = ORIG(recvfrom)(s, buf, len, flags, from, fromlen); 387 if(!_zz_ready || !_zz_iswatched(s) || _zz_islocked(s) || !_zz_isactive(s)) 389 if(!_zz_ready || !_zz_iswatched(s) || !_zz_hostwatched(s) 390 || _zz_islocked(s) || !_zz_isactive(s)) 388 391 return ret; 389 392 … … 425 428 LOADSYM(recvmsg); 426 429 ret = ORIG(recvmsg)(s, hdr, flags); 427 if(!_zz_ready || !_zz_iswatched(s) || _zz_islocked(s) || !_zz_isactive(s)) 430 if(!_zz_ready || !_zz_iswatched(s) || !_zz_hostwatched(s) 431 || _zz_islocked(s) || !_zz_isactive(s)) 428 432 return ret; 429 433 … … 445 449 LOADSYM(read); 446 450 ret = ORIG(read)(fd, buf, count); 447 if(!_zz_ready || !_zz_iswatched(fd) || _zz_islocked(fd)448 || !_zz_isactive(fd))451 if(!_zz_ready || !_zz_iswatched(fd) || !_zz_hostwatched(fd) 452 || _zz_islocked(fd) || !_zz_isactive(fd)) 449 453 return ret; 450 454 -
zzuf/trunk/src/libzzuf.c
r2527 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 45 45 #include "debug.h" 46 46 #include "fd.h" 47 #include "network.h" 47 48 #include "sys.h" 48 49 #include "fuzz.h" … … 141 142 _zz_ports(tmp); 142 143 144 tmp = getenv("ZZUF_ALLOW"); 145 if(tmp && *tmp) 146 _zz_allow(tmp); 147 148 tmp = getenv("ZZUF_DENY"); 149 if(tmp && *tmp) 150 _zz_deny(tmp); 151 143 152 tmp = getenv("ZZUF_PROTECT"); 144 153 if(tmp && *tmp) … … 170 179 171 180 _zz_fd_init(); 181 _zz_network_init(); 172 182 _zz_sys_init(); 173 183 … … 189 199 { 190 200 _zz_fd_fini(); 201 _zz_network_fini(); 191 202 } 192 203 -
zzuf/trunk/src/network.h
r3634 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> 3 * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> 4 * 2009 Corentin Delorme <codelorme@gmail.com> 4 5 * All Rights Reserved 5 6 * … … 14 15 15 16 /* 16 * fuzz.h: fuzzfunctions17 * network.h: network connection helper functions 17 18 */ 18 19 19 extern void _zz_fuzzing(char const *);20 extern void _zz_bytes(char const *);21 extern void _zz_list(char const *);22 20 extern void _zz_ports(char const *); 23 extern void _zz_protect(char const *); 24 extern void _zz_refuse(char const *); 21 extern void _zz_allow(char const *); 22 extern void _zz_deny(char const *); 23 extern void _zz_network_init(void); 24 extern void _zz_network_fini(void); 25 25 26 extern void _zz_fuzz(int, volatile uint8_t *, int64_t); 26 extern int _zz_portwatched(int); 27 extern int _zz_hostwatched(int); 27 28 -
zzuf/trunk/src/opts.c
r2521 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2002, 2007 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2002, 2007-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 35 35 { 36 36 opts->fuzzing = opts->bytes = opts->list = opts->ports = NULL; 37 opts->allow = opts->deny = NULL; 37 38 opts->protect = opts->refuse = NULL; 38 39 opts->seed = DEFAULT_SEED; -
zzuf/trunk/src/opts.h
r1858 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2002, 2007 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2002, 2007-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 21 21 char **oldargv; 22 22 char **newargv; 23 char *fuzzing, *bytes, *list, *ports, *protect, *refuse ;23 char *fuzzing, *bytes, *list, *ports, *protect, *refuse, *allow, *deny; 24 24 uint32_t seed; 25 25 uint32_t endseed; -
zzuf/trunk/src/zzuf.c
r3631 r3635 1 1 /* 2 2 * zzuf - general purpose fuzzer 3 * Copyright (c) 2002, 2007 Sam Hocevar <sam@zoy.org>3 * Copyright (c) 2002, 2007-2009 Sam Hocevar <sam@hocevar.net> 4 4 * All Rights Reserved 5 5 * … … 176 176 #endif 177 177 #define OPTSTR "+" OPTSTR_REGEX OPTSTR_RLIMIT_MEM OPTSTR_RLIMIT_CPU \ 178 " Ab:B:C:dD:f:F:ij:l:mnp:P:qr:R:s:St:vxhV"178 "a:Ab:B:C:dD:e:f:F:ij:l:mnp:P:qr:R:s:St:vxhV" 179 179 #define MOREINFO "Try `%s --help' for more information.\n" 180 180 int option_index = 0; … … 182 182 { 183 183 /* Long option, needs arg, flag, short option */ 184 { "allow", 1, NULL, 'a' }, 184 185 { "autoinc", 0, NULL, 'A' }, 185 186 { "bytes", 1, NULL, 'b' }, … … 191 192 { "debug", 0, NULL, 'd' }, 192 193 { "delay", 1, NULL, 'D' }, 194 { "deny", 1, NULL, 'e' }, 193 195 #if defined HAVE_REGEX_H 194 196 { "exclude", 1, NULL, 'E' }, … … 226 228 switch(c) 227 229 { 230 case 'a': /* --allow */ 231 opts->allow = myoptarg; 232 break; 228 233 case 'A': /* --autoinc */ 229 234 setenv("ZZUF_AUTOINC", "1", 1); … … 256 261 myoptarg++; 257 262 opts->delay = (int64_t)(atof(myoptarg) * 1000000.0); 263 break; 264 case 'e': /* --deny */ 265 opts->deny = myoptarg; 258 266 break; 259 267 #if defined HAVE_REGEX_H … … 387 395 } 388 396 397 if (opts->allow && !network) 398 { 399 fprintf(stderr, "%s: allow option (-a) requires network fuzzing (-n)\n", 400 argv[0]); 401 printf(MOREINFO, argv[0]); 402 _zz_opts_fini(opts); 403 return EXIT_FAILURE; 404 } 405 406 if (opts->deny && !network) 407 { 408 fprintf(stderr, "%s: deny option (-e) requires network fuzzing (-n)\n", 409 argv[0]); 410 printf(MOREINFO, argv[0]); 411 _zz_opts_fini(opts); 412 return EXIT_FAILURE; 413 } 414 389 415 _zz_setratio(opts->minratio, opts->maxratio); 390 416 _zz_setseed(opts->seed); … … 445 471 if(opts->ports) 446 472 setenv("ZZUF_PORTS", opts->ports, 1); 473 if(opts->allow) 474 setenv("ZZUF_ALLOW", opts->allow, 1); 475 if(opts->deny) 476 setenv("ZZUF_DENY", opts->deny, 1); 447 477 if(opts->protect) 448 478 setenv("ZZUF_PROTECT", opts->protect, 1); … … 500 530 if(opts->list) 501 531 _zz_list(opts->list); 502 if(opts->ports)503 _zz_ports(opts->ports);504 532 if(opts->protect) 505 533 _zz_protect(opts->protect); … … 1183 1211 { 1184 1212 printf("zzuf %s\n", PACKAGE_VERSION); 1185 printf("Copyright (C) 2002, 2007-200 8 Sam Hocevar <sam@zoy.org>\n");1213 printf("Copyright (C) 2002, 2007-2009 Sam Hocevar <sam@hocevar.net>\n"); 1186 1214 printf("This program is free software. It comes without any warranty, to the extent\n"); 1187 1215 printf("permitted by applicable law. You can redistribute it and/or modify it under\n"); … … 1189 1217 printf("published by Sam Hocevar. See <http://sam.zoy.org/wtfpl/> for more details.\n"); 1190 1218 printf("\n"); 1191 printf("Written by Sam Hocevar. Report bugs to <sam@ zoy.org>.\n");1219 printf("Written by Sam Hocevar. Report bugs to <sam@hocevar.net>.\n"); 1192 1220 } 1193 1221 … … 1219 1247 printf("\n"); 1220 1248 printf("Mandatory arguments to long options are mandatory for short options too.\n"); 1249 printf(" -a, --allow <list> only fuzz network input for IPs in <list>\n"); 1221 1250 printf(" -A, --autoinc increment seed each time a new file is opened\n"); 1222 1251 printf(" -b, --bytes <ranges> only fuzz bytes at offsets within <ranges>\n"); … … 1228 1257 printf(" -d, --debug print debug messages\n"); 1229 1258 printf(" -D, --delay delay between forks\n"); 1259 printf(" -e, --deny <list> do not fuzz network input for IPs in <list>\n"); 1230 1260 #if defined HAVE_REGEX_H 1231 1261 printf(" -E, --exclude <regex> do not fuzz files matching <regex>\n"); … … 1259 1289 printf(" -V, --version output version information and exit\n"); 1260 1290 printf("\n"); 1261 printf("Written by Sam Hocevar. Report bugs to <sam@ zoy.org>.\n");1262 } 1263 1291 printf("Written by Sam Hocevar. Report bugs to <sam@hocevar.net>.\n"); 1292 } 1293
Note: See TracChangeset
for help on using the changeset viewer.