Added check to avoid clases on similar protocols (FTP adn SMTP) on setting hostname

This commit is contained in:
Luca Deri
2021-08-11 12:11:58 +02:00
parent 5c33fbf19b
commit a2ea67152c
2 changed files with 29 additions and 22 deletions
+2
View File
@@ -33,6 +33,8 @@
static void ndpi_int_ftp_control_add_connection(struct ndpi_detection_module_struct *ndpi_struct, static void ndpi_int_ftp_control_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) { struct ndpi_flow_struct *flow) {
flow->host_server_name[0] = '\0'; /* Remove any data set by other dissectors (eg. SMTP) */
ndpi_set_detected_protocol(ndpi_struct, flow, ndpi_set_detected_protocol(ndpi_struct, flow,
NDPI_PROTOCOL_FTP_CONTROL, NDPI_PROTOCOL_UNKNOWN); NDPI_PROTOCOL_FTP_CONTROL, NDPI_PROTOCOL_UNKNOWN);
} }
+6 -1
View File
@@ -90,9 +90,12 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
if(packet->line[a].len > 4) { if(packet->line[a].len > 4) {
int i, len; int i, len;
if(packet->line[a].ptr[4] != '(') {
for(i=5; (i<packet->line[a].len-1) && (packet->line[a].ptr[i] != ' '); i++) for(i=5; (i<packet->line[a].len-1) && (packet->line[a].ptr[i] != ' '); i++)
; ;
if((packet->line[a].ptr[i+1] != '\r')
&& (packet->line[a].ptr[i+1] != '\n')) {
len = i-4; len = i-4;
/* Copy result for nDPI apps */ /* Copy result for nDPI apps */
len = ndpi_min(len, sizeof(flow->host_server_name)-1); len = ndpi_min(len, sizeof(flow->host_server_name)-1);
@@ -102,7 +105,8 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_match_hostname_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MAIL_SMTP, ndpi_match_hostname_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MAIL_SMTP,
(char *)flow->host_server_name, (char *)flow->host_server_name,
strlen((const char *)flow->host_server_name)); strlen((const char *)flow->host_server_name));
}
}
} }
} }
} else if(memcmp(packet->line[a].ptr, "250", 3) == 0) { } else if(memcmp(packet->line[a].ptr, "250", 3) == 0) {
@@ -206,6 +210,7 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_free(out); ndpi_free(out);
} }
} else { } else {
flow->host_server_name[0] = '\0';
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return; return;
} }