Various TLS improvements
This commit is contained in:
+1
-18
@@ -764,23 +764,6 @@ static char* print_cipher(ndpi_cipher_weakness c) {
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
static char* ssl_version2str(u_int16_t version) {
|
||||
static char v[8];
|
||||
|
||||
switch(version) {
|
||||
case 0x300: return("SSLv3");
|
||||
case 0x301: return("TLSv1");
|
||||
case 0x302: return("TLSv1.1");
|
||||
case 0x303: return("TLSv1.2");
|
||||
case 0x304: return("TLSv1.3");
|
||||
}
|
||||
|
||||
snprintf(v, sizeof(v), "%04X", version);
|
||||
return(v);
|
||||
}
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
/**
|
||||
* @brief Print the flow
|
||||
*/
|
||||
@@ -835,7 +818,7 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa
|
||||
|
||||
if(flow->info[0] != '\0') fprintf(out, "[%s]", flow->info);
|
||||
|
||||
if(flow->ssh_ssl.ssl_version != 0) fprintf(out, "[%s]", ssl_version2str(flow->ssh_ssl.ssl_version));
|
||||
if(flow->ssh_ssl.ssl_version != 0) fprintf(out, "[%s]", ndpi_ssl_version2str(flow->ssh_ssl.ssl_version));
|
||||
if(flow->ssh_ssl.ja3_client[0] != '\0') fprintf(out, "[JA3C: %s%s]", flow->ssh_ssl.ja3_client,
|
||||
print_cipher(flow->ssh_ssl.client_unsafe_cipher));
|
||||
if(flow->ssh_ssl.server_info[0] != '\0') fprintf(out, "[server: %s]", flow->ssh_ssl.server_info);
|
||||
|
||||
@@ -813,6 +813,7 @@ extern "C" {
|
||||
struct ndpi_flow_struct *flow);
|
||||
int ndpi_has_human_readeable_string(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
char *buffer, u_int buffer_size);
|
||||
char* ndpi_ssl_version2str(u_int16_t version);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -687,3 +687,24 @@ int ndpi_has_human_readeable_string(struct ndpi_detection_module_struct *ndpi_st
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
char* ndpi_ssl_version2str(u_int16_t version) {
|
||||
static char v[8];
|
||||
|
||||
switch(version) {
|
||||
case 0x300: return("SSLv3");
|
||||
case 0x301: return("TLSv1");
|
||||
case 0x302: return("TLSv1.1");
|
||||
case 0x303: return("TLSv1.2");
|
||||
case 0x304: return("TLSv1.3");
|
||||
}
|
||||
|
||||
if((version >= 0x7f00) && (version <= 0x7fff))
|
||||
return("TLSv1.3 (draft)");
|
||||
|
||||
snprintf(v, sizeof(v), "%04X", version);
|
||||
return(v);
|
||||
}
|
||||
|
||||
|
||||
+18
-6
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
/* #define CERTIFICATE_DEBUG 1 */
|
||||
#define CERTIFICATE_DEBUG 1
|
||||
|
||||
#define NDPI_MAX_SSL_REQUEST_SIZE 10000
|
||||
|
||||
@@ -238,9 +238,10 @@ static u_int32_t ndpi_ssl_refine_master_protocol(struct ndpi_detection_module_st
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
if(((flow->l4.tcp.ssl_seen_client_cert == 1) && (flow->protos.stun_ssl.ssl.client_certificate[0] != '\0'))
|
||||
|| ((flow->l4.tcp.ssl_seen_server_cert == 1) && (flow->protos.stun_ssl.ssl.server_certificate[0] != '\0'))
|
||||
|| (flow->host_server_name[0] != '\0'))
|
||||
if(((flow->l4.tcp.ssl_seen_client_cert == 1) && (flow->protos.stun_ssl.ssl.ja3_client[0] != '\0'))
|
||||
|| ((flow->l4.tcp.ssl_seen_server_cert == 1) && (flow->protos.stun_ssl.ssl.ja3_server[0] != '\0'))
|
||||
// || (flow->host_server_name[0] != '\0')
|
||||
)
|
||||
protocol = NDPI_PROTOCOL_SSL;
|
||||
else
|
||||
protocol = NDPI_PROTOCOL_SSL_NO_CERT;
|
||||
@@ -409,7 +410,7 @@ int getSSLcertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if((handshake_protocol == 0x02)
|
||||
|| (handshake_protocol == 0xb) /* Server Hello and Certificate message types are interesting for us */) {
|
||||
u_int num_found = 0;
|
||||
u_int16_t ssl_version = ntohs(*((u_int16_t*)&packet->payload[9]));
|
||||
u_int16_t ssl_version = ntohs(*((u_int16_t*)&packet->payload[9]));
|
||||
|
||||
ja3.ssl_version = ssl_version;
|
||||
|
||||
@@ -417,7 +418,18 @@ int getSSLcertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
u_int16_t offset = 43, extension_len, j;
|
||||
u_int8_t session_id_len = packet->payload[43];
|
||||
|
||||
offset += session_id_len+1;
|
||||
#ifdef CERTIFICATE_DEBUG
|
||||
printf("SSL Server Hello [version: 0x%04X]\n", ssl_version);
|
||||
#endif
|
||||
|
||||
/*
|
||||
The server hello decides about the SSL version of this flow
|
||||
https://networkengineering.stackexchange.com/questions/55752/why-does-wireshark-show-version-tls-1-2-here-instead-of-tls-1-3
|
||||
*/
|
||||
flow->protos.stun_ssl.ssl.ssl_version = ssl_version;
|
||||
|
||||
if(ssl_version < 0x7F15 /* TLS 1.3 lacks of session id */)
|
||||
offset += session_id_len+1;
|
||||
|
||||
ja3.num_cipher = 1, ja3.cipher[0] = ntohs(*((u_int16_t*)&packet->payload[offset]));
|
||||
flow->protos.stun_ssl.ssl.server_unsafe_cipher = ndpi_is_safe_ssl_cipher(ja3.cipher[0]);
|
||||
|
||||
Reference in New Issue
Block a user