Cleaned up starcraft protocol code
Fixed false-positive in Skype dissector
This commit is contained in:
@@ -199,7 +199,7 @@
|
|||||||
#define NDPI_PROTOCOL_TELEGRAM 185 /* Gianluca Costa <g.costa@xplico.org> */
|
#define NDPI_PROTOCOL_TELEGRAM 185 /* Gianluca Costa <g.costa@xplico.org> */
|
||||||
#define NDPI_PROTOCOL_QUIC 188 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */
|
#define NDPI_PROTOCOL_QUIC 188 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */
|
||||||
#define NDPI_PROTOCOL_WHATSAPP_VOICE 189
|
#define NDPI_PROTOCOL_WHATSAPP_VOICE 189
|
||||||
#define NDPI_PROTOCOL_STARCRAFT2 214 /* matteobracci1@gmail.com */
|
#define NDPI_PROTOCOL_STARCRAFT 214 /* Matteo Bracci <matteobracci1@gmail.com> */
|
||||||
|
|
||||||
|
|
||||||
#define NDPI_CONTENT_AVI 39
|
#define NDPI_CONTENT_AVI 39
|
||||||
@@ -260,10 +260,10 @@
|
|||||||
#define NDPI_SERVICE_DEEZER 210
|
#define NDPI_SERVICE_DEEZER 210
|
||||||
#define NDPI_SERVICE_INSTAGRAM 211 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
|
#define NDPI_SERVICE_INSTAGRAM 211 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
|
||||||
#define NDPI_SERVICE_MICROSOFT 212
|
#define NDPI_SERVICE_MICROSOFT 212
|
||||||
#define NDPI_SERVICE_BATTLENET 213 /* matteobracci1@gmail.com */
|
#define NDPI_SERVICE_BATTLENET 213 /* Matteo Bracci <matteobracci1@gmail.com> */
|
||||||
|
|
||||||
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE */
|
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE */
|
||||||
#define NDPI_LAST_IMPLEMENTED_PROTOCOL NDPI_PROTOCOL_STARCRAFT2
|
#define NDPI_LAST_IMPLEMENTED_PROTOCOL NDPI_PROTOCOL_STARCRAFT
|
||||||
|
|
||||||
#define NDPI_MAX_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1)
|
#define NDPI_MAX_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1)
|
||||||
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
|
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
|
||||||
|
|||||||
@@ -330,5 +330,6 @@ void init_xdmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_in
|
|||||||
void init_yahoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_yahoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
void init_zattoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_zattoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
void init_zmq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
void init_zmq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
|
void init_stracraft2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
|
||||||
|
|
||||||
#endif /* __NDPI_PROTOCOLS_INCLUDE_FILE__ */
|
#endif /* __NDPI_PROTOCOLS_INCLUDE_FILE__ */
|
||||||
|
|||||||
@@ -804,8 +804,8 @@ typedef struct ndpi_flow_struct {
|
|||||||
u_int32_t pplive_stage2:2; // 0 - 2
|
u_int32_t pplive_stage2:2; // 0 - 2
|
||||||
u_int32_t pplive_stage3:2; // 0 - 2
|
u_int32_t pplive_stage3:2; // 0 - 2
|
||||||
#endif
|
#endif
|
||||||
#ifdef NDPI_PROTOCOL_STARCRAFT2
|
#ifdef NDPI_PROTOCOL_STARCRAFT
|
||||||
u_int32_t starcraft2_udp_stage : 3; // 0-7
|
u_int32_t starcraft_udp_stage : 3; // 0-7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* internal structures to save functions calls */
|
/* internal structures to save functions calls */
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ libndpi_la_SOURCES = ndpi_content_match.c.inc \
|
|||||||
protocols/ssdp.c \
|
protocols/ssdp.c \
|
||||||
protocols/ssh.c \
|
protocols/ssh.c \
|
||||||
protocols/ssl.c \
|
protocols/ssl.c \
|
||||||
|
protocols/starcraft.c \
|
||||||
protocols/stealthnet.c \
|
protocols/stealthnet.c \
|
||||||
protocols/steam.c \
|
protocols/steam.c \
|
||||||
protocols/stun.c \
|
protocols/stun.c \
|
||||||
|
|||||||
+712
-707
File diff suppressed because it is too large
Load Diff
+16
-6
@@ -1607,11 +1607,11 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
|
|||||||
no_master, "VHUA",
|
no_master, "VHUA",
|
||||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
|
||||||
ndpi_build_default_ports(ports_b, 58267, 0, 0, 0, 0) /* UDP */);
|
ndpi_build_default_ports(ports_b, 58267, 0, 0, 0, 0) /* UDP */);
|
||||||
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_STARCRAFT2,
|
ndpi_set_proto_defaults(ndpi_mod, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_STARCRAFT,
|
||||||
no_master,
|
no_master,
|
||||||
no_master, "Starcraft 2",
|
no_master, "Starcraft",
|
||||||
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0), /* TCP */
|
ndpi_build_default_ports(ports_a, 1119, 0, 0, 0, 0), /* TCP */
|
||||||
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0)); /* UDP */
|
ndpi_build_default_ports(ports_b, 1119, 0, 0, 0, 0)); /* UDP */
|
||||||
|
|
||||||
/* calling function for host and content matched protocols */
|
/* calling function for host and content matched protocols */
|
||||||
init_string_based_protocols(ndpi_mod);
|
init_string_based_protocols(ndpi_mod);
|
||||||
@@ -2217,6 +2217,9 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
|
|||||||
/* SKYPE */
|
/* SKYPE */
|
||||||
init_skype_dissector(ndpi_struct, &a, detection_bitmask);
|
init_skype_dissector(ndpi_struct, &a, detection_bitmask);
|
||||||
|
|
||||||
|
/* Stracraft */
|
||||||
|
init_starcraft_dissector(ndpi_struct, &a, detection_bitmask);
|
||||||
|
|
||||||
/* SSL */
|
/* SSL */
|
||||||
init_ssl_dissector(ndpi_struct, &a, detection_bitmask);
|
init_ssl_dissector(ndpi_struct, &a, detection_bitmask);
|
||||||
|
|
||||||
@@ -3392,9 +3395,12 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret_protocols:
|
ret_protocols:
|
||||||
if(flow->detected_protocol_stack[1] != NDPI_PROTOCOL_UNKNOWN)
|
if(flow->detected_protocol_stack[1] != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
ret.master_protocol = flow->detected_protocol_stack[1], ret.protocol = flow->detected_protocol_stack[0];
|
ret.master_protocol = flow->detected_protocol_stack[1], ret.protocol = flow->detected_protocol_stack[0];
|
||||||
else
|
|
||||||
|
if(ret.protocol == ret.master_protocol)
|
||||||
|
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
|
||||||
|
} else
|
||||||
ret.protocol = flow->detected_protocol_stack[0];
|
ret.protocol = flow->detected_protocol_stack[0];
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
@@ -4178,6 +4184,10 @@ ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct
|
|||||||
if(rc != NDPI_PROTOCOL_UNKNOWN) {
|
if(rc != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
ret.protocol = rc,
|
ret.protocol = rc,
|
||||||
ret.master_protocol = ndpi_guess_protocol_id(ndpi_struct, proto, sport, dport);
|
ret.master_protocol = ndpi_guess_protocol_id(ndpi_struct, proto, sport, dport);
|
||||||
|
|
||||||
|
if(ret.protocol == ret.master_protocol)
|
||||||
|
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,13 +68,17 @@ static void ndpi_check_skype(struct ndpi_detection_module_struct *ndpi_struct, s
|
|||||||
flow->l4.udp.skype_packet_id++;
|
flow->l4.udp.skype_packet_id++;
|
||||||
|
|
||||||
if(flow->l4.udp.skype_packet_id < 5) {
|
if(flow->l4.udp.skype_packet_id < 5) {
|
||||||
|
u_int16_t dport = ntohs(packet->udp->dest);
|
||||||
|
|
||||||
/* skype-to-skype */
|
/* skype-to-skype */
|
||||||
if(((payload_len == 3) && ((packet->payload[2] & 0x0F)== 0x0d))
|
if(dport != 1119) /* It can be confused with battle.net */ {
|
||||||
|| ((payload_len >= 16)
|
if(((payload_len == 3) && ((packet->payload[2] & 0x0F)== 0x0d))
|
||||||
&& (packet->payload[0] != 0x30) /* Avoid invalid SNMP detection */
|
|| ((payload_len >= 16)
|
||||||
&& (packet->payload[2] == 0x02))) {
|
&& (packet->payload[0] != 0x30) /* Avoid invalid SNMP detection */
|
||||||
NDPI_LOG(NDPI_PROTOCOL_SKYPE, ndpi_struct, NDPI_LOG_DEBUG, "Found skype.\n");
|
&& (packet->payload[2] == 0x02))) {
|
||||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SKYPE, NDPI_PROTOCOL_UNKNOWN);
|
NDPI_LOG(NDPI_PROTOCOL_SKYPE, ndpi_struct, NDPI_LOG_DEBUG, "Found skype.\n");
|
||||||
|
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SKYPE, NDPI_PROTOCOL_UNKNOWN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* starcraft.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 - Matteo Bracci <matteobracci1@gmail.com>
|
||||||
|
* Copyright (C) 2015 - ntop.org
|
||||||
|
*
|
||||||
|
* 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_protocols.h"
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_STARCRAFT
|
||||||
|
|
||||||
|
/* Sender or receiver are one of the known login portals? */
|
||||||
|
u_int8_t sc2_match_logon_ip(struct ndpi_packet_struct* packet)
|
||||||
|
{
|
||||||
|
if (packet->iph == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
u_int32_t source_ip = ntohl(packet->iph->saddr);
|
||||||
|
u_int32_t dest_ip = ntohl(packet->iph->daddr);
|
||||||
|
return (ndpi_ips_match(source_ip, dest_ip, 0xD5F87F82, 32) // EU 213.248.127.130
|
||||||
|
|| ndpi_ips_match(source_ip, dest_ip, 0x0C81CE82, 32) // US 12.129.206.130
|
||||||
|
|| ndpi_ips_match(source_ip, dest_ip, 0x79FEC882, 32) // KR 121.254.200.130
|
||||||
|
|| ndpi_ips_match(source_ip, dest_ip, 0xCA09424C, 32) // SG 202.9.66.76
|
||||||
|
|| ndpi_ips_match(source_ip, dest_ip, 0x0C81ECFE, 32)); // BETA 12.129.236.254
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
The main TCP flow starts with the user login and stays alive until the logout.
|
||||||
|
Although hard to read, judging from what happens elsewhere this flow probably contains all the data
|
||||||
|
transfer generated by the user interaction with the client, e.g. chatting or looking at someone's
|
||||||
|
match history. The current way to detect this is plain dumb packet matching.
|
||||||
|
*/
|
||||||
|
u_int8_t ndpi_check_starcraft_tcp(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow)
|
||||||
|
{
|
||||||
|
if (sc2_match_logon_ip(&flow->packet)
|
||||||
|
&& flow->packet.tcp->dest == htons(1119) //bnetgame port
|
||||||
|
&& flow->packet.payload_packet_len >= 10
|
||||||
|
&& (match_first_bytes(flow->packet.payload, "\x4a\x00\x00\x0a\x66\x02\x0a\xed\x2d\x66")
|
||||||
|
|| match_first_bytes(flow->packet.payload, "\x49\x00\x00\x0a\x66\x02\x0a\xed\x2d\x66")))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
UPD traffic is the actual game data and it uses a port owned by Blizzard itself, 1119. Therefore the
|
||||||
|
real key point here is to make sure that it's actually Starcraft 2 that is using the port and not
|
||||||
|
some other Blizzard software.
|
||||||
|
The flow is taken if a pattern in the size of some subsequent packets is found.
|
||||||
|
*/
|
||||||
|
u_int8_t ndpi_check_starcraft_udp(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct* packet = &flow->packet;
|
||||||
|
|
||||||
|
/* First off, filter out any traffic not using port 1119, removing the chance of any false positive if we assume that non allowed protocols don't use the port */
|
||||||
|
if (packet->udp->source != htons(1119) && packet->udp->dest != htons(1119))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Then try to detect the size pattern */
|
||||||
|
switch (flow->starcraft_udp_stage)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if (packet->payload_packet_len == 20)
|
||||||
|
flow->starcraft_udp_stage = 1;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (packet->payload_packet_len == 20)
|
||||||
|
flow->starcraft_udp_stage = 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (packet->payload_packet_len == 75 || packet->payload_packet_len == 85)
|
||||||
|
flow->starcraft_udp_stage = 3;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (packet->payload_packet_len == 20)
|
||||||
|
flow->starcraft_udp_stage = 4;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
if (packet->payload_packet_len == 548)
|
||||||
|
flow->starcraft_udp_stage = 5;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (packet->payload_packet_len == 548)
|
||||||
|
flow->starcraft_udp_stage = 6;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (packet->payload_packet_len == 548)
|
||||||
|
flow->starcraft_udp_stage = 7;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
if (packet->payload_packet_len == 484)
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_starcraft(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow)
|
||||||
|
{
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT, ndpi_struct, NDPI_LOG_DEBUG, "Starcraft protocol detection...\n");
|
||||||
|
if (flow->packet.detected_protocol_stack[0] != NDPI_PROTOCOL_STARCRAFT) {
|
||||||
|
struct ndpi_packet_struct* packet = &flow->packet;
|
||||||
|
int8_t result = 0;
|
||||||
|
|
||||||
|
if (packet->udp != NULL) {
|
||||||
|
result = ndpi_check_starcraft_udp(ndpi_struct, flow);
|
||||||
|
if (result == 1) {
|
||||||
|
//printf("Found Starcraft 2 [Game, UDP]\n");
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT, ndpi_struct, NDPI_LOG_DEBUG, "Found Starcraft 2 [Game, UDP]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (packet->tcp != NULL) {
|
||||||
|
result = ndpi_check_starcraft_tcp(ndpi_struct, flow);
|
||||||
|
if (result == 1) {
|
||||||
|
//printf("Found Starcraft 2 [Client, TCP]\n");
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT, ndpi_struct, NDPI_LOG_DEBUG, "Found Starcraft 2 [Client, TCP]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == 1) {
|
||||||
|
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_STARCRAFT, NDPI_PROTOCOL_UNKNOWN);
|
||||||
|
}
|
||||||
|
else if (result == -1) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT, ndpi_struct, NDPI_LOG_DEBUG, "Starcraft excluded\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_STARCRAFT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_starcraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
||||||
|
{
|
||||||
|
ndpi_set_bitmask_protocol_detection("Starcraft", ndpi_struct, detection_bitmask, *id,
|
||||||
|
NDPI_PROTOCOL_STARCRAFT, ndpi_search_starcraft,
|
||||||
|
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
||||||
|
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
||||||
|
ADD_TO_DETECTION_BITMASK);
|
||||||
|
|
||||||
|
*id += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
/*
|
|
||||||
* starcraft2.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009-2011 by ipoque GmbH
|
|
||||||
* Copyright (C) 2011-15 - ntop.org
|
|
||||||
*
|
|
||||||
* 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_protocols.h"
|
|
||||||
#ifdef NDPI_PROTOCOL_STARCRAFT2
|
|
||||||
|
|
||||||
/* Sender or receiver are one of the known login portals? */
|
|
||||||
u_int8_t sc2_match_logon_ip(struct ndpi_packet_struct* packet)
|
|
||||||
{
|
|
||||||
if (packet->iph == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
u_int32_t source_ip = ntohl(packet->iph->saddr);
|
|
||||||
u_int32_t dest_ip = ntohl(packet->iph->daddr);
|
|
||||||
return (ndpi_ips_match(source_ip, dest_ip, 0xD5F87F82, 32) // EU 213.248.127.130
|
|
||||||
|| ndpi_ips_match(source_ip, dest_ip, 0x0C81CE82, 32) // US 12.129.206.130
|
|
||||||
|| ndpi_ips_match(source_ip, dest_ip, 0x79FEC882, 32) // KR 121.254.200.130
|
|
||||||
|| ndpi_ips_match(source_ip, dest_ip, 0xCA09424C, 32) // SG 202.9.66.76
|
|
||||||
|| ndpi_ips_match(source_ip, dest_ip, 0x0C81ECFE, 32)); // BETA 12.129.236.254
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
The main TCP flow starts with the user login and stays alive until the logout.
|
|
||||||
Although hard to read, judging from what happens elsewhere this flow probably contains all the data
|
|
||||||
transfer generated by the user interaction with the client, e.g. chatting or looking at someone's
|
|
||||||
match history. The current way to detect this is plain dumb packet matching.
|
|
||||||
*/
|
|
||||||
u_int8_t ndpi_check_starcraft2_tcp(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow)
|
|
||||||
{
|
|
||||||
if (sc2_match_logon_ip(&flow->packet)
|
|
||||||
&& flow->packet.tcp->dest == htons(1119) //bnetgame port
|
|
||||||
&& flow->packet.payload_packet_len >= 10
|
|
||||||
&& (match_first_bytes(flow->packet.payload, "\x4a\x00\x00\x0a\x66\x02\x0a\xed\x2d\x66")
|
|
||||||
|| match_first_bytes(flow->packet.payload, "\x49\x00\x00\x0a\x66\x02\x0a\xed\x2d\x66")))
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
UPD traffic is the actual game data and it uses a port owned by Blizzard itself, 1119. Therefore the
|
|
||||||
real key point here is to make sure that it's actually Starcraft 2 that is using the port and not
|
|
||||||
some other Blizzard software.
|
|
||||||
The flow is taken if a pattern in the size of some subsequent packets is found.
|
|
||||||
*/
|
|
||||||
u_int8_t ndpi_check_starcraft2_udp(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow)
|
|
||||||
{
|
|
||||||
struct ndpi_packet_struct* packet = &flow->packet;
|
|
||||||
|
|
||||||
/* First off, filter out any traffic not using port 1119, removing the chance of any false positive if we assume that non allowed protocols don't use the port */
|
|
||||||
if (packet->udp->source != htons(1119) && packet->udp->dest != htons(1119))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Then try to detect the size pattern */
|
|
||||||
switch (flow->starcraft2_udp_stage)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if (packet->payload_packet_len == 20)
|
|
||||||
flow->starcraft2_udp_stage = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (packet->payload_packet_len == 20)
|
|
||||||
flow->starcraft2_udp_stage = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (packet->payload_packet_len == 75 || packet->payload_packet_len == 85)
|
|
||||||
flow->starcraft2_udp_stage = 3;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (packet->payload_packet_len == 20)
|
|
||||||
flow->starcraft2_udp_stage = 4;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (packet->payload_packet_len == 548)
|
|
||||||
flow->starcraft2_udp_stage = 5;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (packet->payload_packet_len == 548)
|
|
||||||
flow->starcraft2_udp_stage = 6;
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (packet->payload_packet_len == 548)
|
|
||||||
flow->starcraft2_udp_stage = 7;
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
if (packet->payload_packet_len == 484)
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ndpi_search_starcraft2(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow)
|
|
||||||
{
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT2, ndpi_struct, NDPI_LOG_DEBUG, "Starcraft2 protocol detection...\n");
|
|
||||||
if (flow->packet.detected_protocol_stack[0] != NDPI_PROTOCOL_STARCRAFT2) {
|
|
||||||
struct ndpi_packet_struct* packet = &flow->packet;
|
|
||||||
int8_t result = 0;
|
|
||||||
|
|
||||||
if (packet->udp != NULL) {
|
|
||||||
result = ndpi_check_starcraft2_udp(ndpi_struct, flow);
|
|
||||||
if (result == 1) {
|
|
||||||
//printf("Found Starcraft 2 [Game, UDP]\n");
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT2, ndpi_struct, NDPI_LOG_DEBUG, "Found Starcraft 2 [Game, UDP]\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (packet->tcp != NULL) {
|
|
||||||
result = ndpi_check_starcraft2_tcp(ndpi_struct, flow);
|
|
||||||
if (result == 1) {
|
|
||||||
//printf("Found Starcraft 2 [Client, TCP]\n");
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT2, ndpi_struct, NDPI_LOG_DEBUG, "Found Starcraft 2 [Client, TCP]\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 1) {
|
|
||||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_STARCRAFT2, NDPI_PROTOCOL_UNKNOWN);
|
|
||||||
}
|
|
||||||
else if (result == -1) {
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_STARCRAFT2, ndpi_struct, NDPI_LOG_DEBUG, "Starcraft2 excluded\n");
|
|
||||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_STARCRAFT2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_starcraft2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
|
|
||||||
{
|
|
||||||
ndpi_set_bitmask_protocol_detection("STARCRAFT2", ndpi_struct, detection_bitmask, *id,
|
|
||||||
NDPI_PROTOCOL_STARCRAFT2, ndpi_search_starcraft2,
|
|
||||||
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
|
|
||||||
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
|
|
||||||
ADD_TO_DETECTION_BITMASK);
|
|
||||||
|
|
||||||
*id += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
|||||||
|
Unknown 2 121 1
|
||||||
|
DNS 18 1956 5
|
||||||
|
HTTP 180 134270 2
|
||||||
|
SSDP 11 4984 1
|
||||||
|
IGMP 2 120 1
|
||||||
|
SSL 43 2903 13
|
||||||
|
Google 12 1467 2
|
||||||
|
Quic 6 475 1
|
||||||
|
Battle.net 287 162382 20
|
||||||
|
Starcraft 236 51494 6
|
||||||
|
|
||||||
|
1 TCP 80.239.186.21:80 <-> 192.168.1.100:3516 [proto: 7.213/HTTP.Battle.net][12 pkts/3680 bytes][Host: eu.launcher.battle.net]
|
||||||
|
2 TCP 80.239.186.26:80 <-> 192.168.1.100:3518 [proto: 7.213/HTTP.Battle.net][10 pkts/1226 bytes][Host: nydus.battle.net]
|
||||||
|
3 TCP 80.239.186.21:80 <-> 192.168.1.100:3522 [proto: 7.213/HTTP.Battle.net][11 pkts/3620 bytes][Host: eu.launcher.battle.net]
|
||||||
|
4 TCP 80.239.186.26:80 <-> 192.168.1.100:3524 [proto: 7.213/HTTP.Battle.net][10 pkts/1214 bytes][Host: nydus.battle.net]
|
||||||
|
5 TCP 80.239.186.40:80 <-> 192.168.1.100:3526 [proto: 7.213/HTTP.Battle.net][11 pkts/3686 bytes][Host: eu.battle.net]
|
||||||
|
6 TCP 192.168.1.100:3427 <-> 80.239.208.193:1119 [proto: 214/Starcraft][13 pkts/902 bytes]
|
||||||
|
7 UDP 239.255.255.250:1900 <-> 192.168.1.254:38605 [proto: 12/SSDP][11 pkts/4984 bytes]
|
||||||
|
8 UDP 192.168.1.100:53145 <-> 192.168.1.254:53 [proto: 5.213/DNS.Battle.net][4 pkts/336 bytes][Host: nydus.battle.net]
|
||||||
|
9 UDP 192.168.1.100:58831 <-> 192.168.1.254:53 [proto: 5/DNS][4 pkts/417 bytes][Host: 254.1.168.192.in-addr.arpa]
|
||||||
|
10 UDP 192.168.1.100:58851 <-> 192.168.1.254:53 [proto: 5/DNS][4 pkts/455 bytes][Host: 22.40.194.173.in-addr.arpa]
|
||||||
|
11 TCP 192.168.1.100:3484 <-> 173.194.113.224:443 [proto: 91.126/SSL.Google][3 pkts/168 bytes]
|
||||||
|
12 TCP 192.168.1.100:3486 <-> 199.38.164.156:443 [proto: 91/SSL][4 pkts/228 bytes]
|
||||||
|
13 UDP 192.168.1.100:53146 <-> 5.42.180.154:1119 [proto: 214/Starcraft][2 pkts/104 bytes]
|
||||||
|
14 TCP 192.168.1.100:3052 <-> 216.58.212.110:443 [proto: 91/SSL][2 pkts/121 bytes]
|
||||||
|
15 TCP 192.168.1.100:3528 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][29 pkts/25105 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
16 TCP 192.168.1.100:3530 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][29 pkts/25102 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
17 TCP 192.168.1.100:3532 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][4 pkts/386 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
18 TCP 192.168.1.100:3534 <-> 2.228.46.112:80 [proto: 7/HTTP][1 pkts/66 bytes]
|
||||||
|
19 TCP 192.168.1.100:3489 <-> 2.228.46.104:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
20 TCP 192.168.1.100:3481 <-> 2.228.46.114:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
21 TCP 192.168.1.100:3479 <-> 2.228.46.114:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
22 TCP 192.168.1.100:3491 <-> 2.228.46.104:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
23 TCP 80.239.186.26:80 <-> 192.168.1.100:3515 [proto: 7.213/HTTP.Battle.net][10 pkts/1224 bytes][Host: nydus.battle.net]
|
||||||
|
24 TCP 80.239.186.21:80 <-> 192.168.1.100:3519 [proto: 7.213/HTTP.Battle.net][9 pkts/979 bytes][Host: eu.launcher.battle.net]
|
||||||
|
25 TCP 80.239.186.26:80 <-> 192.168.1.100:3521 [proto: 7.213/HTTP.Battle.net][10 pkts/1224 bytes][Host: nydus.battle.net]
|
||||||
|
26 TCP 80.239.186.26:80 <-> 192.168.1.100:3523 [proto: 7.213/HTTP.Battle.net][10 pkts/1208 bytes][Host: nydus.battle.net]
|
||||||
|
27 TCP 80.239.186.40:80 <-> 192.168.1.100:3525 [proto: 7.213/HTTP.Battle.net][12 pkts/3933 bytes][Host: eu.battle.net]
|
||||||
|
28 TCP 80.239.186.26:443 <-> 192.168.1.100:3476 [proto: 91/SSL][1 pkts/60 bytes]
|
||||||
|
29 TCP 80.239.186.40:443 <-> 192.168.1.100:3478 [proto: 91/SSL][1 pkts/60 bytes]
|
||||||
|
30 TCP 192.168.1.100:3508 <-> 87.248.221.254:80 [proto: 7/HTTP][179 pkts/134204 bytes][Host: llnw.blizzard.com]
|
||||||
|
31 UDP 173.194.40.22:443 <-> 192.168.1.100:53568 [proto: 188/Quic][6 pkts/475 bytes]
|
||||||
|
32 UDP 192.168.1.100:55468 <-> 192.168.1.254:53 [proto: 5.213/DNS.Battle.net][4 pkts/556 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
33 UDP 192.168.1.100:58818 <-> 192.168.1.254:53 [proto: 5/DNS][4 pkts/432 bytes][Host: 91.252.30.192.in-addr.arpa]
|
||||||
|
34 UDP 192.168.1.100:58844 <-> 192.168.1.254:53 [proto: 5/DNS][2 pkts/210 bytes][Host: 40.186.239.80.in-addr.arpa]
|
||||||
|
35 UDP 192.168.1.100:60026 <-> 192.168.1.254:53 [proto: 5/DNS][4 pkts/442 bytes][Host: llnw.blizzard.com]
|
||||||
|
36 TCP 192.168.1.100:3506 <-> 173.194.113.224:80 [proto: 7.126/HTTP.Google][9 pkts/1299 bytes][Host: www.google-analytics.com]
|
||||||
|
37 TCP 192.30.252.91:443 <-> 192.168.1.100:3213 [proto: 91/SSL][3 pkts/234 bytes]
|
||||||
|
38 IGMP 224.0.0.22:0 <-> 192.168.1.107:0 [proto: 82/IGMP][2 pkts/120 bytes]
|
||||||
|
39 TCP 192.168.1.100:3517 <-> 213.248.127.130:1119 [proto: 214/Starcraft][215 pkts/50178 bytes]
|
||||||
|
40 UDP 192.168.1.100:6113 <-> 213.248.127.212:1119 [proto: 214/Starcraft][2 pkts/103 bytes]
|
||||||
|
41 UDP 192.168.1.100:6113 <-> 213.248.127.166:1119 [proto: 214/Starcraft][2 pkts/103 bytes]
|
||||||
|
42 TCP 192.168.1.100:3527 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][41 pkts/37433 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
43 TCP 192.168.1.100:3529 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][29 pkts/25102 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
44 TCP 192.168.1.100:3531 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][29 pkts/25102 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
45 TCP 192.168.1.100:3533 <-> 2.228.46.112:80 [proto: 7.213/HTTP.Battle.net][4 pkts/386 bytes][Host: bnetcmsus-a.akamaihd.net]
|
||||||
|
46 TCP 192.168.1.100:3492 <-> 2.228.46.104:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
47 TCP 192.168.1.100:3490 <-> 2.228.46.104:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
48 TCP 192.168.1.100:3482 <-> 2.228.46.114:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
49 TCP 192.168.1.100:3480 <-> 2.228.46.114:443 [proto: 91/SSL][4 pkts/275 bytes]
|
||||||
|
50 TCP 12.129.222.54:80 <-> 192.168.1.100:3512 [proto: 7.213/HTTP.Battle.net][9 pkts/880 bytes][Host: us.scan.worldofwarcraft.com]
|
||||||
|
51 UDP 62.115.246.51:1119 <-> 192.168.1.100:53146 [proto: 214/Starcraft][2 pkts/104 bytes]
|
||||||
|
|
||||||
|
|
||||||
|
Undetected flows:
|
||||||
|
1 TCP 192.168.1.100:2759 <-> 64.233.184.188:5228 [proto: 0/Unknown][2 pkts/121 bytes]
|
||||||
Reference in New Issue
Block a user