aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/gnutella.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2025-05-20 16:58:53 +0200
committerGitHub <noreply@github.com>2025-05-20 16:58:53 +0200
commit0e0f35c99a99f2f4f8ede49a09ae9ffd75255482 (patch)
tree2276586700d5d33b0dfa6ebb1eadfd62e0e87d25 /src/lib/protocols/gnutella.c
parent0d2213f7ff154af85d8deaaaaa6537e09676574f (diff)
Gnutella: avoid false positives (#2832)
Diffstat (limited to 'src/lib/protocols/gnutella.c')
-rw-r--r--src/lib/protocols/gnutella.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/lib/protocols/gnutella.c b/src/lib/protocols/gnutella.c
index f0f81e376..ecfb1da11 100644
--- a/src/lib/protocols/gnutella.c
+++ b/src/lib/protocols/gnutella.c
@@ -59,13 +59,10 @@ static void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struc
if (packet->payload_packet_len > 23) {
u_int32_t gnutella_payload_len = le32toh(get_u_int32_t(packet->payload, 19));
- /* Some of the Mojito-DHT packets have also this pattern:
- ntohl(get_u_int32_t(packet->payload, 24)) == 0x47544b47 GTKG
- but not all of them, and sometime not the first packets in the flow.
- If the following check is not enough to avoid false positives, we could add
- that pattern back somehow... */
-
- if (gnutella_payload_len == (u_int32_t)packet->payload_packet_len - 23) {
+ if (gnutella_payload_len == (u_int32_t)packet->payload_packet_len - 23 &&
+ ((packet->payload_packet_len > 27 &&
+ ntohl(get_u_int32_t(packet->payload, 24)) == 0x47544b47 /* GTKG */) ||
+ ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 4)) == 0x82514b40)) {
NDPI_LOG_DBG2(ndpi_struct, "detected mojito-dht/gnutella udp\n");
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CONFIDENCE_DPI);
return;