From 5b32c98a21b3d3c4d7ef60501bd2801061a0e6b7 Mon Sep 17 00:00:00 2001 From: Vladimir Gavrilov <105977161+0xA50C1A1@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:11:14 +0300 Subject: Add LoL: Wild Rift detection (#2356) --- src/lib/protocols/lol_wild_rift.c | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/lib/protocols/lol_wild_rift.c (limited to 'src/lib/protocols/lol_wild_rift.c') diff --git a/src/lib/protocols/lol_wild_rift.c b/src/lib/protocols/lol_wild_rift.c new file mode 100644 index 000000000..214c74dcb --- /dev/null +++ b/src/lib/protocols/lol_wild_rift.c @@ -0,0 +1,73 @@ +/* + * lol_wild_rift.c + * + * League of Legends: Wild Rift + * + * Copyright (C) 2024 - ntop.org + * Copyright (C) 2024 - V.G + * + * 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 . + * + */ + +#include "ndpi_protocol_ids.h" + +#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_LOLWILDRIFT + +#include "ndpi_api.h" +#include "ndpi_private.h" + +static void ndpi_search_lolwildrift(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 League of Legends: Wild Rift\n"); + + if (packet->payload_packet_len == 69 && + ntohl(get_u_int32_t(packet->payload, 0)) == 0x4000000) + { + flow->l4.udp.lolwildrift_stage = 1; + return; + } + + if (flow->l4.udp.lolwildrift_stage == 1 && + packet->payload_packet_len == 359 && + ntohl(get_u_int32_t(packet->payload, 0)) == 0x10000000) + { + NDPI_LOG_INFO(ndpi_struct, "found League of Legends: Wild Rift\n"); + ndpi_set_detected_protocol(ndpi_struct, flow, + NDPI_PROTOCOL_LOLWILDRIFT, NDPI_PROTOCOL_UNKNOWN, + NDPI_CONFIDENCE_DPI); + return; + } + + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); +} + +void init_lolwildrift_dissector(struct ndpi_detection_module_struct *ndpi_struct, + u_int32_t *id) +{ + ndpi_set_bitmask_protocol_detection("LoLWildRift", ndpi_struct, *id, + NDPI_PROTOCOL_LOLWILDRIFT, + ndpi_search_lolwildrift, + NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD, + SAVE_DETECTION_BITMASK_AS_UNKNOWN, + ADD_TO_DETECTION_BITMASK); + + *id += 1; +} -- cgit v1.2.3 From 599cc0f4b83a96c247a92aaaa3f39acfec9e1dbe Mon Sep 17 00:00:00 2001 From: Vladimir Gavrilov <105977161+0xA50C1A1@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:01:01 +0300 Subject: Improve LoL: Wild Rift detection (#2359) --- src/lib/protocols/lol_wild_rift.c | 21 +++++++++++++++++---- tests/cfgs/default/pcap/lol_wild_rift_udp.pcap | Bin 1572 -> 1704 bytes .../cfgs/default/result/lol_wild_rift_udp.pcap.out | 16 +++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src/lib/protocols/lol_wild_rift.c') diff --git a/src/lib/protocols/lol_wild_rift.c b/src/lib/protocols/lol_wild_rift.c index 214c74dcb..eb0328112 100644 --- a/src/lib/protocols/lol_wild_rift.c +++ b/src/lib/protocols/lol_wild_rift.c @@ -31,6 +31,14 @@ #include "ndpi_api.h" #include "ndpi_private.h" +static void ndpi_int_lolwildrift_add_connection(struct ndpi_detection_module_struct *ndpi_struct, + struct ndpi_flow_struct *flow) +{ + NDPI_LOG_INFO(ndpi_struct, "found League of Legends: Wild Rift\n"); + ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_LOLWILDRIFT, + NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); +} + static void ndpi_search_lolwildrift(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { @@ -38,6 +46,14 @@ static void ndpi_search_lolwildrift(struct ndpi_detection_module_struct *ndpi_st NDPI_LOG_DBG(ndpi_struct, "search League of Legends: Wild Rift\n"); + if (packet->payload_packet_len == 22 && + ntohl(get_u_int32_t(packet->payload, 0)) == 0x102C841 && + ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len-4)) == 0x41304231) + { + ndpi_int_lolwildrift_add_connection(ndpi_struct, flow); + return; + } + if (packet->payload_packet_len == 69 && ntohl(get_u_int32_t(packet->payload, 0)) == 0x4000000) { @@ -49,10 +65,7 @@ static void ndpi_search_lolwildrift(struct ndpi_detection_module_struct *ndpi_st packet->payload_packet_len == 359 && ntohl(get_u_int32_t(packet->payload, 0)) == 0x10000000) { - NDPI_LOG_INFO(ndpi_struct, "found League of Legends: Wild Rift\n"); - ndpi_set_detected_protocol(ndpi_struct, flow, - NDPI_PROTOCOL_LOLWILDRIFT, NDPI_PROTOCOL_UNKNOWN, - NDPI_CONFIDENCE_DPI); + ndpi_int_lolwildrift_add_connection(ndpi_struct, flow); return; } diff --git a/tests/cfgs/default/pcap/lol_wild_rift_udp.pcap b/tests/cfgs/default/pcap/lol_wild_rift_udp.pcap index fd9827feb..32a7e2b18 100644 Binary files a/tests/cfgs/default/pcap/lol_wild_rift_udp.pcap and b/tests/cfgs/default/pcap/lol_wild_rift_udp.pcap differ diff --git a/tests/cfgs/default/result/lol_wild_rift_udp.pcap.out b/tests/cfgs/default/result/lol_wild_rift_udp.pcap.out index 466bb390e..02fb2df60 100644 --- a/tests/cfgs/default/result/lol_wild_rift_udp.pcap.out +++ b/tests/cfgs/default/result/lol_wild_rift_udp.pcap.out @@ -1,6 +1,6 @@ -DPI Packets (UDP): 6 (2.00 pkts/flow) -Confidence DPI : 3 (flows) -Num dissector calls: 471 (157.00 diss/flow) +DPI Packets (UDP): 8 (1.60 pkts/flow) +Confidence DPI : 5 (flows) +Num dissector calls: 749 (149.80 diss/flow) LRU cache ookla: 0/0/0 (insert/search/found) LRU cache bittorrent: 0/0/0 (insert/search/found) LRU cache zoom: 0/0/0 (insert/search/found) @@ -14,17 +14,19 @@ Automa domain: 0/0 (search/found) Automa tls cert: 0/0 (search/found) Automa risk mask: 0/0 (search/found) Automa common alpns: 0/0 (search/found) -Patricia risk mask: 0/0 (search/found) +Patricia risk mask: 4/0 (search/found) Patricia risk mask IPv6: 0/0 (search/found) Patricia risk: 0/0 (search/found) Patricia risk IPv6: 0/0 (search/found) -Patricia protocols: 3/3 (search/found) +Patricia protocols: 5/5 (search/found) Patricia protocols IPv6: 0/0 (search/found) -LoLWildRift 6 1452 3 +LoLWildRift 8 1552 5 -Fun 6 1452 3 +Fun 8 1552 5 1 UDP 10.215.173.1:43686 <-> 13.51.213.131:15007 [proto: 407/LoLWildRift][IP: 265/AmazonAWS][ClearText][Confidence: DPI][DPI packets: 2][cat: Game/8][1 pkts/97 bytes <-> 1 pkts/387 bytes][Goodput ratio: 70/93][0.03 sec][Plen Bins: 0,0,50,0,0,0,0,0,0,0,0,50,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] 2 UDP 10.215.173.1:46702 <-> 51.20.230.207:15007 [proto: 407/LoLWildRift][IP: 265/AmazonAWS][ClearText][Confidence: DPI][DPI packets: 2][cat: Game/8][1 pkts/97 bytes <-> 1 pkts/387 bytes][Goodput ratio: 70/93][0.08 sec][Plen Bins: 0,0,50,0,0,0,0,0,0,0,0,50,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] 3 UDP 10.215.173.1:47462 <-> 51.20.230.207:15004 [proto: 407/LoLWildRift][IP: 265/AmazonAWS][ClearText][Confidence: DPI][DPI packets: 2][cat: Game/8][1 pkts/97 bytes <-> 1 pkts/387 bytes][Goodput ratio: 70/93][0.09 sec][Plen Bins: 0,0,50,0,0,0,0,0,0,0,0,50,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] + 4 UDP 10.215.173.1:41440 -> 13.53.58.18:18001 [proto: 407/LoLWildRift][IP: 265/AmazonAWS][ClearText][Confidence: DPI][DPI packets: 1][cat: Game/8][1 pkts/50 bytes -> 0 pkts/0 bytes][Goodput ratio: 43/0][< 1 sec][Risk: ** Unidirectional Traffic **][Risk Score: 10][Risk Info: No server to client traffic][Plen Bins: 100,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,0,0,0,0,0] + 5 UDP 10.215.173.1:44513 -> 13.53.58.18:18001 [proto: 407/LoLWildRift][IP: 265/AmazonAWS][ClearText][Confidence: DPI][DPI packets: 1][cat: Game/8][1 pkts/50 bytes -> 0 pkts/0 bytes][Goodput ratio: 43/0][< 1 sec][Risk: ** Unidirectional Traffic **][Risk Score: 10][Risk Info: No server to client traffic][Plen Bins: 100,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,0,0,0,0,0] -- cgit v1.2.3