Improved logic for checking invalid DNS queries

This commit is contained in:
Luca Deri
2024-06-23 22:27:19 +02:00
parent aa1d7247d1
commit e92568e4bb
+13
View File
@@ -768,7 +768,10 @@ static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, st
if (hostname_is_valid == 0) if (hostname_is_valid == 0)
ndpi_set_risk(flow, NDPI_INVALID_CHARACTERS, "Invalid chars detected in domain name"); ndpi_set_risk(flow, NDPI_INVALID_CHARACTERS, "Invalid chars detected in domain name");
/* Ignore reverse DNS queries */
if(strstr(_hostname, ".in-addr.") == NULL) {
dot = strchr(_hostname, '.'); dot = strchr(_hostname, '.');
if(dot) { if(dot) {
uintptr_t first_element_len = dot - _hostname; uintptr_t first_element_len = dot - _hostname;
@@ -778,9 +781,19 @@ static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, st
and this might be an issue or indicate an exfiltration and this might be an issue or indicate an exfiltration
*/ */
if(ends_with(ndpi_struct, _hostname, "multi.surbl.org")
|| ends_with(ndpi_struct, _hostname, "spamhaus.org")
|| ends_with(ndpi_struct, _hostname, "rackcdn.com")
|| ends_with(ndpi_struct, _hostname, "akamaiedge.net")
|| ends_with(ndpi_struct, _hostname, "mx-verification.google.com")
|| ends_with(ndpi_struct, _hostname, "amazonaws.com")
)
; /* Check common domain exceptions [TODO: if the list grows too much use a different datastructure] */
else
ndpi_set_risk(flow, NDPI_DNS_SUSPICIOUS_TRAFFIC, "Long DNS host name"); ndpi_set_risk(flow, NDPI_DNS_SUSPICIOUS_TRAFFIC, "Long DNS host name");
} }
} }
}
if(len > 0) { if(len > 0) {
if(ndpi_struct->cfg.dns_subclassification_enabled) { if(ndpi_struct->cfg.dns_subclassification_enabled) {