diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_protocol_ids.h | 1 | ||||
-rw-r--r-- | src/include/ndpi_protocols.h | 1 | ||||
-rw-r--r-- | src/lib/inc_generated/ndpi_asn_alibaba.c.inc | 67 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 9 | ||||
-rw-r--r-- | src/lib/protocols/alicloud.c | 82 |
5 files changed, 160 insertions, 0 deletions
diff --git a/src/include/ndpi_protocol_ids.h b/src/include/ndpi_protocol_ids.h index 256fd8f24..7485a9062 100644 --- a/src/include/ndpi_protocol_ids.h +++ b/src/include/ndpi_protocol_ids.h @@ -334,6 +334,7 @@ typedef enum { NDPI_PROTOCOL_PSIPHON = 303, NDPI_PROTOCOL_ULTRASURF = 304, NDPI_PROTOCOL_THREEMA = 305, + NDPI_PROTOCOL_ALICLOUD = 306, #ifdef CUSTOM_NDPI_PROTOCOLS #include "../../../nDPI-custom/custom_ndpi_protocol_ids.h" diff --git a/src/include/ndpi_protocols.h b/src/include/ndpi_protocols.h index 9336d08c0..1ac315cf5 100644 --- a/src/include/ndpi_protocols.h +++ b/src/include/ndpi_protocols.h @@ -232,6 +232,7 @@ void init_i3d_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3 void init_riotgames_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_ultrasurf_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); void init_threema_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); +void init_alicloud_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask); /* ndpi_main.c */ extern u_int32_t ndpi_ip_port_hash_funct(u_int32_t ip, u_int16_t port); diff --git a/src/lib/inc_generated/ndpi_asn_alibaba.c.inc b/src/lib/inc_generated/ndpi_asn_alibaba.c.inc new file mode 100644 index 000000000..3d8b3d532 --- /dev/null +++ b/src/lib/inc_generated/ndpi_asn_alibaba.c.inc @@ -0,0 +1,67 @@ +/* + * + * This file is generated automatically and part of nDPI + * + * 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/>. + * + */ + +/* ****************************************************** */ + + +static ndpi_network ndpi_protocol_alibaba_protocol_list[] = { + { 0x08D17A00 /* 8.209.122.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x08D3E400 /* 8.211.228.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x08D42000 /* 8.212.32.0/23 */, 23, NDPI_PROTOCOL_ALIBABA }, + { 0x08D45D00 /* 8.212.93.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x08D46400 /* 8.212.100.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x08D4B800 /* 8.212.184.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x08D6A000 /* 8.214.160.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x08D84C00 /* 8.216.76.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x0E017000 /* 14.1.112.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x2EC75800 /* 46.199.88.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2F39C500 /* 47.57.197.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2F5AAC00 /* 47.90.172.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x2FEB1100 /* 47.235.17.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF59C00 /* 47.245.156.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF65A00 /* 47.246.90.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF66400 /* 47.246.100.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF68200 /* 47.246.130.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF68600 /* 47.246.134.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF69C00 /* 47.246.156.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FF6A300 /* 47.246.163.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x2FFA4000 /* 47.250.64.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x2FFB8000 /* 47.251.128.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x6737CA00 /* 103.55.202.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x67CE2800 /* 103.206.40.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0x80006B00 /* 128.0.107.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0x938BFC00 /* 147.139.252.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0xAA210000 /* 170.33.0.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0xAA210800 /* 170.33.8.0/21 */, 21, NDPI_PROTOCOL_ALIBABA }, + { 0xAA211000 /* 170.33.16.0/20 */, 20, NDPI_PROTOCOL_ALIBABA }, + { 0xAA212000 /* 170.33.32.0/20 */, 20, NDPI_PROTOCOL_ALIBABA }, + { 0xAA214000 /* 170.33.64.0/23 */, 23, NDPI_PROTOCOL_ALIBABA }, + { 0xAA214200 /* 170.33.66.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0xAA214400 /* 170.33.68.0/23 */, 23, NDPI_PROTOCOL_ALIBABA }, + { 0xAA214800 /* 170.33.72.0/21 */, 21, NDPI_PROTOCOL_ALIBABA }, + { 0xAA215000 /* 170.33.80.0/21 */, 21, NDPI_PROTOCOL_ALIBABA }, + { 0xAA215800 /* 170.33.88.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0xAA215C00 /* 170.33.92.0/23 */, 23, NDPI_PROTOCOL_ALIBABA }, + { 0xAA216000 /* 170.33.96.0/21 */, 21, NDPI_PROTOCOL_ALIBABA }, + { 0xAA216800 /* 170.33.104.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + { 0xC60B9000 /* 198.11.144.0/24 */, 24, NDPI_PROTOCOL_ALIBABA }, + { 0xCB6B3000 /* 203.107.48.0/22 */, 22, NDPI_PROTOCOL_ALIBABA }, + /* End */ + { 0x0, 0, 0 } +}; diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index e98577406..afa01d8fd 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -86,6 +86,7 @@ #include "inc_generated/ndpi_asn_goto.c.inc" #include "inc_generated/ndpi_asn_riotgames.c.inc" #include "inc_generated/ndpi_asn_threema.c.inc" +#include "inc_generated/ndpi_asn_alibaba.c.inc" /* Third party libraries */ #include "third_party/include/ndpi_patricia.h" @@ -1949,6 +1950,10 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp "Threema", NDPI_PROTOCOL_CATEGORY_CHAT, 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, 0 /* encrypted */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_ALICLOUD, + "AliCloud", NDPI_PROTOCOL_CATEGORY_CLOUD, + ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */, + ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */); #ifdef CUSTOM_NDPI_PROTOCOLS #include "../../../nDPI-custom/custom_ndpi_main.c" @@ -2593,6 +2598,7 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs ndpi_init_ptree_ipv4(ndpi_str, ndpi_str->protocols_ptree, ndpi_protocol_goto_protocol_list); ndpi_init_ptree_ipv4(ndpi_str, ndpi_str->protocols_ptree, ndpi_protocol_riotgames_protocol_list); ndpi_init_ptree_ipv4(ndpi_str, ndpi_str->protocols_ptree, ndpi_protocol_threema_protocol_list); + ndpi_init_ptree_ipv4(ndpi_str, ndpi_str->protocols_ptree, ndpi_protocol_alibaba_protocol_list); } } @@ -4436,6 +4442,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) { /* Threema */ init_threema_dissector(ndpi_str, &a, detection_bitmask); + /* AliCloud */ + init_alicloud_dissector(ndpi_str, &a, detection_bitmask); + #ifdef CUSTOM_NDPI_PROTOCOLS #include "../../../nDPI-custom/custom_ndpi_main_init.c" #endif diff --git a/src/lib/protocols/alicloud.c b/src/lib/protocols/alicloud.c new file mode 100644 index 000000000..b8ce58d81 --- /dev/null +++ b/src/lib/protocols/alicloud.c @@ -0,0 +1,82 @@ +/* + * alicloud.c + * + * Copyright (C) 2022 - 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_protocol_ids.h" + +#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_ALICLOUD + +#include "ndpi_api.h" + +static void ndpi_int_alicloud_add_connection(struct ndpi_detection_module_struct * const ndpi_struct, + struct ndpi_flow_struct * const flow) +{ + NDPI_LOG_INFO(ndpi_struct, "found alicloud\n"); + + ndpi_set_detected_protocol(ndpi_struct, flow, flow->guessed_host_protocol_id, NDPI_PROTOCOL_ALICLOUD, + NDPI_CONFIDENCE_DPI); +} + +void ndpi_search_alicloud(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 alicloud\n"); + + if (packet->payload_packet_len < 8) + { + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + return; + } + + if (ntohl(get_u_int32_t(packet->payload, 0)) == 0xcefabeba) + { + u_int32_t pdu_len = ntohl(get_u_int32_t(packet->payload, 4)); + + if (packet->payload_packet_len == 8 && pdu_len > 0) + { + ndpi_int_alicloud_add_connection(ndpi_struct, flow); + return; + } else if (pdu_len == (u_int32_t)packet->payload_packet_len - 8) { + ndpi_int_alicloud_add_connection(ndpi_struct, flow); + return; + } + } + + if (flow->packet_counter > 3) + { + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + } +} + +void init_alicloud_dissector(struct ndpi_detection_module_struct *ndpi_struct, + u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) +{ + ndpi_set_bitmask_protocol_detection("AliCloud", ndpi_struct, detection_bitmask, *id, + NDPI_PROTOCOL_ALICLOUD, + ndpi_search_alicloud, + NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, + SAVE_DETECTION_BITMASK_AS_UNKNOWN, + ADD_TO_DETECTION_BITMASK + ); + + *id += 1; +} |