Merge pull request #1014 from lnslbrty/improved/teamspeak

Improved Teamspeak(3) protocol detection.
This commit is contained in:
Luca Deri
2020-09-09 23:28:21 +02:00
committed by GitHub
3 changed files with 28 additions and 43 deletions
+24 -42
View File
@@ -24,7 +24,7 @@
#include "ndpi_api.h" #include "ndpi_api.h"
static void ndpi_int_teamspeak_add_connection(struct ndpi_detection_module_struct static void ndpi_int_teamspeak_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow) *ndpi_struct, struct ndpi_flow_struct *flow)
{ {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TEAMSPEAK, NDPI_PROTOCOL_UNKNOWN); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TEAMSPEAK, NDPI_PROTOCOL_UNKNOWN);
} }
@@ -36,56 +36,38 @@ void ndpi_search_teamspeak(struct ndpi_detection_module_struct *ndpi_struct, str
NDPI_LOG_DBG(ndpi_struct, "search teamspeak\n"); NDPI_LOG_DBG(ndpi_struct, "search teamspeak\n");
if (packet->payload_packet_len >= 20) {
#ifdef WEAK_DETECTION_CODE_DISABLED if (packet->udp != NULL) {
if(packet->udp != NULL) { if (memcmp(packet->payload, "TS3INIT1", strlen("TS3INIT1")) == 0)
u_int16_t udport, usport; {
NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK udp\n");
usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest); ndpi_int_teamspeak_add_connection(ndpi_struct, flow);
}
/* http://www.imfirewall.com/en/protocols/teamSpeak.htm */ } else if(packet->tcp != NULL) {
if(((usport == 9987 || udport == 9987) || (usport == 8767 || udport == 8767)) && packet->payload_packet_len >= 20) { /* https://github.com/Youx/soliloque-server/wiki/Connection-packet */
NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK udp\n"); if(((memcmp(packet->payload, "\xf4\xbe\x03\x00", 4) == 0)) ||
ndpi_int_teamspeak_add_connection(ndpi_struct, flow); ((memcmp(packet->payload, "\xf4\xbe\x02\x00", 4) == 0)) ||
((memcmp(packet->payload, "\xf4\xbe\x01\x00", 4) == 0)))
{
NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK tcp\n");
ndpi_int_teamspeak_add_connection(ndpi_struct, flow);
} /* http://www.imfirewall.com/en/protocols/teamSpeak.htm */
} }
} }
else
#endif
if(packet->tcp != NULL) {
#if WEAK_DETECTION_CODE_DISABLED
u_int16_t tdport, tsport;
tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest);
#endif
/* https://github.com/Youx/soliloque-server/wiki/Connection-packet */
if(packet->payload_packet_len >= 20) {
if(((memcmp(packet->payload, "\xf4\xbe\x03\x00", 4) == 0)) ||
((memcmp(packet->payload, "\xf4\xbe\x02\x00", 4) == 0)) ||
((memcmp(packet->payload, "\xf4\xbe\x01\x00", 4) == 0))) {
NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK tcp\n");
ndpi_int_teamspeak_add_connection(ndpi_struct, flow);
} /* http://www.imfirewall.com/en/protocols/teamSpeak.htm */
}
#if WEAK_DETECTION_CODE_DISABLED
else if((tsport == 14534 || tdport == 14534) || (tsport == 51234 || tdport == 51234)) {
NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK\n");
ndpi_int_teamspeak_add_connection(ndpi_struct, flow);
}
#endif
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow); NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return; return;
} }
void init_teamspeak_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) void init_teamspeak_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
NDPI_PROTOCOL_BITMASK *detection_bitmask)
{ {
ndpi_set_bitmask_protocol_detection("TeamSpeak", ndpi_struct, detection_bitmask, *id, ndpi_set_bitmask_protocol_detection("TeamSpeak", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_TEAMSPEAK, NDPI_PROTOCOL_TEAMSPEAK,
ndpi_search_teamspeak, ndpi_search_teamspeak,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD, NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN, SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK); ADD_TO_DETECTION_BITMASK);
*id += 1; *id += 1;
} }
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
TeamSpeak 13 1911 1
1 UDP 10.0.0.1:53187 -> 10.0.0.2:9987 [proto: 162/TeamSpeak][cat: VoIP/10][13 pkts/1911 bytes -> 0 pkts/0 bytes][Goodput ratio: 71/0][37.01 sec][bytes ratio: 1.000 (Upload)][IAT c2s/s2c min/avg/max/stddev: 0/0 387/0 1301/0 449/0][Pkt Len c2s/s2c min/avg/max/stddev: 76/0 147/0 230/0 77/0][PLAIN TEXT (DDDDDDffffff)][Plen Bins: 0,53,0,0,0,46,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]