]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fuzz: remove obsolete AFL code 4735/head
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 26 Mar 2020 15:11:21 +0000 (16:11 +0100)
committerPhilippe Antoine <contact@catenacyber.fr>
Thu, 26 Mar 2020 15:11:21 +0000 (16:11 +0100)
23 files changed:
README.md
configure.ac
scripts/afl/listcrashedseries.sh [deleted file]
scripts/afl/runafl.sh [deleted file]
src/Makefile.am
src/app-layer-detect-proto.c
src/app-layer-dnp3.c
src/app-layer-enip.c
src/app-layer-modbus.c
src/app-layer-parser.c
src/app-layer-parser.h
src/counters.c
src/decode-afl.c [deleted file]
src/decode.h
src/detect-parse.c
src/detect-parse.h
src/flow-bypass.c
src/flow-manager.c
src/runmode-pcap-file.c
src/suricata.c
src/tm-threads.c
src/util-decode-mime.c
src/util-decode-mime.h

index 606553fdd0121f583db9b73b7c1844abd28e4efd..b4c53ea598210b7c0985faf5be96ad55ee0cfe68 100644 (file)
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ Next to these tests, based on the type of code change further tests can be run m
 
 - traffic replay testing (multi-gigabit)
 - large pcap collection processing (multi-terabytes)
-- AFL based fuzz testing (might take multiple days or even weeks)
+- fuzz testing (might take multiple days or even weeks)
 - pcap based performance testing
 - live performance testing
 - various other manual tests based on evaluation of the proposed changes
index e707d8f8ce89bac488f2d3aaf8e599013ad254df..d85f55ec2970cae23a5f6bfbbebb4bbabbf30b20 100644 (file)
     esac
     AC_MSG_RESULT(ok)
 
-    # enable modifications for AFL fuzzing
-    AC_ARG_ENABLE(afl,
-           AS_HELP_STRING([--enable-afl], Enable AFL fuzzing logic[])], [enable_afl="$enableval"],[enable_afl=no])
-
-    AS_IF([test "x$enable_afl" = "xyes"], [
-        AC_DEFINE([AFLFUZZ_NO_RANDOM], [1], [Disable all use of random functions])
-        AC_DEFINE([AFLFUZZ_DISABLE_MGTTHREADS], [1], [Disable all management threads])
-        AC_DEFINE([AFLFUZZ_PCAP_RUNMODE], [1], [Enable special AFL 'single' runmode])
-        AC_DEFINE([AFLFUZZ_CONF_TEST], [1], [Enable special --afl-parse-rules commandline option])
-        AC_DEFINE([AFLFUZZ_APPLAYER], [1], [Enable --afl-$proto-request commandline option])
-        AC_DEFINE([AFLFUZZ_MIME], [1], [Enable --afl-mime commandline option])
-        AC_DEFINE([AFLFUZZ_DECODER], [1], [Enable --afl-decoder-$proto commandline option])
-        AC_DEFINE([AFLFUZZ_RULES], [1], [Enable --afl-rules commandline option])
-
-        # test for AFL PERSISTANT_MODE support
-        CFLAGS_ORIG=$CFLAGS
-        CFLAGS="-Werror"
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[while (__AFL_LOOP(1000))]])],
-                [AC_DEFINE([AFLFUZZ_PERSISTANT_MODE], [1], [Enable AFL PERSISTANT_MODE])],
-                [])
-        CFLAGS=$CFLAGS_ORIG
-    ])
-
   # disable TLS on user request
     AC_ARG_ENABLE(threading-tls,
            AS_HELP_STRING([--disable-threading-tls], [Disable TLS (thread local storage)]), [enable_tls="$enableval"],[enable_tls=yes])
diff --git a/scripts/afl/listcrashedseries.sh b/scripts/afl/listcrashedseries.sh
deleted file mode 100644 (file)
index 16b7e3b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-NAME=$1
-
-SERIES=$(ls ${NAME}/dump/ |sort|cut -f 1 -d'.'|sort -u)
-
-for S in $SERIES; do
-    FILEPATH="${NAME}/dump/${S}.999"
-    if [ ! -f $FILEPATH ]; then
-        echo "SERIE $S incomplete, possible crash"
-    fi
-done
-
diff --git a/scripts/afl/runafl.sh b/scripts/afl/runafl.sh
deleted file mode 100644 (file)
index 2bab3ad..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-
-PROTO=$1
-
-if [ ! -d $1 ]; then
-        mkdir -p $1/output
-        mkdir -p $1/dump
-        mkdir -p $1/input
-        echo "1" > $1/input/seed.txt
-else
-        CRASHES=$(ls ${1}/output/crashes|wc -l)
-        if [ $CRASHED -ne "0" ]; then
-            DIRNAME=$(date +%s)
-            mkdir "${1}/$DIRNAME"
-            mv -f ${1}/output/crashes/* ${1}/$DIRNAME/
-        fi
-        mv -f $1/output/queue/id* $1/input/
-        rm -r $1/output/
-        mkdir $1/output
-fi
-cd $1
-export ASAN_OPTIONS="detect_leaks=0 abort_on_error=1 symbolize=0"
-export AFL_SKIP_CPUFREQ=1
-/usr/local/bin/afl-fuzz -T ${PROTO} -t 1000 -m none -i input/ -o output/ -- ../../src/suricata --afl-${PROTO}=@@
index 2b2bd03f5214f0c7c4d19bf701ac81e072207886..1fb4326c7525fa7603cc3e28273b7257241f9be3 100755 (executable)
@@ -63,7 +63,6 @@ datasets-string.c datasets-string.h \
 datasets-sha256.c datasets-sha256.h \
 datasets-md5.c datasets-md5.h \
 decode.c decode.h \
-decode-afl.c \
 decode-erspan.c decode-erspan.h \
 decode-ethernet.c decode-ethernet.h \
 decode-events.c decode-events.h \
index ae954fdc1a636625c2c5e5447b883f04f7b7586d..a9c0ce2831adb6c109c434786af0831e781ab756 100644 (file)
@@ -1901,9 +1901,6 @@ int AppLayerProtoDetectConfProtoDetectionEnabled(const char *ipproto,
     ConfNode *node;
     int r;
 
-#ifdef AFLFUZZ_APPLAYER
-    goto enabled;
-#endif
     if (RunmodeIsUnittests())
         goto enabled;
 
index 8fc43f2afc13386616135e61e37ae1ebaa11720b..d0c3f4f336dbff48c9d63e486c8b70cfe8f4df2c 100644 (file)
@@ -1615,9 +1615,7 @@ void RegisterDNP3Parsers(void)
             if (!AppLayerProtoDetectPPParseConfPorts("tcp", IPPROTO_TCP,
                     proto_name, ALPROTO_DNP3, 0, sizeof(DNP3LinkHeader),
                     DNP3ProbingParser, DNP3ProbingParser)) {
-#ifndef AFLFUZZ_APPLAYER
                 return;
-#endif
             }
         }
 
index 446878f3ed9972bb7db635aed00ae70b7710b06b..282294536f73c12414b422bb39a38f05e8e9e45f 100644 (file)
@@ -513,9 +513,7 @@ void RegisterENIPTCPParsers(void)
                     proto_name, ALPROTO_ENIP, 0, sizeof(ENIPEncapHdr),
                     ENIPProbingParser, ENIPProbingParser))
             {
-#ifndef AFLFUZZ_APPLAYER
                 return;
-#endif
             }
         }
 
index 515295514eebbf157fe6f48d77e13a8260f3983b..af4b39533dc7ce739ef90b6d1d71089e3adfed07 100644 (file)
@@ -1510,9 +1510,7 @@ void RegisterModbusParsers(void)
                                                 proto_name, ALPROTO_MODBUS,
                                                 0, sizeof(ModbusHeader),
                                                 ModbusProbingParser, ModbusProbingParser)) {
-#ifndef AFLFUZZ_APPLAYER
                 return;
-#endif
             }
         }
 
@@ -1539,10 +1537,8 @@ void RegisterModbusParsers(void)
         }
         SCLogConfig("Modbus stream depth: %u", stream_depth);
     } else {
-#ifndef AFLFUZZ_APPLAYER
         SCLogConfig("Protocol detection and parser disabled for %s protocol.", proto_name);
         return;
-#endif
     }
     if (AppLayerParserConfParserEnabled("tcp", proto_name)) {
         AppLayerParserRegisterParser(IPPROTO_TCP, ALPROTO_MODBUS, STREAM_TOSERVER, ModbusParseRequest);
index bd60a545bfff83a18fb1fd9f6db54a26815c373c..f160fd106104d5f9dc27ef165a948393f9be11a0 100644 (file)
@@ -297,8 +297,7 @@ void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
 }
 
 /** \brief check if a parser is enabled in the config
- *  Returns enabled always if: were running unittests and
- *                             when compiled with --enable-afl
+ *  Returns enabled always if: were running unittests
  */
 int AppLayerParserConfParserEnabled(const char *ipproto,
                                     const char *alproto_name)
