/src/ndpi/src/lib/protocols/teamspeak.c
Line | Count | Source |
1 | | /* |
2 | | * teamspeak.c |
3 | | * |
4 | | * Copyright (C) 2013 Remy Mudingay <mudingay@ill.fr> |
5 | | * |
6 | | * This module is free software: you can redistribute it and/or modify |
7 | | * it under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation, either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This module is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License. |
17 | | * If not, see <http://www.gnu.org/licenses/>. |
18 | | */ |
19 | | |
20 | | #include "ndpi_protocol_ids.h" |
21 | | |
22 | | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_TEAMSPEAK |
23 | | |
24 | | #include "ndpi_api.h" |
25 | | #include "ndpi_private.h" |
26 | | |
27 | | static void ndpi_int_teamspeak_add_connection(struct ndpi_detection_module_struct |
28 | | *ndpi_struct, struct ndpi_flow_struct *flow) |
29 | 0 | { |
30 | 0 | ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TEAMSPEAK, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); |
31 | 0 | } |
32 | | |
33 | | |
34 | | static void ndpi_search_teamspeak(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) |
35 | 0 | { |
36 | 0 | struct ndpi_packet_struct *packet = &ndpi_struct->packet; |
37 | |
|
38 | 0 | NDPI_LOG_DBG(ndpi_struct, "search teamspeak\n"); |
39 | |
|
40 | 0 | if (packet->payload_packet_len >= 20) { |
41 | 0 | if (packet->udp != NULL) { |
42 | 0 | if (memcmp(packet->payload, "TS3INIT1", strlen("TS3INIT1")) == 0) |
43 | 0 | { |
44 | 0 | NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK udp\n"); |
45 | 0 | ndpi_int_teamspeak_add_connection(ndpi_struct, flow); |
46 | 0 | return; |
47 | 0 | } |
48 | 0 | } else if(packet->tcp != NULL) { |
49 | | /* https://github.com/Youx/soliloque-server/wiki/Connection-packet */ |
50 | 0 | if(((memcmp(packet->payload, "\xf4\xbe\x03\x00", 4) == 0)) || |
51 | 0 | ((memcmp(packet->payload, "\xf4\xbe\x02\x00", 4) == 0)) || |
52 | 0 | ((memcmp(packet->payload, "\xf4\xbe\x01\x00", 4) == 0))) |
53 | 0 | { |
54 | 0 | NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK tcp\n"); |
55 | 0 | ndpi_int_teamspeak_add_connection(ndpi_struct, flow); |
56 | 0 | return; |
57 | 0 | } /* http://www.imfirewall.com/en/protocols/teamSpeak.htm */ |
58 | 0 | } |
59 | 0 | } |
60 | | |
61 | 0 | if (packet->udp != NULL) |
62 | 0 | { |
63 | 0 | if (packet->payload_packet_len == 16 && |
64 | 0 | packet->payload[0] == 0x01 && packet->payload[3] == 0x02 && |
65 | 0 | get_u_int32_t(packet->payload, 11) == 0x00000000 && packet->payload[15] == 0x00) |
66 | 0 | { |
67 | 0 | goto ts3_license_weblist; |
68 | 0 | } |
69 | | |
70 | 0 | if ((packet->payload_packet_len == 4 || packet->payload_packet_len == 8) && |
71 | 0 | packet->payload[0] == 0x01 && packet->payload[3] == 0x01) |
72 | 0 | { |
73 | 0 | goto ts3_license_weblist; |
74 | 0 | } |
75 | | |
76 | 0 | if (packet->payload_packet_len == 5 && |
77 | 0 | packet->payload[0] == 0x01 && packet->payload[3] == 0x02 && |
78 | 0 | packet->payload[4] == 0x00) |
79 | 0 | { |
80 | 0 | goto ts3_license_weblist; |
81 | 0 | } |
82 | 0 | } |
83 | | |
84 | 0 | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
85 | 0 | return; |
86 | | |
87 | 0 | ts3_license_weblist: |
88 | 0 | if (flow->packet_counter == 3) |
89 | 0 | { |
90 | 0 | NDPI_LOG_INFO(ndpi_struct, "found TEAMSPEAK license/weblist\n"); |
91 | 0 | ndpi_int_teamspeak_add_connection(ndpi_struct, flow); |
92 | 0 | return; |
93 | 0 | } |
94 | 0 | } |
95 | | |
96 | | void init_teamspeak_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
97 | 1 | { |
98 | 1 | register_dissector("TeamSpeak", ndpi_struct, |
99 | 1 | ndpi_search_teamspeak, |
100 | 1 | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, |
101 | 1 | 1, NDPI_PROTOCOL_TEAMSPEAK); |
102 | 1 | } |
103 | | |