/src/ndpi/src/lib/protocols/among_us.c
Line | Count | Source |
1 | | /* |
2 | | * among_us.c |
3 | | * |
4 | | * Copyright (C) 2020 - ntop.org |
5 | | * |
6 | | * nDPI 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 | | * nDPI 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 | | * along with nDPI. If not, see <http://www.gnu.org/licenses/>. |
18 | | * |
19 | | */ |
20 | | |
21 | | #include "ndpi_protocol_ids.h" |
22 | | |
23 | | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_AMONG_US |
24 | | |
25 | | #include "ndpi_api.h" |
26 | | #include "ndpi_private.h" |
27 | | |
28 | | static void ndpi_int_among_us_add_connection(struct ndpi_detection_module_struct *ndpi_struct, |
29 | | struct ndpi_flow_struct *flow) |
30 | 25 | { |
31 | 25 | ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AMONG_US, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); |
32 | 25 | } |
33 | | |
34 | | static void ndpi_search_among_us(struct ndpi_detection_module_struct *ndpi_struct, |
35 | | struct ndpi_flow_struct *flow) |
36 | 522k | { |
37 | 522k | struct ndpi_packet_struct * const packet = &ndpi_struct->packet; |
38 | | |
39 | | /* handshake packet */ |
40 | 522k | if (packet->payload_packet_len > 9 && |
41 | 522k | ntohl(*(u_int32_t*)&packet->payload[0]) == 0x08000100 && |
42 | 522k | ntohl(*(u_int32_t*)&packet->payload[4]) == 0x80d90203) |
43 | 25 | { |
44 | 25 | ndpi_int_among_us_add_connection(ndpi_struct, flow); |
45 | 522k | } else { |
46 | 522k | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
47 | 522k | } |
48 | 522k | } |
49 | | |
50 | | void init_among_us_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
51 | 15.4k | { |
52 | 15.4k | register_dissector("AmongUs", ndpi_struct, |
53 | 15.4k | ndpi_search_among_us, |
54 | 15.4k | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD, |
55 | 15.4k | 1, NDPI_PROTOCOL_AMONG_US); |
56 | 15.4k | } |
57 | | |