Skip to content

Commit 1f3fbf1

Browse files
committed
Merge branch 'dev' into config2
2 parents e6a5206 + d8c7a76 commit 1f3fbf1

File tree

163 files changed

+442
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+442
-170
lines changed

doc/protocols.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,30 @@ References: `Wireshark wiki: <https://wiki.wireshark.org/EtherSBus>`_.
324324
`NDPI_PROTOCOL_MONERO`
325325
======================
326326
Monero is a private and decentralized cryptocurrency with focus on confidentiality and security.
327+
328+
329+
.. _Proto 370:
330+
331+
`NDPI_PROTOCOL_DCERPC`
332+
======================
333+
DCE/RPC is a specification for a remote procedure call mechanism that defines both APIs and an over-the-network protocol.
334+
335+
References: `Wireshark wiki: <https://wiki.wireshark.org/DCE/RPC>`_.
336+
337+
338+
.. _Proto 371:
339+
340+
`NDPI_PROTOCOL_PROFINET_IO`
341+
======================
342+
PROFINET/IO is a field bus protocol based on connectionless DCE/RPC.
343+
344+
References: `Protocol Specs: <https://www.profibus.com/download/profinet-specification>`_.
345+
346+
347+
.. _Proto 372:
348+
349+
`NDPI_PROTOCOL_HISLIP`
350+
======================
351+
High-Speed LAN Instrument Protocol (HiSLIP) is a protocol for remote instrument control of LAN-based test and measurement instruments.
352+
353+
References: `Protocol Specs: <https://www.ivifoundation.org/downloads/Protocol%20Specifications/IVI-6.1_HiSLIP-2.0-2020-04-23.pdf>`_.

src/include/ndpi_protocol_ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ typedef enum {
398398
NDPI_PROTOCOL_IEEE_C37118 = 367,
399399
NDPI_PROTOCOL_ETHERSBUS = 368,
400400
NDPI_PROTOCOL_MONERO = 369,
401+
NDPI_PROTOCOL_DCERPC = 370,
402+
NDPI_PROTOCOL_PROFINET_IO = 371,
403+
NDPI_PROTOCOL_HISLIP = 372,
401404

402405
#ifdef CUSTOM_NDPI_PROTOCOLS
403406
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"

src/lib/ndpi_main.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
14801480
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
14811481
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_RPC,
14821482
"RPC", NDPI_PROTOCOL_CATEGORY_RPC,
1483-
ndpi_build_default_ports(ports_a, 135, 0, 0, 0, 0) /* TCP */,
1483+
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
14841484
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
14851485
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_NETFLOW,
14861486
"NetFlow", NDPI_PROTOCOL_CATEGORY_NETWORK,
@@ -2148,6 +2148,22 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
21482148
"Monero", NDPI_PROTOCOL_CATEGORY_CRYPTO_CURRENCY,
21492149
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
21502150
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
2151+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_DCERPC,
2152+
"DCERPC", NDPI_PROTOCOL_CATEGORY_RPC,
2153+
ndpi_build_default_ports(ports_a, 135, 0, 0, 0, 0) /* TCP */,
2154+
ndpi_build_default_ports(ports_b, 135, 0, 0, 0, 0) /* UDP */);
2155+
ndpi_set_proto_subprotocols(ndpi_str, NDPI_PROTOCOL_DCERPC,
2156+
NDPI_PROTOCOL_PROFINET_IO,
2157+
NDPI_PROTOCOL_MATCHED_BY_CONTENT,
2158+
NDPI_PROTOCOL_NO_MORE_SUBPROTOCOLS);
2159+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_PROFINET_IO,
2160+
"PROFINET_IO", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
2161+
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
2162+
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
2163+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_HISLIP,
2164+
"HiSLIP", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
2165+
ndpi_build_default_ports(ports_a, 4880, 0, 0, 0, 0) /* TCP */,
2166+
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
21512167

21522168
#ifdef CUSTOM_NDPI_PROTOCOLS
21532169
#include "../../../nDPI-custom/custom_ndpi_main.c"
@@ -5593,6 +5609,12 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
55935609
/* Monero Protocol */
55945610
init_monero_dissector(ndpi_str, &a);
55955611

