@@ -131,8 +131,6 @@ extern "C" {
|
|||||||
u_int16_t protocol_id,
|
u_int16_t protocol_id,
|
||||||
u_int16_t** tcp_master_proto,
|
u_int16_t** tcp_master_proto,
|
||||||
u_int16_t** udp_master_proto);
|
u_int16_t** udp_master_proto);
|
||||||
#/* NDPI_PROTOCOL_NETBIOS */
|
|
||||||
int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len);
|
|
||||||
|
|
||||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
|
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
|||||||
@@ -66,10 +66,12 @@ static void ndpi_search_setup_capwap(struct ndpi_detection_module_struct *ndpi_s
|
|||||||
else
|
else
|
||||||
offset = 15, to_add = 17;
|
offset = 15, to_add = 17;
|
||||||
|
|
||||||
msg_len = ntohs(*(u_int16_t*)&packet->payload[offset]);
|
if (packet->payload_packet_len >= offset + sizeof(u_int16_t)) {
|
||||||
|
msg_len = ntohs(*(u_int16_t*)&packet->payload[offset]);
|
||||||
|
|
||||||
if((msg_len+to_add) == packet->payload_packet_len)
|
if((msg_len+to_add) == packet->payload_packet_len)
|
||||||
goto capwap_found;
|
goto capwap_found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
&& (((dns_header->flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|
&& (((dns_header->flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|
||||||
|| ((dns_header->num_answers == 0) && (dns_header->authority_rrs == 0)))) {
|
|| ((dns_header->num_answers == 0) && (dns_header->authority_rrs == 0)))) {
|
||||||
/* This is a good query */
|
/* This is a good query */
|
||||||
while(x < flow->packet.payload_packet_len) {
|
while(x+2 < flow->packet.payload_packet_len) {
|
||||||
if(flow->packet.payload[x] == '\0') {
|
if(flow->packet.payload[x] == '\0') {
|
||||||
x++;
|
x++;
|
||||||
flow->protos.dns.query_type = get16(&x, flow->packet.payload);
|
flow->protos.dns.query_type = get16(&x, flow->packet.payload);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct netbios_header {
|
|||||||
/* ****************************************************************** */
|
/* ****************************************************************** */
|
||||||
|
|
||||||
/* The function below has been inherited by tcpdump */
|
/* The function below has been inherited by tcpdump */
|
||||||
int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len) {
|
static int ndpi_netbios_name_interpret(char *in, size_t inlen, char *out, u_int out_len) {
|
||||||
int ret = 0, len;
|
int ret = 0, len;
|
||||||
char *b;
|
char *b;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len) {
|
|||||||
b = out;
|
b = out;
|
||||||
*out = 0;
|
*out = 0;
|
||||||
|
|
||||||
if(len > (out_len-1) || len < 1)
|
if(len > (out_len-1) || len < 1 || 2*len > inlen)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
while (len--) {
|
while (len--) {
|
||||||
@@ -80,7 +80,7 @@ static void ndpi_int_netbios_add_connection(struct ndpi_detection_module_struct
|
|||||||
char name[64];
|
char name[64];
|
||||||
u_int off = flow->packet.payload[12] == 0x20 ? 12 : 14;
|
u_int off = flow->packet.payload[12] == 0x20 ? 12 : 14;
|
||||||
|
|
||||||
if(ndpi_netbios_name_interpret((char*)&flow->packet.payload[off], name, sizeof(name)) > 0)
|
if(ndpi_netbios_name_interpret((char*)&flow->packet.payload[off], flow->packet.payload_packet_len - off, name, sizeof(name)) > 0)
|
||||||
snprintf((char*)flow->host_server_name, sizeof(flow->host_server_name)-1, "%s", name);
|
snprintf((char*)flow->host_server_name, sizeof(flow->host_server_name)-1, "%s", name);
|
||||||
|
|
||||||
if(sub_protocol == NDPI_PROTOCOL_UNKNOWN)
|
if(sub_protocol == NDPI_PROTOCOL_UNKNOWN)
|
||||||
|
|||||||
+10
-9
@@ -825,7 +825,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
||||||
if(rc > 0) ja3_str_len += rc;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc;
|
||||||
|
|
||||||
/* ********** */
|
/* ********** */
|
||||||
|
|
||||||
@@ -1113,7 +1113,8 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
|
|
||||||
s_offset++;
|
s_offset++;
|
||||||
|
|
||||||
for(j=0; j<version_len; j += 2) {
|
// careful not to overflow and loop forever with u_int8_t
|
||||||
|
for(j=0; j+1<version_len; j += 2) {
|
||||||
u_int16_t tls_version = ntohs(*((u_int16_t*)&packet->payload[s_offset+j]));
|
u_int16_t tls_version = ntohs(*((u_int16_t*)&packet->payload[s_offset+j]));
|
||||||
u_int8_t unknown_tls_version;
|
u_int8_t unknown_tls_version;
|
||||||
|
|
||||||
@@ -1155,38 +1156,38 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
for(i=0; i<ja3.num_cipher; i++) {
|
for(i=0; i<ja3.num_cipher; i++) {
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
||||||
(i > 0) ? "-" : "", ja3.cipher[i]);
|
(i > 0) ? "-" : "", ja3.cipher[i]);
|
||||||
if(rc > 0) ja3_str_len += rc; else break;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc; else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
||||||
if(rc > 0) ja3_str_len += rc;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc;
|
||||||
|
|
||||||
/* ********** */
|
/* ********** */
|
||||||
|
|
||||||
for(i=0; i<ja3.num_tls_extension; i++) {
|
for(i=0; i<ja3.num_tls_extension; i++) {
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
||||||
(i > 0) ? "-" : "", ja3.tls_extension[i]);
|
(i > 0) ? "-" : "", ja3.tls_extension[i]);
|
||||||
if(rc > 0) ja3_str_len += rc; else break;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc; else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
||||||
if(rc > 0) ja3_str_len += rc;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc;
|
||||||
|
|
||||||
/* ********** */
|
/* ********** */
|
||||||
|
|
||||||
for(i=0; i<ja3.num_elliptic_curve; i++) {
|
for(i=0; i<ja3.num_elliptic_curve; i++) {
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
||||||
(i > 0) ? "-" : "", ja3.elliptic_curve[i]);
|
(i > 0) ? "-" : "", ja3.elliptic_curve[i]);
|
||||||
if(rc > 0) ja3_str_len += rc; else break;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc; else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, ",");
|
||||||
if(rc > 0) ja3_str_len += rc;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc;
|
||||||
|
|
||||||
for(i=0; i<ja3.num_elliptic_curve_point_format; i++) {
|
for(i=0; i<ja3.num_elliptic_curve_point_format; i++) {
|
||||||
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
rc = snprintf(&ja3_str[ja3_str_len], sizeof(ja3_str)-ja3_str_len, "%s%u",
|
||||||
(i > 0) ? "-" : "", ja3.elliptic_curve_point_format[i]);
|
(i > 0) ? "-" : "", ja3.elliptic_curve_point_format[i]);
|
||||||
if(rc > 0) ja3_str_len += rc; else break;
|
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc; else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_TLS
|
#ifdef DEBUG_TLS
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ __forceinline static
|
|||||||
#endif
|
#endif
|
||||||
u_int8_t check_ymsg(const u_int8_t * payload, u_int16_t payload_packet_len)
|
u_int8_t check_ymsg(const u_int8_t * payload, u_int16_t payload_packet_len)
|
||||||
{
|
{
|
||||||
|
if (payload_packet_len < sizeof(struct ndpi_yahoo_header)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
const struct ndpi_yahoo_header *yahoo = (struct ndpi_yahoo_header *) payload;
|
const struct ndpi_yahoo_header *yahoo = (struct ndpi_yahoo_header *) payload;
|
||||||
|
|
||||||
u_int16_t yahoo_len_parsed = 0;
|
u_int16_t yahoo_len_parsed = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user