Added fix to avoid FTP false positives

This commit is contained in:
Luca Deri
2019-03-14 21:50:09 +01:00
parent 22e431ca67
commit 54f90c7556
+9 -1
View File
@@ -220,6 +220,11 @@ static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_stru
static void ndpi_check_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { static void ndpi_check_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet; struct ndpi_packet_struct *packet = &flow->packet;
/*
Make sure we see the beginning of the connection as otherwise we might have
false positive results
*/
if(flow->l4.tcp.seen_syn) {
if((packet->payload_packet_len > 0) if((packet->payload_packet_len > 0)
&& (ndpi_match_file_header(ndpi_struct, flow) && (ndpi_match_file_header(ndpi_struct, flow)
|| ndpi_match_ftp_data_directory(ndpi_struct, flow) || ndpi_match_ftp_data_directory(ndpi_struct, flow)
@@ -228,7 +233,10 @@ static void ndpi_check_ftp_data(struct ndpi_detection_module_struct *ndpi_struct
) { ) {
NDPI_LOG_INFO(ndpi_struct, "found FTP_DATA request\n"); NDPI_LOG_INFO(ndpi_struct, "found FTP_DATA request\n");
ndpi_int_ftp_data_add_connection(ndpi_struct, flow); ndpi_int_ftp_data_add_connection(ndpi_struct, flow);
} else return;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
} }