Various improvemement when using ndpi_pref_enable_tls_block_dissection:
application data TLS blocks are now ignored when exchanged before - the end of certificate negotiation (up to TLS 1.2) - change cipher
This commit is contained in:
@@ -1219,7 +1219,8 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
|
|||||||
|
|
||||||
for(i=0; i<flow->ndpi_flow->l4.tcp.tls.num_tls_blocks; i++) {
|
for(i=0; i<flow->ndpi_flow->l4.tcp.tls.num_tls_blocks; i++) {
|
||||||
u_int16_t len = abs(flow->ndpi_flow->l4.tcp.tls.tls_application_blocks_len[i]);
|
u_int16_t len = abs(flow->ndpi_flow->l4.tcp.tls.tls_application_blocks_len[i]);
|
||||||
printf("%u\n", len);
|
|
||||||
|
/* printf("[TLS_LEN] %u\n", len); */
|
||||||
ndpi_inc_bin(&flow->payload_len_bin, plen2slot(len), 1);
|
ndpi_inc_bin(&flow->payload_len_bin, plen2slot(len), 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -965,7 +965,7 @@ typedef enum {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ndpi_pref_direction_detect_disable = 0,
|
ndpi_pref_direction_detect_disable = 0,
|
||||||
ndpi_pref_enable_tls_block_dissection
|
ndpi_pref_enable_tls_block_dissection /* nDPI considers only those blocks past the certificate exchange */
|
||||||
} ndpi_detection_preference;
|
} ndpi_detection_preference;
|
||||||
|
|
||||||
/* ntop extensions */
|
/* ntop extensions */
|
||||||
|
|||||||
@@ -602,6 +602,10 @@ int ndpi_set_detection_preferences(struct ndpi_detection_module_struct *ndpi_str
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ndpi_pref_enable_tls_block_dissection:
|
case ndpi_pref_enable_tls_block_dissection:
|
||||||
|
/*
|
||||||
|
If this option is enabled only the TLS Application data blocks past the
|
||||||
|
certificate negotiation are considered
|
||||||
|
*/
|
||||||
ndpi_str->num_tls_blocks_to_follow = NDPI_MAX_NUM_TLS_APPL_BLOCKS;
|
ndpi_str->num_tls_blocks_to_follow = NDPI_MAX_NUM_TLS_APPL_BLOCKS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+23
-2
@@ -604,7 +604,7 @@ int processCertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
certificates_offset += certificate_len;
|
certificates_offset += certificate_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(( ndpi_struct->num_tls_blocks_to_follow != 0)
|
if((ndpi_struct->num_tls_blocks_to_follow != 0)
|
||||||
&& (flow->l4.tcp.tls.num_tls_blocks >= ndpi_struct->num_tls_blocks_to_follow)) {
|
&& (flow->l4.tcp.tls.num_tls_blocks >= ndpi_struct->num_tls_blocks_to_follow)) {
|
||||||
#ifdef DEBUG_TLS_BLOCKS
|
#ifdef DEBUG_TLS_BLOCKS
|
||||||
printf("*** [TLS Block] Enough blocks dissected\n");
|
printf("*** [TLS Block] Enough blocks dissected\n");
|
||||||
@@ -628,6 +628,17 @@ static int processTLSBlock(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
processClientServerHello(ndpi_struct, flow, 0);
|
processClientServerHello(ndpi_struct, flow, 0);
|
||||||
flow->l4.tcp.tls.hello_processed = 1;
|
flow->l4.tcp.tls.hello_processed = 1;
|
||||||
ndpi_int_tls_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_TLS);
|
ndpi_int_tls_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_TLS);
|
||||||
|
|
||||||
|
#ifdef DEBUG_TLS
|
||||||
|
printf("*** TLS [version: %02X][%s Hello]\n",
|
||||||
|
flow->protos.stun_ssl.ssl.ssl_version,
|
||||||
|
(packet->payload[0] == 0x01) ? "Client" : "Server");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if((flow->protos.stun_ssl.ssl.ssl_version >= 0x0304 /* TLS 1.3 */)
|
||||||
|
&& (packet->payload[0] == 0x02 /* Server Hello */)) {
|
||||||
|
flow->l4.tcp.tls.certificate_processed = 1; /* No Certificate with TLS 1.3+ */
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0b: /* Certificate */
|
case 0x0b: /* Certificate */
|
||||||
@@ -700,6 +711,15 @@ static int ndpi_search_tls_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
/* Overwriting packet payload */
|
/* Overwriting packet payload */
|
||||||
p = packet->payload, p_len = packet->payload_packet_len; /* Backup */
|
p = packet->payload, p_len = packet->payload_packet_len; /* Backup */
|
||||||
|
|
||||||
|
if(content_type == 0x14 /* Change Cipher Spec */) {
|
||||||
|
/*
|
||||||
|
Ignore Application Data up until change cipher
|
||||||
|
so in this case we reset the number of observed
|
||||||
|
TLS blocks
|
||||||
|
*/
|
||||||
|
flow->l4.tcp.tls.num_tls_blocks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if((len > 9)
|
if((len > 9)
|
||||||
&& (content_type != 0x17 /* Application Data */)
|
&& (content_type != 0x17 /* Application Data */)
|
||||||
&& (!flow->l4.tcp.tls.certificate_processed)) {
|
&& (!flow->l4.tcp.tls.certificate_processed)) {
|
||||||
@@ -729,7 +749,8 @@ static int ndpi_search_tls_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Process element as a whole */
|
/* Process element as a whole */
|
||||||
if(content_type == 0x17 /* Application Data */) {
|
if((content_type == 0x17 /* Application Data */)
|
||||||
|
&& (flow->l4.tcp.tls.certificate_processed)) {
|
||||||
if(flow->l4.tcp.tls.num_tls_blocks < ndpi_struct->num_tls_blocks_to_follow)
|
if(flow->l4.tcp.tls.num_tls_blocks < ndpi_struct->num_tls_blocks_to_follow)
|
||||||
flow->l4.tcp.tls.tls_application_blocks_len[flow->l4.tcp.tls.num_tls_blocks++] =
|
flow->l4.tcp.tls.tls_application_blocks_len[flow->l4.tcp.tls.num_tls_blocks++] =
|
||||||
(packet->packet_direction == 0) ? (len-5) : -(len-5);
|
(packet->packet_direction == 0) ? (len-5) : -(len-5);
|
||||||
|
|||||||
Reference in New Issue
Block a user