5612+
/* PROFINET/IO */
5613+
init_profinet_io_dissector(ndpi_str, &a);
5614+
5615+
/* HiSLIP */
5616+
init_hislip_dissector(ndpi_str, &a);
5617+
55965618
#ifdef CUSTOM_NDPI_PROTOCOLS
55975619
#include "../../../nDPI-custom/custom_ndpi_main_init.c"
55985620
#endif

src/lib/ndpi_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ void init_beckhoff_ads_dissector(struct ndpi_detection_module_struct *ndpi_struc
606606
void init_iso9506_1_mms_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
607607
void init_ieee_c37118_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
608608
void init_ethersbus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
609+
void init_profinet_io_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
610+
void init_hislip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
609611

610612
#endif
611613

src/lib/protocols/dcerpc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "ndpi_protocol_ids.h"
2525

26-
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_RPC
26+
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DCERPC
2727

2828
#include "ndpi_api.h"
2929
#include "ndpi_private.h"
@@ -32,7 +32,7 @@
3232
static void ndpi_int_dcerpc_add_connection(struct ndpi_detection_module_struct
3333
*ndpi_struct, struct ndpi_flow_struct *flow)
3434
{
35-
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RPC, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
35+
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DCERPC, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
3636
}
3737

3838
static bool is_connection_oriented_dcerpc(struct ndpi_packet_struct *packet, struct ndpi_flow_struct *flow)
@@ -96,8 +96,8 @@ static void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct,
9696

9797
void init_dcerpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
9898
{
99-
ndpi_set_bitmask_protocol_detection("RPC", ndpi_struct, *id,
100-
NDPI_PROTOCOL_RPC,
99+
ndpi_set_bitmask_protocol_detection("DCERPC", ndpi_struct, *id,
100+
NDPI_PROTOCOL_DCERPC,
101101
ndpi_search_dcerpc,
102102
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
103103
SAVE_DETECTION_BITMASK_AS_UNKNOWN,

src/lib/protocols/hislip.c

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* hisleep.c
3+
*
4+
* High-Speed LAN Instrument Protocol
5+
*
6+
* Copyright (C) 2023 - ntop.org
7+
* Copyright (C) 2023 - V.G <[email protected]>
8+
*
9+
* This file is part of nDPI, an open source deep packet inspection
10+
* library based on the OpenDPI and PACE technology by ipoque GmbH
11+
*
12+
* nDPI is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Lesser General Public License as published by
14+
* the Free Software Foundation, either version 3 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* nDPI is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Lesser General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Lesser General Public License
23+
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
#include "ndpi_protocol_ids.h"
28+
29+
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_HISLIP
30+
31+
#include "ndpi_api.h"
32+
#include "ndpi_private.h"
33+
34+
static void ndpi_int_hislip_add_connection(struct ndpi_detection_module_struct * const ndpi_struct,
35+
struct ndpi_flow_struct * const flow)
36+
{
37+
NDPI_LOG_INFO(ndpi_struct, "found HiSLIP\n");
38+
ndpi_set_detected_protocol(ndpi_struct, flow,
39+
NDPI_PROTOCOL_HISLIP,
40+
NDPI_PROTOCOL_UNKNOWN,
41+
NDPI_CONFIDENCE_DPI);
42+
}
43+
44+
static void ndpi_search_hislip(struct ndpi_detection_module_struct *ndpi_struct,
45+
struct ndpi_flow_struct *flow)
46+
{
47+
struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
48+
49+
if ((packet->payload_packet_len >= 16) &&
50+
(memcmp(packet->payload, "HS", 2) == 0) && ((packet->payload[2] - 26) < 0x65) &&
51+
(ndpi_ntohll(get_u_int64_t(packet->payload, 8)) == (u_int64_t)(packet->payload_packet_len - 16)))
52+
{
53+
ndpi_int_hislip_add_connection(ndpi_struct, flow);
54+
return;
55+
}
56+
57+
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
58+
}
59+
60+
void init_hislip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
61+
{
62+
ndpi_set_bitmask_protocol_detection("HiSLIP", ndpi_struct, *id,
63+
NDPI_PROTOCOL_HISLIP,
64+
ndpi_search_hislip,
65+
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
66+
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
67+
ADD_TO_DETECTION_BITMASK);
68+
69+
*id += 1;
70+
}

src/lib/protocols/profinet_io.c

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* profinet_io.c
3+
*
4+
* Copyright (C) 2023 - ntop.org
5+
* Copyright (C) 2023 - V.G <[email protected]>
6+
*
7+
* This file is part of nDPI, an open source deep packet inspection
8+
* library based on the OpenDPI and PACE technology by ipoque GmbH
9+
*
10+
* nDPI is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Lesser General Public License as published by
12+
* the Free Software Foundation, either version 3 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* nDPI is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
25+
#include "ndpi_protocol_ids.h"
26+
27+
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_PROFINET_IO
28+
29+
#include "ndpi_api.h"
30+
#include "ndpi_private.h"
31+
32+
static void ndpi_int_profinet_io_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
33+
struct ndpi_flow_struct *flow)
34+
{
35+
NDPI_LOG_INFO(ndpi_struct, "found PROFINET/IO\n");
36+
ndpi_set_detected_protocol(ndpi_struct, flow,
37+
NDPI_PROTOCOL_PROFINET_IO, NDPI_PROTOCOL_DCERPC,
38+
NDPI_CONFIDENCE_DPI);
39+
}
40+
41+
static void ndpi_search_profinet_io(struct ndpi_detection_module_struct *ndpi_struct,
42+
struct ndpi_flow_struct *flow)
43+
{
44+
struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
45+
46+
NDPI_LOG_DBG(ndpi_struct, "searching PROFINET/IO\n");
47+
48+
/* PROFINET/IO is based on connectionless DCE/RPC */
49+
if ((flow->detected_protocol_stack[0] == NDPI_PROTOCOL_DCERPC) &&
50+
(packet->payload_packet_len > 43))
51+
{
52+
u_int8_t byte_order = (packet->payload[4] >> 4) & 0xF;
53+
u_int32_t time_low = 0;
54+
u_int16_t time_mid = 0;
55+
u_int16_t time_hi_and_version = 0;
56+
57+
if (byte_order == 0) { /* Big Endian */
58+
time_low = ntohl(get_u_int32_t(packet->payload, 8));
59+
time_mid = ntohs(get_u_int16_t(packet->payload, 12));
60+
time_hi_and_version = ntohs(get_u_int16_t(packet->payload, 14));
61+
} else { /* Little Endian */
62+
time_low = le32toh(get_u_int32_t(packet->payload, 8));
63+
time_mid = le16toh(get_u_int16_t(packet->payload, 12));
64+
time_hi_and_version = le16toh(get_u_int16_t(packet->payload, 14));
65+
}
66+
67+
if ((time_low == 0xDEA00000) && (time_mid == 0x6C97) &&
68+
(time_hi_and_version == 0x11D1))
69+
{
70+
ndpi_int_profinet_io_add_connection(ndpi_struct, flow);
71+
return;
72+
}
73+
}
74+
75+
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
76+
}
77+
78+
void init_profinet_io_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
79+
{
80+
ndpi_set_bitmask_protocol_detection("PROFINET_IO", ndpi_struct, *id,
81+
NDPI_PROTOCOL_PROFINET_IO,
82+
ndpi_search_profinet_io,
83+
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
84+
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
85+
ADD_TO_DETECTION_BITMASK
86+
);
87+
88+
*id += 1;
89+
}

tests/cfgs/caches_cfg/result/ookla.pcap.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Guessed flow protos: 1
33
DPI Packets (TCP): 40 (6.67 pkts/flow)
44
Confidence Match by port : 1 (flows)
55
Confidence DPI : 5 (flows)
6-
Num dissector calls: 530 (88.33 diss/flow)
6+
Num dissector calls: 533 (88.83 diss/flow)
77
LRU cache ookla: 0/0/0 (insert/search/found)
88
LRU cache bittorrent: 0/3/0 (insert/search/found)
99
LRU cache zoom: 0/0/0 (insert/search/found)

tests/cfgs/caches_cfg/result/teams.pcap.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DPI Packets (other): 1 (1.00 pkts/flow)
66
Confidence Unknown : 1 (flows)
77
Confidence Match by port : 2 (flows)
88
Confidence DPI : 80 (flows)
9-
Num dissector calls: 520 (6.27 diss/flow)
9+
Num dissector calls: 522 (6.29 diss/flow)
1010
LRU cache ookla: 0/0/0 (insert/search/found)
1111
LRU cache bittorrent: 0/9/0 (insert/search/found)
1212
LRU cache zoom: 0/0/0 (insert/search/found)

tests/cfgs/default/pcap/hislip.pcap

14.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)