diff options
Diffstat (limited to 'src/lib/protocols')
-rw-r--r-- | src/lib/protocols/rdp.c | 45 | ||||
-rw-r--r-- | src/lib/protocols/tls.c | 22 |
2 files changed, 60 insertions, 7 deletions
diff --git a/src/lib/protocols/rdp.c b/src/lib/protocols/rdp.c index 9c42f0055..bc2994286 100644 --- a/src/lib/protocols/rdp.c +++ b/src/lib/protocols/rdp.c @@ -2,7 +2,7 @@ * rdp.c * * Copyright (C) 2009-11 - ipoque GmbH - * Copyright (C) 2011-22 - ntop.org + * Copyright (C) 2011-24 - ntop.org * * This file is part of nDPI, an open source deep packet inspection * library based on the OpenDPI and PACE technology by ipoque GmbH @@ -32,6 +32,11 @@ #include "ndpi_api.h" #include "ndpi_private.h" +extern int ndpi_tls_obfuscated_heur_search_again(struct ndpi_detection_module_struct* ndpi_struct, + struct ndpi_flow_struct* flow); + +/* **************************************** */ + static void ndpi_int_rdp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { NDPI_LOG_INFO(ndpi_struct, "found RDP\n"); @@ -39,6 +44,27 @@ static void ndpi_int_rdp_add_connection(struct ndpi_detection_module_struct *ndp ndpi_set_risk(flow, NDPI_DESKTOP_OR_FILE_SHARING_SESSION, "Found RDP"); /* Remote assistance */ } +/* **************************************** */ + +/* tls.c */ +extern int ndpi_search_tls_tcp(struct ndpi_detection_module_struct *ndpi_struct, + struct ndpi_flow_struct *flow); + +int ndpi_search_tls_over_rdp(struct ndpi_detection_module_struct *ndpi_struct, + struct ndpi_flow_struct *flow) { + const struct ndpi_packet_struct * const packet = &ndpi_struct->packet; + + if((packet->payload_packet_len > 1) + && (packet->payload[0] == 0x16 /* This might be a TLS block */)) { + int rc = ndpi_search_tls_tcp(ndpi_struct, flow); + + return(rc); + } else + return 1; /* Keep searching */ +} + +/* **************************************** */ + static void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { const struct ndpi_packet_struct * const packet = &ndpi_struct->packet; @@ -57,7 +83,21 @@ static void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, packet->payload[13] == 0x08 /* RDP Length */) || (packet->payload_packet_len > 17 && memcmp(&packet->payload[11], "Cookie:", 7) == 0))) /* RDP Cookie */ { + + if(packet->payload_packet_len > 43) { + u_int8_t rdp_requested_proto = packet->payload[43]; + + /* Check if TLS support has been requested in RDP */ + if((rdp_requested_proto & 0x1) == 0x1) { + /* RDP Response + Client Hello + Server hello */ + flow->max_extra_packets_to_check = 5; + + flow->extra_packets_func = ndpi_search_tls_over_rdp; + } + } + ndpi_int_rdp_add_connection(ndpi_struct, flow); + return; } } else { @@ -66,7 +106,7 @@ static void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, packet->payload[11] == 0x02 && /* RDP Negotiation Response */ packet->payload[13] == 0x08 /* RDP Length */) { ndpi_int_rdp_add_connection(ndpi_struct, flow); - return; + return; } } } @@ -139,6 +179,7 @@ static void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, } } +/* **************************************** */ void init_rdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id) { diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c index 74e7da64f..048060188 100644 --- a/src/lib/protocols/tls.c +++ b/src/lib/protocols/tls.c @@ -242,6 +242,8 @@ static int check_set(struct ndpi_detection_module_struct* ndpi_struct, return 0; } +/* **************************************** */ + static int tls_obfuscated_heur_search(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) { struct ndpi_packet_struct* packet = &ndpi_struct->packet; @@ -396,9 +398,10 @@ static int tls_obfuscated_heur_search(struct ndpi_detection_module_struct* ndpi_ return 0; /* Continue */ } +/* **************************************** */ + static int tls_obfuscated_heur_search_again(struct ndpi_detection_module_struct* ndpi_struct, - struct ndpi_flow_struct* flow) -{ + struct ndpi_flow_struct* flow) { int rc; NDPI_LOG_DBG2(ndpi_struct, "TLS-Obf-Heur: extra dissection\n"); @@ -436,6 +439,8 @@ static int tls_obfuscated_heur_search_again(struct ndpi_detection_module_struct* return 0; /* Stop */ } +/* **************************************** */ + void switch_extra_dissection_to_tls_obfuscated_heur(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) { @@ -1287,8 +1292,8 @@ static void ndpi_looks_like_tls(struct ndpi_detection_module_struct *ndpi_struct /* **************************************** */ -static int ndpi_search_tls_tcp(struct ndpi_detection_module_struct *ndpi_struct, - struct ndpi_flow_struct *flow) { +int ndpi_search_tls_tcp(struct ndpi_detection_module_struct *ndpi_struct, + struct ndpi_flow_struct *flow) { struct ndpi_packet_struct *packet = &ndpi_struct->packet; u_int8_t something_went_wrong = 0; message_t *message; @@ -1347,7 +1352,6 @@ static int ndpi_search_tls_tcp(struct ndpi_detection_module_struct *ndpi_struct, break; } - #ifdef DEBUG_TLS_MEMORY printf("[TLS Mem] Processing %u bytes message\n", len); #endif @@ -1863,10 +1867,18 @@ static void ndpi_int_tls_add_connection(struct ndpi_detection_module_struct *ndp printf("[TLS] %s()\n", __FUNCTION__); #endif + if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_RDP) { + /* RDP over TLS */ + ndpi_set_detected_protocol(ndpi_struct, flow, + NDPI_PROTOCOL_RDP, NDPI_PROTOCOL_TLS, NDPI_CONFIDENCE_DPI); + return; + } + if((flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) || (flow->detected_protocol_stack[1] != NDPI_PROTOCOL_UNKNOWN)) { if(!flow->extra_packets_func) tlsInitExtraPacketProcessing(ndpi_struct, flow); + return; } |