Compare commits

...
7 Commits
Author SHA1 Message Date
Alfredo Cardigliano f98fa675d9 Fix ndpi_serialize_string_int64 2022-01-21 17:35:56 +01:00
Ivan Nardi 92a1be2581 Fix use-of-uninitialized-value (#1366)
Close #1346
2021-11-11 17:47:32 +01:00
Luca Deri d7a89fd7df Fixed DES initialisation 2021-10-12 12:39:27 +02:00
Luca Deri 817c00b65a Firs crash on ARM during steam protocol dissection 2021-08-18 11:33:33 +02:00
Luca Deri 5f286a17c1 Report whether a protocol is encrypted 2021-08-17 17:15:41 +02:00
Luca Deri dabab0e951 Added ability to report whether a protocol is encrypted
Added new API calls
- u_int8_t ndpi_is_valid_protoId(u_int16_t protoId);
Cleaned up code and organized in a function.

- u_int8_t ndpi_is_encrypted_proto(struct ndpi_detection_module_struct *ndpi_str, ndpi_protocol proto);
Check whether a protocol is encrypted or not based on master and app protocols
2021-08-17 17:15:34 +02:00
Luca Deri b8806bd2de Moved to 4.0.0 2021-07-26 09:42:48 +02:00
10 changed files with 283 additions and 249 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
NDPI_MAJOR="3" NDPI_MAJOR="4"
NDPI_MINOR="5" NDPI_MINOR="0"
NDPI_PATCH="0" NDPI_PATCH="0"
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH" NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
+3
View File
@@ -1368,6 +1368,9 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa
ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct, ndpi_protocol2name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
flow->detected_protocol, buf1, sizeof(buf1))); flow->detected_protocol, buf1, sizeof(buf1)));
fprintf(out, "[%s]",
ndpi_is_encrypted_proto(ndpi_thread_info[thread_id].workflow->ndpi_struct, flow->detected_protocol) ? "Encrypted" : "ClearText");
if(flow->detected_protocol.category != 0) if(flow->detected_protocol.category != 0)
fprintf(out, "[cat: %s/%u]", fprintf(out, "[cat: %s/%u]",
ndpi_category_get_name(ndpi_thread_info[thread_id].workflow->ndpi_struct, ndpi_category_get_name(ndpi_thread_info[thread_id].workflow->ndpi_struct,
+3 -1
View File
@@ -1054,7 +1054,9 @@ extern "C" {
/* General purpose utilities */ /* General purpose utilities */
u_int64_t ndpi_htonll(u_int64_t v); u_int64_t ndpi_htonll(u_int64_t v);
u_int64_t ndpi_ntohll(u_int64_t v); u_int64_t ndpi_ntohll(u_int64_t v);
u_int8_t ndpi_is_valid_protoId(u_int16_t protoId);
u_int8_t ndpi_is_encrypted_proto(struct ndpi_detection_module_struct *ndpi_str, ndpi_protocol proto);
/* DGA */ /* DGA */
int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str, int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
struct ndpi_flow_struct *flow, struct ndpi_flow_struct *flow,
+1
View File
@@ -103,6 +103,7 @@ extern "C" {
int protoId, ...); int protoId, ...);
extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod, extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod,
u_int8_t is_cleartext,
ndpi_protocol_breed_t protoBreed, u_int16_t protoId, char *protoName, ndpi_protocol_breed_t protoBreed, u_int16_t protoId, char *protoName,
ndpi_protocol_category_t protoCategory, ndpi_protocol_category_t protoCategory,
ndpi_port_range *tcpDefPorts, ndpi_port_range *tcpDefPorts,
+2 -1
View File
@@ -1046,7 +1046,8 @@ typedef enum {
typedef struct ndpi_proto_defaults { typedef struct ndpi_proto_defaults {
char *protoName; char *protoName;
ndpi_protocol_category_t protoCategory; ndpi_protocol_category_t protoCategory;
u_int16_t * subprotocols; u_int8_t isClearTextProto;
u_int16_t *subprotocols;
u_int32_t subprotocol_count; u_int32_t subprotocol_count;
u_int16_t protoId, protoIdx; u_int16_t protoId, protoIdx;
u_int16_t tcp_default_ports[MAX_DEFAULT_PORTS], udp_default_ports[MAX_DEFAULT_PORTS]; u_int16_t tcp_default_ports[MAX_DEFAULT_PORTS], udp_default_ports[MAX_DEFAULT_PORTS];
+2 -1
View File
@@ -1243,7 +1243,8 @@ int ndpi_des_init(struct ndpi_des_struct *des, double alpha, double beta, float
memset(des, 0, sizeof(struct ndpi_des_struct)); memset(des, 0, sizeof(struct ndpi_des_struct));
des->params.alpha = alpha; des->params.alpha = alpha;
des->params.beta = beta;
if((significance < 0) || (significance > 1)) significance = 0.05; if((significance < 0) || (significance > 1)) significance = 0.05;
des->params.ro = ndpi_normal_cdf_inverse(1 - (significance / 2.)); des->params.ro = ndpi_normal_cdf_inverse(1 - (significance / 2.));
+239 -236
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1306,7 +1306,7 @@ int ndpi_serialize_binary_int64(ndpi_serializer *_serializer,
} else { } else {
serializer->buffer.data[serializer->status.buffer.size_used++] = (ndpi_serialization_string << 4) | ndpi_serialization_int64; serializer->buffer.data[serializer->status.buffer.size_used++] = (ndpi_serialization_string << 4) | ndpi_serialization_int64;
ndpi_serialize_single_string(serializer, key, klen); ndpi_serialize_single_string(serializer, key, klen);
ndpi_serialize_single_uint32(serializer, value); ndpi_serialize_single_uint64(serializer, value);
} }
} }
+18
View File
@@ -2226,3 +2226,21 @@ u_int8_t is_a_common_alpn(struct ndpi_detection_module_struct *ndpi_str,
return(0); return(0);
} }
/* ******************************************* */
u_int8_t ndpi_is_valid_protoId(u_int16_t protoId) {
return((protoId >= NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS) ? 0 : 1);
}
/* ******************************************* */
u_int8_t ndpi_is_encrypted_proto(struct ndpi_detection_module_struct *ndpi_str,
ndpi_protocol proto) {
if(ndpi_is_valid_protoId(proto.master_protocol) && ndpi_is_valid_protoId(proto.app_protocol)) {
return((ndpi_str->proto_defaults[proto.master_protocol].isClearTextProto
&& ndpi_str->proto_defaults[proto.app_protocol].isClearTextProto) ? 0 : 1);
} else
return(0);
}
+12 -7
View File
@@ -114,14 +114,19 @@ static void ndpi_check_steam_udp1(struct ndpi_detection_module_struct *ndpi_stru
} }
/* Check for Steam Datagram Relay (SDR) packets. */ /* Check for Steam Datagram Relay (SDR) packets. */
if (payload_len > 8 && if (payload_len > 8) {
ndpi_ntohll(get_u_int64_t(packet->payload, 0)) == 0x0101736470696e67 /* "\x01\x01sdping" */) u_int64_t n;
{
NDPI_LOG_INFO(ndpi_struct, "found STEAM (Steam Datagram Relay)\n");
ndpi_int_steam_add_connection(ndpi_struct, flow);
return;
}
/* Necessary as simple cast crashes on ARM */
memcpy(&n, packet->payload, sizeof(u_int64_t));
if(ndpi_ntohll(n) == 0x0101736470696e67 /* "\x01\x01sdping" */) {
NDPI_LOG_INFO(ndpi_struct, "found STEAM (Steam Datagram Relay)\n");
ndpi_int_steam_add_connection(ndpi_struct, flow);
return;
}
}
/* Check if we so far detected the protocol in the request or not. */ /* Check if we so far detected the protocol in the request or not. */
if (flow->steam_stage1 == 0) { if (flow->steam_stage1 == 0) {
NDPI_LOG_DBG2(ndpi_struct, "STEAM stage 0: \n"); NDPI_LOG_DBG2(ndpi_struct, "STEAM stage 0: \n");