Commit graph

1922 commits

Author SHA1 Message Date
Nardi Ivan
b23cfd6b84 Add sub-classification for GQUIC >= Q050 and (IETF-)QUIC
Add QUIC payload and header decryption: most of the crypto code has been
"copied-and-incolled" from Wireshark. That code has been clearly marked
as such. All credits for that code should go to the original authors.

I tried to keep the Wireshark code as similar as possible to the original,
comments included, to ease future backporting of fixes.
Inevitably, glibc data types and data structures, tvbuff abstraction and
allocation functions have been converted.
2020-08-21 22:04:55 +02:00
Nardi Ivan
7a1147d733 Update TLS dissector to handle QUIC flows
Latest QUIC versions use TLS for the encryption layer: reuse existing code
to allow Client Hello parsing and sub-classification based on SNI value.
Side effect: we might have J3AC, TLS negotiated version, SNI value and
supported cipher list for QUIC, too.
2020-08-21 22:04:55 +02:00
Nardi Ivan
d62ae567d1 Add (optional) dependency on external libraries: libgcrypt and libgpg-error
To support QUIC payload and header decryption, it is necessary to choose an
external crypto library to handle the low-level crypto stuff. Since we will
use some Wireshark code, it is quite natural to choose the same library used
by Wireshark itself: libgcrypt.

More precisely, we will use libgcrypt and libgpg-error.
Both libraries have LGPL license, so there should be no issue from this point
of view.

These libraries are not required to build nDPI, and their usage is optional:
nDPI will keep working (and compiling) even if they are not available.
However, without them, QUIC sub-classification is next to impossible.
The configure flag "--disable-gcrypt" forces the build system to ignore these
libraries.

libgpg-error is only used for debug to have meaningful error messages and its
usage is trivial.
The same cannot be said for libgcrypt because its initialization is a significant
issue.

The rest of this commit message try explaining how libgcrypt is
initialized.

According to the documentation
   https://gnupg.org/documentation/manuals/gcrypt/Initializing-the-library.html
   https://gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html#Multi_002dThreading
libgcrypt must be initialized before using it, but such initialization should
be performed by the actual application and not by any library.

Forcing the users to proper initialize libgcrypt in their own code seems
unreasonable: most people using nDPI might be complete unaware of any crypto
stuff and update each and every one application linking to nDPI with specific
libgcrypt code should be out of question, anyway.

Fortunately, it seems a workaround exists to initialize libgcrypt in a library
    https://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html

Therefore, we could provide a wrapper to this initialization stuff in a nDPI
function. Unfortunately nDPI API lacks a global init function that must be
called only once, before any other functions. We could add it, but that would
be a major API break.
AFAIK, ndpi_init_detection_module() might be called multiple times, for example
to create multiple independent dpi engines in the same program.

The proposed solution is to (optionally) initialize libgcrypt in
ndpi_init_detection_module() anyway:
* if the actual application doesn't directly use libgcrypt and only calls
  ndpi_init_detection_module() once, everything is formally correct and it
  should work out of the box [by far the most common user case];
* if the actual application already uses libgcrypt directly, it already
  performs the required initialization. In this case the ndpi_prefs.ndpi_dont_init_libgcrypt
  flag should be passed to ndpi_init_detection_module() to avoid further
  initializations.

The only scenario not supported by this solution is when the application is
unaware of libgcrypt and calls ndpi_init_detection_module() multiple times
concurrently. But this scenario should be uncommon.

A completely different option should be to switch to another crypto library,
with a huge impact on the QUIC dissector code.

