Viber: add detection of voip calls and avoid false positives (#2434)

This commit is contained in:
Ivan Nardi
2024-05-11 09:21:13 +02:00
committed by GitHub
parent a813121e0a
commit b116456fc5
11 changed files with 62 additions and 42 deletions
+1
View File
@@ -442,6 +442,7 @@ typedef enum {
NDPI_PROTOCOL_BLUESKY = 411,
NDPI_PROTOCOL_MASTODON = 412,
NDPI_PROTOCOL_THREADS = 413,
NDPI_PROTOCOL_VIBER_VOIP = 414,
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"
+4
View File
@@ -2304,6 +2304,10 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
"iQIYI", NDPI_PROTOCOL_CATEGORY_STREAMING,
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
ndpi_set_proto_defaults(ndpi_str, 0 /* encrypted */, 1 /* app proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_VIBER_VOIP,
"ViberVoip", NDPI_PROTOCOL_CATEGORY_VOIP,
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_main.c"
+2
View File
@@ -511,6 +511,8 @@ int is_stun(struct ndpi_detection_module_struct *ndpi_struct,
*app_proto = NDPI_PROTOCOL_ADULT_CONTENT;
} else if(strstr(flow->host_server_name, "telegram") != NULL) {
*app_proto = NDPI_PROTOCOL_TELEGRAM_VOIP;
} else if(strstr(flow->host_server_name, "viber") != NULL) {
*app_proto = NDPI_PROTOCOL_VIBER_VOIP;
}
} else
flow->host_server_name[0] = '\0';
+7 -6
View File
@@ -70,12 +70,13 @@ static void ndpi_search_viber(struct ndpi_detection_module_struct *ndpi_struct,
if((packet->udp != NULL) && (packet->payload_packet_len > 5)) {
NDPI_LOG_DBG2(ndpi_struct, "calculating dport over udp\n");
if((packet->payload[2] == 0x03 && packet->payload[3] == 0x00)
|| (packet->payload_packet_len == 20 && packet->payload[2] == 0x09 && packet->payload[3] == 0x00)
|| (packet->payload[2] == 0x01 && packet->payload[3] == 0x00 && packet->payload[4] == 0x05 && packet->payload[5] == 0x00)
|| (packet->payload_packet_len == 34 && packet->payload[2] == 0x19 && packet->payload[3] == 0x00)
|| (packet->payload_packet_len == 34 && packet->payload[2] == 0x1b && packet->payload[3] == 0x00)
)
if((flow->l4.udp.rtp_stage == 0) && (flow->l4.udp.rtcp_stage == 0) /* Avoid collisions with RTP/RTCP */ &&
((packet->payload[2] == 0x03 && packet->payload[3] == 0x00)
|| (packet->payload_packet_len == 20 && packet->payload[2] == 0x09 && packet->payload[3] == 0x00)
|| (packet->payload[2] == 0x01 && packet->payload[3] == 0x00 && packet->payload[4] == 0x05 && packet->payload[5] == 0x00)
|| (packet->payload_packet_len == 34 && packet->payload[2] == 0x19 && packet->payload[3] == 0x00)
|| (packet->payload_packet_len == 34 && packet->payload[2] == 0x1b && packet->payload[3] == 0x00)
))
{
viber_add_connection(ndpi_struct, flow);
return;