Added check for empty/missing user-agent in HTTP

This commit is contained in:
Luca Deri
2022-12-03 11:32:39 +01:00
parent 557bbcfc5a
commit 2a8d0d1fe4
+6 -4
View File
@@ -210,6 +210,9 @@ static void ndpi_validate_http_content(struct ndpi_detection_module_struct *ndpi
NDPI_LOG_DBG(ndpi_struct, "\n"); NDPI_LOG_DBG(ndpi_struct, "\n");
} }
if((flow->http.user_agent == NULL) || (flow->http.user_agent[0] == '\0'))
ndpi_set_risk(ndpi_struct, flow, NDPI_HTTP_SUSPICIOUS_USER_AGENT, "Empty or missing User-Agent");
} }
/* *********************************************** */ /* *********************************************** */
@@ -602,12 +605,10 @@ int http_process_user_agent(struct ndpi_detection_module_struct *ndpi_struct,
} }
} }
if (ndpi_user_agent_set(flow, ua_ptr, ua_ptr_len) != NULL) if(ndpi_user_agent_set(flow, ua_ptr, ua_ptr_len) != NULL)
{
ndpi_check_user_agent(ndpi_struct, flow, flow->http.user_agent, ua_ptr_len); ndpi_check_user_agent(ndpi_struct, flow, flow->http.user_agent, ua_ptr_len);
} else { else
NDPI_LOG_DBG2(ndpi_struct, "Could not set HTTP user agent\n"); NDPI_LOG_DBG2(ndpi_struct, "Could not set HTTP user agent\n");
}
NDPI_LOG_DBG2(ndpi_struct, "User Agent Type line found %.*s\n", NDPI_LOG_DBG2(ndpi_struct, "User Agent Type line found %.*s\n",
ua_ptr_len, ua_ptr); ua_ptr_len, ua_ptr);
@@ -1371,6 +1372,7 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct
} }
} }
check_content_type_and_change_protocol(ndpi_struct, flow);
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
http_bitmask_exclude_other(flow); http_bitmask_exclude_other(flow);
} else if((flow->l4.tcp.http_stage == 1) || (flow->l4.tcp.http_stage == 2)) { } else if((flow->l4.tcp.http_stage == 1) || (flow->l4.tcp.http_stage == 2)) {