Commit graph

250 commits

Author SHA1 Message Date
Ivan Nardi
f287a6e7f8
Add a configuration to test a huge number of custom protocols (#2865)
File taken from #2136
2025-06-03 20:46:58 +02:00
Ivan Nardi
5e54531282
Remove ndpi_set_proto_defaults() from the API (#2863)
Add an explicit field to indicate if the protocol is custom or internal
2025-06-03 17:43:28 +02:00
Ivan Nardi
ed21057710
First step into a dynamic number of protocols (#2857)
We want to get rid of the defines `NDPI_MAX_SUPPORTED_PROTOCOLS` and
`NDPI_MAX_NUM_CUSTOM_PROTOCOLS`.

You can use:
```
ndpi_get_num_protocols()
```

See #2136

Removed some unused functions from public API
2025-06-03 10:22:15 +02:00
Ivan Nardi
70a72f1638
New API to enable/disable protocols; remove ndpi_set_protocol_detection_bitmask2() (#2853)
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.
2025-06-03 09:45:46 +02:00
Ivan Nardi
8df79a7354
Follow-up of c1d372860 (TCP fingerprint format) (#2850) 2025-05-26 12:32:47 +02:00
Ivan Nardi
c7b71d9e55
UBNTAC2,Ookla: improve detection (#2793) 2025-04-10 13:18:44 +02:00
Ivan Nardi
3e2d69b92a Follow-up of latest Signal call change (see: 4d41588a7) 2025-04-05 14:22:05 +02:00
Ivan Nardi
f4691c518a
fuzz: extend coverage (#2786) 2025-03-31 17:54:14 +02:00
Ivan Nardi
8bb3a9faf7 fuzz: fix configuration 2025-03-26 11:38:24 +01:00
Ivan Nardi
4a66f95808 fuzz: fix configuration after latest updates 2025-03-26 10:02:50 +01:00
Ivan Nardi
29eb89a88f
Improved configuration to enable/disable export of flow risk info (#2780)
Follow-up of f568313363: now the
configuration is for flow-risk, not global
2025-03-25 21:35:01 +01:00
Ivan Nardi
0cf735b12a
fuzz: try to run one (ndpiReader-) fuzzer with a slight different cfg (#2771) 2025-03-18 17:26:23 +01:00
Leonardo Teixeira Alves
c49d126d36
Add Autonomous System Organization to geoip (#2763)
Co-authored-by: Leonardo Teixeira Alves <leonardo.alves@zerum.com>
2025-03-06 14:47:17 +01:00
Ivan Nardi
f568313363
Add configuration parameter to enable/disable export of flow risk info (#2761)
For the most common protocols, avoid creating the string message if we
are not going to use it
2025-03-05 16:14:03 +01:00
Ivan Nardi
e786472f0d Address cache: fix some bugs on cache traversal
Add a new fuzzer to test it
2025-03-01 19:03:35 +01:00
Ivan Nardi
8ee59bb9b9
fuzz: extend fuzzing coverage (#2750) 2025-02-28 12:38:15 +01:00
Leonardo Teixeira Alves
3d0bfc7bfe
Add city as a geoip possibility (#2746) 2025-02-24 19:41:02 +01:00
Ivan Nardi
2d3f08362e
RTP: payload type info should be set only for real RTP flows (#2742) 2025-02-22 13:35:40 +01:00
Ivan Nardi
5f8545d97a
SSDP: add configuration for disabling metadata extraction (#2736) 2025-02-17 15:16:37 +01:00
Ivan Nardi
1dccaf37b0
DNS: fix check for DGA domain (#2716)
If we have a (potential) valid sub-classification, we shoudn't check for
DGA, even if the subclassification itself is disabled!
2025-02-11 15:48:53 +01:00
Ivan Nardi
73d1856525
DNS: disable subclassification by default (#2715)
Prelimary change to start supporting multiple DNS transactions on the
same flow
2025-02-11 13:50:00 +01:00
Luca
64d536752e Compilation fix 2025-02-07 10:58:24 +01:00
Ivan Nardi
dd4807f8ee
bittorrent: add configuration for "hash" metadata (#2706)
Fix confidence value for same TCP flows
2025-01-31 17:42:47 +01:00
Ivan Nardi
cf8f761b93
HTTP: add configuration for some metadata (#2704)
Extend file configuration for just subclassification.
2025-01-31 16:26:53 +01:00
Ivan Nardi
ecf0f8ace3
Create a specific configuration for classification only (#2689)
In some scenarios, you might not be interested in flow metadata or
flow-risks at all, but you might want only flow (sub-)classification.
Examples: you only want to forward the traffic according to the
classification or you are only interested in some protocol statistics.

Create a new configuration file (for `ndpiReader`, but you can trivially
adapt it for the library itself) allowing exactly that. You can use it
via: `ndpiReader --conf=example/only_classification.conf ...`

Note that this way, the nDPI overhead is lower because it might need
less packets per flow:
* TLS: nDPI processes only the CH (in most cases) and not also the SH
  and certificates
* DNS: only the request is processed (instead of both request and
  response)

We might extend the same "shortcut-logic" (stop processing the flow
immediately when there is a final sub-classification) for others
protocols.

Add the configuration options to enable/disable the extraction of some
TLS metadata.
2025-01-31 15:10:30 +01:00
Ivan Nardi
d4fb7b0aa1
fuzz: extend fuzzing coverage (#2696) 2025-01-23 15:23:01 +01:00
Ivan Nardi
af011e338e
TLS: remove JA3C (#2679)
Last step of removing JA3C fingerprint

Remove some duplicate tests: testing with ja4c/ja3s disabled is already
performed by `disable_metadata_and_flowrisks` configuration.

Close:#2551
2025-01-14 15:02:20 +01:00
Ivan Nardi
63a3547f99
Add (kind of) support for loading a list of JA4C malicious fingerprints (#2678)
It might be usefull to be able to match traffic against a list of
suspicious JA4C fingerprints

Use the same code/logic/infrastructure used for JA3C (note that we are
going to remove JA3C...)

See: #2551
2025-01-14 12:05:03 +01:00
Ivan Nardi
8f76b91f6f
fuzz: add 2 new fuzzers for KD-trees and Ball-trees (#2670) 2025-01-13 17:31:45 +01:00
Ivan Nardi
bf830b4236
Add the ability to enable/disable every specific flow risks (#2653) 2025-01-06 16:53:29 +01:00
Ivan Nardi
f20cec4985
fuzz: improve fuzzing coverage (#2642)
Updtae pl7m code (Fix swap-direction mutation)
2024-12-11 16:41:35 +01:00
Ivan Nardi
cff8bd1bb2
Update flow->flow_multimedia_types to a bitmask (#2625)
In the same flow, we can have multiple multimedia types
2024-11-25 10:12:48 +01:00
Ivan Nardi
43f7dc9ba0
fuzz: extend fuzzing coverage (#2626) 2024-11-20 13:36:41 +01:00
Ivan Nardi
1bda2bf414 SIP: extract some basic metadata 2024-11-12 13:34:25 +01:00
Toni
ccbbcdf283
Unify ndpi debug logging to always use a u16 protocol id (#2613)
* fixes SonarCloud complaint

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2024-11-11 15:17:33 +01:00
Ivan Nardi
b63f74a080
fuzz: improve coverage (#2612)
Add fuzzer to test `ndpi_quick_encrypt()` and `ndpi_quick_decrypt()`
2024-11-01 18:17:22 +01:00
Ivan Nardi
819291b7e4
Add configuration of TCP fingerprint computation (#2598)
Extend configuration of raw format of JA4C fingerprint
2024-10-18 16:58:06 +02:00
Ivan Nardi
521d0ca7a0
Add monitoring capability (#2588)
Allow nDPI to process the entire flows and not only the first N packets.
Usefull when the application is interested in some metadata spanning the
entire life of the session.

As initial step, only STUN flows can be put in monitoring.

See `doc/monitoring.md` for further details.

This feature is disabled by default.

Close #2583
2024-10-14 18:05:35 +02:00
Ivan Nardi
785f80f9e7
fuzz: fix fuzzing (#2586) 2024-10-10 21:18:24 +02:00
Luca Deri
7bdb2796c3 Added addr_dump_path definition 2024-10-10 18:18:04 +02:00
Ivan Nardi
a081a5578b
fuzz: try to be a little bit faster (#2578)
See: 9d07cf281
2024-09-30 16:54:42 +02:00
Liam Wilson
cdda369e92
Add enable/disable guessing using client IP/port (#2569)
Add configurable options for whether to include client port or client IP
in the flow's protocol guesses. This defaults to include both client
port/IP if the protocol is not guessed with the server IP/port.

This is intended for when flow direction detection is enabled, so we
know that sport = client port, dport = server port.
2024-09-27 09:23:22 +02:00
Ivan Nardi
ddd08f913c
Add some heuristics to detect encrypted/obfuscated/proxied TLS flows (#2553)
Based on the paper: "Fingerprinting Obfuscated Proxy Traffic with
Encapsulated TLS Handshakes".
See: https://www.usenix.org/conference/usenixsecurity24/presentation/xue-fingerprinting

Basic idea:
* the packets/bytes distribution of a TLS handshake is quite unique
* this fingerprint is still detectable if the handshake is
encrypted/proxied/obfuscated

All heuristics are disabled by default.
2024-09-24 14:20:31 +02:00
Liam Wilson
80971e4a17
Allow IP guess before port in ndpi_detection_giveup (#2562)
Add dpi.guess_ip_before_port which when enabled uses classification
by-ip before classification by-port.
2024-09-20 10:25:41 +02:00
Nardi Ivan
b6f187dffb fuzz: fix compilation 2024-09-17 20:17:35 +02:00
Ivan Nardi
9d07cf2811
fuzz: try to be a little bit faster (#2559)
Some fuzzers don't really need a real and complete local context.
Try to avoid setting it up, creating a simpler fake version with only the
features really needed.
That is a kind of experiment: if it works, we can extend the same logic
to other fuzzers
2024-09-17 11:46:55 +02:00
Ivan Nardi
0ddbda1f82
Add an heuristic to detect encrypted/obfuscated OpenVPN flows (#2547)
Based on the paper: "OpenVPN is Open to VPN Fingerprinting"
See: https://www.usenix.org/conference/usenixsecurity22/presentation/xue-diwen

Basic idea:
* the distribution of the first byte of the messages (i.e. the distribution
of the op-codes) is quite unique
* this fingerprint might be still detectable even if the OpenVPN packets are
somehow fully encrypted/obfuscated

The heuristic is disabled by default.
2024-09-16 18:38:26 +02:00
Nardi Ivan
f310424037 fuzz: fix compilation 2024-09-16 10:10:49 +02:00
Nardi Ivan
85ebda434d OpenVPN, Wireguard: improve sub-classification
Allow sub-classification of OpenVPN/Wireguard flows using their server IP.
That is useful to detect the specific VPN application/app used.
At the moment, the supported protocols are: Mullvad, NordVPN, ProtonVPN.

This feature is configurable.
2024-09-05 16:36:50 +02:00
Ivan Nardi
767f403e0d
fuzz: improve fuzzing coverage (#2535)
Updtae pl7m code (fix a Use-of-uninitialized-value error and add GTP
support)
2024-09-03 12:40:45 +02:00