Bottom line: crypto is hard, using libgcrypt is complex and the proposed
initialization, even if not perfect, should cover the most frequent user
cases and should work, for the time being.
If anyone has some suggestions...
2020-08-21 22:04:55 +02:00
Nardi Ivan
23ec82b59d Major rework of QUIC dissector
Improve support for GQUIC (up to Q046) and add support for Q050 and (IETF-)QUIC
Still no sub-classification for Q050 and QUIC
2020-08-21 22:04:55 +02:00
Luca Deri
fef199ad45 Added new check for detecting suspicious (too long) names 2020-08-21 19:35:27 +02:00
Luca Deri
b23781e807 Added the ability do identigy as DGA those host/domain names with too many consucutive repeated characters
such as ckaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa used fr netbios reflection attacks
https://www.akamai.com/uk/en/multimedia/documents/state-of-the-internet/ddos-reflection-netbios-name-server-rpc-portmap-sentinel-udp-threat-advisory.pdf
2020-08-21 18:41:35 +02:00
Luca Deri
248d756e99
Merge pull request #987 from lnslbrty/update/mysql-protocol-detection
Updated MySQL protocol detection to support server version 8.
2020-08-19 21:49:53 +02:00
Luca Deri
9f431f9218
Merge pull request #985 from lnslbrty/add/SOAP
Added support for SOAP.
2020-08-19 21:49:12 +02:00
Luca Deri
d87bdf9302
Merge pull request #977 from adek05/dev
Enable building on OpenBSD 6.7
2020-08-19 21:48:38 +02:00
Toni Uhlig
3a76786121
Updated MySQL protocol detection to support server version 8.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-19 18:33:06 +02:00
Toni Uhlig
8e93f48c43
Added support for SOAP.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-18 16:21:26 +02:00
Luca Deri
98a9afc40c Added support for discord 2020-08-16 10:01:40 +02:00
Luca Deri
8090765a64
Merge pull request #974 from IvanNardi/esni4
Suspicious ESNI usage: add a comment and a pcap example
2020-08-13 10:40:51 +02:00
Luca Deri
9edddee0b7 Fixes invalid detection on traffic on non standard ports 2020-08-12 11:08:28 +02:00
Luca Deri
d5cac570d6 Improved DGA detection algoritm 2020-08-11 17:13:40 +02:00
Luca Deri
0e363d0ca6 Added HLL notes 2020-08-11 16:23:35 +02:00
Luca Deri
dfa9dd66c0 Added case-insensitive substring matching 2020-08-10 19:36:43 +02:00
Adrian Zgorzałek
8f74d5733d OpenBSD: Introduce pkt_timeval to deal with (bpf_)_timeval
Some BSD APIs called in example/ return `struct bpf_timeval`, where nDPI
APIs expect `struct timeval`. These two structs, besides having
a different name, share the exact same set of fields.
2020-08-09 14:30:12 +01:00
Nardi Ivan
2722861d6e Suspicious ESNI usage: add a comment and a pcap example
See: 79b89d2866
2020-08-06 10:29:35 +02:00
Luca Deri
95dfbdc64a
Merge pull request #973 from IvanNardi/esni3
Add risk flag about suspicious ESNI usage
2020-08-06 10:18:27 +02:00
Luca Deri
c2156a5161 Added note on memory management 2020-08-06 09:19:04 +02:00
Luca Deri
5b6ffad278 Added new ndpi_string_sha1_hash API call 2020-08-05 21:45:38 +02:00
Luca Deri
d3fb1fb25a Fixed possible memory leak in TLS certificate handling 2020-08-05 17:57:00 +02:00
Nardi Ivan
79b89d2866 Add risk flag about suspicious ESNI usage
In a Client Hello, the presence of both SNI and ESNI may obfuscate the real
domain of an HTTPS connection, fooling DPI engines and firewalls, similarly
to Domain Fronting.

Such technique is reported in a presentation at DEF CON 28:
"Domain Fronting is Dead, Long Live Domain Fronting: Using TLS 1.3 to evade
censors, bypass network defenses, and blend in with the noise"
Full credit for the idea must go the original author

At the moment, the only way to get the pdf presention and related video is via
https://forum.defcon.org/node/234492
Hopefully a direct link (and an example pcap) will be available soon
2020-08-05 17:13:23 +02:00
Luca Deri
00b2763399 Added check on payload lenght during extra packet processing 2020-08-04 21:59:45 +02:00
Luca Deri
e16675b700 Added new traffic category for connectivity check detection 2020-08-04 18:09:13 +02:00
Luca Deri
ea10b8e757 Added memory checks 2020-08-02 13:00:31 +02:00
Luca Deri
2ae4c6675d Fixed partial TLS dissection 2020-07-30 18:30:07 +02:00
Luca Deri
6904935934 Restored TLS dissection 2020-07-30 00:06:35 +02:00
Luca Deri
a828ac0191 Tiny changes for TLS block lenght dissection 2020-07-29 22:36:27 +02:00
Luca Deri
32bd3d7a59 TLS dissection improvements 2020-07-28 01:06:38 +02:00
Luca Deri
da87cc3157 Added NDPI_SMB_INSECURE_VERSION for detecting insecure SMB versions (e.g. v1) 2020-07-27 13:05:06 +02:00
Luca Deri
69f140878c Boundary check on QUIC 2020-07-27 07:40:50 +02:00
Luca Deri
4b1cae2c2b Boundary check 2020-07-27 06:52:35 +02:00
Luca Deri
1c405e382a SSH code cleanup 2020-07-25 16:43:54 +02:00
Luca Deri
b26539d65a
Merge pull request #967 from MrRadix/dev
Ssh signature checking
2020-07-25 16:17:24 +02:00
MrRadix
6719fa30f9 added other ssh implementations to check 2020-07-24 20:53:02 +02:00
Luca Deri
21e2e57614 Fixed bin similarity 2020-07-24 01:30:58 +02:00
Luca Deri
439558f6a3 Improved bin clustering 2020-07-22 23:56:50 +02:00
MrRadix
a9ca47fcdb added cipher check 2020-07-22 17:17:12 +02:00
MrRadix
1c1be5a0d1 Resolved conflicts on fetch 2020-07-22 16:25:01 +02:00
Luca Deri
3cd1ec5c9a Added changes for handlign SSSH cipher detection 2020-07-22 15:58:46 +02:00
MrRadix
a3ba9253ef fixed bug inside set bit macro call 2020-07-22 15:39:44 +02:00
MrRadix
c450caae94 modified new last two risks 2020-07-22 15:38:31 +02:00
Luca Deri
36af97a14c Minor HLL fixes 2020-07-22 14:40:15 +02:00
MrRadix
af5d792c08 added sscanf error handling 2020-07-22 13:06:08 +02:00
MrRadix
8e2cd9ff43 improved performance and legibility 2020-07-22 12:42:26 +02:00
MrRadix
d9fc4d52e9 merged with remote 2020-07-22 11:56:51 +02:00
MrRadix
a688e36b51 improved ndpi_risk2str output for new risks 2020-07-22 11:44:56 +02:00
Luca Deri
f83d0b18c6 Introduced SSH rick checks 2020-07-22 11:40:57 +02:00