diff options
Diffstat (limited to 'fuzz')
-rw-r--r-- | fuzz/fuzz_common_code.c | 6 | ||||
-rw-r--r-- | fuzz/fuzz_config.cpp | 14 | ||||
-rw-r--r-- | fuzz/fuzz_filecfg_categories.c | 8 | ||||
-rw-r--r-- | fuzz/fuzz_filecfg_malicious_ja3.c | 8 | ||||
-rw-r--r-- | fuzz/fuzz_filecfg_malicious_sha1.c | 8 | ||||
-rw-r--r-- | fuzz/fuzz_filecfg_protocols.c | 8 | ||||
-rw-r--r-- | fuzz/fuzz_filecfg_risk_domains.c | 8 | ||||
-rw-r--r-- | fuzz/fuzz_ndpi_reader.c | 8 | ||||
-rw-r--r-- | fuzz/fuzz_readerutils_workflow.cpp | 3 |
9 files changed, 29 insertions, 42 deletions
diff --git a/fuzz/fuzz_common_code.c b/fuzz/fuzz_common_code.c index 13318df37..7bda091d5 100644 --- a/fuzz/fuzz_common_code.c +++ b/fuzz/fuzz_common_code.c @@ -37,14 +37,12 @@ void fuzz_set_alloc_callbacks_and_seed(int seed) void fuzz_init_detection_module(struct ndpi_detection_module_struct **ndpi_info_mod) { NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; if(*ndpi_info_mod == NULL) { *ndpi_info_mod = ndpi_init_detection_module(); - NDPI_BITMASK_SET_ALL(debug_bitmask); - ndpi_set_log_level(*ndpi_info_mod, 4); - ndpi_set_debug_bitmask(*ndpi_info_mod, debug_bitmask); + ndpi_set_config(*ndpi_info_mod, NULL, "log.level", "3"); + ndpi_set_config(*ndpi_info_mod, "all", "log.enable", "1"); ndpi_load_categories_dir(*ndpi_info_mod, "./lists/"); ndpi_load_protocols_file(*ndpi_info_mod, "protos.txt"); diff --git a/fuzz/fuzz_config.cpp b/fuzz/fuzz_config.cpp index eda75111f..93bff3313 100644 --- a/fuzz/fuzz_config.cpp +++ b/fuzz/fuzz_config.cpp @@ -140,6 +140,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if(fuzzed_data.ConsumeBool()) { value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1); sprintf(cfg_value, "%d", value); + ndpi_set_config(ndpi_info_mod, "any", "log.enable", cfg_value); + } + for(i = 0; i < NDPI_MAX_SUPPORTED_PROTOCOLS; i++) { + if(fuzzed_data.ConsumeBool()) { + value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1); + sprintf(cfg_value, "%d", value); + sprintf(cfg_proto, "%d", i); + /* TODO: we should try to map integer into name */ + ndpi_set_config(ndpi_info_mod, cfg_proto, "log.enable", cfg_value); + } + } + if(fuzzed_data.ConsumeBool()) { + value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1); + sprintf(cfg_value, "%d", value); ndpi_set_config(ndpi_info_mod, "any", "ip_list.load", cfg_value); } for(i = 0; i < NDPI_MAX_SUPPORTED_PROTOCOLS; i++) { diff --git a/fuzz/fuzz_filecfg_categories.c b/fuzz/fuzz_filecfg_categories.c index 17947b58c..dd782ff67 100644 --- a/fuzz/fuzz_filecfg_categories.c +++ b/fuzz/fuzz_filecfg_categories.c @@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct ndpi_detection_module_struct *ndpi_struct; FILE *fd; NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; /* To allow memory allocation failures */ fuzz_set_alloc_callbacks_and_seed(size); @@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 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); + ndpi_set_config(ndpi_struct, NULL, "log.level", "3"); + ndpi_set_config(ndpi_struct, "all", "log.enable", "1"); fd = buffer_to_file(data, size); load_categories_file_fd(ndpi_struct, fd, NULL); if(fd) fclose(fd); - /* We don't really need to call ndpi_finalize_initialization */ - ndpi_exit_detection_module(ndpi_struct); return 0; } diff --git a/fuzz/fuzz_filecfg_malicious_ja3.c b/fuzz/fuzz_filecfg_malicious_ja3.c index 2073ed5bd..22cc95e59 100644 --- a/fuzz/fuzz_filecfg_malicious_ja3.c +++ b/fuzz/fuzz_filecfg_malicious_ja3.c @@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct ndpi_detection_module_struct *ndpi_struct; FILE *fd; NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; /* To allow memory allocation failures */ fuzz_set_alloc_callbacks_and_seed(size); @@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 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); + ndpi_set_config(ndpi_struct, NULL, "log.level", "3"); + ndpi_set_config(ndpi_struct, "all", "log.enable", "1"); 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; } diff --git a/fuzz/fuzz_filecfg_malicious_sha1.c b/fuzz/fuzz_filecfg_malicious_sha1.c index 665a8f942..649920533 100644 --- a/fuzz/fuzz_filecfg_malicious_sha1.c +++ b/fuzz/fuzz_filecfg_malicious_sha1.c @@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct ndpi_detection_module_struct *ndpi_struct; FILE *fd; NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; /* To allow memory allocation failures */ fuzz_set_alloc_callbacks_and_seed(size); @@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 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); + ndpi_set_config(ndpi_struct, NULL, "log.level", "3"); + ndpi_set_config(ndpi_struct, "all", "log.enable", "1"); 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; } diff --git a/fuzz/fuzz_filecfg_protocols.c b/fuzz/fuzz_filecfg_protocols.c index 74a2c6e3d..deef4b91e 100644 --- a/fuzz/fuzz_filecfg_protocols.c +++ b/fuzz/fuzz_filecfg_protocols.c @@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct ndpi_detection_module_struct *ndpi_struct; FILE *fd; NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; /* To allow memory allocation failures */ fuzz_set_alloc_callbacks_and_seed(size); @@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 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); + ndpi_set_config(ndpi_struct, NULL, "log.level", "3"); + ndpi_set_config(ndpi_struct, "all", "log.enable", "1"); fd = buffer_to_file(data, size); load_protocols_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; } diff --git a/fuzz/fuzz_filecfg_risk_domains.c b/fuzz/fuzz_filecfg_risk_domains.c index e7d0b4c7f..c3521b435 100644 --- a/fuzz/fuzz_filecfg_risk_domains.c +++ b/fuzz/fuzz_filecfg_risk_domains.c @@ -6,7 +6,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct ndpi_detection_module_struct *ndpi_struct; FILE *fd; NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; /* To allow memory allocation failures */ fuzz_set_alloc_callbacks_and_seed(size); @@ -15,17 +14,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 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); + ndpi_set_config(ndpi_struct, NULL, "log.level", "3"); + ndpi_set_config(ndpi_struct, "all", "log.enable", "1"); 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; } diff --git a/fuzz/fuzz_ndpi_reader.c b/fuzz/fuzz_ndpi_reader.c index d65e20b7c..7733b690f 100644 --- a/fuzz/fuzz_ndpi_reader.c +++ b/fuzz/fuzz_ndpi_reader.c @@ -11,8 +11,6 @@ struct ndpi_workflow_prefs *prefs = NULL; struct ndpi_workflow *workflow = NULL; -int nDPI_LogLevel = 0; -char *_debug_protocols = NULL; u_int32_t current_ndpi_memory = 0, max_ndpi_memory = 0; u_int8_t enable_protocol_guess = 1, enable_payload_analyzer = 0; u_int8_t enable_flow_stats = 1; @@ -36,7 +34,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { int r; char errbuf[PCAP_ERRBUF_SIZE]; NDPI_PROTOCOL_BITMASK all; - NDPI_PROTOCOL_BITMASK debug_bitmask; u_int i; FILE *fd; @@ -57,9 +54,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { workflow = ndpi_workflow_init(prefs, NULL /* pcap handler will be set later */, 0, ndpi_serialization_format_json); - NDPI_BITMASK_SET_ALL(debug_bitmask); - ndpi_set_log_level(workflow->ndpi_struct, 4); - ndpi_set_debug_bitmask(workflow->ndpi_struct, debug_bitmask); + ndpi_set_config(workflow->ndpi_struct, NULL, "log.level", "3"); + ndpi_set_config(workflow->ndpi_struct, "all", "log.enable", "1"); ndpi_load_protocols_file(workflow->ndpi_struct, "protos.txt"); ndpi_load_categories_file(workflow->ndpi_struct, "categories.txt", NULL); diff --git a/fuzz/fuzz_readerutils_workflow.cpp b/fuzz/fuzz_readerutils_workflow.cpp index e836cfdbf..ed5238f75 100644 --- a/fuzz/fuzz_readerutils_workflow.cpp +++ b/fuzz/fuzz_readerutils_workflow.cpp @@ -8,8 +8,6 @@ extern u_int8_t enable_doh_dot_detection; -char *_debug_protocols; -int nDPI_LogLevel = 0; u_int32_t current_ndpi_memory = 0, max_ndpi_memory = 0; u_int8_t enable_protocol_guess = 1, enable_payload_analyzer = 0; u_int8_t enable_flow_stats = 0; @@ -34,6 +32,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { char errbuf[PCAP_ERRBUF_SIZE]; FILE *fd; u_int8_t debug_protos_index; + char *_debug_protocols; const char *strs[] = { "all", "dns,quic", "+dns:-quic", |