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])
])
# disable TLS on user request
s->counter_ips_replaced = StatsRegisterCounter("ips.replaced", tv);
}
+#ifdef AFLFUZZ_DECODER
+int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder) {
+ int result = 1;
+ FILE *fp = fopen(filename, "r");
+ BUG_ON(fp == NULL);
+ uint8_t buffer[65536];
+
+ ThreadVars tv;
+ memset(&tv, 0, sizeof(tv));
+ DecodeThreadVars *dtv = DecodeThreadVarsAlloc(&tv);
+ DecodeRegisterPerfCounters(dtv, &tv);
+ StatsSetupPrivate(&tv);
+
+ while (1) {
+ int done = 0;
+ size_t result = fread(&buffer, 1, sizeof(buffer), fp);
+ if (result < sizeof(buffer))
+ done = 1;
+
+ Packet *p = PacketGetFromAlloc();
+ if (p != NULL) {
+ (void) Decoder (&tv, dtv, p, buffer, result, NULL);
+ PacketFree(p);
+ }
+
+ if (done)
+ break;
+ }
+ DecodeThreadVarsFree(&tv, dtv);
+
+ result = 0;
+ fclose(fp);
+ return result;
+
+}
+#endif
+
/**
* @}
*/
void AddressDebugPrint(Address *);
+#ifdef AFLFUZZ_DECODER
+typedef int (*DecoderFunc)(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
+ uint8_t *pkt, uint16_t len, PacketQueue *pq);
+
+int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder);
+#endif
+
/** \brief Set the No payload inspection Flag for the packet.
*
* \param p Packet to set the flag in
{"afl-modbus-request", required_argument, 0 , 0},
{"afl-modbus", required_argument, 0 , 0},
{"afl-mime", required_argument, 0 , 0},
+
+ {"afl-decoder-ppp", required_argument, 0 , 0},
#ifdef BUILD_UNIX_SOCKET
{"unix-socket", optional_argument, 0, 0},
#endif
} else if(strcmp((long_opts[option_index]).name, "afl-mime") == 0) {
//printf("arg: //%s\n", optarg);
exit(MimeParserDataFromFile(optarg));
+#endif
+#ifdef AFLFUZZ_DECODER
+ } else if(strcmp((long_opts[option_index]).name, "afl-decoder-ppp") == 0) {
+ StatsInit();
+ MpmTableSetup();
+ AppLayerProtoDetectSetup();
+ DefragInit();
+ FlowInitConfig(FLOW_QUIET);
+ //printf("arg: //%s\n", optarg);
+ exit(DecoderParseDataFromFile(optarg, DecodePPP));
#endif
} else if(strcmp((long_opts[option_index]).name, "simulate-ips") == 0) {
SCLogInfo("Setting IPS mode");