fuzz: add fuzzers to test reader_util code (#2080)
This commit is contained in:
@@ -77,6 +77,8 @@
|
||||
/fuzz/fuzz_gcrypt_light
|
||||
/fuzz/fuzz_ndpi_reader_payload_analyzer
|
||||
/fuzz/fuzz_filecfg_protocols
|
||||
/fuzz/fuzz_readerutils_workflow
|
||||
/fuzz/fuzz_readerutils_parseprotolist
|
||||
/fuzz/fuzz_ndpi_reader_alloc_fail_seed_corpus.zip
|
||||
/fuzz/fuzz_ndpi_reader_seed_corpus.zip
|
||||
/fuzz/fuzz_quic_get_crypto_data_seed_corpus.zip
|
||||
@@ -100,6 +102,8 @@
|
||||
/fuzz/fuzz_filecfg_protocols_seed_corpus.zip
|
||||
/fuzz/fuzz_dga_seed_corpus.zip
|
||||
/fuzz/fuzz_ndpi_reader_payload_analyzer_seed_corpus.zip
|
||||
/fuzz/fuzz_readerutils_workflow_seed_corpus.zip
|
||||
/fuzz/fuzz_readerutils_parseprotolist_seed_corpus.zip
|
||||
/fuzz/fuzz_*.dict
|
||||
/influxdb/Makefile
|
||||
/install-sh
|
||||
|
||||
@@ -436,7 +436,7 @@ int parse_proto_name_list(char *str, NDPI_PROTOCOL_BITMASK *bitmask, int inverte
|
||||
}
|
||||
proto = ndpi_get_proto_id(module, n);
|
||||
if(proto == NDPI_PROTOCOL_UNKNOWN && strcmp(n,"unknown") && strcmp(n,"0")) {
|
||||
fprintf(stderr,"Invalid protocol %s\n",n);
|
||||
LOG(NDPI_LOG_ERROR, "Invalid protocol %s\n", n);
|
||||
ndpi_exit_detection_module(module);
|
||||
return 1;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref
|
||||
workflow = ndpi_calloc(1, sizeof(struct ndpi_workflow));
|
||||
if(workflow == NULL) {
|
||||
LOG(NDPI_LOG_ERROR, "global structure initialization failed\n");
|
||||
ndpi_free(module);
|
||||
ndpi_exit_detection_module(module);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -489,8 +489,11 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref
|
||||
|
||||
if(_debug_protocols != NULL && ! _debug_protocols_ok) {
|
||||
NDPI_BITMASK_RESET(debug_bitmask);
|
||||
if(parse_proto_name_list(_debug_protocols, &debug_bitmask, 0))
|
||||
exit(-1);
|
||||
if(parse_proto_name_list(_debug_protocols, &debug_bitmask, 0)) {
|
||||
ndpi_exit_detection_module(module);
|
||||
ndpi_free(workflow);
|
||||
return NULL;
|
||||
}
|
||||
_debug_protocols_ok = 1;
|
||||
}
|
||||
if(_debug_protocols_ok)
|
||||
|
||||
@@ -93,6 +93,10 @@ extern int dpdk_port_deinit(int port);
|
||||
#define SERIALIZATION_BUFSIZ (8192 * 2)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// inner hash table (ja3 -> security state)
|
||||
typedef struct ndpi_ja3_info {
|
||||
char * ja3;
|
||||
@@ -408,6 +412,7 @@ void ndpi_flow_info_free_data(struct ndpi_flow_info *flow);
|
||||
void ndpi_flow_info_freer(void *node);
|
||||
const char* print_cipher_id(u_int32_t cipher);
|
||||
double ndpi_flow_get_byte_count_entropy(const uint32_t byte_count[256], unsigned int num_bytes);
|
||||
int parse_proto_name_list(char *str, NDPI_PROTOCOL_BITMASK *bitmask, int inverted_logic);
|
||||
|
||||
extern int nDPI_LogLevel;
|
||||
|
||||
@@ -425,4 +430,8 @@ extern int nDPI_LogLevel;
|
||||
#define LINKTYPE_LINUX_SLL2 276
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+45
-1
@@ -9,6 +9,8 @@ bin_PROGRAMS += fuzz_libinjection
|
||||
bin_PROGRAMS += fuzz_gcrypt_light
|
||||
#Configuration files
|
||||
bin_PROGRAMS += fuzz_filecfg_protocols
|
||||
#Reader utils
|
||||
bin_PROGRAMS += fuzz_readerutils_workflow fuzz_readerutils_parseprotolist
|
||||
|
||||
fuzz_process_packet_SOURCES = fuzz_process_packet.c fuzz_common_code.c
|
||||
fuzz_process_packet_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS)
|
||||
@@ -393,6 +395,36 @@ fuzz_filecfg_protocols_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_filecfg_protocols_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||
|
||||
fuzz_readerutils_workflow_SOURCES = fuzz_readerutils_workflow.cpp fuzz_common_code.c ../example/reader_util.c
|
||||
fuzz_readerutils_workflow_CXXFLAGS = -I../example/ @NDPI_CFLAGS@ $(CXXFLAGS)
|
||||
fuzz_readerutils_workflow_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS)
|
||||
fuzz_readerutils_workflow_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||
fuzz_readerutils_workflow_LDFLAGS = $(PCAP_LIB) $(LIBS)
|
||||
if HAS_FUZZLDFLAGS
|
||||
fuzz_readerutils_workflow_CXXFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_readerutils_workflow_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_readerutils_workflow_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
endif
|
||||
# force usage of CXX for linker
|
||||
fuzz_readerutils_workflow_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_readerutils_workflow_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||
|
||||
fuzz_readerutils_parseprotolist_SOURCES = fuzz_readerutils_parseprotolist.cpp fuzz_common_code.c ../example/reader_util.c
|
||||
fuzz_readerutils_parseprotolist_CXXFLAGS = -I../example/ @NDPI_CFLAGS@ $(CXXFLAGS)
|
||||
fuzz_readerutils_parseprotolist_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS)
|
||||
fuzz_readerutils_parseprotolist_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||
fuzz_readerutils_parseprotolist_LDFLAGS = $(PCAP_LIB) $(LIBS)
|
||||
if HAS_FUZZLDFLAGS
|
||||
fuzz_readerutils_parseprotolist_CXXFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_readerutils_parseprotolist_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
fuzz_readerutils_parseprotolist_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||
endif
|
||||
# force usage of CXX for linker
|
||||
fuzz_readerutils_parseprotolist_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||
$(fuzz_readerutils_parseprotolist_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||
|
||||
|
||||
# required for Google oss-fuzz
|
||||
# see https://github.com/google/oss-fuzz/tree/master/projects/ndpi
|
||||
@@ -502,7 +534,17 @@ files_corpus_fuzz_filecfg_protocols := $(wildcard corpus/fuzz_filecfg_protocols
|
||||
fuzz_filecfg_protocols_seed_corpus.zip: $(files_corpus_fuzz_filecfg_protocols)
|
||||
zip -j fuzz_filecfg_protocols_seed_corpus.zip $(files_corpus_fuzz_filecfg_protocols)
|
||||
|
||||
corpus: fuzz_ndpi_reader_seed_corpus.zip fuzz_ndpi_reader_alloc_fail_seed_corpus.zip fuzz_ndpi_reader_payload_analyzer_seed_corpus.zip fuzz_quic_get_crypto_data_seed_corpus.zip fuzz_config_seed_corpus.zip fuzz_ds_patricia_seed_corpus.zip fuzz_ds_ahocorasick_seed_corpus.zip fuzz_alg_ses_des_seed_corpus.zip fuzz_alg_hw_rsi_outliers_da_seed_corpus.zip fuzz_alg_bins_seed_corpus.zip fuzz_alg_hll_seed_corpus.zip fuzz_alg_jitter_seed_corpus.zip fuzz_ds_libcache_seed_corpus.zip fuzz_community_id_seed_corpus.zip fuzz_ds_tree_seed_corpus.zip fuzz_serialization_seed_corpus.zip fuzz_ds_ptree_seed_corpus.zip fuzz_alg_crc32_md5_seed_corpus.zip fuzz_alg_bytestream_seed_corpus.zip fuzz_libinjection_seed_corpus.zip fuzz_tls_certificate_seed_corpus.zip fuzz_filecfg_protocols_seed_corpus.zip
|
||||
files_corpus_fuzz_readerutils_workflow := $(wildcard corpus/fuzz_readerutils_workflow/*)
|
||||
|
||||
fuzz_readerutils_workflow_seed_corpus.zip: $(files_corpus_fuzz_readerutils_workflow)
|
||||
zip -j fuzz_readerutils_workflow_seed_corpus.zip $(files_corpus_fuzz_readerutils_workflow)
|
||||
|
||||
files_corpus_fuzz_readerutils_parseprotolist := $(wildcard corpus/fuzz_readerutils_parseprotolist/*)
|
||||
|
||||
fuzz_readerutils_parseprotolist_seed_corpus.zip: $(files_corpus_fuzz_readerutils_parseprotolist)
|
||||
zip -j fuzz_readerutils_parseprotolist_seed_corpus.zip $(files_corpus_fuzz_readerutils_parseprotolist)
|
||||
|
||||
corpus: fuzz_ndpi_reader_seed_corpus.zip fuzz_ndpi_reader_alloc_fail_seed_corpus.zip fuzz_ndpi_reader_payload_analyzer_seed_corpus.zip fuzz_quic_get_crypto_data_seed_corpus.zip fuzz_config_seed_corpus.zip fuzz_ds_patricia_seed_corpus.zip fuzz_ds_ahocorasick_seed_corpus.zip fuzz_alg_ses_des_seed_corpus.zip fuzz_alg_hw_rsi_outliers_da_seed_corpus.zip fuzz_alg_bins_seed_corpus.zip fuzz_alg_hll_seed_corpus.zip fuzz_alg_jitter_seed_corpus.zip fuzz_ds_libcache_seed_corpus.zip fuzz_community_id_seed_corpus.zip fuzz_ds_tree_seed_corpus.zip fuzz_serialization_seed_corpus.zip fuzz_ds_ptree_seed_corpus.zip fuzz_alg_crc32_md5_seed_corpus.zip fuzz_alg_bytestream_seed_corpus.zip fuzz_libinjection_seed_corpus.zip fuzz_tls_certificate_seed_corpus.zip fuzz_filecfg_protocols_seed_corpus.zip fuzz_readerutils_workflow_seed_corpus.zip fuzz_readerutils_parseprotolist_seed_corpus.zip
|
||||
cp corpus/fuzz_*seed_corpus.zip .
|
||||
|
||||
#Create dictionaries exactly as expected by oss-fuzz.
|
||||
@@ -529,6 +571,8 @@ distdir:
|
||||
-o -path './corpus/fuzz_*.zip' \
|
||||
-o -path './corpus/fuzz_quic_get_crypto_data/*' \
|
||||
-o -path './corpus/fuzz_filecfg_protocols/*' \
|
||||
-o -path './corpus/fuzz_readerutils_workflow/*' \
|
||||
-o -path './corpus/fuzz_readerutils_parseprotolist/*' \
|
||||
-o -path './corpus/fuzz_config/*' \
|
||||
-o -path './corpus/fuzz_serialization/*' \
|
||||
-o -path './corpus/fuzz_community_id/*' \
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
all
|
||||
@@ -0,0 +1 @@
|
||||
foo
|
||||
@@ -0,0 +1 @@
|
||||
-,"ovpn,"
|
||||
@@ -0,0 +1 @@
|
||||
foo
|
||||
@@ -0,0 +1 @@
|
||||
foo bar
|
||||
@@ -0,0 +1 @@
|
||||
-openvpn
|
||||
@@ -0,0 +1 @@
|
||||
-openvpn;
|
||||
@@ -0,0 +1 @@
|
||||
-openvpn;all
|
||||
@@ -0,0 +1 @@
|
||||
-http\t--dns
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
all;
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
-ovpn
|
||||
@@ -0,0 +1 @@
|
||||
quic;http
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
quic;„p,
|
||||
@@ -0,0 +1 @@
|
||||
-ovpn
|
||||
@@ -0,0 +1 @@
|
||||
quic;http,
|
||||
@@ -0,0 +1 @@
|
||||
,quic;http,
|
||||
@@ -0,0 +1 @@
|
||||
alq
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
all;all;
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
,quic;http,+all
|
||||
@@ -0,0 +1 @@
|
||||
quic;tthttp,
|
||||
@@ -0,0 +1 @@
|
||||
,quic;http,-all
|
||||
@@ -0,0 +1 @@
|
||||
,quic;http,-a
|
||||
@@ -0,0 +1 @@
|
||||
all,+dns
|
||||
@@ -0,0 +1 @@
|
||||
-,"ovpn,"
|
||||
@@ -0,0 +1 @@
|
||||
all,unknown
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
quic,
|
||||
@@ -0,0 +1,2 @@
|
||||
all,+dns
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
OICQ foo
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
qalulij
|
||||
@@ -0,0 +1 @@
|
||||
lal
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user