Merge branch 'dev' of https://github.com/ntop/nDPI into dev

This commit is contained in:
Luca Deri
2020-01-05 18:25:44 +01:00
54 changed files with 1490 additions and 1828 deletions
+1 -3
View File
@@ -72,9 +72,7 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
} else
bt_hash = (const char*)&flow->packet.payload[28];
if(!ndpi_struct->disable_metadata_export) {
if(bt_hash) memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
}
if(bt_hash) memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
}
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN);
+23 -29
View File
@@ -100,42 +100,36 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
if(msg_type <= 8) foundValidMsgType = 1;
} else if(id == 55 /* Parameter Request List / Fingerprint */) {
if(!ndpi_struct->disable_metadata_export) {
u_int idx, offset = 0;
u_int idx, offset = 0;
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
int rc = snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%s%u", (idx > 0) ? "," : "",
(unsigned int)dhcp->options[i+2+idx] & 0xFF);
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
int rc = snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%s%u", (idx > 0) ? "," : "",
(unsigned int)dhcp->options[i+2+idx] & 0xFF);
if(rc < 0) break; else offset += rc;
}
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
if(rc < 0) break; else offset += rc;
}
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
} else if(id == 60 /* Class Identifier */) {
if(!ndpi_struct->disable_metadata_export) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
flow->protos.dhcp.class_ident[j] = '\0';
}
char *name = (char*)&dhcp->options[i+2];
int j = 0;
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
flow->protos.dhcp.class_ident[j] = '\0';
} else if(id == 12 /* Host Name */) {
if(!ndpi_struct->disable_metadata_export) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;
char *name = (char*)&dhcp->options[i+2];
int j = 0;
#ifdef DHCP_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
// while(j < len) { printf( "%c", name[j]); j++; }; printf("\n");
#endif
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, name, j);
flow->host_server_name[j] = '\0';
}
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, name, j);
flow->host_server_name[j] = '\0';
}
i += len + 2;
+11 -18
View File
@@ -149,9 +149,8 @@ static void setHttpUserAgent(struct ndpi_detection_module_struct *ndpi_struct,
* https://github.com/ua-parser/uap-core/blob/master/regexes.yaml */
//printf("==> %s\n", ua);
if(!ndpi_struct->disable_metadata_export) {
snprintf((char*)flow->protos.http.detected_os, sizeof(flow->protos.http.detected_os), "%s", ua);
}
snprintf((char*)flow->protos.http.detected_os,
sizeof(flow->protos.http.detected_os), "%s", ua);
}
/* ************************************************************* */
@@ -160,14 +159,12 @@ static void ndpi_http_parse_subprotocol(struct ndpi_detection_module_struct *ndp
struct ndpi_flow_struct *flow) {
if((flow->l4.tcp.http_stage == 0) || (flow->http.url && flow->http_detected)) {
char *double_col = strchr((char*)flow->host_server_name, ':');
ndpi_protocol_match_result ret_match;
if(double_col) double_col[0] = '\0';
ndpi_match_host_subprotocol(ndpi_struct, flow, (char *)flow->host_server_name,
strlen((const char *)flow->host_server_name),
&ret_match,
NDPI_PROTOCOL_HTTP);
ndpi_match_hostname_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HTTP,
(char *)flow->host_server_name,
strlen((const char *)flow->host_server_name));
}
}
@@ -333,21 +330,17 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
packet->host_line.len, packet->host_line.ptr);
/* Copy result for nDPI apps */
if(!ndpi_struct->disable_metadata_export) {
len = ndpi_min(packet->host_line.len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, (char*)packet->host_line.ptr, len);
flow->host_server_name[len] = '\0';
flow->extra_packets_func = NULL; /* We're good now */
}
len = ndpi_min(packet->host_line.len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, (char*)packet->host_line.ptr, len);
flow->host_server_name[len] = '\0';
flow->extra_packets_func = NULL; /* We're good now */
flow->server_id = flow->dst;
if(packet->forwarded_line.ptr) {
len = ndpi_min(packet->forwarded_line.len, sizeof(flow->protos.http.nat_ip)-1);
if(!ndpi_struct->disable_metadata_export) {
strncpy((char*)flow->protos.http.nat_ip, (char*)packet->forwarded_line.ptr, len);
flow->protos.http.nat_ip[len] = '\0';
}
strncpy((char*)flow->protos.http.nat_ip, (char*)packet->forwarded_line.ptr, len);
flow->protos.http.nat_ip[len] = '\0';
}
ndpi_http_parse_subprotocol(ndpi_struct, flow);
+5 -6
View File
@@ -28,7 +28,7 @@
#include "ndpi_api.h"
//#define KERBEROS_DEBUG 1
/* #define KERBEROS_DEBUG 1 */
#define KERBEROS_PORT 88
@@ -190,7 +190,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
u_int16_t name_offset;
name_offset = body_offset + 13;
for(i=0; i<10; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */
for(i=0; i<20; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */
#ifdef KERBEROS_DEBUG
printf("name_offset=%u [%02X %02X] [byte 0 must be 0x1b]\n", name_offset, packet->payload[name_offset], packet->payload[name_offset+1]);
@@ -222,8 +222,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
for(i=0; i<cname_len; i++) cname_str[i] = tolower(cname_str[i]);
#ifdef KERBEROS_DEBUG
printf("[AS-REQ][s/dport: %u/%u][Kerberos Cname][len: %u][%s]\n",
sport, dport, cname_len, cname_str);
printf("[AS-REQ][s/dport: %u/%u][Kerberos Cname][len: %u][%s]\n", sport, dport, cname_len, cname_str);
#endif
if(((strcmp(cname_str, "host") == 0) || (strcmp(cname_str, "ldap") == 0)) && (packet->payload[name_offset+1+cname_len] == 0x1b)) {
@@ -242,7 +241,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
} else
snprintf(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username), "%s", cname_str);
for(i=0; i<10; i++) if(packet->payload[realm_offset] != 0x1b) name_offset++; /* ASN.1 */
for(i=0; i<14; i++) if(packet->payload[realm_offset] != 0x1b) realm_offset++; /* ASN.1 */
#ifdef KERBEROS_DEBUG
printf("realm_offset=%u [%02X %02X] [byte 0 must be 0x1b]\n", realm_offset, packet->payload[realm_offset], packet->payload[realm_offset+1]);
#endif
@@ -279,7 +278,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
u_int name_offset, padding_offset = body_offset + 4;
name_offset = padding_offset;
for(i=0; i<10; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */
for(i=0; i<14; i++) if(packet->payload[name_offset] != 0x1b) name_offset++; /* ASN.1 */
#ifdef KERBEROS_DEBUG
printf("name_offset=%u [%02X %02X] [byte 0 must be 0x1b]\n", name_offset, packet->payload[name_offset], packet->payload[name_offset+1]);
+3 -5
View File
@@ -82,11 +82,9 @@ static int ndpi_int_check_mdns_payload(struct ndpi_detection_module_struct
/* printf("==> [%d] %s\n", j, answer); */
if(!ndpi_struct->disable_metadata_export) {
len = ndpi_min(sizeof(flow->protos.mdns.answer)-1, j);
strncpy(flow->protos.mdns.answer, (const char *)answer, len);
flow->protos.mdns.answer[len] = '\0';
}
len = ndpi_min(sizeof(flow->protos.mdns.answer)-1, j);
strncpy(flow->protos.mdns.answer, (const char *)answer, len);
flow->protos.mdns.answer[len] = '\0';
NDPI_LOG_INFO(ndpi_struct, "found MDNS with answer query\n");
return 1;
+4 -7
View File
@@ -73,13 +73,10 @@ int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len) {
static void ndpi_int_netbios_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow) {
char name[64];
if(!ndpi_struct->disable_metadata_export) {
u_int off = flow->packet.payload[12] == 0x20 ? 12 : 14;
if(ndpi_netbios_name_interpret((char*)&flow->packet.payload[off], name, sizeof(name)) > 0)
snprintf((char*)flow->host_server_name, sizeof(flow->host_server_name)-1, "%s", name);
}
u_int off = flow->packet.payload[12] == 0x20 ? 12 : 14;
if(ndpi_netbios_name_interpret((char*)&flow->packet.payload[off], name, sizeof(name)) > 0)
snprintf((char*)flow->host_server_name, sizeof(flow->host_server_name)-1, "%s", name);
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_NETBIOS, NDPI_PROTOCOL_UNKNOWN);
}
+74 -77
View File
@@ -83,10 +83,10 @@ static void ndpi_int_oscar_add_connection(struct ndpi_detection_module_struct *n
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_OSCAR, NDPI_PROTOCOL_UNKNOWN);
if (src != NULL) {
if(src != NULL) {
src->oscar_last_safe_access_time = packet->tick_timestamp;
}
if (dst != NULL) {
if(dst != NULL) {
dst->oscar_last_safe_access_time = packet->tick_timestamp;
}
}
@@ -107,10 +107,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
u_int16_t family;
u_int16_t type;
u_int16_t flag;
u_int32_t req_ID;
struct ndpi_packet_struct * packet = &flow->packet;
struct ndpi_id_struct * src = flow->src;
struct ndpi_id_struct * dst = flow->dst;
@@ -124,7 +121,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
* [ 4 byte of data ]
*
* */
if (packet->payload_packet_len >= 6 && packet->payload[0] == 0x2a)
if(packet->payload_packet_len >= 6 && packet->payload[0] == 0x2a)
{
/* FLAP__FRAME_TYPE (Channel)*/
@@ -140,7 +137,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
+ TLVs | [Class: FLAP__SIGNON_TAGS] TLVs +
+--------------------------------------------------+
*/
if (channel == SIGNON &&
if(channel == SIGNON &&
get_u_int16_t(packet->payload, 4) == htons(packet->payload_packet_len - 6) &&
get_u_int32_t(packet->payload, 6) == htonl(FLAPVERSION))
{
@@ -153,28 +150,28 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
return;
}
/* /\* SCREEN_NAME *\/ */
/* if (get_u_int16_t(packet->payload, 10) == htons(SCREEN_NAME)) /\* packet->payload[10] == 0x00 && packet->payload[11] == 0x01 *\/ */
/* if(get_u_int16_t(packet->payload, 10) == htons(SCREEN_NAME)) /\* packet->payload[10] == 0x00 && packet->payload[11] == 0x01 *\/ */
/* { */
/* NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Screen Name \n"); */
/* ndpi_int_oscar_add_connection(ndpi_struct, flow); */
/* return; */
/* } */
/* /\* PASSWD *\/ */
/* if (get_u_int16_t(packet->payload, 10) == htons(PASSWD)) /\* packet->payload[10] == 0x00 && packet->payload[11] == 0x02 *\/ */
/* if(get_u_int16_t(packet->payload, 10) == htons(PASSWD)) /\* packet->payload[10] == 0x00 && packet->payload[11] == 0x02 *\/ */
/* { */
/* NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Password (roasted) \n"); */
/* ndpi_int_oscar_add_connection(ndpi_struct, flow); */
/* return; */
/* } */
/* CLIENT_NAME */
if (get_u_int16_t(packet->payload, 10) == htons(CLIENT_NAME)) /* packet->payload[10] == 0x00 && packet->payload[11] == 0x03 */
if(get_u_int16_t(packet->payload, 10) == htons(CLIENT_NAME)) /* packet->payload[10] == 0x00 && packet->payload[11] == 0x03 */
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Client Name \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
/* LOGIN_COOKIE */
if (get_u_int16_t(packet->payload, 10) == htons(LOGIN_COOKIE) &&
if(get_u_int16_t(packet->payload, 10) == htons(LOGIN_COOKIE) &&
get_u_int16_t(packet->payload, 12) == htons(0x0100))
{
if(get_u_int16_t(packet->payload, packet->payload_packet_len - 5) == htons(MULTICONN_FLAGS)) /* MULTICONN_FLAGS */
@@ -191,35 +188,35 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* MAJOR_VERSION */
if (get_u_int16_t(packet->payload, 10) == htons(MAJOR_VERSION))
if(get_u_int16_t(packet->payload, 10) == htons(MAJOR_VERSION))
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Major_Version \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
/* MINOR_VERSION */
if (get_u_int16_t(packet->payload, 10) == htons(MINOR_VERSION))
if(get_u_int16_t(packet->payload, 10) == htons(MINOR_VERSION))
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Minor_Version \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
/* POINT_VERSION */
if (get_u_int16_t(packet->payload, 10) == htons(POINT_VERSION))
if(get_u_int16_t(packet->payload, 10) == htons(POINT_VERSION))
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Point_Version \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
/* BUILD_NUM */
if (get_u_int16_t(packet->payload, 10) == htons(BUILD_NUM))
if(get_u_int16_t(packet->payload, 10) == htons(BUILD_NUM))
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Build_Num \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
/* CLIENT_RECONNECT */
if (get_u_int16_t(packet->payload, 10) == htons(CLIENT_RECONNECT))
if(get_u_int16_t(packet->payload, 10) == htons(CLIENT_RECONNECT))
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Client_Reconnect \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
@@ -244,24 +241,24 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
+ requestId | 4 byte +
+----------------------------------------------+
*/
if (channel == DATA)
if(channel == DATA)
{
if (packet->payload_packet_len >= 8)
if(packet->payload_packet_len >= 8)
family = get_u_int16_t(packet->payload, 6);
else
family = 0;
if (packet->payload_packet_len >= 10)
if(packet->payload_packet_len >= 10)
type = get_u_int16_t(packet->payload, 8);
else
type = 0;
if (family == 0 || type == 0)
if(family == 0 || type == 0)
{
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
/* Family 0x0001 */
if (family == htons(GE_SE_CTL))
if(family == htons(GE_SE_CTL))
{
switch (type) {
@@ -297,7 +294,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0002 */
if (family == htons(LOC_SRV))
if(family == htons(LOC_SRV))
{
switch (type) {
@@ -320,7 +317,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0003 */
if (family == htons(BUDDY_LIST))
if(family == htons(BUDDY_LIST))
{
switch (type) {
@@ -340,7 +337,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0004 */
if (family == htons(IM))
if(family == htons(IM))
{
switch (type) {
@@ -361,7 +358,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0006 */
if (family == htons(IS))
if(family == htons(IS))
{
switch (type) {
@@ -372,7 +369,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0007 */
if (family == htons(ACC_ADM))
if(family == htons(ACC_ADM))
{
switch (type) {
@@ -389,7 +386,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0008 */
if (family == htons(POPUP))
if(family == htons(POPUP))
{
switch (type) {
@@ -399,7 +396,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0009 */
if (family == htons(PMS))
if(family == htons(PMS))
{
switch (type) {
@@ -418,7 +415,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x000b */
if (family == htons(USS))
if(family == htons(USS))
{
switch (type) {
@@ -430,7 +427,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x000d */
if (family == htons(CHAT_ROOM_SETUP))
if(family == htons(CHAT_ROOM_SETUP))
{
switch (type) {
@@ -447,7 +444,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x000e */
if (family == htons(CHAT_ROOM_ACT))
if(family == htons(CHAT_ROOM_ACT))
{
switch (type) {
@@ -464,7 +461,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x000f */
if (family == htons(USER_SRCH))
if(family == htons(USER_SRCH))
{
switch (type) {
@@ -477,7 +474,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0010 */
if (family == htons(BUDDY_ICON_SERVER))
if(family == htons(BUDDY_ICON_SERVER))
{
switch (type) {
@@ -492,7 +489,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0013 */
if (family == htons(SERVER_STORED_INFO))
if(family == htons(SERVER_STORED_INFO))
{
switch (type) {
@@ -521,7 +518,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0015 */
if (family == htons(ICQ))
if(family == htons(ICQ))
{
switch (type) {
@@ -532,7 +529,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0017 */
if (family == htons(INIT_AUTH))
if(family == htons(INIT_AUTH))
{
switch (type) {
@@ -549,12 +546,12 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
/* Family 0x0018 */
if (family == htons(EMAIL))
if(family == htons(EMAIL))
{
/* TODO */
}
/* Family 0x0085 */
if (family == htons(IS_EXT))
if(family == htons(IS_EXT))
{
switch (type) {
@@ -571,15 +568,15 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
/* flag */
if (packet->payload_packet_len >= 12)
if(packet->payload_packet_len >= 12)
{
flag = get_u_int16_t(packet->payload, 10);
if (flag == htons(0x0000)|| flag == htons(0x8000) || flag == htons(0x0001))
if(flag == htons(0x0000)|| flag == htons(0x8000) || flag == htons(0x0001))
{
if (packet->payload_packet_len >= 16)
if(packet->payload_packet_len >= 16)
{
/* request ID */
req_ID = get_u_int32_t(packet->payload, 12);
// u_int32_t req_ID = get_u_int32_t(packet->payload, 12);
/* if((req_ID <= ((u_int32_t)-1))) */
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR\n");
@@ -594,7 +591,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
ERROR -> FLAP__ERROR_CHANNEL_0x03
A FLAP error - rare
*/
if (channel == O_ERROR)
if(channel == O_ERROR)
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Error frame \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
@@ -604,7 +601,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
Close down the FLAP connection gracefully.
SIGNOFF: FLAP__SIGNOFF_CHANNEL_0x04
*/
if (channel == SIGNOFF)
if(channel == SIGNOFF)
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Signoff frame \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
@@ -614,7 +611,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
Send a heartbeat to server to help keep connection open.
KEEP_ALIVE: FLAP__KEEP_ALIVE_CHANNEL_0x05
*/
if (channel == KEEP_ALIVE)
if(channel == KEEP_ALIVE)
{
NDPI_LOG_INFO(ndpi_struct, "found OSCAR - Keep Alive frame \n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
@@ -624,11 +621,11 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
/* detect http connections */
if (packet->payload_packet_len >= 18) {
if ((packet->payload[0] == 'P') && (memcmp(packet->payload, "POST /photo/upload", 18) == 0)) {
if(packet->payload_packet_len >= 18) {
if((packet->payload[0] == 'P') && (memcmp(packet->payload, "POST /photo/upload", 18) == 0)) {
NDPI_PARSE_PACKET_LINE_INFO(ndpi_struct, flow, packet);
if (packet->host_line.len >= 18 && packet->host_line.ptr != NULL) {
if (memcmp(packet->host_line.ptr, "lifestream.aol.com", 18) == 0) {
if(packet->host_line.len >= 18 && packet->host_line.ptr != NULL) {
if(memcmp(packet->host_line.ptr, "lifestream.aol.com", 18) == 0) {
NDPI_LOG_INFO(ndpi_struct,
"found OSCAR over HTTP, POST method\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
@@ -637,9 +634,9 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
}
if (packet->payload_packet_len > 40) {
if ((packet->payload[0] == 'G') && (memcmp(packet->payload, "GET /", 5) == 0)) {
if ((memcmp(&packet->payload[5], "aim/fetchEvents?aimsid=", 23) == 0) ||
if(packet->payload_packet_len > 40) {
if((packet->payload[0] == 'G') && (memcmp(packet->payload, "GET /", 5) == 0)) {
if((memcmp(&packet->payload[5], "aim/fetchEvents?aimsid=", 23) == 0) ||
(memcmp(&packet->payload[5], "aim/startSession?", 17) == 0) ||
(memcmp(&packet->payload[5], "aim/gromit/aim_express", 22) == 0) ||
(memcmp(&packet->payload[5], "b/ss/aolwpaim", 13) == 0) ||
@@ -649,9 +646,9 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
return;
}
if ((memcmp(&packet->payload[5], "aim", 3) == 0) || (memcmp(&packet->payload[5], "im", 2) == 0)) {
if((memcmp(&packet->payload[5], "aim", 3) == 0) || (memcmp(&packet->payload[5], "im", 2) == 0)) {
NDPI_PARSE_PACKET_LINE_INFO(ndpi_struct, flow, packet);
if (packet->user_agent_line.len > 15 && packet->user_agent_line.ptr != NULL &&
if(packet->user_agent_line.len > 15 && packet->user_agent_line.ptr != NULL &&
((memcmp(packet->user_agent_line.ptr, "mobileAIM/", 10) == 0) ||
(memcmp(packet->user_agent_line.ptr, "ICQ/", 4) == 0) ||
(memcmp(packet->user_agent_line.ptr, "mobileICQ/", 10) == 0) ||
@@ -663,14 +660,14 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
NDPI_PARSE_PACKET_LINE_INFO(ndpi_struct, flow, packet);
if (packet->referer_line.ptr != NULL && packet->referer_line.len >= 22) {
if(packet->referer_line.ptr != NULL && packet->referer_line.len >= 22) {
if (memcmp(&packet->referer_line.ptr[packet->referer_line.len - NDPI_STATICSTRING_LEN("WidgetMain.swf")],
if(memcmp(&packet->referer_line.ptr[packet->referer_line.len - NDPI_STATICSTRING_LEN("WidgetMain.swf")],
"WidgetMain.swf", NDPI_STATICSTRING_LEN("WidgetMain.swf")) == 0) {
u_int16_t i;
for (i = 0; i < (packet->referer_line.len - 22); i++) {
if (packet->referer_line.ptr[i] == 'a') {
if (memcmp(&packet->referer_line.ptr[i + 1], "im/gromit/aim_express", 21) == 0) {
if(packet->referer_line.ptr[i] == 'a') {
if(memcmp(&packet->referer_line.ptr[i + 1], "im/gromit/aim_express", 21) == 0) {
NDPI_LOG_INFO(ndpi_struct,
"found OSCAR over HTTP : aim/gromit/aim_express\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
@@ -681,13 +678,13 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
}
if (memcmp(packet->payload, "CONNECT ", 8) == 0) {
if (memcmp(packet->payload, "CONNECT login.icq.com:443 HTTP/1.", 33) == 0) {
if(memcmp(packet->payload, "CONNECT ", 8) == 0) {
if(memcmp(packet->payload, "CONNECT login.icq.com:443 HTTP/1.", 33) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found OSCAR ICQ-HTTP\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
if (memcmp(packet->payload, "CONNECT login.oscar.aol.com:5190 HTTP/1.", 40) == 0) {
if(memcmp(packet->payload, "CONNECT login.oscar.aol.com:5190 HTTP/1.", 40) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found OSCAR AIM-HTTP\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
@@ -696,32 +693,32 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
}
if (packet->payload_packet_len > 43
if(packet->payload_packet_len > 43
&& memcmp(packet->payload, "GET http://http.proxy.icq.com/hello HTTP/1.", 43) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found OSCAR ICQ-HTTP PROXY\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len > 46
if(packet->payload_packet_len > 46
&& memcmp(packet->payload, "GET http://aimhttp.oscar.aol.com/hello HTTP/1.", 46) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found OSCAR AIM-HTTP PROXY\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len > 5 && get_u_int32_t(packet->payload, 0) == htonl(0x05010003)) {
if(packet->payload_packet_len > 5 && get_u_int32_t(packet->payload, 0) == htonl(0x05010003)) {
NDPI_LOG_DBG2(ndpi_struct, "Maybe OSCAR Picturetransfer\n");
return;
}
if (packet->payload_packet_len == 10 && get_u_int32_t(packet->payload, 0) == htonl(0x05000001) &&
if(packet->payload_packet_len == 10 && get_u_int32_t(packet->payload, 0) == htonl(0x05000001) &&
get_u_int32_t(packet->payload, 4) == 0) {
NDPI_LOG_DBG2(ndpi_struct, "Maybe OSCAR Picturetransfer\n");
return;
}
if (packet->payload_packet_len >= 70 &&
if(packet->payload_packet_len >= 70 &&
memcmp(&packet->payload[packet->payload_packet_len - 26],
"\x67\x00\x65\x00\x74\x00\x43\x00\x61\x00\x74\x00\x61\x00\x6c\x00\x6f\x00\x67", 19) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found OSCAR PICTURE TRANSFER\n");
@@ -729,9 +726,9 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
return;
}
if (NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_OSCAR) != 0) {
if(NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_OSCAR) != 0) {
if (flow->packet_counter == 1
if(flow->packet_counter == 1
&&
((packet->payload_packet_len == 9
&& memcmp(packet->payload, "\x00\x09\x00\x00\x83\x01\xc0\x00\x00", 9) == 0)
@@ -742,13 +739,13 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
}
#if 0
if (flow->oscar_video_voice && ntohs(get_u_int16_t(packet->payload, 0)) == packet->payload_packet_len
if(flow->oscar_video_voice && ntohs(get_u_int16_t(packet->payload, 0)) == packet->payload_packet_len
&& packet->payload[2] == 0x00 && packet->payload[3] == 0x00) {
}
#endif
if (packet->payload_packet_len >= 70 && ntohs(get_u_int16_t(packet->payload, 4)) == packet->payload_packet_len) {
if (memcmp(packet->payload, "OFT", 3) == 0 &&
if(packet->payload_packet_len >= 70 && ntohs(get_u_int16_t(packet->payload, 4)) == packet->payload_packet_len) {
if(memcmp(packet->payload, "OFT", 3) == 0 &&
((packet->payload[3] == '3' && ((memcmp(&packet->payload[4], "\x01\x00\x01\x01", 4) == 0)
|| (memcmp(&packet->payload[6], "\x01\x01\x00", 3) == 0)))
|| (packet->payload[3] == '2' && ((memcmp(&packet->payload[6], "\x01\x01", 2)
@@ -760,7 +757,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
return;
}
if (memcmp(packet->payload, "ODC2", 4) == 0 && memcmp(&packet->payload[6], "\x00\x01\x00\x06", 4) == 0) {
if(memcmp(packet->payload, "ODC2", 4) == 0 && memcmp(&packet->payload[6], "\x00\x01\x00\x06", 4) == 0) {
//PICTURE TRANSFER PATTERN EXMAPLE::
//4f 44 43 32 00 4c 00 01 00 06 00 00 00 00 00 00 ODC2.L..........
NDPI_LOG_INFO(ndpi_struct, "found OSCAR PICTURE TRANSFER\n");
@@ -768,7 +765,7 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
return;
}
}
if (packet->payload_packet_len > 40 && (memcmp(&packet->payload[2], "\x04\x4a\x00", 3) == 0)
if(packet->payload_packet_len > 40 && (memcmp(&packet->payload[2], "\x04\x4a\x00", 3) == 0)
&& (memcmp(&packet->payload[6], "\x00\x00", 2) == 0)
&& packet->payload[packet->payload_packet_len - 15] == 'F'
&& packet->payload[packet->payload_packet_len - 12] == 'L'
@@ -776,21 +773,21 @@ static void ndpi_search_oscar_tcp_connect(struct ndpi_detection_module_struct
&& (memcmp(&packet->payload[packet->payload_packet_len - 2], "\x00\x00", 2) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found OSCAR PICTURE TRANSFER\n");
ndpi_int_oscar_add_connection(ndpi_struct, flow);
if (ntohs(packet->tcp->dest) == 443 || ntohs(packet->tcp->source) == 443) {
if(ntohs(packet->tcp->dest) == 443 || ntohs(packet->tcp->source) == 443) {
flow->oscar_ssl_voice_stage = 1;
}
return;
}
}
if (flow->packet_counter < 3 && packet->payload_packet_len > 11 && (memcmp(packet->payload, "\x00\x37\x04\x4a", 4)
if(flow->packet_counter < 3 && packet->payload_packet_len > 11 && (memcmp(packet->payload, "\x00\x37\x04\x4a", 4)
|| memcmp(packet->payload, "\x00\x0a\x04\x4a",
4))) {
return;
}
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_OSCAR) {
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_OSCAR) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
@@ -800,7 +797,7 @@ void ndpi_search_oscar(struct ndpi_detection_module_struct *ndpi_struct, struct
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search OSCAR\n");
if (packet->tcp != NULL) {
if(packet->tcp != NULL) {
ndpi_search_oscar_tcp_connect(ndpi_struct, flow);
}
}
+14 -16
View File
@@ -129,23 +129,21 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
sni_offset++;
if((sni_offset+len) < udp_len) {
if(!ndpi_struct->disable_metadata_export) {
int max_len = sizeof(flow->host_server_name)-1, j = 0;
ndpi_protocol_match_result ret_match;
if(len > max_len) len = max_len;
while((len > 0) && (sni_offset < udp_len)) {
flow->host_server_name[j++] = packet->payload[sni_offset];
sni_offset++, len--;
}
ndpi_match_host_subprotocol(ndpi_struct, flow,
(char *)flow->host_server_name,
strlen((const char*)flow->host_server_name),
&ret_match,
NDPI_PROTOCOL_QUIC);
int max_len = sizeof(flow->host_server_name)-1, j = 0;
ndpi_protocol_match_result ret_match;
if(len > max_len) len = max_len;
while((len > 0) && (sni_offset < udp_len)) {
flow->host_server_name[j++] = packet->payload[sni_offset];
sni_offset++, len--;
}
ndpi_match_host_subprotocol(ndpi_struct, flow,
(char *)flow->host_server_name,
strlen((const char*)flow->host_server_name),
&ret_match,
NDPI_PROTOCOL_QUIC);
}
break;
+20 -27
View File
@@ -251,18 +251,16 @@ static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct
if(flow->l4.tcp.ssh_stage == 0) {
if(packet->payload_packet_len > 7 && packet->payload_packet_len < 100
&& memcmp(packet->payload, "SSH-", 4) == 0) {
if(!ndpi_struct->disable_metadata_export) {
int len = ndpi_min(sizeof(flow->protos.ssh.client_signature)-1, packet->payload_packet_len);
strncpy(flow->protos.ssh.client_signature, (const char *)packet->payload, len);
flow->protos.ssh.client_signature[len] = '\0';
ndpi_ssh_zap_cr(flow->protos.ssh.client_signature, len);
int len = ndpi_min(sizeof(flow->protos.ssh.client_signature)-1, packet->payload_packet_len);
strncpy(flow->protos.ssh.client_signature, (const char *)packet->payload, len);
flow->protos.ssh.client_signature[len] = '\0';
ndpi_ssh_zap_cr(flow->protos.ssh.client_signature, len);
#ifdef SSH_DEBUG
printf("[SSH] [client_signature: %s]\n", flow->protos.ssh.client_signature);
#endif
}
printf("[SSH] [client_signature: %s]\n", flow->protos.ssh.client_signature);
#endif
NDPI_LOG_DBG2(ndpi_struct, "ssh stage 0 passed\n");
flow->l4.tcp.ssh_stage = 1 + packet->packet_direction;
ndpi_int_ssh_add_connection(ndpi_struct, flow);
@@ -271,24 +269,19 @@ static void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct
} else if(flow->l4.tcp.ssh_stage == (2 - packet->packet_direction)) {
if(packet->payload_packet_len > 7 && packet->payload_packet_len < 500
&& memcmp(packet->payload, "SSH-", 4) == 0) {
if(!ndpi_struct->disable_metadata_export) {
int len = ndpi_min(sizeof(flow->protos.ssh.server_signature)-1, packet->payload_packet_len);
strncpy(flow->protos.ssh.server_signature, (const char *)packet->payload, len);
flow->protos.ssh.server_signature[len] = '\0';
ndpi_ssh_zap_cr(flow->protos.ssh.server_signature, len);
int len = ndpi_min(sizeof(flow->protos.ssh.server_signature)-1, packet->payload_packet_len);
strncpy(flow->protos.ssh.server_signature, (const char *)packet->payload, len);
flow->protos.ssh.server_signature[len] = '\0';
ndpi_ssh_zap_cr(flow->protos.ssh.server_signature, len);
#ifdef SSH_DEBUG
printf("[SSH] [server_signature: %s]\n", flow->protos.ssh.server_signature);
printf("[SSH] [server_signature: %s]\n", flow->protos.ssh.server_signature);
#endif
NDPI_LOG_DBG2(ndpi_struct, "ssh stage 1 passed\n");
flow->guessed_host_protocol_id = flow->guessed_protocol_id = NDPI_PROTOCOL_SSH;
} else {
NDPI_LOG_INFO(ndpi_struct, "found ssh\n");
ndpi_int_ssh_add_connection(ndpi_struct, flow);
}
NDPI_LOG_DBG2(ndpi_struct, "ssh stage 1 passed\n");
flow->guessed_host_protocol_id = flow->guessed_protocol_id = NDPI_PROTOCOL_SSH;
#ifdef SSH_DEBUG
printf("[SSH] [completed stage: %u]\n", flow->l4.tcp.ssh_stage);
#endif
+884 -1283
View File
File diff suppressed because it is too large Load Diff
+3 -5
View File
@@ -64,11 +64,9 @@ void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struc
version[j] = '\0';
if(!ndpi_struct->disable_metadata_export) {
len = ndpi_min(sizeof(flow->protos.ubntac2.version)-1, j);
strncpy(flow->protos.ubntac2.version, (const char *)version, len);
flow->protos.ubntac2.version[len] = '\0';
}
len = ndpi_min(sizeof(flow->protos.ubntac2.version)-1, j);
strncpy(flow->protos.ubntac2.version, (const char *)version, len);
flow->protos.ubntac2.version[len] = '\0';
}
NDPI_LOG_INFO(ndpi_struct, "UBNT AirControl 2 request\n");
+5 -7
View File
@@ -40,15 +40,13 @@ void ndpi_search_whois_das(struct ndpi_detection_module_struct *ndpi_struct, str
u_int max_len = sizeof(flow->host_server_name) - 1;
u_int i, j;
if(!ndpi_struct->disable_metadata_export) {
for(i=strlen((const char *)flow->host_server_name), j=0; (i<max_len) && (j<packet->payload_packet_len); i++, j++) {
if((packet->payload[j] == '\n') || (packet->payload[j] == '\r')) break;
flow->host_server_name[i] = packet->payload[j];
}
flow->host_server_name[i] = '\0';
for(i=strlen((const char *)flow->host_server_name), j=0; (i<max_len) && (j<packet->payload_packet_len); i++, j++) {
if((packet->payload[j] == '\n') || (packet->payload[j] == '\r')) break;
flow->host_server_name[i] = packet->payload[j];
}
flow->host_server_name[i] = '\0';
flow->server_id = ((sport == 43) || (sport == 4343)) ? flow->src : flow->dst;
NDPI_LOG_INFO(ndpi_struct, "[WHOIS/DAS] %s\n", flow->host_server_name);