Added fix for detecting SSL certificate decoding. The old code did not discard non-SSL packets thus incrementing a counter when not necessary and thus terminating SSL decoding too early. This causes some SSL certificates not to be properly dissected and thus handled.
This commit is contained in:
+14
-7
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "ndpi_api.h"
|
#include "ndpi_api.h"
|
||||||
|
|
||||||
// #define CERTIFICATE_DEBUG 1
|
/* #define CERTIFICATE_DEBUG 1 */
|
||||||
|
|
||||||
#ifdef NDPI_PROTOCOL_SSL
|
#ifdef NDPI_PROTOCOL_SSL
|
||||||
|
|
||||||
@@ -134,6 +134,14 @@ int getSSLcertificate(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
char *buffer, int buffer_len) {
|
char *buffer, int buffer_len) {
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
#ifdef CERTIFICATE_DEBUG
|
||||||
|
{
|
||||||
|
static u_int8_t id = 0;
|
||||||
|
|
||||||
|
printf("-> [%u] %02X\n", ++id, packet->payload[0] & 0xFF);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Nothing matched so far: let's decode the certificate with some heuristics
|
Nothing matched so far: let's decode the certificate with some heuristics
|
||||||
Patches courtesy of Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
|
Patches courtesy of Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
|
||||||
@@ -282,6 +290,8 @@ int sslDetectProtocolFromCertificate(struct ndpi_detection_module_struct *ndpi_s
|
|||||||
|
|
||||||
if(!packet->iph /* IPv4 */) return(-1);
|
if(!packet->iph /* IPv4 */) return(-1);
|
||||||
|
|
||||||
|
if((packet->payload_packet_len > 9)
|
||||||
|
&& (packet->payload[0] == 0x16 /* consider only specific SSL packets (handshake) */)) {
|
||||||
if((packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)
|
if((packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)
|
||||||
|| (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL)) {
|
|| (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_SSL)) {
|
||||||
char certificate[64];
|
char certificate[64];
|
||||||
@@ -315,6 +325,7 @@ int sslDetectProtocolFromCertificate(struct ndpi_detection_module_struct *ndpi_s
|
|||||||
)
|
)
|
||||||
ndpi_int_ssl_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_SSL);
|
ndpi_int_ssl_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_SSL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -513,15 +524,11 @@ static u_int8_t ndpi_search_sslv3_direction1(struct ndpi_detection_module_struct
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ndpi_search_ssl_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
void ndpi_search_ssl_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
|||||||
Reference in New Issue
Block a user