@@ -310,9 +309,6 @@ int AppLayerParserConfParserEnabled(const char *ipproto,
     ConfNode *node;
     int r;
 
-#ifdef AFLFUZZ_APPLAYER
-    goto enabled;
-#endif
     if (RunmodeIsUnittests())
         goto enabled;
 
@@ -1659,361 +1655,6 @@ void AppLayerParserStatePrintDetails(AppLayerParserState *pstate)
 }
 #endif
 
-#ifdef AFLFUZZ_APPLAYER
-int AppLayerParserRequestFromFile(uint8_t ipproto, AppProto alproto, char *filename)
-{
-    bool do_dump = (getenv("SC_AFL_DUMP_FILES") != NULL);
-    struct timeval ts;
-    memset(&ts, 0, sizeof(ts));
-    gettimeofday(&ts, NULL);
-
-    int result = 1;
-    Flow *f = NULL;
-    TcpSession ssn;
-    AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
-
-    memset(&ssn, 0, sizeof(ssn));
-
-    f = SCCalloc(1, sizeof(Flow));
-    if (f == NULL)
-        goto end;
-    FLOW_INITIALIZE(f);
-
-    f->flags |= FLOW_IPV4;
-    f->src.addr_data32[0] = 0x01020304;
-    f->dst.addr_data32[0] = 0x05060708;
-    f->sp = 10000;
-    f->dp = 80;
-    f->protoctx = &ssn;
-    f->proto = ipproto;
-    f->protomap = FlowGetProtoMapping(f->proto);
-    f->alproto = alproto;
-
-    uint8_t buffer[65536];
-    uint32_t cnt = 0;
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    while (__AFL_LOOP(1000)) {
-        /* reset state */
-        memset(buffer, 0, sizeof(buffer));
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-        FILE *fp = fopen(filename, "r");
-        BUG_ON(fp == NULL);
-
-        int start = 1;
-        while (1) {
-            int done = 0;
-            size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-            if (size < sizeof(buffer))
-                done = 1;
-
-            if (do_dump) {
-                char outfilename[256];
-                snprintf(outfilename, sizeof(outfilename), "dump/%u-%u.%u",
-                        (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, cnt);
-                FILE *out_fp = fopen(outfilename, "w");
-                BUG_ON(out_fp == NULL);
-                (void)fwrite(buffer, size, 1, out_fp);
-                fclose(out_fp);
-            }
-            //SCLogInfo("result %u done %d start %d", (uint)result, done, start);
-
-            uint8_t flags = STREAM_TOSERVER;
-            if (start--) {
-                flags |= STREAM_START;
-            }
-            if (done) {
-                flags |= STREAM_EOF;
-            }
-            //PrintRawDataFp(stdout, buffer, result);
-
-            (void)AppLayerParserParse(NULL, alp_tctx, f, alproto, flags,
-                                      buffer, size);
-            cnt++;
-
-            if (done)
-                break;
-        }
-
-        fclose(fp);
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    }
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-    if (do_dump) {
-        /* if we get here there was no crash, so we can remove our files */
-        uint32_t x = 0;
-        for (x = 0; x < cnt; x++) {
-            char rmfilename[256];
-            snprintf(rmfilename, sizeof(rmfilename), "dump/%u-%u.%u",
-                    (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, x);
-            unlink(rmfilename);
-        }
-    }
-
-    result = 0;
-
-end:
-    if (alp_tctx != NULL)
-        AppLayerParserThreadCtxFree(alp_tctx);
-    if (f != NULL) {
-        FlowFree(f);
-    }
-    return result;
-}
-
-/* load a serie of files generated by DecoderParseDataFromFile() in
- * the same order as it was produced. */
-int AppLayerParserRequestFromFileSerie(uint8_t ipproto, AppProto alproto, char *fileprefix)
-{
-    uint32_t cnt = 0;
-    int start = 1;
-    int result = 1;
-    Flow *f = NULL;
-    TcpSession ssn;
-    AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
-
-    memset(&ssn, 0, sizeof(ssn));
-
-    f = SCCalloc(1, sizeof(Flow));
-    if (f == NULL)
-        goto end;
-    FLOW_INITIALIZE(f);
-
-    f->flags |= FLOW_IPV4;
-    f->src.addr_data32[0] = 0x01020304;
-    f->dst.addr_data32[0] = 0x05060708;
-    f->sp = 10000;
-    f->dp = 80;
-    f->protoctx = &ssn;
-    f->proto = ipproto;
-    f->protomap = FlowGetProtoMapping(f->proto);
-    f->alproto = alproto;
-
-    uint8_t buffer[65536];
-
-    char filename[256];
-    snprintf(filename, sizeof(filename), "dump/%s.%u", fileprefix, cnt);
-    FILE *fp;
-    while ((fp = fopen(filename, "r")) != NULL)
-    {
-        memset(buffer, 0, sizeof(buffer));
-
-        size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-
-        uint8_t flags = STREAM_TOSERVER;
-        if (start--) {
-            flags |= STREAM_START;
-        }
-
-        (void)AppLayerParserParse(NULL, alp_tctx, f, alproto, flags,
-                buffer, size);
-
-        fclose(fp);
-        cnt++;
-
-        snprintf(filename, sizeof(filename), "dump/%s.%u", fileprefix, cnt);
-    }
-
-    result = 0;
-
-end:
-    if (alp_tctx != NULL)
-        AppLayerParserThreadCtxFree(alp_tctx);
-    if (f != NULL) {
-        FlowFree(f);
-    }
-    return result;
-}
-
-int AppLayerParserFromFile(uint8_t ipproto, AppProto alproto, char *filename)
-{
-    bool do_dump = (getenv("SC_AFL_DUMP_FILES") != NULL);
-    struct timeval ts;
-    memset(&ts, 0, sizeof(ts));
-    gettimeofday(&ts, NULL);
-
-    int result = 1;
-    Flow *f = NULL;
-    TcpSession ssn;
-    AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
-
-    memset(&ssn, 0, sizeof(ssn));
-
-    f = SCCalloc(1, sizeof(Flow));
-    if (f == NULL)
-        goto end;
-    FLOW_INITIALIZE(f);
-
-    f->flags |= FLOW_IPV4;
-    f->src.addr_data32[0] = 0x01020304;
-    f->dst.addr_data32[0] = 0x05060708;
-    f->sp = 10000;
-    f->dp = 80;
-    f->protoctx = &ssn;
-    f->proto = ipproto;
-    f->protomap = FlowGetProtoMapping(f->proto);
-    f->alproto = alproto;
-
-    uint8_t buffer[65536];
-    uint32_t cnt = 0;
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    while (__AFL_LOOP(1000)) {
-        /* reset state */
-        memset(buffer, 0, sizeof(buffer));
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-        FILE *fp = fopen(filename, "r");
-        BUG_ON(fp == NULL);
-
-        int start = 1;
-        int flip = 0;
-        while (1) {
-            int done = 0;
-            size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-            if (size < sizeof(buffer))
-                done = 1;
-            if (do_dump) {
-                char outfilename[256];
-                snprintf(outfilename, sizeof(outfilename), "dump/%u-%u.%u",
-                        (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, cnt);
-                FILE *out_fp = fopen(outfilename, "w");
-                BUG_ON(out_fp == NULL);
-                (void)fwrite(buffer, size, 1, out_fp);
-                fclose(out_fp);
-            }
-            //SCLogInfo("result %u done %d start %d", (uint)result, done, start);
-
-            uint8_t flags = 0;
-            if (flip) {
-                flags = STREAM_TOCLIENT;
-                flip = 0;
-            } else {
-                flags = STREAM_TOSERVER;
-                flip = 1;
-            }
-
-            if (start--) {
-                flags |= STREAM_START;
-            }
-            if (done) {
-                flags |= STREAM_EOF;
-            }
-            //PrintRawDataFp(stdout, buffer, result);
-
-            (void)AppLayerParserParse(NULL, alp_tctx, f, alproto, flags,
-                                      buffer, size);
-
-            cnt++;
-
-            if (done)
-                break;
-        }
-
-        fclose(fp);
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    }
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-    if (do_dump) {
-        /* if we get here there was no crash, so we can remove our files */
-        uint32_t x = 0;
-        for (x = 0; x < cnt; x++) {
-            char rmfilename[256];
-            snprintf(rmfilename, sizeof(rmfilename), "dump/%u-%u.%u",
-                    (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, x);
-            unlink(rmfilename);
-        }
-    }
-
-    result = 0;
-end:
-    if (alp_tctx != NULL)
-        AppLayerParserThreadCtxFree(alp_tctx);
-    if (f != NULL) {
-        FlowFree(f);
-    }
-    return result;
-}
-
-/* load a serie of files generated by DecoderParseDataFromFile() in
- * the same order as it was produced. */
-int AppLayerParserFromFileSerie(uint8_t ipproto, AppProto alproto, char *fileprefix)
-{
-    uint32_t cnt = 0;
-    int start = 1;
-    int result = 1;
-    Flow *f = NULL;
-    TcpSession ssn;
-    AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
-
-    memset(&ssn, 0, sizeof(ssn));
-
-    f = SCCalloc(1, sizeof(Flow));
-    if (f == NULL)
-        goto end;
-    FLOW_INITIALIZE(f);
-
-    f->flags |= FLOW_IPV4;
-    f->src.addr_data32[0] = 0x01020304;
-    f->dst.addr_data32[0] = 0x05060708;
-    f->sp = 10000;
-    f->dp = 80;
-    f->protoctx = &ssn;
-    f->proto = ipproto;
-    f->protomap = FlowGetProtoMapping(f->proto);
-    f->alproto = alproto;
-
-    uint8_t buffer[65536];
-    int flip = 0;
-    char filename[256];
-    snprintf(filename, sizeof(filename), "dump/%s.%u", fileprefix, cnt);
-    FILE *fp;
-    while ((fp = fopen(filename, "r")) != NULL)
-    {
-        memset(buffer, 0, sizeof(buffer));
-
-        size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-
-        uint8_t flags = 0;
-        if (flip) {
-            flags = STREAM_TOCLIENT;
-            flip = 0;
-        } else {
-            flags = STREAM_TOSERVER;
-            flip = 1;
-        }
-
-        if (start--) {
-            flags |= STREAM_START;
-        }
-
-        (void)AppLayerParserParse(NULL, alp_tctx, f, alproto, flags,
-                buffer, size);
-
-        fclose(fp);
-        cnt++;
-
-        snprintf(filename, sizeof(filename), "dump/%s.%u", fileprefix, cnt);
-    }
-
-    result = 0;
-
-end:
-    if (alp_tctx != NULL)
-        AppLayerParserThreadCtxFree(alp_tctx);
-    if (f != NULL) {
-        FlowFree(f);
-    }
-    return result;
-}
-
-#endif /* AFLFUZZ_APPLAYER */
-
 /***** Unittests *****/
 
 #ifdef UNITTESTS
index 44248cceb30420c64386e851f5510740e152e5f1..b43e87da07a5b806fe7ca563bd41d74b7efd46e8 100644 (file)
@@ -278,12 +278,6 @@ void AppLayerParserTransactionsCleanup(Flow *f);
 void AppLayerParserStatePrintDetails(AppLayerParserState *pstate);
 #endif
 
-#ifdef AFLFUZZ_APPLAYER
-int AppLayerParserRequestFromFile(uint8_t ipproto, AppProto alproto, char *filename);
-int AppLayerParserRequestFromFileSerie(uint8_t ipproto, AppProto alproto, char *prefix);
-int AppLayerParserFromFile(uint8_t ipproto, AppProto alproto, char *filename);
-int AppLayerParserFromFileSerie(uint8_t ipproto, AppProto alproto, char *prefix);
-#endif
 
 /***** Unittests *****/
 
index 91141da8435bbf635e12a07056bd70ea14ca820c..3b93a3746cb361c44d6f30a2ddef20ed6371a80d 100644 (file)
@@ -233,10 +233,6 @@ static ConfNode *GetConfig(void) {
 static void StatsInitCtxPreOutput(void)
 {
     SCEnter();
-#ifdef AFLFUZZ_DISABLE_MGTTHREADS
-    stats_enabled = FALSE;
-    SCReturn;
-#endif
     ConfNode *stats = GetConfig();
     if (stats != NULL) {
         const char *enabled = ConfNodeLookupChildValue(stats, "enabled");
diff --git a/src/decode-afl.c b/src/decode-afl.c
deleted file mode 100644 (file)
index 974ebd6..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Copyright (C) 2007-2017 Open Information Security Foundation
- *
- * You can copy, redistribute or modify this Program under the terms of
- * the GNU General Public License version 2 as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#include "suricata-common.h"
-#include "suricata.h"
-#include "conf.h"
-#include "decode.h"
-#include "util-debug.h"
-#include "util-mem.h"
-#include "app-layer-detect-proto.h"
-#include "app-layer.h"
-#include "tm-threads.h"
-#include "util-error.h"
-#include "util-print.h"
-#include "tmqh-packetpool.h"
-#include "util-profiling.h"
-#include "pkt-var.h"
-#include "util-mpm-ac.h"
-
-#include "output.h"
-#include "output-flow.h"
-
-#include "defrag.h"
-#include "flow.h"
-
-#ifdef AFLFUZZ_DECODER
-int AFLDecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len)
-{
-    return DecodeIPV4(tv, dtv, p, pkt, (uint16_t)len);
-}
-int AFLDecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len)
-{
-    return DecodeIPV6(tv, dtv, p, pkt, (uint16_t)len);
-}
-
-/* stateful processing of data as packets. Because AFL in case of a
- * crash will only safe the last input, we dump all the inputs to a
- * directory 'dump' with a unique timestamp for the serie and an
- * incrementing 'id' so that we can 'replay' it in
- * DecoderParseDataFromFileSerie().
- */
-int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder)
-{
-    bool do_dump = (getenv("SC_AFL_DUMP_FILES") != NULL);
-    uint8_t buffer[65536];
-    struct timeval ts;
-    memset(&ts, 0, sizeof(ts));
-    gettimeofday(&ts, NULL);
-
-    uint32_t cnt = 0;
-
-    DefragInit();
-    FlowInitConfig(FLOW_QUIET);
-
-    ThreadVars tv;
-    memset(&tv, 0, sizeof(tv));
-    DecodeThreadVars *dtv = DecodeThreadVarsAlloc(&tv);
-    DecodeRegisterPerfCounters(dtv, &tv);
-    StatsSetupPrivate(&tv);
-    PacketQueue pq;
-    memset(&pq, 0, sizeof(pq));
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    while (__AFL_LOOP(1000)) {
-        /* reset state */
-        memset(buffer, 0, sizeof(buffer));
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-        FILE *fp = fopen(filename, "r");
-        BUG_ON(fp == NULL);
-
-        size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-        if (do_dump) {
-            char outfilename[256];
-            snprintf(outfilename, sizeof(outfilename), "dump/%u-%u.%u",
-                    (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, cnt);
-            FILE *out_fp = fopen(outfilename, "w");
-            BUG_ON(out_fp == NULL);
-            (void)fwrite(buffer, size, 1, out_fp);
-            fclose(out_fp);
-        }
-
-        Packet *p = PacketGetFromAlloc();
-        if (p != NULL) {
-            PacketSetData(p, buffer, size);
-            (void) Decoder (&tv, dtv, p, buffer, size);
-            while (1) {
-                Packet *extra_p = PacketDequeueNoLock(&tv.decode_pq);
-                if (unlikely(extra_p == NULL))
-                    break;
-                PacketFree(extra_p);
-            }
-            PacketFree(p);
-        }
-        fclose(fp);
-        cnt++;
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    }
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-    /* if we get here there was no crash, so we can remove our files */
-    if (do_dump) {
-        for (uint32_t x = 0; x < cnt; x++) {
-            char rmfilename[256];
-            snprintf(rmfilename, sizeof(rmfilename), "dump/%u-%u.%u",
-                    (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, x);
-            unlink(rmfilename);
-        }
-    }
-    DecodeThreadVarsFree(&tv, dtv);
-    FlowShutdown();
-    DefragDestroy();
-    StatsThreadCleanup(&tv);
-    StatsReleaseResources();
-    return 0;
-}
-
-/* load a serie of files generated by DecoderParseDataFromFile() in
- * the same order as it was produced. */
-int DecoderParseDataFromFileSerie(char *fileprefix, DecoderFunc Decoder)
-{
-    uint8_t buffer[65536];
-    uint32_t cnt = 0;
-
-    DefragInit();
-    FlowInitConfig(FLOW_QUIET);
-    ThreadVars tv;
-    memset(&tv, 0, sizeof(tv));
-    DecodeThreadVars *dtv = DecodeThreadVarsAlloc(&tv);
-    DecodeRegisterPerfCounters(dtv, &tv);
-    StatsSetupPrivate(&tv);
-    PacketQueue pq;
-    memset(&pq, 0, sizeof(pq));
-
-    char filename[256];
-    snprintf(filename, sizeof(filename), "dump/%s.%u", fileprefix, cnt);
-    FILE *fp;
-    while ((fp = fopen(filename, "r")) != NULL)
-    {
-        memset(buffer, 0, sizeof(buffer));
-
-        size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-
-        Packet *p = PacketGetFromAlloc();
-        if (p != NULL) {
-            PacketSetData(p, buffer, size);
-            (void) Decoder (&tv, dtv, p, buffer, size);
-            while (1) {
-                Packet *extra_p = PacketDequeueNoLock(&tv.decode_pq);
-                if (unlikely(extra_p == NULL))
-                    break;
-                PacketFree(extra_p);
-            }
-            PacketFree(p);
-        }
-        fclose(fp);
-        cnt++;
-        snprintf(filename, sizeof(filename), "dump/%s.%u", fileprefix, cnt);
-    }
-    DecodeThreadVarsFree(&tv, dtv);
-    FlowShutdown();
-    DefragDestroy();
-    return 0;
-}
-#endif /* AFLFUZZ_DECODER */
-
index 4e2ecf0e5933ea0d048df4da6ae8fd16b32790ef..0787707d1c445483566923dad4b794f6d119e777 100644 (file)
@@ -946,14 +946,6 @@ void AddressDebugPrint(Address *);
 
 typedef int (*DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
          const uint8_t *pkt, uint32_t len);
-#ifdef AFLFUZZ_DECODER
-int AFLDecodeIPV4(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len);
-int AFLDecodeIPV6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
-        const uint8_t *pkt, uint32_t len);
-int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder);
-int DecoderParseDataFromFileSerie(char *fileprefix, DecoderFunc Decoder);
-#endif
 void DecodeGlobalConfig(void);
 void DecodeUnregisterCounters(void);
 
index 67f71da07a0d7ed3b1f493b3458b6ea5cfbe9c26..4663afefbe5fafb8a4ca128a1248e5070e49cc7d 100644 (file)
@@ -2443,49 +2443,6 @@ void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_par
     return;
 }
 
-#ifdef AFLFUZZ_RULES
-#include "util-reference-config.h"
-int RuleParseDataFromFile(char *filename)
-{
-    char buffer[65536];
-
-    SigTableSetup();
-    SCReferenceConfInit();
-    SCClassConfInit();
-
-    DetectEngineCtx *de_ctx = DetectEngineCtxInit();
-    if (de_ctx == NULL)
-        return 0;
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    while (__AFL_LOOP(10000)) {
-        /* reset state */
-        memset(buffer, 0, sizeof(buffer));
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-        FILE *fp = fopen(filename, "r");
-        BUG_ON(fp == NULL);
-
-        size_t result = fread(&buffer, 1, sizeof(buffer), fp);
-        if (result < sizeof(buffer)) {
-            buffer[result] = '\0';
-            Signature *s = SigInit(de_ctx, buffer);
-            if (s != NULL) {
-                SigFree(s);
-            }
-        }
-        fclose(fp);
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    }
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-    DetectEngineCtxFree(de_ctx);
-    SCClassConfDeinit();
-    SCReferenceConfDeinit();
-    return 0;
-}
-#endif /* AFLFUZZ_RULES */
 
 /*
  * TESTS
index 5921b35150f18c114e45d26df56b3ecfb1a34ab8..6a939aa00c629ef62997acc0445cd040f31c2e5a 100644 (file)
@@ -102,10 +102,6 @@ int DetectParsePcreExecLen(DetectParseRegex *parse_regex, const char *str,
                    int str_len, int start_offset, int options,
                    int *ovector, int ovector_size);
 
-#ifdef AFLFUZZ_RULES
-int RuleParseDataFromFile(char *filename);
-#endif
-
 /* typical size of ovector */
 #define MAX_SUBSTRINGS 30
 
index 7c39e8ca1527cf801fe59bc77706de9cf2da0a50..9b4e75e702fee4bc22f5fc7e1c30577f80574fb1 100644 (file)
@@ -183,9 +183,6 @@ int BypassedFlowManagerRegisterUpdateFunc(BypassedUpdateFunc UpdateFunc,
 void BypassedFlowManagerThreadSpawn()
 {
 #ifdef CAPTURE_OFFLOAD_MANAGER
-#ifdef AFLFUZZ_DISABLE_MGTTHREADS
-    return;
-#endif
 
     ThreadVars *tv_flowmgr = NULL;
     tv_flowmgr = TmThreadCreateMgmtThreadByName(thread_name_flow_bypass,
index 0535dbd19f403dce7bcc0068827ced84af97c33e..26a452a23d0bbfb262cce97751b98721e0e267c9 100644 (file)
@@ -145,9 +145,6 @@ typedef struct FlowTimeoutCounters_ {
  */
 void FlowDisableFlowManagerThread(void)
 {
-#ifdef AFLFUZZ_DISABLE_MGTTHREADS
-    return;
-#endif
     /* wake up threads */
     uint32_t u;
     for (u = 0; u < flowmgr_number; u++)
@@ -879,9 +876,6 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
 /** \brief spawn the flow manager thread */
 void FlowManagerThreadSpawn()
 {
-#ifdef AFLFUZZ_DISABLE_MGTTHREADS
-    return;
-#endif
     intmax_t setting = 1;
     (void)ConfGetInt("flow.managers", &setting);
 
@@ -1033,9 +1027,6 @@ static int FlowRecyclerReadyToShutdown(void)
 /** \brief spawn the flow recycler thread */
 void FlowRecyclerThreadSpawn()
 {
-#ifdef AFLFUZZ_DISABLE_MGTTHREADS
-    return;
-#endif
     intmax_t setting = 1;
     (void)ConfGetInt("flow.recyclers", &setting);
 
@@ -1077,9 +1068,6 @@ void FlowRecyclerThreadSpawn()
  */
 void FlowDisableFlowRecyclerThread(void)
 {
-#ifdef AFLFUZZ_DISABLE_MGTTHREADS
-    return;
-#endif
     int cnt = 0;
 
     /* move all flows still in the hash to the recycler queue */
index 3de5c98e519ba302273f31608ef543f690f5ff0f..7d0029dccbe5ce02f38bd40dd5c82fa097ca8306 100644 (file)
@@ -106,23 +106,10 @@ int RunModeFilePcapSingle(void)
 
     TmThreadSetCPU(tv, WORKER_CPU_SET);
 
-#ifndef AFLFUZZ_PCAP_RUNMODE
     if (TmThreadSpawn(tv) != TM_ECODE_OK) {
         SCLogError(SC_ERR_RUNMODE, "TmThreadSpawn failed");
         exit(EXIT_FAILURE);
     }
-#else
-    /* in afl mode we don't spawn a new thread, but run the pipeline
-     * in the main thread */
-    tv->tm_func(tv);
-    int afl_runmode_exit_immediately = 0;
-    (void)ConfGetBool("afl.exit_after_pcap", &afl_runmode_exit_immediately);
-    if (afl_runmode_exit_immediately) {
-        SCLogNotice("exit because of afl-runmode-exit-after-pcap commandline option");
-        exit(EXIT_SUCCESS);
-    }
-#endif
-
     return 0;
 }
 
index a60fa74b7fa9c1d5fb873a47b4d2d52ea26987e5..07c28659a3a78d2df7e3624b6b36d7fd8ce1e629 100644 (file)
@@ -1166,248 +1166,6 @@ static bool IsLogDirectoryWritable(const char* str)
     return false;
 }
 
-static void ParseCommandLineAFL(const char *opt_name, char *opt_arg)
-{
-#ifdef AFLFUZZ_RULES
-    if(strcmp(opt_name, "afl-rules") == 0) {
-        MpmTableSetup();
-        SpmTableSetup();
-        exit(RuleParseDataFromFile(opt_arg));
-    } else
-#endif
-#ifdef AFLFUZZ_APPLAYER
-    if(strcmp(opt_name, "afl-http-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterHTPParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_HTTP, opt_arg));
-    } else if(strcmp(opt_name, "afl-http") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterHTPParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_HTTP, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-tls-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterSSLParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_TLS, opt_arg));
-    } else if(strcmp(opt_name, "afl-tls") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterSSLParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_TLS, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-dns-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        RegisterDNSUDPParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_UDP, ALPROTO_DNS, opt_arg));
-    } else if(strcmp(opt_name, "afl-dns") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        AppLayerParserSetup();
-        RegisterDNSUDPParsers();
-        exit(AppLayerParserFromFile(IPPROTO_UDP, ALPROTO_DNS, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-dnstcp-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        RegisterDNSTCPParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_DNS, opt_arg));
-    } else if(strcmp(opt_name, "afl-dnstcp") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        AppLayerParserSetup();
-        RegisterDNSTCPParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_DNS, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-ssh-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        RegisterSSHParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_SSH, opt_arg));
-    } else if(strcmp(opt_name, "afl-ssh") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterSSHParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_SSH, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-ftp-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        IPPairInitConfig(FLOW_QUIET);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterFTPParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_FTP, opt_arg));
-    } else if(strcmp(opt_name, "afl-ftp") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        IPPairInitConfig(FLOW_QUIET);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterFTPParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_FTP, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-smtp-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterSMTPParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_SMTP, opt_arg));
-    } else if(strcmp(opt_name, "afl-smtp") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterSMTPParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_SMTP, opt_arg));
-
-    } else if(strcmp(opt_name, "afl-smb-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        RegisterSMBParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_SMB, opt_arg));
-    } else if(strcmp(opt_name, "afl-smb") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterSMBParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_SMB, opt_arg));
-    } else if(strstr(opt_name, "afl-dcerpc-request") != NULL) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterDCERPCParsers();
-        if (strcmp(opt_name, "afl-dcerpc-request") == 0)
-            exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_DCERPC, opt_arg));
-        else
-            exit(AppLayerParserRequestFromFileSerie(IPPROTO_TCP, ALPROTO_DCERPC, opt_arg));
-    } else if(strstr(opt_name, "afl-dcerpc") != NULL) {
-        //printf("arg: //%s\n", opt_arg);
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        AppLayerParserSetup();
-        RegisterDCERPCParsers();
-        if (strcmp(opt_name, "afl-dcerpc") == 0)
-            exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_DCERPC, opt_arg));
-        else
-            exit(AppLayerParserFromFileSerie(IPPROTO_TCP, ALPROTO_DCERPC, opt_arg));
-    } else if(strcmp(opt_name, "afl-modbus-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        AppLayerParserSetup();
-        RegisterModbusParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_MODBUS, opt_arg));
-    } else if(strcmp(opt_name, "afl-modbus") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        AppLayerParserSetup();
-        RegisterModbusParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_MODBUS, opt_arg));
-    } else if(strcmp(opt_name, "afl-enip-request") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        AppLayerParserSetup();
-        RegisterENIPTCPParsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_ENIP, opt_arg));
-    } else if(strcmp(opt_name, "afl-enip") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        AppLayerParserSetup();
-        RegisterENIPTCPParsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_ENIP, opt_arg));
-    } else if(strcmp(opt_name, "afl-dnp3-request") == 0) {
-        AppLayerParserSetup();
-        RegisterDNP3Parsers();
-        exit(AppLayerParserRequestFromFile(IPPROTO_TCP, ALPROTO_DNP3, opt_arg));
-    } else if(strcmp(opt_name, "afl-dnp3") == 0) {
-        AppLayerParserSetup();
-        RegisterDNP3Parsers();
-        exit(AppLayerParserFromFile(IPPROTO_TCP, ALPROTO_DNP3, opt_arg));
-    } else
-#endif
-#ifdef AFLFUZZ_MIME
-    if(strcmp(opt_name, "afl-mime") == 0) {
-        //printf("arg: //%s\n", opt_arg);
-        exit(MimeParserDataFromFile(opt_arg));
-    } else
-#endif
-#ifdef AFLFUZZ_DECODER
-    if(strstr(opt_name, "afl-decoder-ppp") != NULL) {
-        StatsInit();
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        if (strcmp(opt_name, "afl-decoder-ppp") == 0)
-            exit(DecoderParseDataFromFile(opt_arg, DecodePPP));
-        else
-            exit(DecoderParseDataFromFileSerie(opt_arg, DecodePPP));
-    } else if(strstr(opt_name, "afl-decoder-ipv4") != NULL) {
-        StatsInit();
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        if (strcmp(opt_name, "afl-decoder-ipv4") == 0)
-            exit(DecoderParseDataFromFile(opt_arg, AFLDecodeIPV4));
-        else
-            exit(DecoderParseDataFromFileSerie(opt_arg, AFLDecodeIPV4));
-    } else if(strstr(opt_name, "afl-decoder-ipv6") != NULL) {
-        StatsInit();
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        if (strcmp(opt_name, "afl-decoder-ipv6") == 0)
-            exit(DecoderParseDataFromFile(opt_arg, AFLDecodeIPV6));
-        else
-            exit(DecoderParseDataFromFileSerie(opt_arg, AFLDecodeIPV6));
-    } else if(strstr(opt_name, "afl-decoder-ethernet") != NULL) {
-        StatsInit();
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        if (strcmp(opt_name, "afl-decoder-ethernet") == 0)
-            exit(DecoderParseDataFromFile(opt_arg, DecodeEthernet));
-        else
-            exit(DecoderParseDataFromFileSerie(opt_arg, DecodeEthernet));
-    } else if(strstr(opt_name, "afl-decoder-erspan") != NULL) {
-        StatsInit();
-        MpmTableSetup();
-        SpmTableSetup();
-        AppLayerProtoDetectSetup();
-        if (strcmp(opt_name, "afl-decoder-erspan") == 0)
-            exit(DecoderParseDataFromFile(opt_arg, DecodeERSPAN));
-        else
-            exit(DecoderParseDataFromFileSerie(opt_arg, DecodeERSPAN));
-    } else
-#endif
-    {
-        abort();
-    }
-}
-
 static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
 {
     int opt;
@@ -1420,9 +1178,6 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
     int list_keywords = 0;
     int build_info = 0;
     int conf_test = 0;
-#ifdef AFLFUZZ_CONF_TEST
-    int conf_test_force_success = 0;
-#endif
     int engine_analysis = 0;
     int ret = TM_ECODE_OK;
 
@@ -1448,48 +1203,6 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
         {"no-random", 0, &g_disable_randomness, 1},
         {"strict-rule-keywords", optional_argument, 0, 0},
 
-        /* AFL app-layer options. */
-        {"afl-http-request", required_argument, 0 , 0},
-        {"afl-http", required_argument, 0 , 0},
-        {"afl-tls-request", required_argument, 0 , 0},
-        {"afl-tls", required_argument, 0 , 0},
-        {"afl-dns-request", required_argument, 0 , 0},
-        {"afl-dns", required_argument, 0 , 0},
-        {"afl-ssh-request", required_argument, 0 , 0},
-        {"afl-ssh", required_argument, 0 , 0},
-        {"afl-ftp-request", required_argument, 0 , 0},
-        {"afl-ftp", required_argument, 0 , 0},
-        {"afl-smtp-request", required_argument, 0 , 0},
-        {"afl-smtp", required_argument, 0 , 0},
-        {"afl-smb-request", required_argument, 0 , 0},
-        {"afl-smb", required_argument, 0 , 0},
-        {"afl-modbus-request", required_argument, 0 , 0},
-        {"afl-modbus", required_argument, 0 , 0},
-        {"afl-enip-request", required_argument, 0 , 0},
-        {"afl-enip", required_argument, 0 , 0},
-        {"afl-mime", required_argument, 0 , 0},
-        {"afl-dnp3-request", required_argument, 0, 0},
-        {"afl-dnp3", required_argument, 0, 0},
-        {"afl-dcerpc", required_argument, 0, 0},
-        {"afl-dcerpc-serie", required_argument, 0, 0},
-        {"afl-dcerpc-request", required_argument, 0, 0},
-        {"afl-dcerpc-request-serie", required_argument, 0, 0},
-
-        /* Other AFL options. */
-        {"afl-rules", required_argument, 0 , 0},
-        {"afl-mime", required_argument, 0 , 0},
-        {"afl-decoder-ppp", required_argument, 0 , 0},
-        {"afl-decoder-ppp-serie", required_argument, 0 , 0},
-        {"afl-decoder-ethernet", required_argument, 0 , 0},
-        {"afl-decoder-ethernet-serie", required_argument, 0 , 0},
-        {"afl-decoder-erspan", required_argument, 0 , 0},
-        {"afl-decoder-erspan-serie", required_argument, 0 , 0},
-        {"afl-decoder-ipv4", required_argument, 0 , 0},
-        {"afl-decoder-ipv4-serie", required_argument, 0 , 0},
-        {"afl-decoder-ipv6", required_argument, 0 , 0},
-        {"afl-decoder-ipv6-serie", required_argument, 0 , 0},
-        {"afl-der", required_argument, 0, 0},
-
 #ifdef BUILD_UNIX_SOCKET
         {"unix-socket", optional_argument, 0, 0},
 #endif
@@ -1525,9 +1238,6 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
         {"set", required_argument, 0, 0},
 #ifdef HAVE_NFLOG
         {"nflog", optional_argument, 0, 0},
-#endif
-#ifdef AFLFUZZ_CONF_TEST
-        {"afl-parse-rules", 0, &conf_test_force_success, 1},
 #endif
         {NULL, 0, NULL, 0}
     };
