fuzz: extend fuzzing coverage (#2208)
This commit is contained in:
@@ -86,6 +86,9 @@
|
|||||||
/fuzz/fuzz_ndpi_reader_payload_analyzer
|
/fuzz/fuzz_ndpi_reader_payload_analyzer
|
||||||
/fuzz/fuzz_filecfg_protocols
|
/fuzz/fuzz_filecfg_protocols
|
||||||
/fuzz/fuzz_filecfg_categories
|
/fuzz/fuzz_filecfg_categories
|
||||||
|
/fuzz/fuzz_filecfg_malicious_sha1
|
||||||
|
/fuzz/fuzz_filecfg_malicious_ja3
|
||||||
|
/fuzz/fuzz_filecfg_risk_domains
|
||||||
/fuzz/fuzz_readerutils_workflow
|
/fuzz/fuzz_readerutils_workflow
|
||||||
/fuzz/fuzz_readerutils_parseprotolist
|
/fuzz/fuzz_readerutils_parseprotolist
|
||||||
/fuzz/fuzz_ndpi_reader_alloc_fail_seed_corpus.zip
|
/fuzz/fuzz_ndpi_reader_alloc_fail_seed_corpus.zip
|
||||||
@@ -114,6 +117,9 @@
|
|||||||
/fuzz/fuzz_tls_certificate_seed_corpus.zip
|
/fuzz/fuzz_tls_certificate_seed_corpus.zip
|
||||||
/fuzz/fuzz_filecfg_protocols_seed_corpus.zip
|
/fuzz/fuzz_filecfg_protocols_seed_corpus.zip
|
||||||
/fuzz/fuzz_filecfg_categories_seed_corpus.zip
|
/fuzz/fuzz_filecfg_categories_seed_corpus.zip
|
||||||
|
/fuzz/fuzz_filecfg_malicious_sha1_seed_corpus.zip
|
||||||
|
/fuzz/fuzz_filecfg_malicious_ja3_seed_corpus.zip
|
||||||
|
/fuzz/fuzz_filecfg_risk_domains_seed_corpus.zip
|
||||||
/fuzz/fuzz_dga_seed_corpus.zip
|
/fuzz/fuzz_dga_seed_corpus.zip
|
||||||
/fuzz/fuzz_ndpi_reader_payload_analyzer_seed_corpus.zip
|
/fuzz/fuzz_ndpi_reader_payload_analyzer_seed_corpus.zip
|
||||||
/fuzz/fuzz_readerutils_workflow_seed_corpus.zip
|
/fuzz/fuzz_readerutils_workflow_seed_corpus.zip
|
||||||
|
|||||||
+58
-4
@@ -8,7 +8,7 @@ bin_PROGRAMS += fuzz_libinjection fuzz_binaryfusefilter
|
|||||||
#Internal crypto
|
#Internal crypto
|
||||||
bin_PROGRAMS += fuzz_gcrypt_light fuzz_gcrypt_aes fuzz_gcrypt_gcm fuzz_gcrypt_cipher
|
bin_PROGRAMS += fuzz_gcrypt_light fuzz_gcrypt_aes fuzz_gcrypt_gcm fuzz_gcrypt_cipher
|
||||||
#Configuration files
|
#Configuration files
|
||||||
bin_PROGRAMS += fuzz_filecfg_protocols fuzz_filecfg_categories
|
bin_PROGRAMS += fuzz_filecfg_protocols fuzz_filecfg_categories fuzz_filecfg_malicious_sha1 fuzz_filecfg_malicious_ja3 fuzz_filecfg_risk_domains
|
||||||
#Reader utils
|
#Reader utils
|
||||||
bin_PROGRAMS += fuzz_readerutils_workflow fuzz_readerutils_parseprotolist
|
bin_PROGRAMS += fuzz_readerutils_workflow fuzz_readerutils_parseprotolist
|
||||||
|
|
||||||
@@ -499,7 +499,7 @@ fuzz_gcrypt_cipher_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|||||||
$(fuzz_gcrypt_cipher_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
$(fuzz_gcrypt_cipher_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
fuzz_filecfg_protocols_SOURCES = fuzz_filecfg_protocols.c fuzz_common_code.c
|
fuzz_filecfg_protocols_SOURCES = fuzz_filecfg_protocols.c fuzz_common_code.c
|
||||||
fuzz_filecfg_protocols_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS)
|
fuzz_filecfg_protocols_CFLAGS = -I../src/lib/ @NDPI_CFLAGS@ $(CXXFLAGS) -DNDPI_LIB_COMPILATION
|
||||||
fuzz_filecfg_protocols_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
fuzz_filecfg_protocols_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||||
fuzz_filecfg_protocols_LDFLAGS = $(LIBS)
|
fuzz_filecfg_protocols_LDFLAGS = $(LIBS)
|
||||||
if HAS_FUZZLDFLAGS
|
if HAS_FUZZLDFLAGS
|
||||||
@@ -512,7 +512,7 @@ fuzz_filecfg_protocols_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|||||||
$(fuzz_filecfg_protocols_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
$(fuzz_filecfg_protocols_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
fuzz_filecfg_categories_SOURCES = fuzz_filecfg_categories.c fuzz_common_code.c
|
fuzz_filecfg_categories_SOURCES = fuzz_filecfg_categories.c fuzz_common_code.c
|
||||||
fuzz_filecfg_categories_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS)
|
fuzz_filecfg_categories_CFLAGS = -I../src/lib/ @NDPI_CFLAGS@ $(CXXFLAGS) -DNDPI_LIB_COMPILATION
|
||||||
fuzz_filecfg_categories_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
fuzz_filecfg_categories_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||||
fuzz_filecfg_categories_LDFLAGS = $(LIBS)
|
fuzz_filecfg_categories_LDFLAGS = $(LIBS)
|
||||||
if HAS_FUZZLDFLAGS
|
if HAS_FUZZLDFLAGS
|
||||||
@@ -524,6 +524,45 @@ fuzz_filecfg_categories_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
|||||||
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||||
$(fuzz_filecfg_categories_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
$(fuzz_filecfg_categories_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
fuzz_filecfg_malicious_sha1_SOURCES = fuzz_filecfg_malicious_sha1.c fuzz_common_code.c
|
||||||
|
fuzz_filecfg_malicious_sha1_CFLAGS = -I../src/lib/ @NDPI_CFLAGS@ $(CXXFLAGS) -DNDPI_LIB_COMPILATION
|
||||||
|
fuzz_filecfg_malicious_sha1_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||||
|
fuzz_filecfg_malicious_sha1_LDFLAGS = $(LIBS)
|
||||||
|
if HAS_FUZZLDFLAGS
|
||||||
|
fuzz_filecfg_malicious_sha1_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||||
|
fuzz_filecfg_malicious_sha1_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||||
|
endif
|
||||||
|
# force usage of CXX for linker
|
||||||
|
fuzz_filecfg_malicious_sha1_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
|
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||||
|
$(fuzz_filecfg_malicious_sha1_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
fuzz_filecfg_malicious_ja3_SOURCES = fuzz_filecfg_malicious_ja3.c fuzz_common_code.c
|
||||||
|
fuzz_filecfg_malicious_ja3_CFLAGS = -I../src/lib/ @NDPI_CFLAGS@ $(CXXFLAGS) -DNDPI_LIB_COMPILATION
|
||||||
|
fuzz_filecfg_malicious_ja3_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||||
|
fuzz_filecfg_malicious_ja3_LDFLAGS = $(LIBS)
|
||||||
|
if HAS_FUZZLDFLAGS
|
||||||
|
fuzz_filecfg_malicious_ja3_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||||
|
fuzz_filecfg_malicious_ja3_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||||
|
endif
|
||||||
|
# force usage of CXX for linker
|
||||||
|
fuzz_filecfg_malicious_ja3_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
|
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||||
|
$(fuzz_filecfg_malicious_ja3_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
fuzz_filecfg_risk_domains_SOURCES = fuzz_filecfg_risk_domains.c fuzz_common_code.c
|
||||||
|
fuzz_filecfg_risk_domains_CFLAGS = -I../src/lib/ @NDPI_CFLAGS@ $(CXXFLAGS) -DNDPI_LIB_COMPILATION
|
||||||
|
fuzz_filecfg_risk_domains_LDADD = ../src/lib/libndpi.a $(ADDITIONAL_LIBS)
|
||||||
|
fuzz_filecfg_risk_domains_LDFLAGS = $(LIBS)
|
||||||
|
if HAS_FUZZLDFLAGS
|
||||||
|
fuzz_filecfg_risk_domains_CFLAGS += $(LIB_FUZZING_ENGINE)
|
||||||
|
fuzz_filecfg_risk_domains_LDFLAGS += $(LIB_FUZZING_ENGINE)
|
||||||
|
endif
|
||||||
|
# force usage of CXX for linker
|
||||||
|
fuzz_filecfg_risk_domains_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
|
$(LIBTOOLFLAGS) --mode=link $(CXX) @NDPI_CFLAGS@ $(AM_CXXFLAGS) $(CXXFLAGS) \
|
||||||
|
$(fuzz_filecfg_risk_domains_LDFLAGS) @NDPI_LDFLAGS@ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
fuzz_readerutils_workflow_SOURCES = fuzz_readerutils_workflow.cpp fuzz_common_code.c ../example/reader_util.c
|
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) -DDISABLE_CUSTOM_ALLOCATOR_ON_READERUTILS
|
fuzz_readerutils_workflow_CXXFLAGS = -I../example/ @NDPI_CFLAGS@ $(CXXFLAGS) -DDISABLE_CUSTOM_ALLOCATOR_ON_READERUTILS
|
||||||
fuzz_readerutils_workflow_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -DDISABLE_CUSTOM_ALLOCATOR_ON_READERUTILS
|
fuzz_readerutils_workflow_CFLAGS = @NDPI_CFLAGS@ $(CXXFLAGS) -DDISABLE_CUSTOM_ALLOCATOR_ON_READERUTILS
|
||||||
@@ -656,6 +695,18 @@ files_corpus_fuzz_filecfg_categories := $(wildcard corpus/fuzz_filecfg_categori
|
|||||||
fuzz_filecfg_categories_seed_corpus.zip: $(files_corpus_fuzz_filecfg_categories)
|
fuzz_filecfg_categories_seed_corpus.zip: $(files_corpus_fuzz_filecfg_categories)
|
||||||
zip -j fuzz_filecfg_categories_seed_corpus.zip $(files_corpus_fuzz_filecfg_categories)
|
zip -j fuzz_filecfg_categories_seed_corpus.zip $(files_corpus_fuzz_filecfg_categories)
|
||||||
|
|
||||||
|
files_corpus_fuzz_filecfg_malicious_sha1 := $(wildcard corpus/fuzz_filecfg_malicious_sha1/*)
|
||||||
|
fuzz_filecfg_malicious_sha1_seed_corpus.zip: $(files_corpus_fuzz_filecfg_malicious_sha1)
|
||||||
|
zip -j fuzz_filecfg_malicious_sha1_seed_corpus.zip $(files_corpus_fuzz_filecfg_malicious_sha1)
|
||||||
|
|
||||||
|
files_corpus_fuzz_filecfg_malicious_ja3 := $(wildcard corpus/fuzz_filecfg_malicious_ja3/*)
|
||||||
|
fuzz_filecfg_malicious_ja3_seed_corpus.zip: $(files_corpus_fuzz_filecfg_malicious_ja3)
|
||||||
|
zip -j fuzz_filecfg_malicious_ja3_seed_corpus.zip $(files_corpus_fuzz_filecfg_malicious_ja3)
|
||||||
|
|
||||||
|
files_corpus_fuzz_filecfg_risk_domains := $(wildcard corpus/fuzz_filecfg_risk_domains/*)
|
||||||
|
fuzz_filecfg_risk_domains_seed_corpus.zip: $(files_corpus_fuzz_filecfg_risk_domains)
|
||||||
|
zip -j fuzz_filecfg_risk_domains_seed_corpus.zip $(files_corpus_fuzz_filecfg_risk_domains)
|
||||||
|
|
||||||
files_corpus_fuzz_readerutils_workflow := $(wildcard corpus/fuzz_readerutils_workflow/*)
|
files_corpus_fuzz_readerutils_workflow := $(wildcard corpus/fuzz_readerutils_workflow/*)
|
||||||
fuzz_readerutils_workflow_seed_corpus.zip: $(files_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)
|
zip -j fuzz_readerutils_workflow_seed_corpus.zip $(files_corpus_fuzz_readerutils_workflow)
|
||||||
@@ -672,7 +723,7 @@ files_corpus_fuzz_ds_domain_classify := $(wildcard corpus/fuzz_ds_domain_classi
|
|||||||
fuzz_ds_domain_classify_seed_corpus.zip: $(files_corpus_fuzz_ds_domain_classify)
|
fuzz_ds_domain_classify_seed_corpus.zip: $(files_corpus_fuzz_ds_domain_classify)
|
||||||
zip -j fuzz_ds_domain_classify_seed_corpus.zip $(files_corpus_fuzz_ds_domain_classify)
|
zip -j fuzz_ds_domain_classify_seed_corpus.zip $(files_corpus_fuzz_ds_domain_classify)
|
||||||
|
|
||||||
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 fuzz_ds_bitmap64_seed_corpus.zip fuzz_ds_domain_classify_seed_corpus.zip fuzz_filecfg_protocols_seed_corpus.zip fuzz_is_stun_udp_seed_corpus.zip fuzz_is_stun_tcp_seed_corpus.zip
|
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 fuzz_ds_bitmap64_seed_corpus.zip fuzz_ds_domain_classify_seed_corpus.zip fuzz_filecfg_protocols_seed_corpus.zip fuzz_is_stun_udp_seed_corpus.zip fuzz_is_stun_tcp_seed_corpus.zip fuzz_filecfg_malicious_sha1_seed_corpus.zip fuzz_filecfg_malicious_ja3_seed_corpus.zip fuzz_filecfg_risk_domains_seed_corpus.zip
|
||||||
cp corpus/fuzz_*seed_corpus.zip .
|
cp corpus/fuzz_*seed_corpus.zip .
|
||||||
|
|
||||||
#Create dictionaries exactly as expected by oss-fuzz.
|
#Create dictionaries exactly as expected by oss-fuzz.
|
||||||
@@ -702,6 +753,9 @@ distdir:
|
|||||||
-o -path './corpus/fuzz_quic_get_crypto_data/*' \
|
-o -path './corpus/fuzz_quic_get_crypto_data/*' \
|
||||||
-o -path './corpus/fuzz_filecfg_protocols/*' \
|
-o -path './corpus/fuzz_filecfg_protocols/*' \
|
||||||
-o -path './corpus/fuzz_filecfg_categories/*' \
|
-o -path './corpus/fuzz_filecfg_categories/*' \
|
||||||
|
-o -path './corpus/fuzz_filecfg_malicious_sha1/*' \
|
||||||
|
-o -path './corpus/fuzz_filecfg_malicious_ja3/*' \
|
||||||
|
-o -path './corpus/fuzz_filecfg_risk_domains/*' \
|
||||||
-o -path './corpus/fuzz_readerutils_workflow/*' \
|
-o -path './corpus/fuzz_readerutils_workflow/*' \
|
||||||
-o -path './corpus/fuzz_readerutils_parseprotolist/*' \
|
-o -path './corpus/fuzz_readerutils_parseprotolist/*' \
|
||||||
-o -path './corpus/fuzz_config/*' \
|
-o -path './corpus/fuzz_config/*' \
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# ja3_md5,Firstseen,Lastseen,Listingreason
|
||||||
|
b386946a5a44d1ddcc843bc75336dfce,2017-07-14 18:08:15,2019-07-27 20:42:54,Dridex
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
8991a387e4cc841740f25d6f5139f92d8991a387e4cc841740f25d6f5139f92d,2017-07-14 19:02:03,2019-07-28 00:34:38,Adware
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#The first entry (and only the first one) is fake. It is used to trigger the risk in the tests
|
||||||
|
1970-01-01 00:00:00,0DDB34F875632C7E1EC09D75827F82D2336DFEB6, Fake
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
2022-07-02 07:02:11,3784422d67a6ae0c82d60eeaf3850960a9896cb22,AsyncRAT C&C
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# https://www.spamhaus.org/statistics/tlds/
|
||||||
|
.fail
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "ndpi_api.h"
|
#include "ndpi_api.h"
|
||||||
|
#include "ndpi_private.h"
|
||||||
#include "fuzz_common_code.h"
|
#include "fuzz_common_code.h"
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
@@ -35,7 +36,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||||
|
|
||||||
fd = buffer_to_file(data, size);
|
fd = buffer_to_file(data, size);
|
||||||
ndpi_load_categories_file_fd(ndpi_struct, fd, NULL);
|
load_categories_file_fd(ndpi_struct, fd, NULL);
|
||||||
if(fd)
|
if(fd)
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#include "ndpi_api.h"
|
||||||
|
#include "ndpi_private.h"
|
||||||
|
#include "fuzz_common_code.h"
|
||||||
|
|
||||||
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
|
struct ndpi_detection_module_struct *ndpi_struct;
|
||||||
|
FILE *fd;
|
||||||
|
/* Try to be fast */
|
||||||
|
ndpi_init_prefs prefs = ndpi_dont_load_tor_list |
|
||||||
|
ndpi_dont_load_azure_list |
|
||||||
|
ndpi_dont_load_whatsapp_list |
|
||||||
|
ndpi_dont_load_amazon_aws_list |
|
||||||
|
ndpi_dont_load_ethereum_list |
|
||||||
|
ndpi_dont_load_zoom_list |
|
||||||
|
ndpi_dont_load_cloudflare_list |
|
||||||
|
ndpi_dont_load_microsoft_list |
|
||||||
|
ndpi_dont_load_google_list |
|
||||||
|
ndpi_dont_load_google_cloud_list |
|
||||||
|
ndpi_dont_load_asn_lists |
|
||||||
|
ndpi_dont_init_risk_ptree |
|
||||||
|
ndpi_dont_load_cachefly_list |
|
||||||
|
ndpi_dont_load_protonvpn_list |
|
||||||
|
ndpi_dont_load_mullvad_list;
|
||||||
|
NDPI_PROTOCOL_BITMASK all;
|
||||||
|
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||||
|
|
||||||
|
/* To allow memory allocation failures */
|
||||||
|
fuzz_set_alloc_callbacks_and_seed(size);
|
||||||
|
|
||||||
|
ndpi_struct = ndpi_init_detection_module(prefs);
|
||||||
|
NDPI_BITMASK_SET_ALL(all);
|
||||||
|
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||||
|
|
||||||
|
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||||
|
ndpi_set_log_level(ndpi_struct, 4);
|
||||||
|
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||||
|
|
||||||
|
fd = buffer_to_file(data, size);
|
||||||
|
load_malicious_ja3_file_fd(ndpi_struct, fd);
|
||||||
|
if(fd)
|
||||||
|
fclose(fd);
|
||||||
|
|
||||||
|
/* We don't really need to call ndpi_finalize_initialization */
|
||||||
|
|
||||||
|
ndpi_exit_detection_module(ndpi_struct);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#include "ndpi_api.h"
|
||||||
|
#include "ndpi_private.h"
|
||||||
|
#include "fuzz_common_code.h"
|
||||||
|
|
||||||
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
|
struct ndpi_detection_module_struct *ndpi_struct;
|
||||||
|
FILE *fd;
|
||||||
|
/* Try to be fast */
|
||||||
|
ndpi_init_prefs prefs = ndpi_dont_load_tor_list |
|
||||||
|
ndpi_dont_load_azure_list |
|
||||||
|
ndpi_dont_load_whatsapp_list |
|
||||||
|
ndpi_dont_load_amazon_aws_list |
|
||||||
|
ndpi_dont_load_ethereum_list |
|
||||||
|
ndpi_dont_load_zoom_list |
|
||||||
|
ndpi_dont_load_cloudflare_list |
|
||||||
|
ndpi_dont_load_microsoft_list |
|
||||||
|
ndpi_dont_load_google_list |
|
||||||
|
ndpi_dont_load_google_cloud_list |
|
||||||
|
ndpi_dont_load_asn_lists |
|
||||||
|
ndpi_dont_init_risk_ptree |
|
||||||
|
ndpi_dont_load_cachefly_list |
|
||||||
|
ndpi_dont_load_protonvpn_list |
|
||||||
|
ndpi_dont_load_mullvad_list;
|
||||||
|
NDPI_PROTOCOL_BITMASK all;
|
||||||
|
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||||
|
|
||||||
|
/* To allow memory allocation failures */
|
||||||
|
fuzz_set_alloc_callbacks_and_seed(size);
|
||||||
|
|
||||||
|
ndpi_struct = ndpi_init_detection_module(prefs);
|
||||||
|
NDPI_BITMASK_SET_ALL(all);
|
||||||
|
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||||
|
|
||||||
|
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||||
|
ndpi_set_log_level(ndpi_struct, 4);
|
||||||
|
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||||
|
|
||||||
|
fd = buffer_to_file(data, size);
|
||||||
|
load_malicious_sha1_file_fd(ndpi_struct, fd);
|
||||||
|
if(fd)
|
||||||
|
fclose(fd);
|
||||||
|
|
||||||
|
/* We don't really need to call ndpi_finalize_initialization */
|
||||||
|
|
||||||
|
ndpi_exit_detection_module(ndpi_struct);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "ndpi_api.h"
|
#include "ndpi_api.h"
|
||||||
|
#include "ndpi_private.h"
|
||||||
#include "fuzz_common_code.h"
|
#include "fuzz_common_code.h"
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
@@ -35,7 +36,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||||
|
|
||||||
fd = buffer_to_file(data, size);
|
fd = buffer_to_file(data, size);
|
||||||
ndpi_load_protocols_file_fd(ndpi_struct, fd);
|
load_protocols_file_fd(ndpi_struct, fd);
|
||||||
if(fd)
|
if(fd)
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#include "ndpi_api.h"
|
||||||
|
#include "ndpi_private.h"
|
||||||
|
#include "fuzz_common_code.h"
|
||||||
|
|
||||||
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
|
struct ndpi_detection_module_struct *ndpi_struct;
|
||||||
|
FILE *fd;
|
||||||
|
/* Try to be fast */
|
||||||
|
ndpi_init_prefs prefs = ndpi_dont_load_tor_list |
|
||||||
|
ndpi_dont_load_azure_list |
|
||||||
|
ndpi_dont_load_whatsapp_list |
|
||||||
|
ndpi_dont_load_amazon_aws_list |
|
||||||
|
ndpi_dont_load_ethereum_list |
|
||||||
|
ndpi_dont_load_zoom_list |
|
||||||
|
ndpi_dont_load_cloudflare_list |
|
||||||
|
ndpi_dont_load_microsoft_list |
|
||||||
|
ndpi_dont_load_google_list |
|
||||||
|
ndpi_dont_load_google_cloud_list |
|
||||||
|
ndpi_dont_load_asn_lists |
|
||||||
|
ndpi_dont_init_risk_ptree |
|
||||||
|
ndpi_dont_load_cachefly_list |
|
||||||
|
ndpi_dont_load_protonvpn_list |
|
||||||
|
ndpi_dont_load_mullvad_list;
|
||||||
|
NDPI_PROTOCOL_BITMASK all;
|
||||||
|
NDPI_PROTOCOL_BITMASK debug_bitmask;
|
||||||
|
|
||||||
|
/* To allow memory allocation failures */
|
||||||
|
fuzz_set_alloc_callbacks_and_seed(size);
|
||||||
|
|
||||||
|
ndpi_struct = ndpi_init_detection_module(prefs);
|
||||||
|
NDPI_BITMASK_SET_ALL(all);
|
||||||
|
ndpi_set_protocol_detection_bitmask2(ndpi_struct, &all);
|
||||||
|
|
||||||
|
NDPI_BITMASK_SET_ALL(debug_bitmask);
|
||||||
|
ndpi_set_log_level(ndpi_struct, 4);
|
||||||
|
ndpi_set_debug_bitmask(ndpi_struct, debug_bitmask);
|
||||||
|
|
||||||
|
fd = buffer_to_file(data, size);
|
||||||
|
load_risk_domain_file_fd(ndpi_struct, fd);
|
||||||
|
if(fd)
|
||||||
|
fclose(fd);
|
||||||
|
|
||||||
|
/* We don't really need to call ndpi_finalize_initialization */
|
||||||
|
|
||||||
|
ndpi_exit_detection_module(ndpi_struct);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -754,8 +754,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod,
|
int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
const char* path);
|
const char* path);
|
||||||
int ndpi_load_protocols_file_fd(struct ndpi_detection_module_struct *ndpi_mod,
|
|
||||||
FILE *fd);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an IP-address based risk mask
|
* Add an IP-address based risk mask
|
||||||
@@ -798,7 +796,6 @@ extern "C" {
|
|||||||
* -1 else
|
* -1 else
|
||||||
*/
|
*/
|
||||||
int ndpi_load_categories_file(struct ndpi_detection_module_struct *ndpi_str, const char* path, void *user_data);
|
int ndpi_load_categories_file(struct ndpi_detection_module_struct *ndpi_str, const char* path, void *user_data);
|
||||||
int ndpi_load_categories_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd, void *user_data);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a file (separated by <cr>) of domain names associated with the specified category
|
* Loads a file (separated by <cr>) of domain names associated with the specified category
|
||||||
|
|||||||
+59
-28
@@ -4460,15 +4460,15 @@ int ndpi_load_categories_file(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ndpi_load_categories_file_fd(ndpi_str, fd, user_data);
|
rc = load_categories_file_fd(ndpi_str, fd, user_data);
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ndpi_load_categories_file_fd(struct ndpi_detection_module_struct *ndpi_str,
|
int load_categories_file_fd(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
FILE *fd, void *user_data) {
|
FILE *fd, void *user_data) {
|
||||||
char buffer[512], *line, *name, *category, *saveptr;
|
char buffer[512], *line, *name, *category, *saveptr;
|
||||||
int len, num = 0;
|
int len, num = 0;
|
||||||
|
|
||||||
@@ -4678,20 +4678,32 @@ static int ndpi_load_risky_domain(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
* - you can add a .<domain name> to avoid mismatches
|
* - you can add a .<domain name> to avoid mismatches
|
||||||
*/
|
*/
|
||||||
int ndpi_load_risk_domain_file(struct ndpi_detection_module_struct *ndpi_str, const char *path) {
|
int ndpi_load_risk_domain_file(struct ndpi_detection_module_struct *ndpi_str, const char *path) {
|
||||||
char buffer[128], *line;
|
int rc;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
int len, num = 0;
|
|
||||||
|
|
||||||
if(!ndpi_str || !path)
|
if(!ndpi_str || !path)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
fd = fopen(path, "r");
|
fd = fopen(path, "r");
|
||||||
|
|
||||||
if(fd == NULL) {
|
if(fd == NULL) {
|
||||||
NDPI_LOG_ERR(ndpi_str, "Unable to open file %s [%s]\n", path, strerror(errno));
|
NDPI_LOG_ERR(ndpi_str, "Unable to open file %s [%s]\n", path, strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = load_risk_domain_file_fd(ndpi_str, fd);
|
||||||
|
|
||||||
|
fclose(fd);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_risk_domain_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd) {
|
||||||
|
char buffer[128], *line;
|
||||||
|
int len, num = 0;
|
||||||
|
|
||||||
|
if(!ndpi_str || !fd)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
line = fgets(buffer, sizeof(buffer), fd);
|
line = fgets(buffer, sizeof(buffer), fd);
|
||||||
|
|
||||||
@@ -4709,8 +4721,6 @@ int ndpi_load_risk_domain_file(struct ndpi_detection_module_struct *ndpi_str, co
|
|||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fd);
|
|
||||||
|
|
||||||
if(ndpi_str->risky_domain_automa.ac_automa)
|
if(ndpi_str->risky_domain_automa.ac_automa)
|
||||||
ac_automata_finalize((AC_AUTOMATA_t *)ndpi_str->risky_domain_automa.ac_automa);
|
ac_automata_finalize((AC_AUTOMATA_t *)ndpi_str->risky_domain_automa.ac_automa);
|
||||||
|
|
||||||
@@ -4726,22 +4736,34 @@ int ndpi_load_risk_domain_file(struct ndpi_detection_module_struct *ndpi_str, co
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int ndpi_load_malicious_ja3_file(struct ndpi_detection_module_struct *ndpi_str, const char *path) {
|
int ndpi_load_malicious_ja3_file(struct ndpi_detection_module_struct *ndpi_str, const char *path) {
|
||||||
char buffer[128], *line;
|
int rc;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
int len, num = 0;
|
|
||||||
|
|
||||||
if(!ndpi_str || !path)
|
if(!ndpi_str || !path)
|
||||||
return(-1);
|
return(-1);
|
||||||
if(ndpi_str->malicious_ja3_hashmap == NULL && ndpi_hash_init(&ndpi_str->malicious_ja3_hashmap) != 0)
|
|
||||||
return(-1);
|
|
||||||
|
|
||||||
fd = fopen(path, "r");
|
fd = fopen(path, "r");
|
||||||
|
|
||||||
if(fd == NULL) {
|
if(fd == NULL) {
|
||||||
NDPI_LOG_ERR(ndpi_str, "Unable to open file %s [%s]\n", path, strerror(errno));
|
NDPI_LOG_ERR(ndpi_str, "Unable to open file %s [%s]\n", path, strerror(errno));
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = load_malicious_ja3_file_fd(ndpi_str, fd);
|
||||||
|
|
||||||
|
fclose(fd);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_malicious_ja3_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd) {
|
||||||
|
char buffer[128], *line;
|
||||||
|
int len, num = 0;
|
||||||
|
|
||||||
|
if(!ndpi_str || !fd)
|
||||||
|
return(-1);
|
||||||
|
if(ndpi_str->malicious_ja3_hashmap == NULL && ndpi_hash_init(&ndpi_str->malicious_ja3_hashmap) != 0)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
char *comma;
|
char *comma;
|
||||||
|
|
||||||
@@ -4771,8 +4793,6 @@ int ndpi_load_malicious_ja3_file(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fd);
|
|
||||||
|
|
||||||
return(num);
|
return(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4788,24 +4808,37 @@ int ndpi_load_malicious_ja3_file(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
*/
|
*/
|
||||||
int ndpi_load_malicious_sha1_file(struct ndpi_detection_module_struct *ndpi_str, const char *path)
|
int ndpi_load_malicious_sha1_file(struct ndpi_detection_module_struct *ndpi_str, const char *path)
|
||||||
{
|
{
|
||||||
char buffer[128];
|
int rc;
|
||||||
char *first_comma, *second_comma;
|
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
size_t i, len;
|
|
||||||
int num = 0;
|
|
||||||
|
|
||||||
if(!ndpi_str || !path)
|
if(!ndpi_str || !path)
|
||||||
return(-1);
|
return(-1);
|
||||||
if(ndpi_str->malicious_sha1_hashmap == NULL && ndpi_hash_init(&ndpi_str->malicious_sha1_hashmap) != 0)
|
|
||||||
return(-1);
|
|
||||||
|
|
||||||
fd = fopen(path, "r");
|
fd = fopen(path, "r");
|
||||||
|
|
||||||
if(fd == NULL) {
|
if(fd == NULL) {
|
||||||
NDPI_LOG_ERR(ndpi_str, "Unable to open file %s [%s]\n", path, strerror(errno));
|
NDPI_LOG_ERR(ndpi_str, "Unable to open file %s [%s]\n", path, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = load_malicious_sha1_file_fd(ndpi_str, fd);
|
||||||
|
|
||||||
|
fclose(fd);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int load_malicious_sha1_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
char *first_comma, *second_comma;
|
||||||
|
size_t i, len;
|
||||||
|
int num = 0;
|
||||||
|
|
||||||
|
if(!ndpi_str || !fd)
|
||||||
|
return(-1);
|
||||||
|
if(ndpi_str->malicious_sha1_hashmap == NULL && ndpi_hash_init(&ndpi_str->malicious_sha1_hashmap) != 0)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
|
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
|
||||||
len = strlen(buffer);
|
len = strlen(buffer);
|
||||||
|
|
||||||
@@ -4836,8 +4869,6 @@ int ndpi_load_malicious_sha1_file(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fd);
|
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4874,14 +4905,14 @@ int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_str, cons
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ndpi_load_protocols_file_fd(ndpi_str, fd);
|
rc = load_protocols_file_fd(ndpi_str, fd);
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ndpi_load_protocols_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd) {
|
int load_protocols_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd) {
|
||||||
char *buffer, *old_buffer;
|
char *buffer, *old_buffer;
|
||||||
int chunk_len = 1024, buffer_len = chunk_len, old_buffer_len;
|
int chunk_len = 1024, buffer_len = chunk_len, old_buffer_len;
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -355,6 +355,12 @@ char* ndpi_intoav4(unsigned int addr, char* buf, u_int16_t bufLen);
|
|||||||
|
|
||||||
u_int16_t icmp4_checksum(u_int8_t const * const buf, size_t len);
|
u_int16_t icmp4_checksum(u_int8_t const * const buf, size_t len);
|
||||||
|
|
||||||
|
int load_protocols_file_fd(struct ndpi_detection_module_struct *ndpi_mod, FILE *fd);
|
||||||
|
int load_categories_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd, void *user_data);
|
||||||
|
int load_malicious_sha1_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd);
|
||||||
|
int load_malicious_ja3_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd);
|
||||||
|
int load_risk_domain_file_fd(struct ndpi_detection_module_struct *ndpi_str, FILE *fd);
|
||||||
|
|
||||||
|
|
||||||
/* TLS */
|
/* TLS */
|
||||||
int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
|||||||
Reference in New Issue
Block a user