Ignore:
Timestamp:
Aug 6, 2009, 11:17:00 PM (11 years ago)
Author:
Sam Hocevar
Message:

Allow remote network host filtering, courtesy of Corentin Delorme.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/zzuf.c

    r3631 r3635  
    11/*
    22 *  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>
    44 *                All Rights Reserved
    55 *
     
    176176#endif
    177177#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"
    179179#define MOREINFO "Try `%s --help' for more information.\n"
    180180        int option_index = 0;
     
    182182        {
    183183            /* Long option, needs arg, flag, short option */
     184            { "allow",      1, NULL, 'a' },
    184185            { "autoinc",     0, NULL, 'A' },
    185186            { "bytes",       1, NULL, 'b' },
     
    191192            { "debug",       0, NULL, 'd' },
    192193            { "delay",       1, NULL, 'D' },
     194            { "deny",        1, NULL, 'e' },
    193195#if defined HAVE_REGEX_H
    194196            { "exclude",     1, NULL, 'E' },
     
    226228        switch(c)
    227229        {
     230        case 'a': /* --allow */
     231            opts->allow = myoptarg;
     232            break;
    228233        case 'A': /* --autoinc */
    229234            setenv("ZZUF_AUTOINC", "1", 1);
     
    256261                myoptarg++;
    257262            opts->delay = (int64_t)(atof(myoptarg) * 1000000.0);
     263            break;
     264        case 'e': /* --deny */
     265            opts->deny = myoptarg;
    258266            break;
    259267#if defined HAVE_REGEX_H
     
    387395    }
    388396
     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
    389415    _zz_setratio(opts->minratio, opts->maxratio);
    390416    _zz_setseed(opts->seed);
     
    445471    if(opts->ports)
    446472        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);
    447477    if(opts->protect)
    448478        setenv("ZZUF_PROTECT", opts->protect, 1);
     
    500530    if(opts->list)
    501531        _zz_list(opts->list);
    502     if(opts->ports)
    503         _zz_ports(opts->ports);
    504532    if(opts->protect)
    505533        _zz_protect(opts->protect);
     
    11831211{
    11841212    printf("zzuf %s\n", PACKAGE_VERSION);
    1185     printf("Copyright (C) 2002, 2007-2008 Sam Hocevar <sam@zoy.org>\n");
     1213    printf("Copyright (C) 2002, 2007-2009 Sam Hocevar <sam@hocevar.net>\n");
    11861214    printf("This program is free software. It comes without any warranty, to the extent\n");
    11871215    printf("permitted by applicable law. You can redistribute it and/or modify it under\n");
     
    11891217    printf("published by Sam Hocevar. See <http://sam.zoy.org/wtfpl/> for more details.\n");
    11901218    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");
    11921220}
    11931221
     
    12191247    printf("\n");
    12201248    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");
    12211250    printf("  -A, --autoinc             increment seed each time a new file is opened\n");
    12221251    printf("  -b, --bytes <ranges>      only fuzz bytes at offsets within <ranges>\n");
     
    12281257    printf("  -d, --debug               print debug messages\n");
    12291258    printf("  -D, --delay               delay between forks\n");
     1259    printf("  -e, --deny <list>         do not fuzz network input for IPs in <list>\n");
    12301260#if defined HAVE_REGEX_H
    12311261    printf("  -E, --exclude <regex>     do not fuzz files matching <regex>\n");
     
    12591289    printf("  -V, --version             output version information and exit\n");
    12601290    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.