HTTP: fix classification (#1692)

If we have a valid HTTP sessions, we should ignore
`flow->guessed_protocol_id` field (i.e. classification "by-port")
altogheter.

The attached trace was classified as "SIP/HTTP" only because the *client*
port was 5060...
As a general rule, having a classification such as "XXXX/HTTP" is
*extremely* suspicious.
This commit is contained in:
Ivan Nardi
2022-07-30 22:57:20 +02:00
committed by GitHub
parent 8b6a00f84b
commit 2a596c79e6
4 changed files with 30 additions and 5 deletions
+3 -2
View File
@@ -759,9 +759,10 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
if(flow->detected_protocol_stack[1] == NDPI_PROTOCOL_UNKNOWN) {
/* Avoid putting as subprotocol a "core" protocol such as SSL or DNS */
if(ndpi_struct->proto_defaults[flow->guessed_protocol_id].subprotocol_count == 0) {
flow->detected_protocol_stack[1] = flow->guessed_protocol_id;
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
flow->detected_protocol_stack[0] = flow->guessed_host_protocol_id;
flow->detected_protocol_stack[1] = flow->guessed_protocol_id;
}
}
}
else {