@@ -1628,8 +1338,6 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
                 if (ParseCommandLinePcapLive(suri, optarg) != TM_ECODE_OK) {
                     return TM_ECODE_FAILED;
                 }
-            } else if(strncmp((long_opts[option_index]).name, "afl-", 4) == 0) {
-                ParseCommandLineAFL((long_opts[option_index]).name, optarg);
             } else if(strcmp((long_opts[option_index]).name, "simulate-ips") == 0) {
                 SCLogInfo("Setting IPS mode");
                 EngineModeSetIPS();
@@ -2108,11 +1816,6 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
         SCLogError(SC_ERR_INITIALIZATION, "can't use -s/-S when detection is disabled");
         return TM_ECODE_FAILED;
     }
-#ifdef AFLFUZZ_CONF_TEST
-    if (conf_test && conf_test_force_success) {
-        (void)ConfSetFinal("engine.init-failure-fatal", "0");
-    }
-#endif
 
     if ((suri->run_mode == RUNMODE_UNIX_SOCKET) && suri->set_logdir) {
         SCLogError(SC_ERR_INITIALIZATION,
index 7146ad84c5a85ccf55eb3aa8f40c863f0f633fbe..b8e14e12966a3a8a625721ba5be432aa11c8af71 100644 (file)
@@ -145,8 +145,6 @@ TmEcode TmThreadsSlotVarRun(ThreadVars *tv, Packet *p, TmSlot *slot)
     return TM_ECODE_OK;
 }
 
-#ifndef AFLFUZZ_PCAP_RUNMODE
-
 /** \internal
  *
  *  \brief Process flow timeout packets
@@ -350,122 +348,6 @@ error:
     return NULL;
 }
 
-#endif /* NO  AFLFUZZ_PCAP_RUNMODE */
-
-#ifdef AFLFUZZ_PCAP_RUNMODE
-/** \brief simplified loop to speed up AFL
- *
- *  The loop runs in the caller's thread. No separate thread.
- */
-static void *TmThreadsSlotPktAcqLoopAFL(void *td)
-{
-    SCLogNotice("AFL mode starting");
-
-    ThreadVars *tv = (ThreadVars *)td;
-    TmSlot *s = tv->tm_slots;
-    char run = 1;
-    TmEcode r = TM_ECODE_OK;
-    TmSlot *slot = NULL;
-
-    PacketPoolInit();
-
-    /* check if we are setup properly */
-    if (s == NULL || s->PktAcqLoop == NULL || tv->tmqh_in == NULL || tv->tmqh_out == NULL) {
-        SCLogError(SC_ERR_FATAL, "TmSlot or ThreadVars badly setup: s=%p,"
-                                 " PktAcqLoop=%p, tmqh_in=%p,"
-                                 " tmqh_out=%p",
-                   s, s ? s->PktAcqLoop : NULL, tv->tmqh_in, tv->tmqh_out);
-        TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
-        return NULL;
-    }
-
-    for (slot = s; slot != NULL; slot = slot->slot_next) {
-        if (slot->SlotThreadInit != NULL) {
-            void *slot_data = NULL;
-            r = slot->SlotThreadInit(tv, slot->slot_initdata, &slot_data);
-            if (r != TM_ECODE_OK) {
-                if (r == TM_ECODE_DONE) {
-                    EngineDone();
-                    TmThreadsSetFlag(tv, THV_CLOSED | THV_INIT_DONE | THV_RUNNING_DONE);
-                    goto error;
-                } else {
-                    TmThreadsSetFlag(tv, THV_CLOSED | THV_RUNNING_DONE);
-                    goto error;
-                }
-            }
-            (void)SC_ATOMIC_SET(slot->slot_data, slot_data);
-        }
-
-        /* if the flowworker module is the first, get the threads input queue */
-        if (slot == (TmSlot *)tv->tm_slots && (slot->tm_id == TMM_FLOWWORKER)) {
-            tv->stream_pq = tv->inq->pq;
-            tv->tm_flowworker = slot;
-            SCLogDebug("pre-stream packetqueue %p (inq)", tv->stream_pq);
-        /* setup a queue */
-        } else if (slot->tm_id == TMM_FLOWWORKER) {
-            tv->stream_pq_local = SCCalloc(1, sizeof(PacketQueue));
-            if (tv->stream_pq_local == NULL)
-                FatalError(SC_ERR_MEM_ALLOC, "failed to alloc PacketQueue");
-            SCMutexInit(&tv->stream_pq_local->mutex_q, NULL);
-            tv->stream_pq = tv->stream_pq_local;
-            tv->tm_flowworker = slot;
-            SCLogDebug("pre-stream packetqueue %p (local)", tv->stream_pq);
-        }
-    }
-
-    StatsSetupPrivate(tv);
-
-    TmThreadsSetFlag(tv, THV_INIT_DONE);
-
-    while(run) {
-        /* run right away */
-
-        r = s->PktAcqLoop(tv, SC_ATOMIC_GET(s->slot_data), s);
-
-        if (r == TM_ECODE_FAILED) {
-            TmThreadsSetFlag(tv, THV_FAILED);
-            run = 0;
-        }
-        if (TmThreadsCheckFlag(tv, THV_KILL_PKTACQ) || suricata_ctl_flags) {
-            run = 0;
-        }
-        if (r == TM_ECODE_DONE) {
-            run = 0;
-        }
-    }
-    StatsSyncCounters(tv);
-
-    TmThreadsSetFlag(tv, THV_FLOW_LOOP);
-
-    TmThreadsSetFlag(tv, THV_RUNNING_DONE);
-
-    PacketPoolDestroy();
-
-    for (slot = s; slot != NULL; slot = slot->slot_next) {
-        if (slot->SlotThreadExitPrintStats != NULL) {
-            slot->SlotThreadExitPrintStats(tv, SC_ATOMIC_GET(slot->slot_data));
-        }
-
-        if (slot->SlotThreadDeinit != NULL) {
-            r = slot->SlotThreadDeinit(tv, SC_ATOMIC_GET(slot->slot_data));
-            if (r != TM_ECODE_OK) {
-                TmThreadsSetFlag(tv, THV_CLOSED);
-                goto error;
-            }
-        }
-    }
-
-    tv->stream_pq = NULL;
-    SCLogDebug("%s ending", tv->name);
-    TmThreadsSetFlag(tv, THV_CLOSED);
-    return NULL;
-
-error:
-    tv->stream_pq = NULL;
-    return NULL;
-}
-#endif
-
 static void *TmThreadsSlotVar(void *td)
 {
     ThreadVars *tv = (ThreadVars *)td;
@@ -688,11 +570,7 @@ static TmEcode TmThreadSetSlots(ThreadVars *tv, const char *name, void *(*fn_p)(
     if (strcmp(name, "varslot") == 0) {
         tv->tm_func = TmThreadsSlotVar;
     } else if (strcmp(name, "pktacqloop") == 0) {
-#ifndef AFLFUZZ_PCAP_RUNMODE
         tv->tm_func = TmThreadsSlotPktAcqLoop;
-#else
-        tv->tm_func = TmThreadsSlotPktAcqLoopAFL;
-#endif
     } else if (strcmp(name, "management") == 0) {
         tv->tm_func = TmThreadsManagement;
     } else if (strcmp(name, "command") == 0) {
index 5c0ae1b2856bb79516ee4b51ac3ba21824d5b4db..cb6ae8d489e056979edbebf24d570dfe8591a239 100644 (file)
@@ -2678,65 +2678,6 @@ MimeDecEntity * MimeDecParseFullMsg(const uint8_t *buf, uint32_t blen, void *dat
     return msg;
 }
 
-#ifdef AFLFUZZ_MIME
-static int MimeParserDataFromFileCB(const uint8_t *chunk, uint32_t len,
-        MimeDecParseState *state)
-{
-    return MIME_DEC_OK;
-}
-
-int MimeParserDataFromFile(char *filename)
-{
-    int result = 1;
-    uint8_t buffer[256];
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    while (__AFL_LOOP(1000)) {
-        /* reset state */
-        memset(buffer, 0, sizeof(buffer));
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-        FILE *fp = fopen(filename, "r");
-        BUG_ON(fp == NULL);
-
-        uint32_t line_count = 0;
-
-        MimeDecParseState *state = MimeDecInitParser(&line_count,
-                MimeParserDataFromFileCB);
-
-        while (1) {
-            int done = 0;
-            size_t size = fread(&buffer, 1, sizeof(buffer), fp);
-            if (size < sizeof(buffer))
-                done = 1;
-
-            (void) MimeDecParseLine(buffer, size, 1, state);
-
-            if (done)
-                break;
-        }
-
-        /* Completed */
-        (void)MimeDecParseComplete(state);
-
-        if (state->msg) {
-            MimeDecFreeEntity(state->msg);
-        }
-
-        /* De Init parser */
-        MimeDecDeInitParser(state);
-
-        fclose(fp);
-
-#ifdef AFLFUZZ_PERSISTANT_MODE
-    }
-#endif /* AFLFUZZ_PERSISTANT_MODE */
-
-    result = 0;
-    return result;
-}
-#endif /* AFLFUZZ_MIME */
-
 #ifdef UNITTESTS
 
 /* Helper body chunk callback function */
index 80bb96c23450f8c8a23c1ff3e971aa11254074e0..29dd75bc2c00c95784419e77fb4098ec48ca006f 100644 (file)
@@ -241,10 +241,6 @@ MimeDecEntity * MimeDecParseFullMsg(const uint8_t *buf, uint32_t blen, void *dat
         int (*DataChunkProcessorFunc)(const uint8_t *chunk, uint32_t len, MimeDecParseState *state));
 const char *MimeDecParseStateGetStatus(MimeDecParseState *state);
 
-#ifdef AFLFUZZ_MIME
-int MimeParserDataFromFile(char *filename);
-#endif
-
 /* Test functions */
 void MimeDecRegisterTests(void);