* Update WebattackRCE.pcap.out to the new "Known Proto on Non Std
Port" risk description
* Windows: add missing MAX_NUM_TLS_MONITORED_BLOCKS define
* Mingw: avoid %zu in printf formats; with GCC 13 and mingw-w64 13
headers (Ubuntu 26.04) it is rejected by -Wformat
* Python: switch from 3.9 (not available on Ubuntu 26.04) to 3.14
and explicitly install setuptools
* Move PROFINET/IO detection into the DCERPC dissector: match the
PROFINET/IO interface UUIDs (Device, Controller, Supervisor,
ParameterServer) and the full object UUID prefix, and recognize the
Endpoint Mapper lookups for PROFINET/IO interfaces. Remove the
standalone PROFINET/IO dissector,
* After a generic EPM classification, look for PROFINET/IO calls in the
next packets of the flow
* Add UDP 34964 as PROFINET/IO default port and don't trigger the
`NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT` flow risk for PROFINET/IO:
responses and following calls use dynamic ports
* Fix the byte order check of the connectionless DCERPC fragment length
* Active Directory Web Services (ADWS, TCP/9389), used by the PowerShell
ActiveDirectory module (Get-ADUser & co.): new dissector looking at the
clear-text .NET Message Framing (MC-NMF) preamble sent by the client
* Task Scheduler (MS-TSCH, i.e. schtasks.exe, atexec): "atsvc" named pipe
over SMB and ITaskSchedulerService/ATSvc/SASec interfaces in DCE/RPC BIND
requests
NetMotion Mobility (Mobility XE) tunnels clients to the Mobility
server using the Internet Mobility Protocol (IMP), by default over
UDP/5008. The payload is encrypted, but every datagram carries a
fixed header: a 0x4c magic, a self-inclusive length prefix, a
per-direction connection id plus sequence, and a per-direction
session token. Detection verifies these framing invariants are
constant within a direction and differ across directions, following
the same stateful approach as the Hamachi dissector.
Add NDPI_PROTOCOL_NETMOTION (VPN category) with the netmotion
dissector and its unit test. The remaining unit-test results are
regenerated because the new protocol id shifts the auto-numbered
custom-rule ids and adds one dissector call per UDP flow.
Signed-off-by: Chad Monroe <chad@monroe.io>
Put all the internal unit tests in a separate file.
The tests suite run (via `ndpiReader`):
* if the option `--run-tests` is used,
* always if the library is compiled with `-DNDPI_EXTENDED_SANITY_CHECKS`
(useful in CI)
Extend tests using part of #3146.
We keep `tests/unit/unit.c` for serialization tests, like now, because
that is the only code that depends on the external library libjson-c
Current ApplePush dissector only look for IP match and doesn't allow
full metadata extraction (see #3074).
Since all ApplePush flows are TLS ones, let TLS dissector do its job and
handle IP match as usual; with this change, the dissector itself is
useless: remove it.
Close#3074
Signed-off-by: Chad Monroe <chad@monroe.io>
Co-authored-by: Ivan Nardi <nardi.ivan@gmail.com>
* In order to reduce ndpi_main.c file size:
- Removed nDPI configuration code from ndpi_main.c and placed into ndpi_config.c
- Moved some utils functions from ndpi_main.c to ndpi_utils.c
* Added
- ndpi_dump_host_based_protocol_id()
- ndpi_dump_host_based_category_id()
to enable users to dump protocolId and categoryId of host-based protocols
ndpiReader
- Added
--protos-dump <mode> | Dump host-based protocolId (mode=1) and categoryId (mode=2)
Old compilers (example: gcc < 7, mingw or VS older than 2022) don't
work with latest croaring versions; note that we had this issue even
before this change...
We somehow try to autodect if we can use latest version (TODO: we can do
better!): otherwise we fallback to legacy code.
The user can force that via `--enable-old-croaring` option: that's the
option to use if you get any errors on `roaring.c` filw while compiling.
Remove `-AC_COMPILE_IFELSE` check which does nothing and provides
misleading output!
On CI, we always use legacy version on Windows (if we use VisualStudio)
and with Mingw compiler.
Please, note that before the recent code adding
`NDPI_UNRESOLVED_HOSTNAME` support, the croaring code, even if present
in the repository, was NEVER used!!
The hard limit of total number of protocols (internal and custom) is ~65535,
because protocol ids are `u_int16_t`...
API changes:
1. From `NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS` to
`ndpi_get_num_protocols()` (after having called
`ndpi_finalize_initialization()`);
2. From `proto_id >= NDPI_MAX_SUPPORTED_PROTOCOLS` to
`ndpi_is_custom_protocol(proto_id)` (after having called
`ndpi_finalize_initialization()`);
Close#2136Close#2545
The main difference is that the memory is allocated at runtime
Typical usercase:
```
struct ndpi_bitmask b;
ndpi_bitmask_alloc(&b, ndpi_get_num_internal_protocols());
ndpi_bitmask_set(&b, $BIT);
ndpi_bitmask_is_set(&b, $BIT);
[...]
ndpi_bitmask_dealloc(&b);
```
See #2136
The main goal is not to have the bitmask depending on the total number
of protocols anymore: `NDPI_INTERNAL_PROTOCOL_BITMASK` depends only on
internal protocols, i.e. on `NDPI_MAX_INTERNAL_PROTOCOLS`, i.e.
custom-defined protocols are not counted.
See #2136
Keep the old data structure `NDPI_PROTOCOL_BITMASK` with the old
semantic.
Since we need to change the API (and all the application code...)
anyway, simplify the API: by default all the protocols are enabled.
If you need otherwise, please use `ndpi_init_detection_module_ext()`
instead of `ndpi_init_detection_module()` (you can find an example in
the `ndpiReader` code).
To update the application code you likely only need to remove these 3
lines from your code:
```
- NDPI_PROTOCOL_BITMASK all;
- NDPI_BITMASK_SET_ALL(all);
- ndpi_set_protocol_detection_bitmask2(ndpi_str, &all);
```
Removed an unused field and struct definition.
We use `registr_dissector()` instead of
`ndpi_set_bitmask_protocol_detection()`.
Every file in `src/lib/protocols/*.c` is a dissector.
Every dissector can handle multiple protocols.
The real goal is this small change:
```
struct call_function_struct {
- NDPI_PROTOCOL_BITMASK detection_bitmask;
```
i.e. getting rid of another protocol bitmask: this is mandatory to try
to fix#2136 (see also e845e8205b68752c997d05224d8b2fd45acde714)
As a nice side effect, we remove a bitmask comparison in the hot function
`check_ndpi_detection_func()`
TODO: change logging configuration from per-protocol to per-dissector
In the flow, we should keep track of state of "dissectors", not
"protocols". This way, flow structure doesn't depend anymore on
the max number of protocols.
This is also the first step into fixing #2136