Added known protocol on unknown port for ntop

This commit is contained in:
Luca Deri
2020-12-28 16:11:39 +01:00
parent 7f944cc43b
commit 84132c6735
2 changed files with 15 additions and 2 deletions
+12 -1
View File
@@ -4488,6 +4488,15 @@ static void ndpi_reset_packet_line_info(struct ndpi_packet_struct *packet) {
/* ********************************************************************************* */
static int ndpi_is_ntop_protocol(ndpi_protocol *ret) {
if((ret->master_protocol == NDPI_PROTOCOL_HTTP) && (ret->app_protocol == NDPI_PROTOCOL_NTOP))
return(1);
else
return(0);
}
/* ********************************************************************************* */
static int ndpi_check_protocol_port_mismatch_exceptions(struct ndpi_detection_module_struct *ndpi_str,
struct ndpi_flow_struct *flow,
ndpi_default_ports_tree_node_t *expected_proto,
@@ -4498,6 +4507,8 @@ static int ndpi_check_protocol_port_mismatch_exceptions(struct ndpi_detection_mo
options available
*/
if(ndpi_is_ntop_protocol(returned_proto)) return(1);
if(returned_proto->master_protocol == NDPI_PROTOCOL_TLS) {
switch(expected_proto->proto->protoId) {
case NDPI_PROTOCOL_MAIL_IMAPS:
@@ -4847,7 +4858,7 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
if(!ndpi_check_protocol_port_mismatch_exceptions(ndpi_str, flow, found, &ret))
NDPI_SET_BIT(flow->risk, NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT);
} else if(default_ports && (default_ports[0] != 0)) {
} else if((!ndpi_is_ntop_protocol(&ret)) && default_ports && (default_ports[0] != 0)) {
u_int8_t found = 0, i, num_loops = 0;
check_default_ports:
+3 -1
View File
@@ -446,8 +446,10 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
}
if(packet->server_line.ptr != NULL && (packet->server_line.len > 7)) {
if(strncmp((const char *)packet->server_line.ptr, "ntopng ", 7) == 0)
if(strncmp((const char *)packet->server_line.ptr, "ntopng ", 7) == 0) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NTOP, NDPI_PROTOCOL_HTTP);
NDPI_CLR_BIT(flow->risk, NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT);
}
}
if(packet->user_agent_line.ptr != NULL && packet->user_agent_line.len != 0) {