Add Call of Duty Mobile support (#2438)

This commit is contained in:
Vladimir Gavrilov
2024-05-15 12:46:02 +02:00
committed by GitHub
parent d6b1c24079
commit 3d1da00d8d
88 changed files with 218 additions and 83 deletions
+1
View File
@@ -918,6 +918,7 @@ void init_knxnet_ip_dissector(struct ndpi_detection_module_struct *ndpi_struct,
void init_bfcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_iqiyi_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_egd_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_cod_mobile_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
#endif
+1 -1
View File
@@ -214,7 +214,7 @@ typedef enum {
NDPI_PROTOCOL_PINTEREST = 183,
NDPI_PROTOCOL_VHUA = 184,
NDPI_PROTOCOL_TELEGRAM = 185,
NDPI_PROTOCOL_FREE_186 = 186, /* FREE */
NDPI_PROTOCOL_COD_MOBILE = 186,
NDPI_PROTOCOL_PANDORA = 187,
NDPI_PROTOCOL_QUIC = 188,
NDPI_PROTOCOL_ZOOM = 189, /* Zoom video conference. */
+2
View File
@@ -1616,6 +1616,8 @@ static ndpi_protocol_match host_match[] =
{ "irc.undernet.org", "IRC", NDPI_PROTOCOL_IRC, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL },
{ "irc.ircnet.com", "IRC", NDPI_PROTOCOL_IRC, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL },
{ "codmwest.com", "CoD_Mobile", NDPI_PROTOCOL_COD_MOBILE, NDPI_PROTOCOL_CATEGORY_GAME, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL },
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_content_match_host_match.c.inc"
#endif
+5 -2
View File
@@ -2308,8 +2308,8 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
"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 */);
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_FREE_186,
"Free186", NDPI_PROTOCOL_CATEGORY_MUSIC,
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_COD_MOBILE,
"CoD_Mobile", NDPI_PROTOCOL_CATEGORY_GAME,
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
@@ -6223,6 +6223,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
/* Ethernet Global Data */
init_egd_dissector(ndpi_str, &a);
/* Call of Duty: Mobile */
init_cod_mobile_dissector(ndpi_str, &a);
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_main_init.c"
#endif
+83
View File
@@ -0,0 +1,83 @@
/*
* cod_mobile.c
*
* Call of Duty: Mobile
*
* Copyright (C) 2024 - ntop.org
* Copyright (C) 2024 - V.G <v.gavrilov@securitycode.ru>
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* nDPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* nDPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_protocol_ids.h"
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_COD_MOBILE
#include "ndpi_api.h"
#include "ndpi_private.h"
static void ndpi_int_cod_mobile_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
NDPI_LOG_INFO(ndpi_struct, "found Call of Duty: Mobile\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_COD_MOBILE,
NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
}
static void ndpi_search_cod_mobile(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
NDPI_LOG_DBG(ndpi_struct, "search Call of Duty: Mobile\n");
if (packet->payload_packet_len == 12 &&
(ntohs(packet->udp->source) == 7500 || ntohs(packet->udp->dest) == 7500))
{
if (memcmp(&packet->payload[8], "ping", 4) == 0)
{
ndpi_int_cod_mobile_add_connection(ndpi_struct, flow);
return;
}
}
if (packet->payload_packet_len > 350 && packet->payload[0] == 0xCE)
{
if (ndpi_memmem(packet->payload, packet->payload_packet_len, "LOC_PREFAB_LOADOUTNAME_1",
NDPI_STATICSTRING_LEN("LOC_PREFAB_LOADOUTNAME_1")))
{
ndpi_int_cod_mobile_add_connection(ndpi_struct, flow);
return;
}
}
if (flow->packet_counter >= 4) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
}
void init_cod_mobile_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
{
ndpi_set_bitmask_protocol_detection("CoD_Mobile", ndpi_struct, *id,
NDPI_PROTOCOL_COD_MOBILE,
ndpi_search_cod_mobile,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}