Compare commits

...
1397 Commits
Author SHA1 Message Date
Luca Deri 64929a75e0 3.4 nDPI Release 2020-10-19 16:18:25 +02:00
Luca Deri 02de8e10ca Added makefile target for creating changelog
Updated Changelog
2020-10-19 15:39:48 +02:00
Toni c2d8955c18 Fixed missing PCAP include directories in Makefiles. (#1034)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-10-19 11:25:22 +02:00
Luca Deri e9721eb4ce Improved processing of IPv6 header
Improved QUIC serialization
2020-10-15 21:57:59 +02:00
Alfredo Cardigliano 88f3519ab3 Handle list items in ndpi_deserialize_get_single_size 2020-10-15 12:02:43 +02:00
Alfredo Cardigliano 031cd04b7c Add serialization of values list in TLV 2020-10-15 10:45:43 +02:00
aouinizied d5d2a7e3f3 Fix CAPWAP handling. 2020-10-13 19:13:07 +02:00
Alfredo Cardigliano 2051e51380 Decoupled fuzzy and unit tests 2020-10-12 12:11:35 +02:00
Alfredo Cardigliano c92e0d13fd Serialized doxygen doc 2020-10-05 11:25:48 +02:00
Luca 05d93790e4 Added ndpi_quick_16_byte_hash
Warning fix
2020-10-05 08:26:24 +02:00
Luca Deri 32e4922c5a Warning fix 2020-10-03 17:14:40 +02:00
Luca Deri d4d82c27a5 Tests update 2020-10-02 21:35:15 +02:00
Luca Deri addc775811 Added fix for invalid SNI check when SNI is missing 2020-10-02 21:26:43 +02:00
Luca Deri b68a3707f6 Updated serialization test unit 2020-10-02 12:39:08 +02:00
b0c4d01734 don't pass arguments to ./configure as 1 string (#1027)
this causes the following error if there are arguments after --host :
'checking host system type... config.sub: too many arguments'

Co-authored-by: sahnalys12 <boris.vanhoof_ext@softathome.com>
Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
2020-09-29 18:02:08 +02:00
Ivan Nardi 2c1b7cf1bd QUIC: fix dissection of "offset" field (#1025)
The "offset" field is a variable-length integer.
This bug hasn't any practical effects right now, since we are ignoring any
packet with "offset" != 0 (and the value 0 is always encoded in only one byte).
But extracting a correct "offset" is important if we are ever going to handle
fragmented Client Hello messages.
2020-09-29 17:59:03 +02:00
Toni 656323c334 Added missing files to `make dist' target which are not required to build nDPI but still somehow essential. (#1024)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-29 17:58:33 +02:00
Luca Deri 8e1a3f5cdc Added JSON-C check for unit tests 2020-09-26 12:50:30 +02:00
Luca Deri 58538b7d19 Added extra boundary checks 2020-09-26 12:33:57 +02:00
Luca Deri d0dbcf6dd6 Added back ndpi_check_flow_func (correct) prototype 2020-09-25 10:39:33 +02:00
Luca Deri 8413faf2ef Boundary fix 2020-09-25 09:56:24 +02:00
Luca Deri 204f3ddff5 Compilation fix 2020-09-25 09:36:10 +02:00
Luca Deri 044ed14b4f Various optimizations to reduce not-necessary calls
Optimized various UDP dissectors
Removed dead protocols such as pando and pplive
2020-09-24 23:26:03 +02:00
Luca Deri 51e86346d3 Added -fno-sanitize=alignment in clang-7 2020-09-24 16:46:28 +02:00
Luca Deri 8e7a707be1 -O0 -> -Og 2020-09-23 18:49:44 +02:00
Luca Deri 837ce7306b Attempt to avoid errors due to misaligned packet headers 2020-09-23 18:17:51 +02:00
Luca Deri 05dfae6430 Improved boundary check to prevent overflow 2020-09-23 17:14:40 +02:00
Luca Deri d29a0241ee Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-09-22 12:45:44 +02:00
Luca Deri cbf1be5789 Macro redefinition 2020-09-22 12:23:44 +02:00
Luca Deri 5f99433ee7 Minor UA handling improvement to avoid heap-overflow 2020-09-22 08:56:35 +02:00
lucaderi 27bad14738 Added missing install target in newly added unit tsts 2020-09-22 08:42:50 +02:00
Luca Deri 362baa6321 Minor change for alignment issue 2020-09-21 21:15:52 +02:00
Luca Deri 60a9f6610d Added risks for checking
- invalid DNS traffic (probably carrying exfiltrated data)
- TLS traffic with no SNI extension
2020-09-21 19:57:23 +02:00
Alfredo Cardigliano 0259ff58e1 Exclude sanitizer on unit tests involving json-c due to a bug in the lib 2020-09-21 17:59:06 +02:00
Alfredo Cardigliano d700ab3994 Add distdir directive 2020-09-21 17:32:57 +02:00
Alfredo Cardigliano e6d206fd15 Add unit tests to travis. Move ndpi serializer tests to unit tests. 2020-09-21 17:24:06 +02:00
Luca Deri a263ac9024 Merge pull request #1022 from lnslbrty/fix/ndpi-mingw-fn-redef
Do not re-define libc functions for mingw builds.
2020-09-21 14:42:06 +02:00
Toni Uhlig 87c43450f3 Do not re-define libc functions for mingw builds.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-20 23:29:23 +02:00
Luca Deri 8ba1baace1 Added sample Windows MSVC project 2020-09-20 18:44:57 +02:00
Luca Deri ff1cc1fa41 Merge pull request #1019 from IvanNardi/quic_fb
QUIC: add support for MVFST EXPERIMENTAL version
2020-09-20 18:34:27 +02:00
Luca Deri ea9177cc93 Merge pull request #1018 from lnslbrty/fix/make-dist
Fixed broken `make dist' and added CI check.
2020-09-20 18:33:57 +02:00
Luca Deri 1385f05713 Merge pull request #1017 from lnslbrty/fix/mingw-xcompile
Added support for mingw xcompile.
2020-09-20 18:33:40 +02:00
Nardi Ivan dcac633878 QUIC: add support for MVFST EXPERIMENTAL version 2020-09-20 16:38:28 +02:00
Toni Uhlig fdef6f3545 Fixed broken `make dist' and added CI check.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-19 02:23:53 +02:00
Toni Uhlig d0052fd5b2 Using NDPI_I64_FORMAT, NDPI_U64_FORMAT format string to differentiate between Windows and non-Windows.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-18 19:46:20 +02:00
Toni Uhlig bcce122665 Fixed mingw build w/o examples/tests/fuzzer.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-18 19:46:07 +02:00
Luca Deri 6a7139bb24 Updated results 2020-09-18 00:17:43 +02:00
Luca Deri b5b4512022 Added MDNS in extra packet dissection function 2020-09-18 00:08:27 +02:00
Luca Deri d81bc1add6 Reworked MDNS dissector that is not based on the DNS dissector 2020-09-17 23:24:02 +02:00
Luca Deri 753b5dde16 Merge pull request #1012 from IvanNardi/ua
QUIC: extract User Agent information
2020-09-17 21:32:25 +02:00
Luca Deri 9189aee83b Disabled QUIC tracing that pollutes the output 2020-09-17 14:37:56 +02:00
aouinizied 4cc4efa228 Update example. 2020-09-14 16:42:33 +02:00
Luca ad8318e247 Commented unused function 2020-09-13 09:48:29 +02:00
Alfredo Cardigliano 91e3292e6b Temporarily keep using snprintf 2020-09-11 19:17:10 +02:00
Luca Deri 98a81cb163 Reworked DGA checks 2020-09-11 10:31:19 +02:00
Alfredo Cardigliano 3a6ba7fa12 Replace snprintf with ndpi_snappend 2020-09-11 10:04:43 +02:00
Luca Deri 37abe0daea Added boundary check 2020-09-10 20:06:25 +02:00
Luca Deri 1c0e617d80 Added buffer check in DGA analysis 2020-09-10 19:58:31 +02:00
Nardi Ivan 8db084ab06 TLS: fix memory accesses in QUIC transport parameters extension 2020-09-10 18:19:18 +02:00
lucaderi ea4240055d Complation fix as not on all platforms isnumber() is available 2020-09-10 00:05:02 +02:00
Luca Deri 5ac870074b Merge pull request #1014 from lnslbrty/improved/teamspeak
Improved Teamspeak(3) protocol detection.
2020-09-09 23:28:21 +02:00
Luca Deri 7086197047 Added extension to detect nested subdomains as used in Browsertunnel attack tool
https://github.com/veggiedefender/browsertunnel
2020-09-09 23:25:19 +02:00
Toni Uhlig 8ca13bc46a Improved Teamspeak(3) protocol detection.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-09 21:57:31 +02:00
Alfredo Cardigliano 842c00e681 Add missing low-level serializer calls to the API 2020-09-09 17:09:01 +02:00
Toni Uhlig 4c776501a6 Fixed shlib xcompile for x86_64-w64-mingw32
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-08 19:52:46 +02:00
Nardi Ivan 7d5a0e1f04 QUIC: extract User Agent information 2020-09-08 11:03:22 +02:00
Nardi Ivan a1014e8895 http: create a common function to parse User Agent field
Prepare the code to handle UA information from flows other than HTTP
2020-09-08 10:34:05 +02:00
Luca Deri 601928cc8e Merge pull request #1008 from lnslbrty/add/dnscrypt
Improved dnscrypt v1/v2 protocol detection (and DoH provider).
2020-09-08 09:53:22 +02:00
Luca Deri 5a3956fe27 Added command for specifying the aux files dir 2020-09-08 09:51:02 +02:00
Toni Uhlig df14d225f6 Added pcap file which contains dnscrypt-v1 data and resolver update requests/responses (v1/v2).
* Renamed dnscrypt.pcap to simple-dnscrypt.pcap

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-07 21:04:23 +02:00
Toni Uhlig fe5aa7ebca Added dnscrypt-v2-doh resolver test pcaps.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-07 20:22:52 +02:00
Toni Uhlig 41d35fc7d0 Updated DoT/DoH provider.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-07 20:22:45 +02:00
Toni Uhlig 799a6abfe6 Improved dnscrypt v1/v2 protocol detection.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-06 23:24:55 +02:00
Alfredo Cardigliano 8ed6409b35 Add start_of_block/end_of_block support to TLV 2020-09-04 17:23:04 +02:00
Luca Deri 3f49062db9 Added some additional TLS mappings 2020-09-02 23:35:22 +02:00
Luca Deri 3cca5af8c3 Merge pull request #1003 from lnslbrty/fix/fals-positive-cisco-hsrp-radius-detection
Fixed false positive detection for Skype.SkypeCall (affects at least Cisco HSRP and RADIUS).
2020-09-02 12:32:48 +02:00
Toni Uhlig 7051acc0b5 Fixed off-by-one error in Kerberos protocol.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-02 07:37:26 +02:00
Toni Uhlig 580859a47d Fixed false positive detection for Skype.SkypeCall (affects at least Cisco HSRP and RADIUS).
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-09-02 07:29:33 +02:00
Luca Deri 5d2551ff3e Added boundary check 2020-09-01 22:31:34 +02:00
Luca Deri cefb667d8b Added trademark information 2020-09-01 18:03:01 +02:00
Luca Deri 8575a07113 Added check for ndpi_ssl_version2str() 2020-08-31 17:23:00 +02:00
Luca Deri 460ff3c7ab Added (optional) notifier for LRU add 2020-08-31 08:47:16 +02:00
Luca Deri 029448759b Merge pull request #999 from IvanNardi/quic
QUIC: add support for GQUIC T050 and T051
2020-08-30 20:56:15 +02:00
Luca Deri 448265a151 Merge pull request #998 from lnslbrty/fix/ndpireader-opt-sigsegv
Fixed invalid memory access leading to a SIGSEGV in ndpiReader's option parser.
2020-08-30 20:55:44 +02:00
Nardi Ivan 7da4abe6ad QUIC: add support for GQUIC T050 and T051
QUIC versioning wasn't complex enough without T05X family...
These versions are very similar to Q050, but use TLS as their handshake
protocol.
2020-08-30 20:51:33 +02:00
Luca Deri 638624869a Added new risk for NDPI_UNSAFE_PROTOCOL that identifies protocols that are not condidered safe/secure 2020-08-30 20:48:58 +02:00
Luca Deri 647c7d59bb Improved ntop detection over HTTP
Added cap on number of attempts for CiscoVPN
2020-08-30 19:42:09 +02:00
Luca Deri f597086386 Stddev calculation changes 2020-08-30 12:48:32 +02:00
Luca Deri dd75060932 Fixed false positive in suspicous user agent
Optimized stddev calculation
2020-08-30 12:25:15 +02:00
Luca Deri 8bf95b6198 Merge pull request #996 from lnslbrty/fix/travis-ci
Fix travis-ci related errors.
2020-08-28 13:04:26 +02:00
Toni Uhlig adab0139c2 Fixed invalid memory access leading to a SIGSEGV in ndpiReader's option parser.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-28 06:53:58 +02:00
Toni Uhlig bf9dbd6ccf Fixed travis-ci fuzzm job. Might be a false positive related to clang-7's MSAN.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-27 16:42:24 +02:00
Toni Uhlig e998fc28d1 Fixed use-of-uninitialized-value in QUIC clho decryption probably caused by a BUG in libgcrypt (not verified).
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-27 16:30:05 +02:00
Simone Mainardi 1810281d7f Fixes control reaches end of non-void function 2020-08-27 10:39:36 +02:00
Simone Mainardi f0325f713a Passes method_len param to ndpi_http_str2method 2020-08-27 10:05:38 +02:00
Toni Uhlig 5b27dfdd0c Moved NDPI_CURRENT_PROTO define before ndpi_api.h include to prevent a redefinition warning.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-27 00:29:44 +02:00
Toni Uhlig c17463539f Fixed broken travis-ci YAML.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-27 00:27:31 +02:00
Luca Deri 2e8aa9f08e Added ndpi_http_method ndpi_http_str2method(const char* method) API call 2020-08-26 23:17:19 +02:00
Luca Deri 487d915262 Added ndpi_http_method2str() API call 2020-08-26 12:25:28 +02:00
Luca Deri 5e1bb0dbc1 Merge pull request #992 from lnslbrty/fix/pkg-config
Fixed broken pkg-config file which did not care about gcrypt/pcre.
2020-08-26 10:29:39 +02:00
Toni Uhlig 363ab2259c Fixed broken pkg-config file which did not care about gcrypt/pcre.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-24 18:12:49 +02:00
Luca Deri b94e13da43 Merge pull request #991 from IvanNardi/quic2
QUIC: minor fixes
2020-08-24 14:45:04 +02:00
Nardi Ivan 97b80a8838 QUIC: minor fixes
LGTM found a real issue on a boundary check
Fix unit tests: a pcap ha been uploaded twice (with different names)
Fix compilation when using DPDK (see #990)
2020-08-24 13:53:36 +02:00
Luca Deri b8307eb855 Creared IoT-Scada category
Minor dnp3 changes
2020-08-23 13:32:36 +02:00
Luca Deri 46ba657562 Cosmetic fix 2020-08-22 23:48:00 +02:00
Luca Deri 4570dbfece Added QUIC dependency 2020-08-22 17:02:11 +02:00
Luca Deri 35fd4ddb27 Added libgcrypt20-dev dependency to handle QUIC 2020-08-22 16:53:44 +02:00
Luca Deri fe1e2c241f Added som GQUIC and IETF QUIC test pcaps 2020-08-22 16:47:05 +02:00
Luca Deri af3ce74e02 Fixes compilation issues introduced by https://github.com/ntop/nDPI/pull/989 2020-08-22 16:41:51 +02:00
Luca Deri 93003d0523 Warning fix 2020-08-22 16:41:42 +02:00
Luca Deri 519ba7a9d5 Merge pull request #989 from IvanNardi/quic
Improve QUIC detection
2020-08-22 16:30:29 +02:00
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 da2684dbe1 MySQL8 update 2020-08-21 07:17:34 +02:00
Luca Deri 7e9354ef23 Merge pull request #988 from lnslbrty/add/mysql-8-manipulated-pkt
Added (manipulated) MySQL 8 test pcap.
2020-08-21 06:49:18 +02:00
Toni Uhlig f4421314b0 Added (manipulated) MySQL 8 test pcap.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-20 23:46:47 +02:00
Luca Deri 59ac73b37f Configure code cleanup 2020-08-19 22:01:03 +02:00
Luca Deri 115888ef7a Compilation fix 2020-08-19 21:56:34 +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 673d8b7fac Updated OpenWRT instructions 2020-08-17 18:17:43 +02:00
Luca Deri 1f921562d1 Added fix for API versions starting with 0 2020-08-17 18:11:18 +02:00
Luca Deri 34a98abcc0 Added --with-only-libndpi configure option to build just lindpi 2020-08-17 18:00:38 +02:00
Luca Deri b501239d3f Added README for building libndpi under OpenWRT 2020-08-17 17:17:09 +02:00
Luca Deri ebf89f46e3 Merge pull request #984 from lnslbrty/fix/invalid-fncall-dpdk
Fixed invalid dpdk fn call.
2020-08-16 10:03:55 +02:00
Luca Deri 019a64630b Merge pull request #983 from lnslbrty/fix/libpcap-obsolete-pcap_lookupdev-usage
Replaced obsolete libpcap pcap_lookupdev with pcap_findalldevs.
2020-08-16 10:03:33 +02:00
Luca Deri 98a9afc40c Added support for discord 2020-08-16 10:01:40 +02:00
Toni Uhlig 13cbd1e4ae Fixed invalid dpdk fn call.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-15 12:38:47 +02:00
Toni Uhlig b31fde4bbb Replaced obsolete libpcap pcap_lookupdev with pcap_findalldevs.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-15 12:35:49 +02:00
Luca Deri 46ec91ca4b Merge pull request #976 from lnslbrty/fix/ndpi_simpleint_builderr
Fix/ndpi simpleint builderr
2020-08-13 10:41:25 +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
Toni Uhlig aa856735c0 num_extra_packets_checked check can be 0 for some protocols and therefor requires lesser-or-equal condition for max_extra_packets_to_check
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-13 10:32:31 +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
aouinizied 8c2c388d54 Add Connectivity check category and blacklisted host risk. 2020-08-10 21:19:17 +02:00
aouinizied 8fcb49af25 Fix typo. 2020-08-10 21:17:36 +02:00
Luca Deri dfa9dd66c0 Added case-insensitive substring matching 2020-08-10 19:36:43 +02:00
Adrian Zgorzałek 56a3a33bc0 OpenBSD: Do not redefine __LITTLE_ENDIAN__
Will silence omnipresent compiler warnings when building ntopng.
2020-08-09 14:30:12 +01: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
Toni Uhlig 4ead6d6594 travis-ci: build ndpiSimpleIntegration as well
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-08 12:17:54 +02:00
Toni Uhlig 8da5f42fa0 Changed ndpi_ssl_version2str function call in ndpiSimpleIntegration.
Fixes build error introduced with 23c072153.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-08-08 12:05:11 +02: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 07d9fa7f96 Win #define fix 2020-08-05 11:13:27 +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
aouinizied 57e28e03ee Sync TLS definitions. 2020-08-01 01:27:29 +02:00
Luca Deri 2ae4c6675d Fixed partial TLS dissection 2020-07-30 18:30:07 +02:00
Luca Deri e71df49b3e Changed due to bin size extension 2020-07-30 00:06:46 +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
aouinizied c4b19fd6c5 Update CFFI definitions. 2020-07-29 12:31:21 +02:00
Luca Deri 02dc8d5feb Merge pull request #970 from IvanNardi/fix
Minor fixes
2020-07-28 19:38:12 +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
Nardi Ivan 7d843f4d17 Minor fixes
Fix a memory leak and an issue (re)-introduced in configure script
2020-07-26 21:11:34 +02:00
Luca Deri 95263fc32e Added parentheses to avoid issues with macro expansion 2020-07-25 18:59:48 +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
Luca Deri 0956badd11 Merge pull request #968 from catenacyber/fuzzci
Reenables CI with sanitizers
2020-07-22 19:38:05 +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
Philippe Antoine 2723ac70ce msan cxx 2020-07-22 16:09:13 +02:00
Luca Deri 3cd1ec5c9a Added changes for handlign SSSH cipher detection 2020-07-22 15:58:46 +02:00
Philippe Antoine a279423bff Reenables CI with sanitizers 2020-07-22 15:49:03 +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 88dd3ebd62 added modified risks 2020-07-22 12:41:59 +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
Luca Deri 66178e37cc Merge pull request #966 from catenacyber/ossfuzzbuild
Enables fuzz targets even without sanitizer
2020-07-22 11:36:48 +02:00
Luca Deri 1740042cbb Merge branch 'dev' into ossfuzzbuild 2020-07-22 11:36:31 +02:00
Luca Deri f6242f0e46 HLL memory usage notes 2020-07-22 11:28:14 +02:00
MrRadix 0a182c6d18 Merge remote-tracking branch 'ntop_origin/dev' into dev 2020-07-22 11:15:02 +02:00
MrRadix 53b2b08aeb added new risks to ndpi_risk_enum 2020-07-22 10:56:59 +02:00
MrRadix 9c521c5ddd added new risks iside ndpi_risk2str function 2020-07-22 10:55:53 +02:00
MrRadix 847eb7b180 improved performance by removing linear scan 2020-07-22 10:54:55 +02:00
Luca Deri d90b333363 Merge pull request #965 from lnslbrty/fix/autoconf-ubuntu
fixes autoconf issue on ubuntu 18 (#953)
2020-07-21 21:41:02 +02:00
MrRadix f66cd5aabc added ssh_analyse_signature_version and ssh_has_old_signature for check old signature version of ssh 2020-07-21 19:31:02 +02:00
MrRadix 4b4dcabeda added ssh obsolete version risks 2020-07-21 19:29:59 +02:00
Luca Deri 879cec94b2 User agent detection improvements 2020-07-21 12:06:34 +02:00
Luca Deri 9f4f228832 Added skeleton for checking SSH signature 2020-07-20 17:25:17 +02:00
Philippe Antoine b568c26989 Enables fuzz targets even without sanitizer
Should fix ossfuzz build
2020-07-20 10:07:54 +02:00
Toni Uhlig 29315cee6d fixes autoconf issue on ubuntu 18 (#953)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-19 20:30:41 +02:00
Luca Deri f452dabd92 Fix for invalid boundary check 2020-07-17 23:26:28 +02:00
Luca Deri 64fb40d21e Added ndpi_reset_data_analysis() API call 2020-07-17 13:16:01 +02:00
Luca Deri 6e1dcba9dd Indendentation fix 2020-07-16 17:56:37 +02:00
Luca Deri ebf18a0c61 Merge pull request #964 from yskcg/dev
1:add free pointer NULL check;2:fix xbox and teredo protocol detected…
2020-07-16 17:05:40 +02:00
ysk a268952068 remove the unused code 2020-07-16 17:26:46 +08:00
Luca Deri acd05b171e Added ndpi_data_last() API call 2020-07-16 11:22:06 +02:00
ysk 69ca98ca35 1:add free pointer NULL check;2:fix xbox and teredo protocol detected error when use the commm udp port 3544 2020-07-16 16:07:04 +08:00
Luca Deri 46e97d5da3 Added ndpi_data_window_variance() and ndpi_data_window_stddev() API calls 2020-07-15 18:13:06 +02:00
Luca Deri 9f3e3e8456 Add ndpi_hll_reset() API call
Fixes bug in ndpi_data_window_average() with zero points
2020-07-15 10:30:45 +02:00
Luca Deri 91d132ea3d Check for avoiding buffer overflow in netbios dissector 2020-07-14 22:16:43 +02:00
Luca Deri 3fd3153089 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-07-13 15:48:53 +02:00
Luca Deri a8ad99aca5 Fixed makefile error message
Code hardedning fix
2020-07-13 15:46:19 +02:00
aouinizied 7744c225f9 Add note for sync with cffi bindings. 2020-07-13 12:51:32 +02:00
aouinizied e2e0303099 Add ssl_version_str to flow structure. 2020-07-13 12:48:35 +02:00
Luca Deri 802254327a wrapper cleanup 2020-07-13 10:53:25 +02:00
Luca Deri 9d8717a0c7 Merge pull request #963 from yskcg/dev
add improved boundary check and check malloc return is NULL
2020-07-13 10:24:23 +02:00
Luca Deri 9d35364ef1 Merge pull request #961 from lnslbrty/fix/ssl-version2str-race-condition
Fixed race condition in ndpi_ssl_version2str() caused by static quali…
2020-07-13 10:23:47 +02:00
Luca Deri 051bdb1957 Merge pull request #960 from lnslbrty/fix/heap-overflow-in-llc-readear-util
Fixed heap overflow caused by missing lengthcheck in 802.11 LLC heade…
2020-07-13 10:23:06 +02:00
Toni Uhlig 96c193cf79 Fixed heap overflow caused by missing lengthcheck in 802.11 LLC header parsing.
* triggered by fuzz traces from wireshark

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-11 13:10:03 +02:00
Toni Uhlig 23c0721538 Fixed race condition in ndpi_ssl_version2str() caused by static qualifier in the version string buffer.
* added also GREASE supported tls versions as specified in
   https://tools.ietf.org/html/draft-davidben-tls-grease-01#page-4

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-11 01:05:39 +02:00
ysk 35f1c362b9 add improved boundary check and check malloc return is NULL 2020-07-10 17:49:35 +08:00
Luca Deri 12abcd516b Updated test results due to bin changes 2020-07-09 17:28:02 +02:00
Luca Deri 014fdd9a02 Various fixes in bins implementation
Added -b flag in ndpiReader to test bins
2020-07-09 17:28:02 +02:00
Luca Deri 9d8967236e Merge pull request #957 from lnslbrty/fix/build
Fix/build
2020-07-09 17:27:53 +02:00
Alfredo Cardigliano 6511db8941 Guide update 2020-07-09 15:37:02 +02:00
aouinizied b8d406b1f8 Update note. 2020-07-09 00:58:48 +02:00
aouinizied ce02359953 Add NDPI_MALFORMED_PACKET risk. 2020-07-09 00:56:44 +02:00
Toni Uhlig 24fea66a26 travis-ci cleanups
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-09 00:33:20 +02:00
Luca Deri d658ac9e61 Added -b to ndpiReader to evaluate bins 2020-07-09 00:15:21 +02:00
Toni Uhlig f75984633b ndpiSimpleIntegration should not be included in a static library
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-08 23:47:51 +02:00
Toni Uhlig 20fed83e0f Removed csv_fp as external symbol. Instead passing csv_fp through as argument.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-08 23:21:35 +02:00
Luca Deri f72b402aa2 Merge pull request #956 from IvanNardi/leak
Fix memory leak reported in #955
2020-07-08 17:15:13 +02:00
Luca Deri 4f794aec22 Merge pull request #955 from lnslbrty/fix/heap-overflow-thunder
Fixed thunder protocol detection heap overflow caused by missing leng…
2020-07-08 17:14:45 +02:00
Nardi Ivan fd6a5bc1cd Fix memory leak reported in #955
This leak is clearly happening because of missing/disabled code in "bins"
handling.
This is a trivial workaround useful until such code is completed.
In this way tavis-ci will stop complaining
2020-07-08 11:30:39 +02:00
Alfredo Cardigliano 5be9370cd2 Fix warnings 2020-07-08 09:15:48 +02:00
Toni Uhlig ccb30a04ad Fixed thunder protocol detection heap overflow caused by missing lengthcheck.
* triggered by fuzz traces from wireshark

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-08 00:21:00 +02:00
Luca Deri fb04dbbc47 Added testing bin code 2020-07-07 19:18:43 +02:00
Luca Deri f1dd8bc8c5 Memory allocation fixes 2020-07-07 17:32:26 +02:00
Luca Deri 0c80e6ee3b Merge pull request #954 from lnslbrty/fix/memleak-cluster-bins
fixed memory leak in ndpi_cluster_bins / binUnitTest
2020-07-07 17:18:03 +02:00
Toni Uhlig e308e59002 fixed memory leak in ndpi_cluster_bins / binUnitTest
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-07 17:07:20 +02:00
Luca Deri 1c60c22893 Added ndpi_cluster_bins() for clustering bins and ancillary functions for bins manipulation 2020-07-07 15:10:51 +02:00
Luca Deri db707e0829 Merge pull request #932 from IvanNardi/log
Log
2020-07-07 14:43:32 +02:00
Luca Deri 540326f3ff Merge pull request #953 from lnslbrty/fix/broken-autoconf-fsanitizer
fix broken sanitizer CFLAGS, --enable-fuzztargets should also set -fs…
2020-07-07 14:42:42 +02:00
Luca Deri 94bf7b0130 Merge pull request #952 from lnslbrty/fix/missing-lengthcheck-in-reader-uutil
Fixed heap overflow caused by missing lengthcheck in reader uutil.
2020-07-07 14:42:20 +02:00
Nardi Ivan 030f3f3d48 Fix a memory leak 2020-07-07 10:27:57 +02:00
Toni Uhlig de25ba7d0b Fixed heap overflow caused by missing lengthcheck in reader uutil.
* triggered by fuzz traces from wireshark

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-06 23:30:40 +02:00
Toni Uhlig 9bbcc2548e fix broken sanitizer CFLAGS, --enable-fuzztargets should also set -fsanitize
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-06 22:09:11 +02:00
lucaderi 055422503c configure fixes 2020-07-06 10:38:29 +02:00
Luca Deri c0b34555c2 Merge pull request #951 from lnslbrty/fix/ossfuzzer
ossfuzz.sh: do not use wildcards for fuzzer e.g. fuzz/fuzz*
2020-07-06 10:23:50 +02:00
Luca Deri b4edb75824 Merge pull request #950 from lnslbrty/improved/http-line-parsing
Improved HTTP line parsing if request splitted into multiple packets.
2020-07-06 10:23:29 +02:00
Luca Deri dfb9e8ec1f Merge pull request #940 from lnslbrty/fix/small-and-optimistic-improvments
Fixed CodeInspector issues.
2020-07-06 10:23:04 +02:00
Toni Uhlig c17a21359b Fixed CodeInspector issues.
* Added compiler search list for AC_PROG_CC, AM_PROG_CC_C_O, AC_PROG_CXX, AC_PROG_CC_STDC
   for Mac OS X only
   The list rendered the AX_CHECK_COMPILE_FLAG([-fsanitize=fuzzer]) useless as it did use
   clang for AX_CHECK_COMPILE_FLAG but gcc during the compile process. Seems broken somehow.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-05 20:41:02 +02:00
Toni Uhlig 6e8f268873 ossfuzz.sh: do not use wildcards for fuzzer e.g. fuzz/fuzz*
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-05 20:18:16 +02:00
Toni Uhlig 4b8c8608d1 Improved HTTP line parsing if request splitted into multiple packets.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-05 18:36:57 +02:00
Luca Deri 503e3bb495 Added comment on stddev 2020-07-03 14:45:58 +02:00
Luca Deri 513c857631 Added unit test 2020-07-03 14:43:14 +02:00
Luca Deri f7b91b46fa Merge pull request #947 from lnslbrty/add/download-script-wireshark-traces
added shell script to download wireshark traces, can be used in combi…
2020-07-03 00:45:45 +02:00
Luca Deri 143fcf0b0e Merge pull request #946 from lnslbrty/fix/teamviewer-iprange
Improved TeamViewer IP range (fixes #944)
2020-07-03 00:45:11 +02:00
Toni Uhlig ae89831055 added shell script to download wireshark fuzzing traces, can be used in combination with ./tests/do.sh
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-02 20:22:58 +02:00
Toni Uhlig 8f53c231df Improved TeamViewer IP range (fixes #944)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-07-02 18:11:39 +02:00
Nardi Ivan 974c1cc681 Improve help message of --dbg-proto option
Make it clear that such option is general, not about extcap
functionality
2020-07-02 09:42:53 +02:00
Nardi Ivan c08693fda5 Incorporated some feedback 2020-07-01 20:16:16 +02:00
Luca Deri 08698c65e5 Merge pull request #943 from lnslbrty/fix/missing-lengthcheck-in-tls-esni
Fixed heap overflow in tls esni extraction triggered by manipulated p…
2020-07-01 12:37:29 +02:00
Luca Deri 2d68f8f635 Merge pull request #942 from lnslbrty/improved/fuzzer-automake-dependency-tracking
Added fuzz_*_LDADD to give Automake the opportunity to do some depend…
2020-07-01 12:37:06 +02:00
Luca Deri 2860e3af15 Merge pull request #941 from lnslbrty/add/ossfuzz-script
Copy&Paste ./tests/ossfuzz.sh from https://github.com/google/oss-fuzz…
2020-07-01 12:36:42 +02:00
Luca Deri be35d423b4 Make clean enhancement 2020-07-01 12:34:28 +02:00
Luca Deri cf9c0b96b8 Indent 2020-06-30 16:25:53 +02:00
Alfredo Cardigliano ea6332e004 Fix segfault on ndpi_guess_protocol_id with flow = null 2020-06-30 15:54:52 +02:00
Luca Deri 392ce44573 Added ndpi_print_bin() API call 2020-06-29 22:36:46 +02:00
Toni Uhlig 05d7400563 Fixed heap overflow in tls esni extraction triggered by manipulated packets.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-29 21:51:46 +02:00
Toni Uhlig ea30fcb5de Added fuzz_*_LDADD to give Automake the opportunity to do some dependency tracking.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-29 21:27:03 +02:00
Toni Uhlig 3068306b60 Copy&Paste ./tests/ossfuzz.sh from https://github.com/google/oss-fuzz/pull/4041
* Changing the OSS-Fuzz script from our side is much more easier then
   opening a PR to google/oss-fuzz every time we have to change a single line.
 * https://github.com/google/oss-fuzz/pull/4041 will be updated once this PR is merged

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-29 20:50:09 +02:00
Luca Deri 0d2d44f1b6 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-06-29 19:51:36 +02:00
Luca Deri 07615903e2 Merge pull request #939 from lnslbrty/improved/fuzzy-reader-smp
Improved fuzz_ndpi_reader which supports now SMP/MT w/o race-coniditi…
2020-06-29 19:15:46 +02:00
Luca Deri 2c263bc726 Added ndpi_bin_similarity() for computing bin similarity 2020-06-29 19:09:38 +02:00
Toni Uhlig 4a6c525db8 Improved fuzz_ndpi_reader which supports now SMP/MT w/o race-coniditions.
./tests/do.sh can supports SMP/MT via environment variables.
Removed -fno-sanitize=shift as well, was fixed by 317d3ffd.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-29 19:07:59 +02:00
Luca Deri 93a4a4387a Merge pull request #938 from IvanNardi/errors
Errors
2020-06-28 21:32:08 +02:00
Nardi Ivan f39e3c98f0 Update test results 2020-06-28 12:47:27 +02:00
Nardi Ivan 317d3ffd3e Fix undefined behaviour in internal tests
Error messages:
ndpiReader.c:3211:2: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
ndpiReader.c:3207:5: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

The errors started popping up since 3d9285f1
2020-06-28 12:13:21 +02:00
Nardi Ivan b24f5c4c0a Fix memory leak about purged/expired flows
Create an helper to avoid similar errors in the future
Fixes: 1a62f4c7
2020-06-28 12:05:12 +02:00
Nardi Ivan d6a97219ea Fix use-after-free in http content parsing 2020-06-28 12:05:12 +02:00
Nardi Ivan 3669c14afd DNP3: add missing initialization 2020-06-28 12:05:12 +02:00
Nardi Ivan ece5d3e199 Fix (harmless) memory leaks when DPDK is enabled 2020-06-28 12:05:12 +02:00
Nardi Ivan 2cdf7ce806 Fix startup when DPDK is enabled
Fixes:a58c838c4
2020-06-28 12:05:12 +02:00
Nardi Ivan 2effa57d8a ndpiReader: fix ports statistics
They should take idle/expired flows into account, too
2020-06-28 12:05:12 +02:00
Nardi Ivan b68b45f3bb TLS: extract JA3 signatures in some corner cases
In some (rare) cases, Client Hello message contains lots of cipher
suits.
2020-06-28 12:05:12 +02:00
Luca Deri b2e89e6736 Merge pull request #937 from lnslbrty/re-add-corpus-zipfile-for-google-oss-fuzz
Re-Added corpus zipfile generation required for google-oss fuzzer
2020-06-28 07:29:45 +02:00
Luca Deri 1010520cc4 Merge pull request #936 from lnslbrty/fix/h323-off-by-one
Fixed off-by-one error in h323.
2020-06-28 07:28:55 +02:00
Toni Uhlig f028cce209 Re-Added corpus zipfile generation required for google-oss fuzzer
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-27 23:04:20 +02:00
Toni Uhlig fbfa54eee6 Fixed off-by-one error in h323.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-27 22:58:05 +02:00
Luca Deri ff67e09101 Restored compiler check for fuzzy targets 2020-06-27 19:34:57 +02:00
Luca Deri 76e6c38459 Use clang where available and fallback to gcc when missing 2020-06-27 19:15:52 +02:00
Luca Deri 243104a8c2 Merge pull request #935 from lnslbrty/fix/fuzzing-tests
fixed fuzzing tests in a way that ./tests/do.sh is now able to use co…
2020-06-27 18:57:56 +02:00
Toni Uhlig 1f4523e331 fixed fuzzing tests in a way that ./tests/do.sh is now able to use corpus *.pcap files from ./tests/pcap
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-27 18:41:03 +02:00
Luca Deri b5f3facf7c Added notes whenever a new flow risk is added 2020-06-26 23:39:48 +02:00
Luca Deri 8566288e43 Added malformed packet risk support 2020-06-26 22:37:52 +02:00
Luca Deri 8de62c6d34 Values stored in patricia tree are now 32 bit (they used to be 16 bit) long 2020-06-26 17:49:45 +02:00
Nardi Ivan 0cd0905400 mqtt: add boundary check in log message 2020-06-26 12:04:02 +02:00
Nardi Ivan 56d87186f7 Fix compilation with --enable-debug-messages flag
NDPI_LOG* macros dereference ndpi_detection_module_struct object which is
private to ndpi library (via NDPI_LIB_COMPILATION define). So we can't use
them outside the library itself, i.e. in ndpiReader code
Therefore, in files in example/, convert all (rare) uses of NDPI_LOG* macros
to a new very simple macro, private to ndpiReader program. If necessary,
such macro may be improved.

According to a comment in ndpi_define.h, each dissector must define its own
NDPI_CURRENT_PROTO macro before including ndpi_api.h file
2020-06-26 12:04:02 +02:00
lucaderi ebfb5e7f01 Check for CentOS 6 2020-06-26 09:01:58 +02:00
Luca Deri d805611fcb Merge pull request #931 from lnslbrty/fix/autogen.sh
fixed autoconf version check
2020-06-25 23:31:10 +02:00
Luca Deri 9742dcc45c Merge pull request #930 from IvanNardi/extcap
Extcap
2020-06-25 23:30:20 +02:00
Toni Uhlig f38a8bd7a5 fixed autoconf version check
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-25 20:02:23 +02:00
Nardi Ivan 3c66ca236b Make lua script more robust 2020-06-25 18:02:03 +02:00
Nardi Ivan 70a926088f Fixed harmless memory leak in extcap initialization 2020-06-25 18:02:03 +02:00
Nardi Ivan 6b69e7ebbc Restore extcap functionality, i.e. integration with wireshark 2020-06-25 18:02:03 +02:00
Luca Deri 0b53bc2aab Disabled unused code 2020-06-25 10:50:39 +02:00
lucaderi ecdf7df454 Compilation fixes for non-Linux (or outdated Linux) platforms 2020-06-25 10:25:24 +02:00
lucaderi 3034e53d00 CentOS6 fix (santize won't work as too old system)
Fixes warning
2020-06-25 10:22:16 +02:00
Luca Deri 2350daa2dc Merge pull request #928 from lnslbrty/added/yet-another-ndpi-integration-example
PROPOSAL: ndpiSimpleIntegration: added another integration example
2020-06-25 10:05:49 +02:00
Luca Deri d710b8291d Merge pull request #927 from lnslbrty/fix/fbzero-missing-length-check
Fixed missing length check in fbzero.
2020-06-24 22:17:35 +02:00
Luca Deri 485e56d855 Merge pull request #926 from lnslbrty/added/hulustream-sni-pattern
Added hulustream SNI pattern. Fixes #904.
2020-06-24 22:17:09 +02:00
Luca Deri 38c0d927a9 Merge pull request #925 from lnslbrty/fix/ndpi-rader-unitialized-values
Fixed unitialized values in ndpiReader protocol detection bitmask dur…
2020-06-24 22:16:48 +02:00
Luca Deri 94a68451df Merge pull request #924 from lnslbrty/improved/autoconf-sanitizer-compile-flag-checks
Allow -fsanitize for LLVM as well as for GCC.
2020-06-24 22:15:11 +02:00
Toni Uhlig 17c26911fb ndpiSimpleIntegration: added another integration example
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-24 22:03:18 +02:00
Toni Uhlig ca68beda85 Fixed missing length check in fbzero.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-23 18:35:50 +02:00
Toni Uhlig 2f5766d2f5 Added hulustream SNI pattern. Fixes #904.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-23 17:30:37 +02:00
Toni Uhlig 39800c88fa Fixed unitialized values in ndpiReader protocol detection bitmask during dga selftest.
* make ./tests/vagrind_test.sh directory agnostic

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-23 17:23:56 +02:00
Toni Uhlig 678fbcdfd6 Allow -fsanitize for LLVM as well as for GCC.
* renamed --with-llvm-sanitizer to --with-sanitizer
 * disable all optimisations (-O0) if --with-sanitizer set,
   no functions/paramaters/variables will be optimised, improves debugging
 * enable undefined behaviour sanitizer (ubsan)
 * enable leak sanitizer (lsan)
 * check if -fsanitize=fuzzer is available and --enable-fuzztargets set,
   fail if not (only supported by clang)
 * include level 3 debugging information (-g3), improves macro debugging
 * disabled ubsan misaligned pointer access and lshift overflow

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-23 00:22:33 +02:00
Luca Deri d9af1562f0 Fixes #906
Packet bins are not printed wehn empty
2020-06-22 14:30:26 +02:00
Luca Deri e29e14b7aa Merge pull request #921 from lnslbrty/improved/test-sh
make tests/do.sh directory agnostic
2020-06-22 12:51:17 +02:00
Luca Deri c9d8efc2a4 Warning fix 2020-06-22 10:20:05 +02:00
Luca Deri 1a62f4c799 Added ndpi_bin_XXX API
Added packet lenght distribution bins
2020-06-22 01:02:54 +02:00
Luca Deri 2a137100da Merge pull request #922 from lnslbrty/fix/http-content-disposition-crash
Fixed use after free caused by dangling pointer
2020-06-22 00:57:15 +02:00
Toni Uhlig 6a9f5e4f7c Fixed use after free caused by dangling pointer
* This fix also improved RCE Injection detection

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-21 20:05:38 +02:00
Luca Deri fd0591b4fc Merge pull request #920 from lnslbrty/fix/tls-rdn-crash
Fixed stack overflow caused by missing length check
2020-06-19 11:44:37 +02:00
Luca Deri 48758d28ea Added GoogleDNS DoH on Android 10 2020-06-19 09:55:58 +02:00
Toni Uhlig 14f514134d make tests/do.sh directory agnostic
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-19 07:15:20 +02:00
Luca Deri 63670927e7 Fixed API documentation: packet tiestamp is expressed in milliseconds 2020-06-18 14:15:18 +02:00
Toni Uhlig 23594f0365 Fixed stack overflow caused by missing length check
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-18 00:52:04 +02:00
Luca Deri b2c24558c5 DGA detection improvements 2020-06-18 00:17:30 +02:00
Luca Deri 46d96e7f32 Added checks for DGA detection 2020-06-17 19:46:37 +02:00
Luca Deri ffd20ebdf9 Merge pull request #919 from lnslbrty/new/protocol/anydesk
Implemented proprietary AnyDesk protocol
2020-06-17 06:47:35 +02:00
Toni Uhlig da37f2444f Implemented proprietary AnyDesk protocol
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-17 01:23:03 +02:00
Alfredo Cardigliano 073e3a027b Add API ndpi_serializer_get_format 2020-06-16 18:40:17 +02:00
Luca Deri 0ddc3a0052 Fixed invalid assignment (typo) 2020-06-14 09:37:56 +02:00
Luca Deri 38e4910636 Added improved boundary check 2020-06-14 09:29:52 +02:00
aouinizied 4247dd8322 Synchronize type definitions. 2020-06-12 22:58:58 +02:00
Luca Deri 55364ef0b4 Added DGA risk for names that look like a DGA 2020-06-11 18:51:53 +02:00
Luca Deri 60aaa80570 Added HyperLogLog cardinality estimator API calls
/* Memory lifecycle */
int ndpi_hll_init(struct ndpi_hll *hll, u_int8_t bits);
void ndpi_hll_destroy(struct ndpi_hll *hll);

/* Add values */
void ndpi_hll_add(struct ndpi_hll *hll, const char *data, size_t data_len);
void ndpi_hll_add_number(struct ndpi_hll *hll, u_int32_t value) ;

/* Get cardinality estimation */
double ndpi_hll_count(struct ndpi_hll *hll);
2020-06-10 23:43:35 +02:00
Luca Deri 0b9e46e65a Updated (C) 2020-06-08 23:11:20 +02:00
Luca Deri 64fab4a478 Win fixes 2020-06-08 23:08:12 +02:00
Luca Deri 3506a07864 Added check in TLS 1.2+ for reporting a risk when TLS is not used to carry HTTPS 2020-06-08 14:20:10 +02:00
Luca Deri d318285cae Added HTTP check 2020-06-07 09:46:27 +02:00
Luca Deri 1479c0a278 Added TLS bounadry check 2020-06-07 09:25:19 +02:00
Luca Deri 43ddbfdfba Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-06-06 11:30:47 +02:00
Luca Deri 801c9481cb Removed some obsolete protocols (battlefield, oscar, pcanywhere, tvants) 2020-06-06 11:29:03 +02:00
Alfredo Cardigliano 2beecdc8af Handle EOR in TLV test 2020-06-06 11:18:17 +02:00
Luca Deri 605d548d4a removed obsolete yahoo plugin 2020-06-06 09:38:19 +02:00
Alfredo Cardigliano 0da76fdac6 Support for multiple records in CSV serialization 2020-06-05 17:28:27 +02:00
Luca Deri 597d6e5d60 Merge pull request #913 from yskcg/fix_segment_fault_dev
Fix segment fault dev
2020-06-05 16:57:46 +02:00
Alfredo Cardigliano 67c72a8cb5 Add ndpi_serializer_get_header API (CSV only) 2020-06-05 16:52:26 +02:00
Luca Deri 07c54f9992 Added ndpi_dpi2json() API call 2020-06-05 16:08:23 +02:00
Luca Deri 16ca69733a Improved teamviewer detection 2020-06-03 10:14:27 +02:00
ysk 40550073ef fix segment fault cause by the ssl.server_names when it may NULL 2020-06-03 11:19:37 +08:00
ysk 52893d99f6 fix segment fault cause by the ssl.server_names when it may NULL 2020-06-03 10:44:35 +08:00
ysk 86a3dc5bea Merge branch 'dev' of github.com:yskcg/nDPI into dev 2020-06-03 10:41:40 +08:00
Luca Deri 5afa3ad818 Improved spotify detection 2020-06-02 15:00:14 +02:00
Luca Deri af2a44ae5f Added boundary check in kerberos protocol 2020-06-01 18:22:10 +02:00
Luca Deri 241af016e9 Added check for spotify payload lenght 2020-06-01 16:36:12 +02:00
Luca Deri 16dc0ec29e Check to avoid allocating twice the esni memory 2020-06-01 16:34:24 +02:00
Luca Deri 29d9c2d2c8 Reworked HTTP header processing workflow 2020-06-01 09:54:05 +02:00
Luca Deri 669b7579ff HTTP comparison optimization 2020-05-31 19:31:01 +02:00
Luca Deri a4f8d913ea Minor changes 2020-05-31 19:11:12 +02:00
Luca Deri dc5b4cbde0 Reworked ndpi_strncasestr 2020-05-31 18:50:25 +02:00
Luca Deri b0bf66c436 Added offset check in kerberos dissector 2020-05-31 08:30:55 +02:00
Luca Deri c793e16050 Added extra TLS memory boundary checks 2020-05-31 08:28:02 +02:00
Luca Deri b6eef17e54 Added check to avoid producing alerts for known protocol on unknown port when using TLS 2020-05-30 19:33:13 +02:00
Luca Deri 374a24a1fb HTTP dissector improvements 2020-05-30 18:40:15 +02:00
Luca Deri cbb0b864a2 Minor cleanup 2020-05-29 21:51:51 +02:00
Luca Deri 61066fb106 Added check for heap buffer overflow read 2020-05-29 21:43:06 +02:00
Luca Deri 4ceff1dc77 Fixes for https://github.com/ntop/nDPI/pull/911
Added code for dumping invalid HTTP header
2020-05-29 21:23:46 +02:00
Luca Deri 0271e29097 Added references to ESNI 2020-05-29 21:23:34 +02:00
Luca Deri fcb50dec70 Merge pull request #911 from tmacchioni/dev
Added check for suspicious HTTP headers
2020-05-29 21:14:39 +02:00
Tommaso Macchioni db5cd92fe1 Added check for suspicious HTTP headers 2020-05-29 15:55:52 +02:00
Luca Deri 3085d8e4ff Refreshed test pcap 2020-05-28 21:23:02 +02:00
Luca Deri 9c3bfeca80 Added support for Encrypted TLS SNI dissection
https://datatracker.ietf.org/doc/draft-ietf-tls-sni-encryption/
2020-05-28 17:44:18 +02:00
Luca Deri f6038c358a Added ndpi_serialize_risk() API function 2020-05-27 17:35:11 +02:00
Luca Deri 3108c75059 Result update 2020-05-27 15:26:30 +02:00
Luca Deri 811d7a39b5 Added pcap with encrypted SNI
- https://blog.cloudflare.com/encrypted-sni/
- https://www.inmotionhosting.com/support/website/security/dns-over-https-encrypted-sni-in-firefox/
2020-05-27 15:00:55 +02:00
Luca Deri 030e9dddb7 Extended the cache for services that need to be reconciled such as Microsoft Teams
Added JSON-formatted Microsoft list of IP/services
2020-05-27 12:40:35 +02:00
Alfredo Cardigliano 2dce6cd525 Add ndpi_serialize_start_of_list/ndpi_serialize_end_of_list to serialize simple lists in JSON 2020-05-25 16:37:00 +02:00
Luca Deri 8fa5c31996 Added ndpi_serialize_risk() to the nDPI API 2020-05-24 08:54:38 +02:00
Luca Deri ee35834be6 Added flow risk serilization 2020-05-24 08:46:10 +02:00
aouinizied e5c2c400ef Update APIs and structures. 2020-05-22 23:48:54 +02:00
Luca Deri bbbc5fdbae Added memory boundary checks 2020-05-22 07:24:02 +02:00
Luca Deri 3874f0e0e0 Added stub for checking HTTP header
Updated Teams result
2020-05-21 15:19:55 +02:00
ysk 83ae5b7256 nDpi#remove build warnings 2020-05-21 14:06:52 +08:00
Luca Deri c02b00e0ce MS Teams uses as underlying protocol for voice/video. This commit adds the ability
to mark as MS Teams all Skype traffic made by a host with active MS Teams flows
2020-05-21 00:06:22 +02:00
Luca Deri 07d9e4f9ba Fixed valse positive whatsapp detection
Cleaned Microsoft IP addresses list
2020-05-20 23:28:21 +02:00
Luca Deri e9519c9aca Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-05-20 23:14:46 +02:00
Luca Deri 329eff069e Removed bittorrent false positive detection 2020-05-20 23:14:09 +02:00
Luca Deri 246ec53bcf Merge pull request #905 from lnslbrty/dev
Fixed docstring typos for ndpi_finalize_initalization
2020-05-20 08:48:49 +02:00
ysk cd65da69d3 Merge branch 'dev' of github.com:yskcg/nDPI into dev 2020-05-20 13:21:36 +08:00
ysk 068c1b1f22 someip#fix when run across architectures such ARM ,may be occour sigbus error(),Unhandled fault: alignment fault (0x92000021) at 0x00000000f67004aa 2020-05-20 13:15:42 +08:00
Luca Deri b7e666e465 Added fix to avoid potential heap buffer overflow in H.323 dissector
Modified HTTP report information to make it closer to the HTTP field names
2020-05-19 08:31:05 +02:00
Toni Uhlig c5e16b4ff7 Fixed docstring typos for ndpi_finalize_initalization
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-05-17 16:59:57 +02:00
Luca Deri 3d9285f1be Added check for invalid HTTP URLs 2020-05-16 00:10:35 +02:00
Luca Deri c375782b96 Added check for binary scripts
Added NDPI_HTTP_NUMERIC_IP_HOST risk
ndpi_risk moved to 32 bit
2020-05-15 22:49:55 +02:00
Luca Deri 8e7b1ea7a1 Fix for potential heap-buffer-overflow in ndpi_search_openvpn 2020-05-15 21:10:37 +02:00
Luca Deri e90c5c7c32 Added NDPI_HTTP_SUSPICIOUS_USER_AGENT ndpi_risk 2020-05-15 19:19:17 +02:00
Luca Deri 7dfbfff743 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-05-15 18:58:10 +02:00
Luca Deri da22aa5fc7 Added NDPI_TLS_CERTIFICATE_EXPIRED, NDPI_TLS_CERTIFICATE_MISMATCH, to ndpi_risk 2020-05-15 18:57:49 +02:00
Luca Deri a183b2ab9b Added link to nfstream 2020-05-15 18:11:59 +02:00
Luca Deri adfe6b763c Gotomeeting address range fix 2020-05-15 11:20:21 +02:00
Luca Deri 9ed94a722c Improvements on GotoMeeting
Added pcap for testing malware
2020-05-15 10:52:23 +02:00
Luca Deri 7037e79604 Merge pull request #903 from Loures/dev
Extend packet struct with Content-Disposition HTTP header field
2020-05-14 20:56:07 +02:00
loures 1edf5c49d6 Extend filetype matching for Content-Disposition header 2020-05-14 14:30:34 +02:00
loures baddfbb6c3 Extend packet struct with Content-Disposition HTTP header field
and improve HTTP binary transfer mime type check
2020-05-14 12:47:22 +02:00
Luca Deri fb64346e28 Code clenup for PR #902 2020-05-14 09:49:47 +02:00
Luca Deri 50be0b0049 Merge pull request #902 from Loures/dev
Add check for HTTP transfer of executable files
2020-05-14 09:12:17 +02:00
loures 08f32f2e0e Set risk field instead of changing protocol when checking for dangerous
HTTP traffic
2020-05-13 19:56:49 +02:00
loures 0a4fbb8cfb Add check for HTTP transfer of executable files 2020-05-13 18:32:29 +02:00
Luca Deri 9dfd0d0071 Code cleanup 2020-05-13 17:49:02 +02:00
Luca Deri 17235d234e Merge pull request #897 from catenacyber/fuzzoracle
Adds bound check in oracle protocol
2020-05-12 13:53:55 +02:00
Luca Deri db16a987c5 Merge pull request #896 from IvanNardi/nats
Fix NATS dissector
2020-05-12 13:52:42 +02:00
Luca Deri f7f705406f Invalid TLS check 2020-05-12 12:25:07 +02:00
Luca Deri cd765c08d6 Added NDPI_XXX_BIT_16 2020-05-11 09:07:30 +02:00
Luca Deri ee15c6149d Added TLS weak cipher and obsolete protocol version detection 2020-05-10 21:55:35 +02:00
Luca Deri ae803c8b51 Added detection of self-signed TLS certificates 2020-05-10 21:40:35 +02:00
Luca Deri e5e69d0f7a Added the ability to detect when a known protocol is using a non-standard port
Added check to spot executables exchanged via HTTP
2020-05-10 21:25:38 +02:00
Philippe Antoine b69177be2f Adds bound check in oracle protocol
Found by oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21780
2020-05-10 15:04:23 +02:00
Nardi Ivan f8503da9e9 Fix NATS dissector 2020-05-09 15:41:20 +02:00
Luca Deri 39ae57e6a3 Cleaned hyperscan leftover
Added further hyperscan hooks
2020-05-08 18:24:07 +02:00
Luca Deri c9b37b92f5 Added self signed certificate test pcap 2020-05-08 09:09:58 +02:00
Luca Deri 4a09b4efa0 Added TLS issuerDN and subjectDN 2020-05-07 18:44:51 +02:00
Luca Deri fd646bd05f Reworked TLS dissector with a certificate RDN sequence reader 2020-05-07 17:22:01 +02:00
Luca Deri 6a1b8baa00 Fixed category matching 2020-05-06 23:50:35 +02:00
Luca Deri 2ccd2c204b API cleanup for indetifying explicitly in automa's what we're searching (protocol or category)
Removed hyperscan support that is apperently unused
2020-05-06 23:19:59 +02:00
Luca Deri 263547e77d Updated automa API to use 32 bit values splits from protocol/categpry 2020-05-06 21:57:32 +02:00
Luca Deri 86e34fbf6d Added support for Telegram v6 2020-05-06 18:06:30 +02:00
Luca Deri 84f66b4d6b Introduced custom protocols with IP and (optional) port support
Example

- Single IP address
  ip:213.75.170.11@CustomProtocol

- IP address with CIDR
  ip:213.75.170.11/32@CustomProtocol

- IP address with CIDR and port
  ip:213.75.170.11/32:443@CustomProtocol

Please note that there are some restrictions on the port
usage. They have been listed in example/protos.txt
2020-05-06 12:51:44 +02:00
Luca Deri 7855e0318d Various fixes to patricia tree handling 2020-05-06 11:13:57 +02:00
Luca Deri 48282369e2 False positive fixes 2020-05-06 01:34:55 +02:00
Luca Deri 7d63149ced Updated API 2020-05-06 00:41:07 +02:00
Luca Deri 427002d14f Reworked protocol handling chnging it is u_int16_t 2020-05-06 00:31:40 +02:00
Luca Deri 4148c5e065 Removed now obsolete MSN protocol
Added nats.io protocol dissector
2020-05-03 18:20:21 +02:00
Luca Deri c120cca662 SSH boundary check rework 2020-04-30 20:08:03 +02:00
Luca Deri 7344bf65bc Minor cleanup 2020-04-30 19:58:07 +02:00
Luca Deri 6f79b78f71 Merge pull request #891 from catenacyber/ghsl2
Better fix for integer overflow in SSH
2020-04-30 19:53:16 +02:00
Philippe Antoine a70fd6ed3b Better fix for integer overflow in SSH
Credits to GHSL
2020-04-30 18:44:40 +02:00
Luca Deri bd0fd6cf8d Merge pull request #883 from leonn/websocket
💡 implement WebSocket protocol dissector
2020-04-27 23:28:23 +02:00
Luca Deri 0bf809f8e5 Merge pull request #884 from lnslbrty/dev
Added missing ndpiReader dependency for the install target
2020-04-27 23:27:26 +02:00
Luca Deri 44259ab2b9 Merge pull request #887 from IvanNardi/tunnel
Tunnel
2020-04-27 23:27:03 +02:00
Alfredo Cardigliano 328016895f Handle empty blocks 2020-04-27 13:34:54 +00:00
Leonn Paiva 780dc8d1e7 💡 implement websocket protocol dissector 2020-04-26 02:53:12 -03:00
Alfredo Cardigliano 4d746dabe9 Enable IEC 60870-5-104 dissector 2020-04-24 15:31:44 +00:00
Nardi Ivan 097127c31d Fix heap-overflow error in CAPWAP detunneling code 2020-04-24 10:42:52 +02:00
Nardi Ivan c2ebbb15ad Fix "division by zero" runtime error 2020-04-23 14:24:49 +02:00
Nardi Ivan f965983c23 Add basic support for some ip-in-ip tunnels
Add support for 4in4, 6in6 and 4in6 encapsulations
Add support for ipv6 traffic in gtp tunnels, too

To allow gtp unit test, gtp detunneling flag has been globally enabled
in the test suite
2020-04-23 10:55:33 +02:00
Toni Uhlig 8d8e61b256 Added missing ndpiReader dependency for the install target
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-04-22 21:51:57 +02:00
Luca Deri 0b702c20d3 Warning fix 2020-04-22 18:52:36 +02:00
Luca Deri 473a5d1d0b Merge pull request #881 from leonn/bug_protocol_was_guessed
Bug protocol was guessed
2020-04-22 18:49:55 +02:00
Luca Deri 65b428899d Fix for nDPI code not downlooaded from git 2020-04-22 16:15:15 +02:00
Leonn Paiva 6769168d89 🐛 use protocol_was_guessed in ndpi_detection_giveup 2020-04-22 03:48:12 -03:00
Leonn Paiva 4d5ca2c473 🆒 code ident & style 2020-04-22 03:40:55 -03:00
Luca Deri e8cae3cff9 Updated results 2020-04-21 19:26:49 +02:00
Luca Deri 019b51bb17 Merge pull request #879 from IvanNardi/warnings
Fix some compilation warnings
2020-04-21 19:23:57 +02:00
Luca Deri e2be7daed6 Merge pull request #880 from catenacyber/fuzz8fix
Gets right protocol after IPv6 header
2020-04-21 19:22:50 +02:00
Philippe Antoine 1b73f7372e Gets right protocol after IPv6 header 2020-04-21 15:34:53 +02:00
Nardi Ivan b1a6c6b895 Fix some compilation warnings 2020-04-20 16:53:39 +02:00
Luca Deri e603549967 Office365 renamed to Microsoft365 (by Microsoft) 2020-04-20 15:44:27 +02:00
Luca Deri 3bdec5ae5f Updated node list (fixes #766) 2020-04-20 15:16:31 +02:00
Luca Deri 25cd2a23a6 Compilation fixes 2020-04-20 15:08:51 +02:00
Luca Deri 97badc574b Merge pull request #877 from catenacyber/fuzz7fix
Adds bound check before calling ndpi_handle_ipv6_extension_headers
2020-04-20 13:56:53 +02:00
Luca Deri 493bffb3e0 Added check for pkg-config presence 2020-04-19 21:48:24 +02:00
Philippe Antoine c2b2692e65 Seeting right flow protocol after IP6 extensions
Finally fixing https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20727
2020-04-18 14:39:57 +02:00
Philippe Antoine db5f3b38b7 Adds CIFuzz to check PRs
cf https://google.github.io/oss-fuzz/getting-started/continuous-integration/
2020-04-18 10:50:56 +02:00
Philippe Antoine da0889d3ba Adds bound check before calling ndpi_handle_ipv6_extension_headers 2020-04-17 22:21:03 +02:00
Luca Deri 94eee66a7b CiscoVPN dissection improvements 2020-04-17 16:56:55 +02:00
Luca Deri 748df7972a Results update 2020-04-17 10:36:27 +02:00
Luca Deri a766de7b94 Merge pull request #876 from a-czyrny/dev
additional csv semicolon fix
2020-04-17 10:34:41 +02:00
Luca Deri 711ba99eaa Added detection of Microsoft Teams 2020-04-16 15:23:07 +02:00
Alexander Czyrny 32d25bfdaf additional csv semicolon fix
Created function correct_csv_data_field to pevent duplicated code. Additionally used for _flow->ndpi_flow->protos.stun_ssl.ssl.alpn_ and _flow->ndpi_flow->protos.stun_ssl.ssl.tls_supported_versions_ to guarantee a valid csv output (commas replaced by semicolon) .
2020-04-16 14:12:48 +02:00
Luca Deri 287015ffdc Fixed invalid check 2020-04-15 22:42:09 +02:00
Luca Deri f4c24663fc Merge pull request #874 from catenacyber/fuzz6fix
Fuzz6fix
2020-04-15 18:05:16 +02:00
Luca Deri 9f2dabbda4 Merge pull request #873 from a-czyrny/a-czyrny-ndpireader-csv-patch
Fix for missing line breaks in CSV file
2020-04-15 18:04:26 +02:00
Philippe Antoine 4f370fe7c4 Adds netbios bound check 2020-04-15 16:40:00 +02:00
Philippe Antoine 9483c842b5 TLS initializes version_str 2020-04-15 16:40:00 +02:00
Philippe Antoine c1f9f05d33 Adds tls check before reading memory 2020-04-15 16:22:16 +02:00
Philippe Antoine cf47ba234a Use ndpi_handle_ipv6_extension_headers in reader_util 2020-04-15 16:19:57 +02:00
Philippe Antoine 98f2d3a73c Adds bound check for IRC 2020-04-15 15:56:58 +02:00
Philippe Antoine c1baf1516d Adds bound check for TZSP 2020-04-15 15:50:58 +02:00
Philippe Antoine 369dc65c1a Fix integer overflow in quic 2020-04-15 15:45:32 +02:00
Philippe Antoine 4ec3e6c064 Adds bound check in TLS 2020-04-15 15:42:54 +02:00
Philippe Antoine 81e97d7515 Fixes OOB reads in postgres
Reported by GHSL
2020-04-15 15:35:34 +02:00
Alexander Czyrny 32ab88a26e Fix for missing line breaks in CSV file
If "-v" is used as an argument, the line breaks are missing in the csv file ("-C"), because the argument "-J" is assumed. Moving the condition for the CSV file handler out of the scope of the "enable_joy_stats" condition removes this dependency and the CSV file is formatted correctly.
2020-04-15 10:12:37 +02:00
Luca Deri afdae85b30 Restored ndpi_get_api_version() prototype 2020-04-15 09:06:02 +02:00
Luca Deri 63c4eaae9b Invalid function definition fix 2020-04-13 22:40:20 +02:00
Luca Deri 4e876a4543 Merge pull request #866 from anticomputer/packet_payload_integer_ql
ql query to identify suspicious use of network sourced integers
2020-04-15 08:38:23 +02:00
Luca Deri 7b54d028a3 Merge pull request #872 from aouinizied/dev
Update python example.
2020-04-15 08:37:28 +02:00
Luca Deri 9cba06a080 Merge pull request #869 from disconnect3d/patch-2
Fix incorrect "<iq from=\"' parsing
2020-04-15 08:36:27 +02:00
Luca Deri 794f7fa124 Merge pull request #868 from disconnect3d/patch-1
Fix off by one when checking for "GET / HTTP" string
2020-04-15 08:35:59 +02:00
Luca Deri d3b4b81d6f Merge pull request #867 from IvanNardi/memory-leaks
Memory leaks
2020-04-15 08:35:28 +02:00
Zied Aouini 1bee9d85a4 Fix flow_printer example. 2020-04-15 08:05:03 +02:00
Disconnect3d fa15e170b4 Fix incorrect "<iq from=\"' parsing
This PR fixes a wrong size arg passed to memcmp when checking for "<iq from=\"" and "<iq from \'" strings.
2020-04-13 16:35:03 +02:00
Disconnect3d b75838b771 Fix off by one when checking for "GET / HTTP" string 2020-04-13 16:33:27 +02:00
Luca Deri d665df64e2 Added ndpi_serialize_raw_record() API call 2020-04-10 21:39:23 +02:00
Nardi Ivan e84563f971 ndpiReader: fix memory leak in idle sessions purging 2020-04-08 15:15:34 +02:00
Nardi Ivan a60854bae6 Fix some debug messages 2020-04-08 15:15:34 +02:00
Nardi Ivan 7b690d8b2d kerberos: fix heap-overflow error 2020-04-08 15:15:34 +02:00
Nardi Ivan 0c1322a718 s7comm: fix heap-overflow error 2020-04-08 15:15:34 +02:00
Nardi Ivan b40732d8a5 Fix an harmless memory leak
Leak introduced in 90e08b35, while fixing #845
2020-04-08 15:15:34 +02:00
Luca Deri db8497778d Fixes #853 and adds a self check for duplicates 2020-04-07 19:17:37 +02:00
Luca Deri dea883a25d Minor refresh 2020-04-07 19:01:38 +02:00
Luca Deri 81a2f54dd7 Merge pull request #865 from catenacyber/ghsl-2020-05x
Ghsl 2020 05x
2020-04-05 08:29:43 +02:00
Luca Deri c2c01b618b Fix for string serialization with initial empty string 2020-04-03 15:26:24 +02:00
Bas Alberts fb863c6bfb ql query to identify suspicious use of network sourced integers 2020-04-02 17:14:49 -04:00
Philippe Antoine 7ce478a58b ssh: fixing unsigned overflow leading to heap overflow
cf GHSL-2020-051
2020-04-02 16:48:35 +02:00
Philippe Antoine 3bbb0cd329 ssh: adds systematic bounds checks in concat_hash_string
cf GHSL-2020-052
2020-04-02 16:35:10 +02:00
Luca Deri 56ca71bda9 Merge pull request #863 from IvanNardi/memory-errors
Memory errors
2020-03-31 17:51:20 +02:00
Nardi Ivan 498571354d openvpn: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan 3924257f32 telnet: fix another heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan 817aa54214 telnet: fix heap-overflow error
There is some boilerplate since I removed an if branch and I had to reindent
the code
2020-03-27 11:09:53 +01:00
Nardi Ivan 97fc94c7e8 kerberos: fix use-after-free error
After leaving kerberos code, the original packet may be processed from
other dissector (i.e. TLS)
2020-03-27 11:09:53 +01:00
Nardi Ivan 9ec711aa90 tls: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan 9c2c04d8ce ssh: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan 4f399356a6 quic: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan 45ff2a3f5a h323: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan 58f0f29113 soulseek: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Nardi Ivan da5e5a3e2a ciscovpn: fix heap-overflow error 2020-03-27 11:09:53 +01:00
Luca Deri 17d531e3db Added s7comm test pcap 2020-03-27 09:35:59 +01:00
Luca Deri 0d223ada3f Compilation fix 2020-03-27 08:46:03 +01:00
Luca Deri 890e8644ac Merge pull request #861 from havup/dev
pull request with s7comm
2020-03-27 08:38:44 +01:00
havup 1bab8a1c22 Update s7comm.c 2020-03-27 14:02:10 +08:00
havup 24bb0b7f53 Update s7comm.c 2020-03-27 13:09:46 +08:00
havup 803b13a7a8 Update s7comm.c 2020-03-27 12:58:56 +08:00
havup 7841145d9c Update tls_long_cert.pcap.out 2020-03-27 12:28:15 +08:00
havup efdac78ddc Update s7comm.c 2020-03-27 11:19:50 +08:00
havup 74825ffc6e Update s7comm.c 2020-03-26 13:06:02 +08:00
emanuele-f 1b8f7ed101 Fix API version generation 2020-03-25 14:07:19 +01:00
emanuele-f 9cf016c5f1 Fix ndpi_get_api_version version truncation 2020-03-25 14:00:47 +01:00
Luca Deri 47a4507d9e NDPI_API_VERSION is now computed automatically 2020-03-25 12:51:06 +01:00
havup 779d9a6e51 Add files via upload 2020-03-25 19:09:14 +08:00
havup ac17e0bea7 Update ndpi_main.c 2020-03-25 19:06:36 +08:00
havup 4d95dae2ae Update ndpi_main.c 2020-03-25 19:05:49 +08:00
havup 6c3cbe50e2 Update ndpi_protocols.h 2020-03-25 19:04:35 +08:00
havup a2b163beca Update ndpi_protocol_ids.h 2020-03-25 19:04:00 +08:00
Luca Deri c8a1767465 Fixed invalid allocation 2020-03-24 13:36:03 +01:00
Luca Deri 40be74c629 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-03-23 14:45:08 +01:00
Luca Deri df5cf59787 Format update 2020-03-23 14:44:33 +01:00
Luca Deri d26349e082 Format update 2020-03-23 14:37:14 +01:00
Luca Deri 7add3acc53 Added fuzz-2020-02-16-11 fuzzy pcap 2020-03-23 10:27:32 +01:00
Luca Deri 1c1a18d12f Added fuzz-2006-09-29-2858 fuzzy pcap 2020-03-23 10:25:28 +01:00
Luca Deri 92bd223c34 Added fuzz-2006-06-26-2594.pcap fuzzy pcap 2020-03-23 10:24:11 +01:00
Luca Deri 9d53c3c3b8 Added wa_video.pcap 2020-03-23 10:23:05 +01:00
Luca Deri 906d7fe0c1 Added wa_voice.pcap 2020-03-23 10:22:46 +01:00
Luca Deri cd78740caf Added netflow-fritz.pcap 2020-03-23 10:11:51 +01:00
Luca Deri 626ee52049 Added smb_deletefile.pcap 2020-03-23 10:09:47 +01:00
Luca Deri 7a93994802 Added iphone.pcap 2020-03-23 10:09:14 +01:00
Luca Deri 1bb10863e4 Added android.pcap 2020-03-23 10:08:57 +01:00
Luca Deri 924bc9698b Added badpackets.pcap 2020-03-23 10:06:16 +01:00
Luca Deri 9aba94713c Added dns_exfiltration.pcap 2020-03-23 10:06:00 +01:00
Luca Deri 00beac6b1a Added netbios.pcap 2020-03-23 10:05:41 +01:00
Luca Deri 8c2ffc5b37 Added dos_win98_smb_netbeui.pcap 2020-03-23 10:05:24 +01:00
Luca Deri a845e99720 Merge pull request #859 from catenacyber/fuzzudpfix
Checks enough data for UDP header
2020-03-20 18:02:27 +01:00
Luca Deri 8cda02bb14 Fixed loop in serialization 2020-03-20 18:01:37 +01:00
Philippe Antoine 3e259aac98 tls_supported_versions only if version_str is initialized
With version_len == (extension_len-1)
2020-03-19 17:19:28 +01:00
Philippe Antoine 2aec630202 Fix use of uninitialized value in TLS 2020-03-19 17:16:41 +01:00
Philippe Antoine c6acf97bfb Adds different checks against overflows 2020-03-19 16:54:31 +01:00
Philippe Antoine e9195589d2 Checks enough data for UDP header 2020-03-19 16:44:53 +01:00
Luca Deri b2cbe76e71 Added QUIC v046 test pcap 2020-03-17 16:51:25 +01:00
Luca Deri 4227be7989 Update for QUIC 046 2020-03-17 16:48:34 +01:00
Simone Mainardi e282e43279 Fixes netbios overread
This commit inherits from https://github.com/ntop/nDPI/commit/7a2bcd9c395f9fe554109e04add33e9e65564d82
but leaves ndpi_netbios_name_interpret as part of the API as it
is used by ntopng
2020-03-12 22:21:07 +01:00
Simone Mainardi 2f15ce706f Fixed API change which removed ndpi_netbios_name_interpret
This reverts commit 7a2bcd9c39.
2020-03-12 22:08:59 +01:00
Luca Deri 70ee793ff3 Merge pull request #856 from catenacyber/fuzzfix5
Fuzzfix5
2020-03-12 18:13:30 +01:00
Philippe Antoine 7806eb5f5b Fix infinite loop in tls 2020-03-12 14:31:47 +01:00
Philippe Antoine 9d1340a8e7 Fix buffer overread in yahoo 2020-03-12 14:26:08 +01:00
Philippe Antoine 7a2bcd9c39 Fix buffer overread in netbios 2020-03-12 14:22:46 +01:00
Philippe Antoine fe513014a8 Fix buffer over read in dns 2020-03-12 14:13:04 +01:00
Philippe Antoine 3c05d4551d Fix snprintf return value check for tls 2020-03-12 14:05:48 +01:00
Philippe Antoine 4976d93d4e Fix buffer overread in ndpi_search_setup_capwap 2020-03-12 14:03:31 +01:00
Luca Deri 1e933e8b02 Win fixes 2020-03-12 11:26:38 +01:00
Luca Deri 942a71c7eb NetBIOS dissection improvements 2020-03-01 11:42:21 +01:00
Luca Deri 7fd135a8c9 Added SMBv1 over NetBIOS detection 2020-03-01 11:32:09 +01:00
Luca Deri 34ad06fef5 Compilation fix 2020-02-28 16:03:27 +01:00
Luca Deri 8f45f51e6c Compilation fix 2020-02-28 15:28:41 +01:00
Luca Deri 9f72b15fff Merge pull request #850 from catenacyber/fuzz4fix
Fuzz4fix
2020-02-28 14:39:17 +01:00
Philippe Antoine 6fe9535881 Adds check before memcpy for bittorrent 2020-02-26 17:12:46 +01:00
Philippe Antoine 5fc9d41eb0 Run ndpi_detection_process_packet only with payload
Real problem is decapsulation of all ipv6 headers
2020-02-26 17:05:08 +01:00
Philippe Antoine 933351840d Fix off by one in imap 2020-02-26 16:59:04 +01:00
Philippe Antoine 83fdfe24d0 Fix read overflow before UDP header 2020-02-26 16:16:29 +01:00
Alfredo Cardigliano d4c093e828 Check NULL strings in ndpi_serialize_string_string 2020-02-26 09:55:24 +01:00
Luca Deri c0ec78885d Merge pull request #849 from annp1987/fix_ndpi_flow2json_segfault
ndpi_flow2json should check http.url before serializer
2020-02-26 08:06:11 +01:00
Luca Deri a55c410202 Merge pull request #848 from aouinizied/dev
nDPI 3.2 support in python cffi bindings
2020-02-26 08:05:45 +01:00
Nguyen Phuong An e675be1a83 ndpi_flow2json should check http.url before serializer
This patch will fix issue: https://github.com/ntop/PF_RING/issues/557
2020-02-26 13:32:13 +07:00
Luca Deri f07a329447 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-02-23 19:10:14 +01:00
Luca Deri 2ceff3e214 Fixed swapped protocol 2020-02-23 19:09:58 +01:00
Zied Aouini dcb6fde0c9 Update Python cffi bindings. 2020-02-21 17:28:44 +01:00
Zied Aouini e67604a583 Remove trailing alignment directives. 2020-02-21 16:37:36 +01:00
Zied Aouini 40896d3d44 Fix docstrings. 2020-02-21 15:51:17 +01:00
Zied Aouini 5a0f609086 Add ndpi_flow_tcp_struct and ndpi_flow_udp_struct api calls. 2020-02-21 15:49:46 +01:00
Alfredo Cardigliano 2972e29097 Moved to 3.3 2020-02-20 10:15:11 +01:00
Luca Deri dd80ec869a Fixes #837 2020-02-19 23:44:22 +01:00
Luca Deri 1714d7aa52 Fixes #842 2020-02-19 23:40:53 +01:00
Luca Deri 90e08b3568 Fixes #845 2020-02-19 23:38:33 +01:00
Luca Deri 080e23e30e Merge pull request #846 from catenacyber/fuzzofix
Fix various buffer over reads
2020-02-19 22:55:18 +01:00
Luca Deri edce5a8c1f Fix for disabling guess when not requested 2020-02-19 12:24:26 +01:00
Alfredo Cardigliano c8ccf33f07 nDPI 3.2 changelog 2020-02-19 12:10:49 +01:00
Philippe Antoine ee979ac14a Fix kerberos leak 2020-02-18 13:32:20 +01:00
Philippe Antoine 3eb9907dd7 Fix various buffer over reads 2020-02-18 11:50:22 +01:00
Luca Deri fdf8dd724f Minor fix 2020-02-17 22:15:36 +01:00
Luca Deri 37121a9b58 Added protocol range check 2020-02-17 19:34:47 +01:00
Luca Deri bbaf9147b6 Fixed TLS client SNI dissection 2020-02-17 18:48:21 +01:00
Luca Deri 9796fdc0e9 Temporarely disabled x390 s390x as we have no way to debug the code on such platforms 2020-02-15 17:31:30 +01:00
Luca Deri e0a058af67 Merge pull request #844 from catenacyber/fuzz2fix
Fuzz2fix
2020-02-15 17:21:52 +01:00
Alfredo Cardigliano 80e9826040 Add ndpi_serialize_string_raw to add raw json values 2020-02-14 16:32:00 +01:00
Philippe Antoine bf7dcd63c3 Checks length for next ip header 2020-02-14 14:18:31 +01:00
Philippe Antoine b287dccecf Checks l4 size against l3 size 2020-02-14 14:02:19 +01:00
emanuele-f cb34c6b233 Add fpic in the reader 2020-02-14 12:06:55 +01:00
emanuele-f fd94270507 Remove decimals in test results for IAT, packet lengths and goodput ratio 2020-02-14 11:42:20 +01:00
Emanuele Faranda 03cf975c07 Merge pull request #840 from xnox/more-tests
travis: bump to bionic, add arm64 & s390x.
2020-02-14 10:32:31 +00:00
emanuele-f 428661c00b Add debug symbols when using --with-llvm-sanitizer 2020-02-14 11:09:00 +01:00
emanuele-f 5c52c00ea4 Add the --with-llvm-sanitizer flag
To enable the leaks detector, set the ASAN_OPTIONS=detect_leaks=1
environment variable, e.g:

	ASAN_OPTIONS=detect_leaks=1 example/ndpiReader -i test.pcap
2020-02-13 18:42:13 +01:00
Luca Deri f89f25c118 Added ndpi_is_protocol_detected() API call 2020-02-13 15:20:47 +01:00
emanuele-f d4ae8a5f16 Fix memory invalid access in SMTP and leaks in TLS 2020-02-13 10:46:30 +01:00
emanuele-f 7234f36949 Fix possible leak 2020-02-13 10:14:57 +01:00
emanuele-f 2efc09a20e Fix invalid memory read 2020-02-12 19:36:47 +01:00
emanuele-f 3fa61a394b Fix little leak on the proto_defaults strdup 2020-02-12 17:15:01 +01:00
Dimitri John Ledkov 582a01303f travis: bump to bionic, add arm64 & s390x. 2020-02-10 18:26:47 +00:00
Luca 97fb50e837 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-02-10 15:26:21 +01:00
Luca Deri a3da5604a3 Allocation fix in kerberos dissector 2020-02-10 15:25:40 +01:00
Luca af6c86de28 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-02-10 15:04:37 +01:00
Luca Deri 34984f1aec Removed outdated AppVeyor link 2020-02-08 11:25:39 +01:00
Luca Deri 83bbb4cb69 Compliation warning fixes 2020-02-08 11:24:40 +01:00
Luca Deri ff4f32ff48 Merge pull request #839 from catenacyber/fuzzbadge
Adds oss-fuzz badge to REAMDE
2020-02-08 11:21:23 +01:00
Luca Deri 33d761a55a Merge pull request #838 from catenacyber/fix2
Adds missing checks
2020-02-08 11:20:54 +01:00
Luca Deri 2bd89be3e2 Added new TLS test files 2020-02-08 10:38:22 +01:00
Luca Deri 5cad39f0e8 Added export of TLS supported version in TLS header 2020-02-07 23:26:03 +01:00
Luca Deri 3be263aafc Added TLS ALPN support 2020-02-07 21:54:04 +01:00
Luca 452ba1f339 Improvements for DNS continuous flow dissection 2020-02-06 19:19:36 +01:00
emanuele-f ec15089208 Little enhancements 2020-02-06 18:22:00 +01:00
Philippe Antoine af661bd652 Adds oss-fuzz badge to REAMDE 2020-02-06 10:56:33 +01:00
Luca Deri 4613515635 Category matching fix 2020-02-05 08:37:24 +01:00
Luca Deri 2009361b89 Fix for IPv6 address format across the various platforms/distributions 2020-02-04 22:51:07 +01:00
Luca Deri f027ab1ae7 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-02-04 22:50:37 +01:00
Luca Deri fa26c62b0c Fix for IPv6 address format across the various platforms/distributions 2020-02-04 22:50:08 +01:00
Luca Deri 0faba29351 Result update 2020-02-04 22:38:56 +01:00
Luca Deri 2701cc9491 Warnign fix 2020-02-04 22:34:08 +01:00
Luca Deri 88fc9232ff Code improvements 2020-02-04 22:31:02 +01:00
Luca Deri 0703ab5ac5 Improved DNS response decoding
The first decoded address is now reported by ndpiReader
2020-02-04 22:16:54 +01:00
Philippe Antoine 418ea234ae Adds missing checks
Found by fuzzing
2020-02-03 22:38:31 +01:00
Luca 3e99b73635 Updte WebattackRCE.pcap.out with libpcre disabled 2020-02-02 22:15:55 +01:00
Luca 6dbe81588f Added --with-pcre to enable libpcre usage 2020-02-02 22:07:21 +01:00
Luca 2b6a639192 Libfuzz fixes 2020-02-02 21:54:36 +01:00
Luca 9e87645022 PCRE fixes 2020-02-02 19:54:31 +01:00
Luca 626fcf1418 Added missing additiona libs 2020-02-02 17:01:07 +01:00
Luca Deri 5b11c2ffc5 Merge pull request #836 from MrTiz9/dev
nDPI now detects RCE injections in HTTP requests
2020-02-02 16:19:26 +01:00
Luca Deri 8486eb08ea Merge pull request #835 from catenacyber/fuzzfix
Fuzz fixes
2020-02-02 16:17:03 +01:00
MrTiz9 ce4f4fbe2f Added missing pcap.out for RCE detections 2020-02-01 17:23:22 +01:00
MrTiz9 3422574c17 FIXED - nDPI now detect RCE injections via PCRE instead Intel Hyperscan 2020-02-01 17:18:35 +01:00
MrTiz9 b3138d5e3e Merge branch 'dev' of https://github.com/ntop/nDPI into dev-unstable 2020-02-01 13:47:42 +01:00
Philippe Antoine 0bf2ca56a8 Uses ip_size in get_ndpi_flow_info6 2020-01-31 15:37:36 +01:00
Philippe Antoine b97360d931 Fix infinite loop in ndpi_workflow_process_packet 2020-01-31 15:26:34 +01:00
Philippe Antoine 579dd7dff9 Fix memcached read overflow 2020-01-31 15:21:03 +01:00
Philippe Antoine ff89a14b49 Modifies fuzz target to fix leaks 2020-01-31 15:13:35 +01:00
Philippe Antoine b5b2260f2e Fix undefined shift in dns 2020-01-31 14:50:18 +01:00
lucaderi 39b1ad3087 PCRE fix 2020-01-31 07:09:54 +01:00
Luca Deri c68ea3067b Added libpcre lib if present 2020-01-30 22:24:24 +01:00
Alfredo Cardigliano 4e538b1e4d Disabeld community id debug 2020-01-30 15:20:52 +01:00
MrTiz9 5c8c2d843a nDPI now detect RCE injections via PCRE instead Intel Hyperscan - BUGGY, DOES NOT COMPILE 2020-01-30 15:08:26 +01:00
MrTiz9 ea957687e1 Merge branch 'dev' of https://github.com/ntop/nDPI into dev-unstable 2020-01-30 14:57:58 +01:00
Luca Deri c84ed5a712 Added check for libpcre presence 2020-01-29 00:41:35 +01:00
Alfredo Cardigliano ab2a011cf9 Community ID hash fixes 2020-01-25 16:04:00 +01:00
Luca Deri d86d632fe6 Added memory boundary check in HTTP dissector 2020-01-24 21:04:27 +01:00
Luca Deri 87d228f78e Fixed heap-buffer-overflow in citrix decoder 2020-01-24 19:50:38 +01:00
Luca Deri a7a4bf32d3 Merge pull request #833 from catenacyber/travisfuzz2
Fix sanitizers build on Travis
2020-01-24 19:38:18 +01:00
Alfredo Cardigliano e20c4acbde Implement ndpi_flowv6_flow_hash ndpi_flowv4_flow_hash. Add ndpi_base64_encode. 2020-01-24 18:36:38 +01:00
MrTiz9 daf15e70bf Added missing pcap.out for RCE detections 2020-01-24 17:16:18 +01:00
MrTiz9 daa1171593 nDPI now detect RCE in HTTP GET requests 2020-01-24 17:16:18 +01:00
Philippe Antoine dc5fecfc92 Use MSAN_SYMBOLIZER_PATH now that it works 2020-01-24 10:15:16 +01:00
Philippe Antoine 79e1ec9f50 Complete absolute path for symbolizer 2020-01-24 10:03:23 +01:00
Philippe Antoine 902a1c7b4c Trying with ASAN_SYMBOLIZER_PATH 2020-01-24 09:53:06 +01:00
Philippe Antoine 5b88867084 Looking for symbolizer 2020-01-24 09:46:53 +01:00
Philippe Antoine 4749e61bdb Debug symbols in LDFLAGS 2020-01-24 09:23:56 +01:00
Philippe Antoine 4f230943cf Debug compilation flag for fuzz targets
And adding include file to fuzz_ndpi_reader
2020-01-24 09:10:52 +01:00
Philippe Antoine 6186e1ab01 Only one env 2020-01-24 08:40:05 +01:00
Philippe Antoine 9fe8bf018a Use clang++7 for fuzz targets in Travis 2020-01-24 08:24:18 +01:00
Philippe Antoine e082134a0d Fix sanitizers build on Travis 2020-01-24 08:14:44 +01:00
Luca Deri cedbf3b636 Merge pull request #832 from catenacyber/travisfuzz
Adds fuzz targets build and run to travis
2020-01-23 18:36:40 +01:00
Luca Deri 5f6fd8d2a5 Merge pull request #831 from catenacyber/fuzzcorpus
Generates automatically corpus for fuzz target
2020-01-23 18:35:48 +01:00
Philippe Antoine cbb755666e Typo fix 2020-01-23 09:09:21 +01:00
Philippe Antoine 1d024ece7a Adds fuzz targets build and run to travis
Build comes with the different sanitizers
2020-01-22 16:36:12 +01:00
Philippe Antoine 77db14fd7a Generates automatically corpus for fuzz target 2020-01-22 16:12:50 +01:00
Luca Deri 5a40f9b7fd Minor fixes 2020-01-21 20:52:42 +01:00
Luca Deri 931f51bd77 ndpi_load_categories_file() now returns the number of loaded hosts or -1 in case of error 2020-01-20 23:37:09 +01:00
Luca Deri 283588a37b Crash fix when not using CSV output 2020-01-19 20:50:23 +01:00
Luca 812505b56b Added sanity check 2020-01-15 20:49:21 -07:00
Luca Deri 98d9f524f9 Merge pull request #830 from catenacyber/fuzzpcap
Adds another fuzz target
2020-01-14 16:37:55 -08:00
Luca Deri 0023a96f80 Merge pull request #828 from vitalivanov/pull_764
example: fix compilation of ndpireader on latest dpdk.
2020-01-14 16:37:28 -08:00
Luca Deri 9f7b1c84f2 Merge pull request #829 from vitalivanov/pull_warning_vit
example: fix build warning.
2020-01-14 16:36:51 -08:00
Alfredo Cardigliano e1047b324b Fix misleading error message 2020-01-14 10:57:05 +01:00
Philippe Antoine 10738a0ca3 New fuzz target : fuzz_ndpi_reader 2020-01-14 08:20:15 +01:00
Philippe Antoine fe312ffbe1 Compile libndpireader 2020-01-14 08:20:15 +01:00
Vitaliy Ivanov 24f2cd6fc1 example: fix build warning.
ndpiReader.c:24:0: warning: "_GNU_SOURCE" redefined
 #define _GNU_SOURCE
<command-line>:0:0: note: this is the location of the previous definition

Signed-off-by: Vitaliy Ivanov <vitaliyi@interfacemasters.com>
2020-01-13 16:15:58 +02:00
Vitaliy Ivanov cbabbd5865 example: fix compilation of ndpireader on latest dpdk.
reader_util.c:1708:43: error: 'ETHER_MAX_LEN' undeclared here (not in a function)
             .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
                                           ^~~~~~~~~~~~~

DPDK before 19.08 had a macro ETHER_MAX_LEN, in later versions it was
changed to RTE_ETHER_MAX_LEN.

Signed-off-by: Vitaliy Ivanov <vitaliyi@interfacemasters.com>
2020-01-13 16:10:09 +02:00
Luca Deri da5208ee68 Updated results with the new output 2020-01-10 23:21:11 +01:00
Luca Deri bccf1c433a Added missing flow extra info export in flows 2020-01-10 23:15:54 +01:00
Luca Deri cc7593fe5a Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-01-10 22:21:42 +01:00
Luca Deri 5571ce114d Added flow extra info field
Updated tests/results
2020-01-10 22:21:16 +01:00
Luca 4dd887e516 Added further TLS checks 2020-01-10 18:18:07 +01:00
Luca Deri a3e06da2a8 Minor cleanup 2020-01-10 12:46:53 +01:00
Luca Deri dc21079851 Fix for invalid TLS leght 2020-01-09 18:51:03 +01:00
Luca Deri 5987ec6014 Added check for preventing TLS misbehavior 2020-01-09 17:14:37 +01:00
Luca 757b0c602f Fix for avoiding misdetection in TLS 2020-01-09 10:30:14 +01:00
Luca Deri 498b346219 Added bootstrap ethereum nodes 2020-01-08 22:44:30 +01:00
Luca Deri 3e66bbc5bc Tool for listing the current bitcoin IPv4 nodes 2020-01-08 22:14:34 +01:00
Luca Deri 3ba7667887 Various ethereum improvements 2020-01-08 22:01:45 +01:00
Luca Deri fd943d6000 Code hardening 2020-01-08 17:13:24 +01:00
Luca Deri 691778df33 Cosmetic fixes 2020-01-06 22:25:20 +01:00
Luca Deri 81c3f5813c Added check to avoid double allocations with retransmitted packets 2020-01-06 21:27:51 +01:00
Luca Deri fdf402d027 Added missing RPM files 2020-01-06 18:20:52 +01:00
Luca Deri f0014a5a24 Removed TLS debug code that could have caused crashes 2020-01-05 21:28:35 +01:00
Luca Deri 53a5be3399 Added packet boundary checks 2020-01-05 20:58:16 +01:00
Luca Deri f389969c0b Use share instead of sbin for sample files
Fixes #826
2020-01-05 18:50:56 +01:00
Luca Deri dc02afa3ea Merge pull request #825 from aouinizied/fix_python_bindings
Update Python cffi bindings.
2020-01-05 18:47:43 +01:00
Luca Deri d1fb41a161 Minor cleanup 2020-01-05 18:42:36 +01:00
Luca Deri ef16591f3f Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2020-01-05 18:25:44 +01:00
Luca Deri 29dd45838d Updated (C) 2020-01-05 18:24:58 +01:00
emanuele-f 798bb6e2e1 Fix leaks and sha1 certificate detection 2020-01-02 14:39:51 +01:00
emanuele-f 2332cbfefe Fix invalid free on non-tls flows 2020-01-02 14:10:21 +01:00
emanuele-f a58a135758 Add fingerprint_set flag 2020-01-02 12:56:25 +01:00
Luca 634457615c Updated TLS support 2020-01-02 10:47:23 +01:00
Luca cb825766ea Minor changes 2020-01-02 10:37:53 +01:00
Luca 8b01056b21 Renamed TLS requested server name 2020-01-02 07:37:03 +01:00
Luca f6c7a33177 Added TLS test 2020-01-01 21:27:18 +01:00
Luca daae1cc9b1 Reworked TLS dissection 2020-01-01 12:59:19 +01:00
Luca Deri 499c80535b Minor fix 2019-12-29 22:27:48 +01:00
Luca 9fb3a57a71 Kerberos fixes
Minor TLS cleanup
2019-12-29 10:45:42 +01:00
Luca 257ec7cc5f Removed disable_metadata_export preference that is no longer useful
since ndpi_process_extra_packet() can drive limited or full metadata export
2019-12-29 08:07:35 +01:00
emanuele-f 73c7ccdb65 Fix crash in ndpi_fill_ip_protocol_category when both saddr and daddr are 0
In this corner case, the "prefix" variable was not initialized leading to a failed assertion and crash:

ndpi_patricia_search_best2: Assertion `prefix->bitlen <= patricia->maxbits' failed.
2019-12-23 15:20:09 +01:00
Zied Aouini cffb11fbc9 Update ndpi_flow_struct definition. 2019-12-23 11:22:23 +01:00
Luca Deri 23421b47d9 Added snprintf() return code check 2019-12-18 19:49:46 +01:00
Luca Deri 1cab9fe838 Fix for custom protocol detection 2019-12-18 19:35:40 +01:00
Luca Deri 27ea04c08e Merge pull request #824 from catenacyber/stunfix
Fix read buffer overflow in stun
2019-12-18 19:29:23 +01:00
Luca Deri 5c225b8a2e Merge pull request #821 from aouinizied/win32-lib-appveyor
Win32 lib appveyor
2019-12-18 19:22:12 +01:00
Luca Deri 4961241c62 Merge pull request #823 from haroflow/dev
Changed 13.64.0.0/11 range from Skype to Microsoft
2019-12-18 19:18:28 +01:00
Philippe Antoine 843204299c Fix read buffer overflow in stun 2019-12-18 13:48:33 +01:00
Simone Mainardi 09cd95d54a Fixes informative subprotocols
Wrongly marked subprotocols were causing issues on ntopng.
This fixes https://github.com/ntop/ntopng/issues/3129
2019-12-17 18:12:15 +01:00
Renan de Souza 1d3bef41a4 Added *whatsapp-*.fbcdn.net IPs as WhatsApp 2019-12-16 15:32:46 -03:00
Luca Deri e21fe5d594 Added intrusion_detection.c in DPDK makefile 2019-12-16 17:56:08 +01:00
Renan de Souza 9133955219 Changed 13.64.0.0/11 range from Skype to Microsoft, blocking this range also blocks some azure-hosted websites 2019-12-16 10:50:19 -03:00
Zied Aouini acb74905a5 Switch to dev branch. 2019-12-16 01:36:02 +01:00
Zied Aouini ed3fff554a Add Appveyor build status. 2019-12-16 01:34:42 +01:00
Zied Aouini 7ebe6a0c82 Add LDFLAGS for Win32. 2019-12-16 01:24:42 +01:00
Zied Aouini 87333aa68c Add branch. 2019-12-16 01:19:37 +01:00
Zied Aouini e593319ba0 Fix Win32. 2019-12-16 01:14:10 +01:00
Zied Aouini 812a3e7099 Add mingw host target 2019-12-16 01:11:55 +01:00
Zied Aouini 1097f5488d Add .appveyor.yml 2019-12-16 01:10:26 +01:00
Zied Aouini b90410e335 Add .gitattributes 2019-12-16 01:09:09 +01:00
Luca Deri deed27cbef Implemented nDPI timeline visualizer 2019-12-15 23:35:43 +01:00
Luca Deri ea001b439a TLS decoding improvements 2019-12-14 16:17:34 +01:00
Luca Deri 14e5adc7c2 Win fixes 2019-12-14 15:05:47 +01:00
Luca Deri 81012b3201 CSV output enhancements 2019-12-13 12:50:52 +01:00
Luca Deri 406aa12468 Fixed CSV output 2019-12-13 09:45:34 +01:00
Luca 2c2bb11c9b Fixed output format 2019-12-11 11:27:00 +01:00
Luca Deri 1bd63d68a5 CSV export improvements 2019-12-11 09:45:14 +01:00
Luca Deri bf5e9b7b0b Fixed bug that prevented SMTP email to be dissected 2019-12-09 19:04:13 +01:00
Luca Deri 7fe9dddf65 Fixed invalid password report on telnet 2019-12-09 18:43:05 +01:00
Luca Deri 6d7f3976f3 Code cleanup 2019-12-09 18:02:48 +01:00
Luca Deri 65d526d8f6 Code cleanup 2019-12-09 15:28:44 +01:00
Luca Deri 56eeb965bf Code cleanup 2019-12-09 13:10:21 +01:00
Luca Deri c4d476cc58 Code improvements 2019-12-09 00:29:02 +01:00
Luca Deri 23b0b8625d Minor changes to the IDS score calculation 2019-12-09 00:11:32 +01:00
Luca Deri 558983c99c Merge pull request #813 from SimoneRicci97/dev
Fixed intrusion detection
2019-12-09 00:01:09 +01:00
Luca Deri c8d6f2845f Improved memory management in the kerberos dissector 2019-12-08 23:59:53 +01:00
Luca Deri 1a115cac5a Merge pull request #817 from MrTiz9/dev
Integration of the libinjection library
2019-12-08 23:49:23 +01:00
Luca Deri 11401edfe7 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-12-08 23:47:25 +01:00
Luca Deri 239842b821 Major kerberos rework 2019-12-08 23:47:04 +01:00
MrTiz9 606ff10ecf Integration of the libinjection library to detect SQL injections and XSS type attacks in HTTP requests 2019-12-05 18:09:43 +01:00
emanuele-f d37b69ce9c Fix corner case causing access to already freed memory 2019-12-04 18:36:54 +01:00
emanuele-f 226a9abf22 Additional memory bounds checks 2019-12-04 18:34:08 +01:00
emanuele-f f26096ee4c Fix reversed offset check 2019-12-04 15:20:49 +01:00
emanuele-f 2b3ef7e762 Fix invalid memory access 2019-12-04 14:21:04 +01:00
emanuele-f d62526f9ed Fix invalid reads and add valgrind test 2019-12-04 13:06:05 +01:00
Luca Deri e66d7216b8 Removed header space with JSON serialization 2019-12-04 10:52:51 +01:00
Luca Deri fbc59c5f81 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-12-01 22:27:26 +01:00
Luca Deri 32dc9e3225 Refreshed Whatsapp server list 2019-12-01 22:26:57 +01:00
Luca Deri b4468239b9 Merge pull request #814 from aouinizied/python_cffi_bindings
Implement cffi bindings.
2019-12-01 21:56:10 +01:00
Luca Deri 95c1282ef4 Improved categories with streaming 2019-12-01 21:52:28 +01:00
Luca Deri a7b0457753 Improved category detection with HTTP 2019-12-01 21:40:04 +01:00
Luca Deri 7da7ae622b Improvements to stop dissection when the first protocol is detected
Used IP-based detection to compute the application protocol
Improved application detection
2019-11-28 23:20:40 +01:00
aouinizied a95cfcc989 Implement cffi bindings. 2019-11-28 03:09:13 +01:00
Simone Ricci a65c959940 Fixed intrusion detection 2019-11-26 21:20:22 +01:00
Luca Deri d328c3bccc Overflow fix 2019-11-26 17:58:49 +01:00
Luca Deri 8368568443 Added buffer overflow check in smpp dissector 2019-11-26 17:45:08 +01:00
Luca Deri c223bb1f10 Fixed buffer overflow in DNS dissection 2019-11-26 17:42:59 +01:00
Luca Deri c7efd0892f Fixed buffer overflow in amazon video dissector 2019-11-26 17:30:36 +01:00
Luca ae9429408b Added webattacj results 2019-11-25 18:40:14 +01:00
Luca Deri 0ce56d5714 Updated results 2019-11-23 19:55:06 +01:00
Luca Deri 509cfcb556 Fixed invalid category matching in HTTP
Fixed overlapping categories
2019-11-23 19:54:06 +01:00
Luca Deri 3b203d57e9 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-11-23 13:28:15 +01:00
Luca Deri 68d66b780c Added new test pcaps
Renamed protocol 104 to IEC60870 (more meaningful)
2019-11-23 13:27:34 +01:00
Luca Deri f94d6cca7d Memory fixes 2019-11-23 12:14:52 +01:00
Luca Deri 382217887b Nested encapsulation dissection 2019-11-23 11:53:00 +01:00
Luca Deri 537c11a985 Fixes for uninitialized variables 2019-11-23 11:39:23 +01:00
Luca Deri bdc0719e76 Added auth failed support with FTP 2019-11-21 23:31:52 +01:00
Luca Deri fc82cdfa4a Implemented telnet password export 2019-11-21 19:36:01 +01:00
Luca Deri e98b994a39 Updated results 2019-11-21 13:35:04 +01:00
Luca Deri a58c838c4c Added flow duration and goodput in output (-v and -c) 2019-11-21 13:31:56 +01:00
Luca Deri f91f2c57ef Fixed skype/soom false positives 2019-11-20 23:28:24 +01:00
emanuele-f 68b7986d9b Expose API to calculate the MD5 hash 2019-11-20 11:57:21 +01:00
Alfredo Cardigliano ead0325deb Rounding up serializer buffer to be divisible by 4 (required by zmq encryption) 2019-11-19 19:03:06 +01:00
emanuele-f 0b819badd2 Possible leak fix 2019-11-19 11:42:04 +01:00
Simone Mainardi 3754e6dd12 Fixes crash when searching kerberos usernames
Fixes

(gdb) f 0
101                         if(cname_str[cname_len-1] == '$') {
(gdb) p cname_len
$3 = 0
2019-11-19 11:34:34 +01:00
Luca Deri da029607a0 Removed (unreliable) line protocol detection 2019-11-18 21:21:52 +01:00
Luca Deri 803dc6ff77 Minor fix 2019-11-17 22:42:32 +01:00
Luca Deri 65a629304c Kerberos dissection improvements 2019-11-17 22:35:10 +01:00
Luca Deri 51cfdfb0d8 Removed unused JSON-C code 2019-11-17 17:51:45 +01:00
Luca Deri 53108c9ff1 Merge pull request #811 from aouinizied/python_bindings_fix
Python bindings fix and improve
2019-11-15 19:51:15 +01:00
aouinizied 82a186e096 Polish. 2019-11-15 19:30:50 +01:00
aouinizied e467fe9aa6 Improve python bindings. 2019-11-15 19:18:30 +01:00
Luca Deri 7a1940e1f7 Modified Diameter category to network
Updated test results
2019-11-14 15:13:13 +01:00
Alfredo Cardigliano 6b7c56c909 New ndpi_serialize_string_boolean/ndpi_serialize_uint32_boolean 2019-11-13 18:16:44 +01:00
Luca 470d30ac23 Fixed SQL Injection detection 2019-11-13 17:37:48 +01:00
Luca 7e87bfd039 Added support of default /32 in ndpi_load_ipv4_ptree() 2019-11-12 16:37:18 +01:00
Luca Deri ab9ccf9eb9 Fixed new nDPi API 2019-11-12 12:28:34 +01:00
Luca Deri 15ec013af8 Added ndpi_load_ipv4_ptree() API call 2019-11-11 23:52:24 +01:00
emanuele-f 748f10c0d6 Fix possible crash due to unsigned int number wrapping 2019-11-11 10:18:55 +01:00
Luca Deri 8181d63a95 Added ndpi_init_detection_module() API preferences 2019-11-10 22:57:21 +01:00
Luca d0e7e69552 Renamed DNSoverHTTPS to handle bot DoH and DoT 2019-11-08 09:23:52 +00:00
Luca 0558d641f2 Added ndpi_finalize_initalization() initialization function 2019-11-07 19:28:16 +00:00
Alfredo Cardigliano ac46a4dd58 Added L2TP tunnel type. Warning fix. 2019-11-06 09:55:22 +01:00
Luca fb56b042c0 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-11-05 12:15:27 +00:00
Luca 6298ecc271 Added tunnelling decapsulation 2019-11-05 08:21:31 +00:00
Luca Deri a26fe08aa6 Updated results 2019-11-04 22:11:33 +01:00
Luca Deri 5b2c0f68fe Telnet fix 2019-11-04 22:06:02 +01:00
Luca Deri e695dd6ead Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-11-03 17:15:48 +01:00
Luca Deri 953571e3d8 Added comment 2019-11-03 17:15:40 +01:00
Luca Deri 01455c3188 Merge pull request #808 from oleg-umnik/dev
Change type
2019-11-03 17:15:06 +01:00
Luca Deri a5210af823 Merge pull request #807 from oleg-umnik/fix_3
Align CSV header with actual row data
2019-11-03 17:14:38 +01:00
Luca Deri 9e42b525ec Merge pull request #806 from oleg-umnik/fix_1
Don't leak memory in live capture mode
2019-11-03 17:13:49 +01:00
Luca Deri 02d69b72f5 Merge pull request #803 from haroflow/dev
Updated Breed's descriptions in ndpi_get_proto_breed_name
2019-11-03 17:13:18 +01:00
Luca Deri c998e2e9ef Merge pull request #802 from AndrewKarelin/dev
Added some public DNSoverHTTPS servers
2019-11-03 17:07:17 +01:00
Luca Deri a3a85106a1 Implemented SQL Injection and XSS attack detection 2019-11-01 23:05:11 +01:00
Luca 75302a10bd Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-31 09:31:42 +01:00
Luca 2ab0433aca Updated content-type parsing 2019-10-31 09:31:26 +01:00
Luca e272db0f7f content type parsing fix 2019-10-31 09:15:57 +01:00
Luca Deri 3580765ba3 Updated result 2019-10-31 09:04:52 +01:00
Luca cb79d89f83 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-31 08:58:03 +01:00
Luca 2e178d0f05 Improved libary initialization for custom protocols 2019-10-31 08:57:33 +01:00
Luca Deri edf0b171e2 Merge pull request #810 from catenacyber/fuzztarget
Adds fuzz target
2019-10-31 08:54:44 +01:00
Philippe Antoine 148506ede8 Adds fuzz target
And configur option enable-fuzztargets
2019-10-31 08:37:42 +01:00
Luca c0a08d9ca2 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-31 00:14:40 +01:00
Luca 4802987178 Initial work towards HTTP content-type export 2019-10-31 00:14:20 +01:00
Luca Deri 1cd7cf9990 Merge pull request #809 from catenacyber/fuzz1fix
Fix buffer over read in ndpi_handle_ipv6_extension_headers
2019-10-30 17:31:28 +01:00
Philippe Antoine 4830755fac Fix buffer over read in ndpi_handle_ipv6_extension_headers 2019-10-30 17:18:21 +01:00
Renan de Souza 124545e1ed Added twitch.tv website 2019-10-29 16:26:17 -03:00
Luca af01e61c89 Fixed invalid guess with the top defined protocol 2019-10-29 19:45:15 +01:00
Renan de Souza 9400a3b9ef Added ranges 20.180.0.0/14, 20.184.0.0/13 to Skype 2019-10-29 15:28:08 -03:00
Luca 6e314ea6d7 Added zabbix dissector 2019-10-29 19:25:46 +01:00
Oleg A. Arkhangelsky dfd962a8bc Change type
Use double type instead of float when printing time for CSV file.
Float type is too small for 64 bit int time so cast corrupts value.
2019-10-29 21:23:42 +03:00
Oleg A. Arkhangelsky cfcbfe1e8f Align CSV header with actual row data 2019-10-29 21:20:56 +03:00
Luca 0e54f87b18 Added telnet dissector
Improved data report
2019-10-29 19:12:42 +01:00
Oleg A. Arkhangelsky 9f5e5b90e5 Don't leak memory in live capture mode 2019-10-29 21:11:31 +03:00
Renan de Souza d619ba0857 Merge remote-tracking branch 'upstream/dev' into dev 2019-10-29 14:59:18 -03:00
Renan de Souza fbea243e56 Added brasilbandalarga.com.br and .eaqbr.com.br as EAQ on host_match[] 2019-10-29 11:48:23 -03:00
Renan de Souza d062386656 Added ^pastebin.com to host_match[] 2019-10-29 09:54:42 -03:00
Luca Deri d2f04f5bdf Fixed prototype 2019-10-29 10:32:13 +01:00
Luca Deri 42c8d3ac27 Added ability to defien custom protocols 2019-10-29 10:29:12 +01:00
Luca Deri d53563ab46 Implemented Microsoft range 2019-10-28 00:15:51 +01:00
Luca Deri 3d5f0ee315 Implemented stacked DPI decoding 2019-10-27 23:20:56 +01:00
Luca Deri ecdb7cdc55 Various improvements in particular for CapWAP and Bloomberg 2019-10-27 23:05:24 +01:00
Luca Deri fd38b752c4 Added capwap support 2019-10-27 19:03:23 +01:00
Luca Deri 64804a2a24 Fixed some false positivies with skype and stun-based protocols 2019-10-27 12:23:57 +01:00
Luca Deri b603cb4530 nDPI TLS improvements using the server certificate 2019-10-26 10:54:32 +02:00
Luca Deri 8f2c7c0638 Code cleanup 2019-10-26 08:28:14 +02:00
Luca Deri 044ba7697a Improved guess 2019-10-25 16:02:44 +02:00
Luca Deri e6bd64b3ea Improved HTTP reporting in ndpiReader 2019-10-25 15:56:47 +02:00
Renan de Souza 56db916833 Merge remote-tracking branch 'upstream/dev' into dev 2019-10-25 08:57:49 -03:00
Luca Deri 12cf0c4763 Further SMB improvements 2019-10-25 07:22:29 +02:00
Luca Deri 0a92e0f532 Ficed invalid SMBv1 detection 2019-10-25 07:00:57 +02:00
Luca Deri e6f9177fdb SSH dissection improvements 2019-10-25 00:05:18 +02:00
Luca Deri c3f6a4a57a SMTP and SSH dissection fixes 2019-10-24 23:28:32 +02:00
Renan de Souza 653c209253 Added 52.84.0.0/14 range as Amazon 2019-10-24 14:50:54 -03:00
Luca Deri 0974075fa0 Major cleanup
Removed ndpi_pref_http_dont_dissect_response and ndpi_pref_dns_dont_dissect_response as the ndpi_extra_dissection_possible() call will now handle everything
2019-10-24 19:48:55 +02:00
Renan de Souza 53e1ee3475 Changed Breeds descriptions in ndpi_get_proto_breed_name: Dangerous to Potentially Dangerous, added Dangerous (SMBv1) 2019-10-24 14:43:10 -03:00
Andrew Karelin 46affea055 Added some public DNSoverHTTPS servers
List of servers taken from https://github.com/curl/curl/wiki/DNS-over-HTTPS
2019-10-23 18:47:51 +05:00
Luca Deri 0ffe5cf1ff Added extra processing for POP and SMTP 2019-10-22 00:57:35 +02:00
Luca Deri d023f9bf2d Silenced TLS warning 2019-10-21 15:33:20 +02:00
Alfredo Cardigliano b2832cee8e rpm-sign fix for centos8 2019-10-21 09:26:40 +02:00
Luca Deri 960aa77b6d Reworked email metaata extraction 2019-10-21 01:27:07 +02:00
Luca Deri 58daa5ed7d Added POP3 metadata extraction 2019-10-20 23:06:05 +02:00
Luca Deri 437e8bd706 Implemented IMAP data extraction 2019-10-20 22:46:08 +02:00
Luca Deri 1a5c7daaf6 Implemented FTP user/pwd extraction 2019-10-20 21:49:45 +02:00
Luca Deri c1ba4764b5 Merge pull request #799 from ntop/ndpi_memleak_fix
Fix memory leak in ndpiReader.
2019-10-20 11:47:13 +02:00
Ravi Kerur 7cb3cb7353 Fix memory leak in ndpiReader.
Changes in library for strict function prototype.

Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-10-19 08:59:48 -07:00
Alfredo Cardigliano 604abaf81c Disabled debug_package 2019-10-18 12:30:42 +02:00
Luca Deri 8b157bb13f Ports are not JSON printed when 0 (e.g. with ICMP) 2019-10-17 00:38:42 +02:00
Luca Deri a8c71dcd20 Improved ndpi_flow2json 2019-10-17 00:29:30 +02:00
Alfredo Cardigliano 363a8f6282 Checking gmtime_r return value 2019-10-16 07:54:33 +02:00
Luca Deri 5b314cf1c3 Updated ndpi_flow2json 2019-10-16 12:31:41 +02:00
Luca Deri 02783bd7c6 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-15 23:06:41 +02:00
Luca Deri d5c918d258 Initial implementation of ndpi_flow2json APi call 2019-10-15 23:06:30 +02:00
emanuele-f 6b044335cd Implement nDPI patricia tree API 2019-10-15 01:22:17 +02:00
Luca Deri cbe20d3740 Fixes for API changes 2019-10-09 22:25:40 +02:00
Luca Deri 21bc84e837 Modified API signatures for
- ndpi_ssl_version2str()
- ndpi_detection_giveup()
2019-10-09 22:09:58 +02:00
Luca Deri 203359ed7f Fixed ndpi_ssl_version2str() 2019-10-08 23:57:56 +02:00
Luca Deri 24a26a2e94 Added NetBIOS metadata export 2019-10-08 23:40:56 +02:00
Luca Deri 0a7521060a Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-08 13:32:43 +02:00
Luca Deri 6b5a9aa992 Implemented Kerberos metadata extraction 2019-10-08 13:32:21 +02:00
emanuele-f 2dfdaa4d70 Replace strtok with reentrant version 2019-10-08 11:59:20 +02:00
emanuele-f f2504494fe New API functions: ndpi_load_categories_file and ndpi_load_category 2019-10-08 11:55:47 +02:00
Luca Deri 256858d2e5 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-08 11:36:11 +02:00
Luca Deri 10873bfe35 Added ndpi_get_l4_proto_name() and ndpi_get_l4_proto_info() API calls to print L4 protocol 2019-10-08 11:35:33 +02:00
emanuele-f e939f1c1d1 Fix leaks in ndpi_load_hostname_category when ac_automata_add fails 2019-10-08 11:07:59 +02:00
emanuele-f b2c8cb655c ndpi_load_hostname_category now performs strdup on the name argument
This simplifies the API as an application is not required to keep references to the strings to free
2019-10-08 10:23:00 +02:00
emanuele-f 4bdbf02c2d Fix invalid memory accesses 2019-10-04 14:35:51 +02:00
Luca Deri f83b2a0940 Fixed ndpi_extra_dissection_possible() 2019-10-04 14:13:53 +02:00
emanuele-f 76ec74cbf1 Fix out of bounds read in ndpi_match_custom_category 2019-10-04 11:54:05 +02:00
Luca Deri 8ae5da1472 Moved to 3.1 release 2019-10-04 07:45:57 +00:00
Luca Deri d8067cdc1d Extended changelog for v3 2019-10-04 09:42:43 +02:00
Luca Deri 67dbcb7375 Fixed invalid network searchthat caused categories to be set randomly 2019-10-04 07:19:20 +00:00
Luca Deri 3180f279c8 Merge pull request #792 from ntop/ndpi_streaming
Move Hulu and Disney+ to category match.
2019-10-03 22:35:31 +02:00
Simone Mainardi 1982e6cef9 Adds nDPI 3.0 changelog 2019-10-03 20:04:26 +02:00
emanuele-f d2f0a8d493 Add missing results 2019-10-03 16:26:14 +02:00
emanuele-f 37cb113c45 Handle TCP DNS replies and add is_reply flag 2019-10-03 16:19:15 +02:00
emanuele-f 04a97fa72b Fix DNS reply dissection issues 2019-10-03 15:52:55 +02:00
Ravi Kerur 8897aa6acb Move Hulu and Disney+ to category match.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-10-02 20:03:18 -07:00
Luca Deri c247a9d191 Code cleanup 2019-10-02 23:25:05 +02:00
Luca Deri 4fd7e5734a Manual merge of pull #769 2019-10-02 23:01:29 +02:00
Luca Deri 3dbf7bbabb Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-10-02 20:58:02 +02:00
Luca Deri 8f20e482ce Improved Viber protocol dissection
Added Hulu dissection
2019-10-02 20:57:17 +02:00
Luca Deri 329a33ed59 Merge pull request #791 from ntop/ndpi_hs
Fix crash due to recent code changes when using hyperscan and mining_…
2019-10-02 20:50:19 +02:00
Ravi Kerur 77edf1f680 Fix crash due to recent code changes when using hyperscan and mining_hosts.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-10-02 09:32:39 -07:00
emanuele-f 7f510c10fe Fix double free after b19bfa1e20 2019-10-02 16:26:52 +02:00
Luca Deri a559ba20b1 Merge pull request #790 from emanuele-f/managed_strings
Fixes leaks in ndpi_add_host_url_subprotocol
2019-10-02 15:30:33 +02:00
emanuele-f b19bfa1e20 Fixes leaks in ndpi_add_host_url_subprotocol
It is now possible to deallocate strings in ac_automata_release via
an additional parameter
2019-10-02 14:02:19 +02:00
Luca Deri 6a22bee2ca Added URL in results 2019-10-01 12:26:15 +02:00
Luca Deri e45237a93f Removed http:// from HTTP url
Reported URL in ndpiReader
2019-10-01 12:25:39 +02:00
Luca Deri a62cf10233 Added SSH handling in ndpi_extra_dissection_possible() 2019-09-30 23:23:52 +02:00
Luca Deri 1361c8fbdf Updated the logic of ndpi_is_subprotocol_informative() 2019-09-30 17:28:41 +02:00
Luca Deri f2a5bbef17 Reworked categories handling
Removed GenericProtocol and replaced with categories
Removed ndpi_pref_enable_category_substring_match option: substring matching is now default
2019-09-29 21:46:41 +02:00
Luca Deri 016d568c2b Merge pull request #787 from bohmax/explanation-file
Adding explanation file
2019-09-29 18:32:46 +02:00
bohmax 02609114d3 Add files via upload 2019-09-29 11:10:46 +02:00
Luca Deri 53ea3481ea Fixed ICMP parsing bug introduced by pull #770 2019-09-29 08:10:12 +02:00
Luca Deri 59b8399923 Merge pull request #778 from choyos/dev
Added support for dissection of DNP3 and IEC104 protocols
2019-09-29 08:02:49 +02:00
Luca Deri 3b06d2191c Merge pull request #770 from ntop/ndpi_icmp
Add icmp and icmp6 to calculate splt and bd values.
2019-09-29 07:59:02 +02:00
Luca Deri e9df2b187c Merge pull request #786 from ntop/ndpi_ac_vpn
Add Cisco anyconnect VPN signature.
2019-09-29 07:58:27 +02:00
Ravi Kerur bc1b266174 Add Cisco anyconnect VPN signature.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-28 19:52:53 -07:00
Luca Deri b0c68dc29b Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-09-27 17:35:08 +02:00
Luca Deri c839dcb74c Improved category handlign in subprotocols
Further DNS dissection fixes
Fixed WeChat invalid category
2019-09-27 17:34:22 +02:00
emanuele-f 05aa27e477 Add test for custom categories match on HTTP and SSL flows 2019-09-27 14:01:12 +02:00
Luca Deri 7c788f0779 Fixed partial string matches 2019-09-27 13:42:41 +02:00
emanuele-f 5099646938 Fix missing strdup on ndpi_load_hostname_category 2019-09-27 12:09:51 +02:00
emanuele-f 277b4a060a Add categories test PCAP 2019-09-27 10:15:20 +02:00
Luca Deri 17f560a1cd Added ndpi_extra_dissection_possible() API call 2019-09-26 23:50:02 +02:00
Luca Deri 194cdcf581 Fixed false positive with STUN detection 2019-09-26 22:18:56 +02:00
Luca Deri 7de9fd7170 Updated instagram check 2019-09-26 22:08:21 +02:00
Luca Deri 0e9918464b Added Zoom protocol support removing invalid STUN/Skype detections 2019-09-26 21:52:42 +02:00
Luca Deri ce40155377 Merge pull request #783 from ntop/ndpi_ps_vue
Ndpi ps vue
2019-09-26 19:37:49 +02:00
emanuele-f 4dc60f151d Restructure DNS search code 2019-09-26 13:20:13 +02:00
emanuele-f 937dcb38ea Fix bad protocols returned in ndpi_detection_giveup when detection is already complete 2019-09-26 12:15:49 +02:00
Ravi Kerur 4170eb3a1d Modified logic and test pcap file included.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-25 16:21:22 -07:00
Ravi Kerur c3a5650071 Initial PS_VUE support based on public IP.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-25 15:20:19 -07:00
Luca Deri 62fa0908a3 Improved packet datastructure cleanup after packet processing
Cleaned up code of steam dissector
Added steam test pcap
2019-09-25 23:59:22 +02:00
Ravi Kerur d2c0b9872d Initial Zoom detection based on IP and ports.
Following IP and ports are reported by Zoom support
to open up in firewall.

https://support.zoom.us/hc/en-us/articles/201362683-Network-Firewall-or-Proxy-Server-Settings-for-Zoom

Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-25 12:59:34 -07:00
Alfredo Cardigliano 3709e673d9 New serializer APIs ndpi_serialize_start_of_block / ndpi_serialize_end_of_block (JSON only) 2019-09-25 17:19:33 +02:00
Luca Deri 0b62c0ad45 Merge pull request #781 from marco-testa/dev
Update dissector stun.c
2019-09-24 16:39:46 +02:00
Luca 0ed679e795 Improves IAT calculation 2019-09-24 16:37:42 +02:00
marco-testa b706730e10 Loaded in the wrong place 2019-09-24 09:45:34 +02:00
marco-testa bd83847027 Changed the packets handling with STUN msg_type > 0x000C and other fixes.
Eliminated double call to the ndpi_int_stun_add_connection function.
2019-09-24 09:43:47 +02:00
marco-testa d3348ff730 Changed the packets handling with STUN msg_type > 0x000C and other fixes.
Eliminated double call to the ndpi_int_stun_add_connection function.
2019-09-24 09:41:58 +02:00
Ravi Kerur e29032085d Merge branch 'dev' of https://github.com/ntop/nDPI into ndpi_icmp 2019-09-23 17:06:43 -07:00
Luca Deri 19dbcaa3a9 Fixes #777 2019-09-23 18:04:55 +02:00
Luca Deri 3f56b2476a Merge pull request #780 from bohmax/fix_wrap
Fix wrap
2019-09-23 17:48:02 +02:00
bohmax 8246467022 Add files via upload 2019-09-23 17:40:34 +02:00
bohmax 90c28e9d63 Delete ndpi_typestruct.py 2019-09-23 17:40:16 +02:00
Luca Deri 64513b1c0e Rewritten qq dissector 2019-09-23 17:39:58 +02:00
Ravi Kerur e8d501158e Restore protocol extraction to original method.
Add microseconds to time series if milliseconds returns 0.

Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-21 10:38:04 -07:00
Ravi Kerur d92015a092 Merge branch 'dev' of https://github.com/ntop/nDPI into ndpi_icmp 2019-09-21 10:16:10 -07:00
Luca Deri 5c2e495792 ndpiReader now report protocol category and breed
Modified TikTok category to Fun
2019-09-21 09:52:44 +02:00
Luca Deri 421f819b8a Added signal test pcap 2019-09-21 09:40:20 +02:00
Luca Deri ab9246f51f Adedd DTLS check in STUN
Uodated (C)
2019-09-21 09:16:56 +02:00
Ravi Kerur e2e05cd499 Merge branch 'dev' of https://github.com/ntop/nDPI into ndpi_icmp 2019-09-20 10:54:58 -07:00
Luca bdcc6dc173 STUN protocol dissector code cleanup 2019-09-20 18:47:39 +02:00
Luca f9716c5139 Unified WhatsApp Video and Audio under WhatsAppCall 2019-09-20 17:37:41 +02:00
choyos bae36d2e25 added dnp3 and iec104 pcaps for tests 2019-09-20 13:35:46 +02:00
choyos cbda4c2af1 Added support for industrial protocols DNP3, IEC 60780-5-104 2019-09-20 13:29:49 +02:00
Luca f678486393 Improved STUN-based protocol heuristic both in terms of accuracy and packets necessary for the detection 2019-09-20 07:29:02 +02:00
emanuele-f 518df786ed Add ndpi_parse_ip_string and ndpi_get_ip_string API 2019-09-19 16:08:47 +02:00
Luca Deri 16da3f58cc Fixed JA3C compuration wtih SSL (no TLS) traffic 2019-09-19 00:01:44 +02:00
Luca Deri cf0ca7db51 Improved STUN caching 2019-09-18 23:31:25 +02:00
Luca Deri 0d8a161d15 Further line update 2019-09-18 23:24:41 +02:00
Luca Deri 487110693c Line protocol update 2019-09-18 23:23:13 +02:00
Luca Deri 3287dfbff4 Added dissection of TLS version in supported_versions of Hello packets 2019-09-18 14:20:01 +02:00
Luca Deri ac1f7d71dd New instagram testing set 2019-09-18 12:23:55 +02:00
Luca Deri a716d5a317 Improved Line protocol heuristic 2019-09-18 12:14:23 +02:00
Ravi Kerur 7e3fd16b0d Merge branch 'dev' of https://github.com/ntop/nDPI into ndpi_icmp 2019-09-17 17:01:17 -07:00
emanuele-f e152e687a5 Fix notBefore/notAfter broken in previous commit 2019-09-17 18:43:11 +02:00
emanuele-f 10e560a508 Fix notBefore/notAfter issues 2019-09-17 18:09:17 +02:00
Luca Deri 2fc68a441d Improved -C output 2019-09-17 12:07:00 +02:00
Luca Deri 64ed0ac6b3 Various STUN improvements 2019-09-17 00:11:17 +02:00
Ravi Kerur ce79626679 Merge branch 'dev' of https://github.com/ntop/nDPI into ndpi_icmp 2019-09-16 13:56:17 -07:00
Luca Deri 8f4e8d8254 Code cleanup 2019-09-15 22:56:55 +02:00
Luca Deri 62c9766cc1 Warnign fix 2019-09-15 22:43:43 +02:00
Luca Deri f0013e826e Added python bindings for nDPI 2019-09-15 22:32:18 +02:00
Luca Deri 5fd79567f0 Merge pull request #767 from LocutusOfBorg/fix-cross-ftbfs
Fix cross-build from source, because of direct pkg-config check calls
2019-09-15 20:57:13 +02:00
Luca Deri 11e9fd8cef As TLS certificate fingerprint is computed, TLS without certificate protocol has been removed
Various improvemenets in detection quality
2019-09-15 12:18:24 +02:00
Luca Deri 2b0945b88d TLS disection improvements 2019-09-15 10:56:08 +02:00
Ravi Kerur 23780a655d Fix protocol for v4 and v6.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-14 18:38:18 -07:00
Ravi Kerur 9f83bf4624 Add icmp and icmp6 to calculate splt and bd values.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-09-14 10:06:37 -07:00
Luca Deri 00e639d513 TLS certificate hash is not reported 2019-09-14 15:00:52 +02:00
Luca Deri 659f75138c TLS cerficate hash calculation 2019-09-14 12:38:58 +02:00
Alfredo Cardigliano d7c2ced475 Fix ndpi_serializer_rollback_snapshot with single records 2019-09-11 20:04:32 +02:00
Helmut Grohne 2e01a1fe53 Fix cross-build from source, because of direct pkg-config check calls
ndpi fails to cross build from source, because configure.seed hard codes
the build architecture pkg-config. It is best to use PKG_CHECK_MODULES
instead. Please consider applying the attached patch.

See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=939286
2019-09-11 19:11:42 +02:00
Luca Deri e687a73cb2 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-09-11 17:14:52 +02:00
Luca Deri 6966e0d19b Added STUN check to avoid false positives
Added fingerprint comments in SSH/TLS
Added netflow test pcap
2019-09-11 17:13:49 +02:00
Alfredo Cardigliano 7d9ed162c7 Optimized memory utlization resizing serialization buffer buffer 2019-09-11 16:32:40 +02:00
Alfredo Cardigliano 848c9db4fb Added ndpi_init_serializer_ll() to specify low-level settings for optimizing memory allocations 2019-09-11 16:10:18 +02:00
Alfredo Cardigliano 16fe2574b1 Fix ndpi_serializer_rollback_snapshot with JSON 2019-09-11 11:32:11 +02:00
Luca Deri c3c975a51a Renamed snapshot API call 2019-09-11 09:45:29 +02:00
Alfredo Cardigliano a265b50a66 Support for nDPI serializer snapshot set/reset 2019-09-10 20:24:36 +02:00
Luca Deri 67a1455619 ndpi_serializer_set_buffer_len() fix 2019-09-10 23:55:00 +02:00
Luca Deri 844e2bab3b warnng fix 2019-09-10 22:46:37 +02:00
Luca Deri b1583cc29e Added ndpi_serializer_set_buffer_len() API call 2019-09-10 22:45:52 +02:00
Luca Deri 0f9107bef3 Fixed timezone conversion 2019-09-10 22:15:23 +02:00
Luca Deri 068611e8ba Changes in validity format 2019-09-10 21:44:42 +02:00
Luca Deri 1f417fe67d Validity format fix 2019-09-10 21:44:04 +02:00
Alfredo Cardigliano 8186b72c11 Added ndpi_deserialize_clone_all to the public API 2019-09-10 19:30:52 +02:00
Alfredo Cardigliano 4c0cc80771 New API ndpi_deserialize_clone_all to clone an record from TLV to a different format (e.g. JSON) 2019-09-10 18:57:28 +02:00
Alfredo Cardigliano 9c8c165a2c Added ndpi_deserialize_clone to the public API 2019-09-10 17:32:13 +02:00
Alfredo Cardigliano 84ce1861a2 New API ndpi_deserialize_clone to clone an element from a deserialized TLV to another TLV 2019-09-10 17:30:15 +02:00
Alfredo Cardigliano 990d06d10c TLC EOR/Unknown items size 2019-09-10 16:40:29 +02:00
Alfredo Cardigliano 3e1c811780 Added ndpi_deserialize_get_format() to read the serialization format 2019-09-10 15:02:02 +02:00
Alfredo Cardigliano b96b618443 nDPI serialization: uint key compression, new deserialization API 2019-09-10 14:47:47 +02:00
Luca Deri 65bdd0de9a Uddated results 2019-09-10 00:43:03 +02:00
Luca Deri 086c511a11 Parsed TLS certificate validity 2019-09-10 00:34:48 +02:00
Luca Deri c5fffce96c Added IMO dissector
Fixed TLS/UDP detection
Reduced UBNT buffer for saving space
2019-09-09 21:17:53 +02:00
Luca Deri d457b07f9f Refreshed Tor node list 2019-09-08 21:42:33 +02:00
Luca a0a8149833 Skype STUN enhancements 2019-09-06 10:41:53 +02:00
Luca 241cfb319b Enhanced Signal detection 2019-09-05 10:45:08 +02:00
Luca 9b80c6314d Enhanced STUN cache 2019-09-05 10:23:07 +02:00
Luca Deri 3d21c33409 Compilation fix when JSON-C is not present 2019-09-03 18:45:51 +02:00
Luca b3c88a7e24 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-09-03 18:39:36 +02:00
Luca 886d575157 Added -C to generate CSV analysis files
Improved IAT and byte distribution
2019-09-03 18:38:54 +02:00
Alfredo Cardigliano 2a8f9c3a81 Return value fix in ndpi_deserialize_* 2019-09-03 11:44:32 +02:00
Alfredo Cardigliano 2cbad47d7b Added vxlan header 2019-09-03 02:26:40 +02:00
Luca Deri eb154bac69 Added ndpi_alloc_data_analysis APi call 2019-09-02 22:12:46 +02:00
Alfredo Cardigliano ab178e62f5 Transparently handle int8/16 deserialization 2019-09-02 17:29:08 +02:00
Luca Deri bc4c48fa0b Added packetIDs with -P 2019-09-02 14:47:37 +02:00
Luca Deri 5d5d056849 Added payload memory free 2019-09-02 14:14:13 +02:00
Luca Deri f1ad951bf6 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-09-02 14:00:45 +02:00
Luca Deri d0436e7b29 Added new parameter to -P 2019-09-02 14:00:18 +02:00
Alfredo Cardigliano 2616dcb424 TLV signed int compression 2019-09-02 12:33:16 +02:00
Luca Deri eb6afa17c0 Added ndpi_serialize_string_binary() call 2019-09-02 10:18:54 +02:00
Alfredo Cardigliano 77409a3833 TLV: encoding uint 32/64 as 16/8 bit whenever possible 2019-08-30 11:00:04 +02:00
Alfredo Cardigliano 49a02c9b96 TLV deserialization of uint16/uint8/int16/int8 when deserializing uint32/uint64/int32/int64 2019-08-30 10:31:54 +02:00
emanuele-f 1bf23dc2a8 Fix mangled stack by invalid sscanf 2019-08-29 22:40:29 +02:00
emanuele-f fce2cd9817 Fix memory corruptions in ndpi_node handler
Crash occurred with clang version 6.0.0-1ubuntu2 on ubuntu 18
2019-08-29 20:13:19 +02:00
emanuele-f 2c4495e483 Add missing lib 2019-08-29 17:55:51 +02:00
emanuele-f 6781485c42 Warning fix 2019-08-29 16:49:44 +02:00
emanuele-f d27e7e2786 Add missing pack_on on ajp struct 2019-08-29 16:47:33 +02:00
Luca Deri 68f6310222 AJP crash fix 2019-08-29 16:17:43 +02:00
Luca c328452687 Average calculation fix 2019-08-29 16:08:18 +02:00
Luca Deri 536b520750 Added stub for ndpi_free_memory_at_termination() (TODO) 2019-08-29 15:47:34 +02:00
Luca Deri 8b8fd25626 Compilation fix on systems without JSON-C 2019-08-29 15:35:29 +02:00
emanuele-f e98eb294c7 Add missing json cleanup 2019-08-29 15:25:52 +02:00
Luca b1270fc7bb Uodated results 2019-08-29 15:23:01 +02:00
Luca 9eb1676b4b Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-08-29 15:22:46 +02:00
emanuele-f aea91781aa Fix alignment issue on IPv6 structs 2019-08-29 14:50:17 +02:00
Luca 9a6f6d9fe4 Implemented IAT (Inter Arrival Time) stats 2019-08-29 13:40:44 +02:00
Luca e4e40e3c70 Added entropy, average, stddev, variance, bytes ratio calculation 2019-08-28 14:02:39 +02:00
Luca Deri 84aeee49bd Disable debug code 2019-08-27 10:45:33 +02:00
Luca Deri 6011790d79 Entropy calculation example 2019-08-27 10:44:41 +02:00
Luca 2acffb4163 Initial work towards traffic classification 2019-08-27 12:56:15 +02:00
Luca Deri b837f3753d SSH hash fix 2019-08-26 19:13:45 +02:00
Alfredo Cardigliano d043cd2ac7 Serialization/deserialization of int32/int64/float with uint key 2019-08-26 12:55:23 +02:00
Alfredo Cardigliano dbf8c24ecb Fix ndpi_serialize_end_of_record in JSON mode 2019-08-24 03:08:07 +02:00
Alfredo Cardigliano c50709a8d0 Fix ndpi_reset_serializer 2019-08-24 02:56:17 +02:00
emanuele-f 1231b81839 Add more length checks in HASSH
This to prevent possible crashes on invalid packets
2019-08-23 11:36:35 +02:00
Luca Deri d2fe21ddff Enhanced -P in ndpiReader so that it can now specify additional parameters 2019-08-22 23:42:07 +02:00
Luca Deri 2134f83948 Warning fixes 2019-08-22 20:04:15 +02:00
Luca Deri 3d3cae1f20 SSH test file 2019-08-22 19:36:36 +02:00
Luca Deri 1e8a43d51e Merge pull request #758 from tansly/wireguard
Add support for WireGuard VPN
2019-08-22 19:31:51 +02:00
Luca Deri e7c0ac37d8 Implemented HASSH (https://github.com/salesforce/hassh) 2019-08-22 19:25:58 +02:00
Luca Deri 385e848a0f Disabled weak (port-based) teamspeak detection 2019-08-22 15:37:31 +02:00
Luca Deri 9f42a4482a Initial work workards payload analysis 2019-08-21 19:01:56 +02:00
Luca fdeecf5d41 Implemented STUN cache to enhance matching of STUN-based protocols 2019-08-12 14:16:28 +02:00
Luca 51ac583d83 Improved google duo detection 2019-08-12 11:59:57 +02:00
emanuele-f e226f99e4e Fix possible intoaV4 1 byte overflow 2019-08-09 17:02:15 +02:00
emanuele-f f73dc61ff8 Add NDPI_PROTOCOL_DANGEROUS classification 2019-08-09 10:04:56 +02:00
Luca 90547c4fd2 Added SMBv1 test file 2019-08-08 23:33:40 +02:00
Luca c6e832be18 Various TLS/STUN improvememnts 2019-08-08 18:09:12 +02:00
Luca cce8a6026f Reworked SSL/TLS field naming 2019-08-08 15:20:05 +02:00
Luca 419160f351 Implemented DTLS support
Renamed ssl to tls
2019-08-08 12:45:27 +02:00
Luca Deri 3c4a959c1e Updated results when adding client hello 2019-08-07 20:06:31 +02:00
Luca 800deb3f54 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-08-07 20:00:59 +02:00
Luca 49f5beab84 Added client SSL hello 2019-08-07 19:35:33 +02:00
emanuele-f a6fe581d48 Change SMBv1 breed to potentially dangerous
https://techcommunity.microsoft.com/t5/Storage-at-Microsoft/Stop-using-SMB1/ba-p/425858
2019-08-07 12:39:07 +02:00
Luca Deri ff1234cce3 Changes in QUIC dissector to avoid miing QUIC with STUN 2019-08-06 23:13:47 +02:00
Luca Deri 32665e6417 Removed non-ASCII chars from JSON header 2019-07-31 00:11:40 +02:00
Luca Deri b2f7a52f98 Serialization fix 2019-07-30 23:46:20 +02:00
Luca Deri 4ebc8d54f4 Compilation fix 2019-07-30 22:51:54 +02:00
Luca Deri 9c3e623bb4 Split serialization code from ndpi_utils 2019-07-30 22:48:55 +02:00
Luca Deri e1b7005c2b Minro change 2019-07-30 10:28:30 +02:00
Luca Deri 398e9718ea JSON serialization fixes 2019-07-30 08:04:39 +02:00
Luca a0be9ea639 Fixed wrong detection of RTP as WhatsApp voice 2019-07-29 16:28:56 +02:00
Luca Deri fbe87ed640 Fixed CSV initialization 2019-07-29 00:41:29 +02:00
Luca Deri 23af4d8211 Initial CSV implementation 2019-07-29 00:33:48 +02:00
Luca Deri bfc3a00e6c Fix for ndpi_serialize_string_uint32_format with JSON 2019-07-28 23:02:55 +02:00
Luca Deri 40f55e2d06 Added string/float support in (de)serialization 2019-07-27 17:48:23 +02:00
Luca Deri 3e044a759b Code cleanup 2019-07-27 17:24:32 +02:00
Luca Deri 5c38e7b126 Better messenger traffic guess 2019-07-25 17:23:32 +02:00
Alfredo Cardigliano 32c61d3ea1 RPM spec cleanup 2019-07-25 14:23:11 +02:00
Alfredo Cardigliano ea80c4dacc Removed conflict with nprobe-dev 2019-07-25 11:59:01 +02:00
Luca Deri 7f66f1053f Updated google docs detection in wechat.pcap 2019-07-25 09:13:46 +02:00
Luca Deri 734305e111 Updated Google docs category 2019-07-25 08:58:44 +02:00
Luca Deri 3369716fc3 Added SPLT (sequence of packet length and time) and BD (byte distribution) with -J 2019-07-24 23:55:07 +02:00
Yağmur Oymak cdf61de129 Add test for WireGuard 2019-07-24 19:18:20 +03:00
Yağmur Oymak 786ea3c0f9 Merge branch 'dev' into wireguard
Conflicts:
	src/include/ndpi_protocols.h
	src/lib/ndpi_main.c

Get upstream developments.
2019-07-24 19:16:44 +03:00
Yağmur Oymak 9a899c54c9 Harden WireGuard detection
Exploit the fixed size handshake messages and sender/receiver indices.
2019-07-24 18:51:29 +03:00
Luca Deri 2148568347 Added int32/int64 (with sign) serialization/deserialization 2019-07-24 15:20:31 +02:00
Luca Deri 5c6c64ed1d Warnign fix 2019-07-24 14:16:38 +02:00
Luca Deri b99ef159ed Added missing result for nest 2019-07-24 11:32:15 +02:00
lucaderi a9ce7ccb83 Packages fixes 2019-07-24 08:47:36 +02:00
Luca Deri b715467da6 Added -e option to ndpiReader for searchign human readeable strings lenght
Default human readeable strings lenght is not 5 chars (used to be 8)
2019-07-24 00:25:00 +02:00
Luca Deri 63173e7360 Updated results with new dissection 2019-07-24 00:13:07 +02:00
Luca Deri d398b0aba6 Simplified makefile
Fixed warning
2019-07-23 22:45:31 +02:00
Luca Deri 8ff68a58f2 Merge pull request #759 from themadprofessor/patch-2
Create CONTRIBUTING.md
2019-07-23 22:33:29 +02:00
Luca Deri f55391f99d Merge pull request #760 from ntop/nDPI-SPLT-BD
Ndpi splt bd
2019-07-23 22:32:59 +02:00
Ravi Kerur a262f8dd29 Add SPLT and BD classification to the lib.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-07-23 10:00:34 -07:00
Ravi Kerur c6ca6ec712 Add new datastructures.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-07-23 09:56:32 -07:00
Ravi Kerur 1ec160d4c9 nDPI ovs changes.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-07-23 09:56:24 -07:00
Ravi Kerur 6b8234d938 Xbox and PS4 static port classification.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-07-23 09:56:15 -07:00
Ravi Kerur b6db991710 Amazon video static classification.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-07-23 09:56:05 -07:00
Ravi Kerur 6ff9b8b90e Add default port based iperf classification.
Signed-off-by: Ravi Kerur <ravi.kerur@viasat.com>
2019-07-23 09:55:32 -07:00
Stuart Reilly e781ddfa43 Create CONTRIBUTING.md
Add simple contribution guidelines.
2019-07-23 10:47:25 +01:00
Yağmur Oymak a0d8ce4159 Add support for WireGuard VPN 2019-07-23 12:00:23 +03:00
Luca Deri 974abaa275 Merged Google Hangout and Duo as they are pretty similar from the network standpoint and from the features they implement 2019-07-22 23:24:40 +02:00
Luca Deri ccea4669de Improved WhatsApp detection 2019-07-22 23:06:25 +02:00
Luca Deri db36294dcb Warnign fix 2019-07-22 21:42:55 +02:00
Alfredo Cardigliano b13780c6e0 Serialization of arrays in JSON format 2019-07-22 17:24:04 +02:00
Luca Deri 6d00b59bb8 Compilarion fix
Updated SIP result
2019-07-22 16:08:44 +02:00
Luca Deri 72b05fed75 STUN, Hangout, Duo dissection improvements 2019-07-21 08:17:28 +02:00
Alfredo Cardigliano e2d2ca5fe0 Added braces in JSON object serialization 2019-07-19 19:55:21 +02:00
Alfredo Cardigliano d43cfe1ead JSON serialization fixes in buffer offset and room computarion, string escape 2019-07-19 17:33:17 +00:00
Luca Deri 11004de056 Restored serializerUnitTest() after fixes 2019-07-19 16:54:48 +02:00
Alfredo Cardigliano f3faaec9d8 serializer char* parameters are now const 2019-07-19 14:36:41 +00:00
Alfredo Cardigliano 8350b7269f Fix Makefile.dpdk 2019-07-19 10:00:12 +00:00
Luca Deri 6bce0c4a9c Added support for Google Duo 2019-07-19 00:48:07 +02:00
Luca Deri 4bda18a079 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-07-18 15:14:06 +02:00
Luca Deri 46499a53aa Improved Facebook messnger mobile detection 2019-07-18 15:13:48 +02:00
Luca Deri 57ef7c1276 Added QUIC 046 support 2019-07-18 15:00:24 +02:00
Luca Deri b8867642fc Refresh after data leak detection 2019-07-18 11:49:53 +02:00
Luca Deri e902478bd3 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-07-18 11:38:43 +02:00
Luca Deri b50635cb89 Renamed ndpi_util.c -> reader_util.c
Added crash fix with IPv6
2019-07-18 11:38:16 +02:00
Luca Deri cbb31fa204 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-07-18 11:26:17 +02:00
Luca Deri 20bac32e1f Improvements for dta dissection 2019-07-18 11:24:44 +02:00
Luca Deri f394102b80 Merge pull request #752 from marcopiangatello/dev
ndpi_has_human_readeable_string Test
2019-07-18 07:32:38 +02:00
Alfredo Cardigliano dc375aed81 Corruptioon fix 2019-07-18 00:01:52 +02:00
Alfredo Cardigliano c85f7de2c1 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-07-17 22:06:15 +02:00
Alfredo Cardigliano ac3a618458 Improved deserialization safety checks 2019-07-17 22:06:00 +02:00
Alfredo Cardigliano 6081e46ad9 Fix memory corruption (reworked space computation and safety checks) 2019-07-17 21:20:51 +02:00
Alfredo Cardigliano c990d6bbd9 Deserialization boundary check fix, new end_of_record type 2019-07-17 17:58:14 +02:00
marcopiangatello 4ad12dcd19 Update ndpiReader.c 2019-07-17 17:09:33 +02:00
marcopiangatello dea4f784e2 Update ndpiReader.c 2019-07-17 16:55:49 +02:00
marcopiangatello 20c3d90163 Update ndpiReader.c 2019-07-17 16:53:24 +02:00
marcopiangatello 7053721aae Add files via upload 2019-07-17 16:50:38 +02:00
marcopiangatello adcb05d213 Delete ndpiReader.c 2019-07-17 16:50:25 +02:00
marcopiangatello 11639dcc8b Update ndpiReader.c 2019-07-17 16:34:13 +02:00
marcopiangatello 44dd09b438 Add files via upload 2019-07-17 16:08:22 +02:00
marcopiangatello 7280fc7d31 Delete ndpi_util.h 2019-07-17 16:08:00 +02:00
marcopiangatello e93ccab279 Delete ndpi_util.c 2019-07-17 16:07:53 +02:00
marcopiangatello 5294945554 Delete ndpiReader.c 2019-07-17 16:07:45 +02:00
Luca Deri 9ca87a620a Added extar check
Warning fix
2019-07-17 15:31:48 +02:00
Luca Deri b54863edc6 Merge pull request #747 from themadprofessor/travis-gcc
Add more compilers to travis
2019-07-17 15:26:47 +02:00
Stuart Reilly 065d0c7e9f Add ubuntu toolchain to clang builds 2019-07-17 12:14:45 +01:00
Stuart Reilly e2fcb942e8 Add clang-7 2019-07-17 11:44:44 +01:00
Stuart Reilly cfdf832d3a Remove brew update 2019-07-17 11:44:44 +01:00
Stuart Reilly 098c4228fb Make travis more explicit 2019-07-17 11:44:44 +01:00
Stuart Reilly 79a0cfbcdb Remove gcc7, add clang 8 2019-07-17 11:44:44 +01:00
Stuart Reilly e923ca4f17 Add gcc-8 and gcc-9 2019-07-17 11:44:44 +01:00
Stuart Reilly 95ba3fa142 Add gcc-7 to travis.yml 2019-07-17 11:44:38 +01:00
Alfredo Cardigliano 2fcc4f3e73 Added ndpi_serialization_uint32_uint64 and ndpi_serialization_string_uint64 2019-07-17 10:10:41 +00:00
Alfredo Cardigliano 1657686eb4 Moved json2tlv to ntopng 2019-07-17 08:55:46 +00:00
Alfredo Cardigliano c0835968af ZMQ export in json2tlv 2019-07-16 16:04:04 +00:00
Alfredo Cardigliano 4b2fbdb277 json2tlv tool to convert from JSON to TLV and run performance tests 2019-07-16 13:31:26 +00:00
Alfredo Cardigliano 2ce4adf09d Added ndpi_serialization_string_uint32 2019-07-16 12:31:41 +02:00
Luca Deri 1777841ec1 Line dissection improvements 2019-07-16 00:02:34 +02:00
Luca Deri f570eccf81 Fixes #741 2019-07-15 23:53:28 +02:00
Luca 67dfddd065 Line fix 2019-07-15 16:25:53 +02:00
Luca 9a4d01cb26 Lenght fix 2019-07-15 16:17:23 +02:00
Luca Deri 5c758d4564 Reworked output
-v 1 now prints only unknown flows
-v 2 now prints all flows
2019-07-15 14:45:25 +02:00
emanuele-f fc531334ae Remove Werror 2019-07-15 09:31:15 +02:00
Luca Deri 5a018e0bc0 Added Line protocol dissection
Add fix for discarding STUN over TCP flows
2019-07-15 00:19:45 +02:00
Luca Deri f8fb1f838c Fixes #740 2019-07-14 12:25:08 +02:00
Luca Deri 7b16c68e92 JA3 format cleanup 2019-07-13 19:32:51 +02:00
Luca Deri af2dc0860c Merge pull request #734 from glpaparelli/dev
fixed the printing layout, even with IPv6
2019-07-13 18:44:03 +02:00
Luca Deri acd3db13f8 Fixes #735 2019-07-13 18:39:18 +02:00
Luca Deri c8a867bf29 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-07-13 18:38:20 +02:00
Luca Deri 17c49b2e6d Updated test resultss after export changes 2019-07-13 18:37:57 +02:00
Luca Deri 9bdc021f98 Merge pull request #736 from themadprofessor/patch-1
Fix invalid function prototype
2019-07-13 18:36:09 +02:00
Luca Deri c65025f7b0 Merge pull request #737 from themadprofessor/dev
Add compiler warnings and fix them
2019-07-13 18:34:40 +02:00
Luca Deri ea32d535eb initial work towards simple serilizer/deserialier 2019-07-13 18:32:22 +02:00
Stuart Reilly 92c769f206 Solve remaining warnings 2019-07-12 16:41:39 +01:00
Stuart Reilly 343ee0c9b6 Merge branch 'dev' of github.com:themadprofessor/nDPI into github 2019-07-12 16:28:38 +01:00
Stuart Reilly 8b1c68aed3 Add compiler warnings and fix them 2019-07-12 16:01:22 +01:00
Stuart Reilly 929cbbb7fc Add compiler warnings and fix them 2019-07-12 15:59:11 +01:00
Stuart Reilly 22e323528e Fix invalid function prototype
Solves a warning when compiling with strict-prototypes.
2019-07-12 15:02:20 +01:00
Giulio Paparelli 52533c3b66 all fixed 2019-07-12 12:06:10 +02:00
Luca Deri 563215a05e Compilation fix 2019-07-12 07:24:07 +02:00
Luca Deri 4ac60d88d7 Improved whatsapp dissection 2019-07-11 22:49:24 +02:00
Luca Deri 3e2e616507 Dissection improvents
Fixed QUIC dissection
Disabled debug message
2019-07-11 22:35:50 +02:00
Luca Deri da7e595fcf Fixed uninitialized variable that caused weird errors 2019-07-10 19:27:27 +02:00
Luca Deri 829a284d48 Fix that caused nDPI to provide false positive results with pattern matching 2019-07-10 16:08:12 +02:00
Luca Deri c0d9dc9969 Typo 2019-07-03 18:03:44 +02:00
Luca Deri cc15389729 Improved protocol guess 2019-07-02 23:25:55 +02:00
Luca edd4f2e37d Remvoed debug info 2019-07-02 15:28:40 +02:00
Luca Deri 8205f2c6f1 Various TLS improvements 2019-07-02 00:05:17 +02:00
Luca Deri dd9db5d0b7 SSL ciphers improvements 2019-07-01 23:25:48 +02:00
Luca Deri 9590b18fdd Fixed invalid changes in ndpi_get_proto_category() and ndpi_get_proto_name() dur to https://github.com/ntop/nDPI/pull/731/commits/4b717276614e20feada22e6fe29ea2099ba9fd37 2019-07-01 23:16:43 +02:00
Luca Deri 7cb7a12f96 Merge pull request #731 from themadprofessor/dev
Stability Fixes
2019-07-01 20:02:49 +02:00
Stuart Reilly 5ce5bae99d Merge remote-tracking branch 'upstream' into dev 2019-07-01 17:49:14 +01:00
Luca Deri 8fdef484f6 Minor change 2019-07-01 12:51:55 +02:00
Luca Deri 65e842effa Merge pull request #730 from hoermto/hoermto-patch-alpine
Alpine linux: "ln -F" not supported in alpine
2019-06-30 15:34:00 +02:00
Luca Deri 2c43b61798 Added DNSoverHTTPS detection 2019-06-30 12:36:58 +02:00
Luca Deri a1ac31062d Added ndpi_has_human_readeable_string for detecting human-readeable strings in buffers 2019-06-30 11:59:51 +02:00
Luca Deri 06b05e21c6 Improvemnts in SSL certificate detection 2019-06-30 08:19:51 +02:00
Luca Deri 3f460ad5a9 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-06-29 17:34:45 +02:00
Luca Deri e9e647f043 ntohl Portability fixes 2019-06-29 17:34:08 +02:00
Luca Deri e8c84f3c5d Initial implementation of datasaver protocol support 2019-06-29 13:04:06 +02:00
Stuart Reilly f3161309ff Fix missing braces 2019-06-28 16:21:49 +01:00
Stuart Reilly ef1b8e36a0 Fix potential NULL dref in btlib.c 2019-06-28 16:12:42 +01:00
Stuart Reilly 79634a6789 Fix two resource leaks 2019-06-28 16:11:33 +01:00
Stuart Reilly d8ec0a9229 Move NULL checks to start of functions 2019-06-28 16:08:36 +01:00
Stuart Reilly bc1b4885de Fix potential NULL deref in libcache 2019-06-28 16:00:32 +01:00
Stuart Reilly 4b71727661 Fix two potential OOB reads in ndpi_main.c 2019-06-28 15:55:00 +01:00
Stuart Reilly cc39ef0946 Remove duplicate defintions and fix function prototypes 2019-06-28 15:53:11 +01:00
hoermto e47c0c3e49 Makefile: ln -F not supported in alpine
removed -F option from makefile for alpine support. Actually not sure the relevance of -F flag for other OS
2019-06-28 15:54:59 +02:00
Luca Deri 81d3fc8a24 Dissection improvements 2019-06-27 16:38:36 +02:00
Luca Deri cc51253007 Removed debug message 2019-06-25 16:30:51 +02:00
Luca Deri a4d797f832 WhatsApp improvements for video/audio detection 2019-06-25 15:18:49 +02:00
Luca Deri 6ed8ccfa46 Merge pull request #723 from lance-wyvern/dev
OICQ protocol version:0x371b
2019-06-22 15:42:15 +02:00
Luca Deri c4f513f6e7 Merge pull request #717 from weiyanhua100/dev
add null process for malloc.
2019-06-22 15:40:25 +02:00
Luca Deri 4ea8eaf103 Merge pull request #724 from themadprofessor/fix_dhcp_tests
Fix tests broken by new DHCP fingerprinting
2019-06-22 15:40:08 +02:00
Luca Deri 00ed2653fe Further WhatsApp improvements 2019-06-21 19:06:41 +02:00
Luca Deri 179b93d625 Better UDP flow handling 2019-06-21 12:14:57 +02:00
Luca Deri 3e43e77b1c Cleanup 2019-06-21 12:14:51 +02:00
Luca Deri b66606bc16 Improved OpenVPN support for UDP-based VPNs 2019-06-21 12:01:07 +02:00
Luca Deri b6ac750e21 Added WhatsApp Video 2019-06-20 23:16:36 +02:00
Luca Deri 936a95e10e WhatsApp improvements 2019-06-20 23:11:16 +02:00
Luca Deri 13e8354f37 JSON-C fix 2019-06-20 22:16:53 +02:00
Luca Deri 0fe7f16ecf Fixed invalid false positive 2019-06-20 21:11:21 +02:00
Stuart Reilly 784f4e4bba Add dhcp fingerprints to expected results 2019-06-19 13:20:55 +01:00
zhenxian.wang 1e616b227b new QQ version:0x3823 2019-06-19 15:58:30 +08:00
Luca 4830aa9a14 DHCP fingerprint is now in human readeable format 2019-06-18 17:44:05 +02:00
Luca 5f26149938 Added DHCP fingerpring handling 2019-06-18 17:36:39 +02:00
zhenxian.wang 1891f687b6 new QQ version 2019-06-18 18:04:46 +08:00
Luca Deri 41b75485eb SSL cipher improvements 2019-06-16 21:42:12 +02:00
Luca Deri 1a3f2b3f0d Reworked SSL cipher handling 2019-06-16 16:05:13 +02:00
Luca Deri 5b7a08bac3 Added SSL cipher print 2019-06-16 10:08:21 +02:00
weiyanhua e814cd0b9e add null process for malloc. 2019-06-13 15:05:22 +08:00
Luca Deri 709a87c8d4 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-06-05 23:15:42 +02:00
Luca Deri 4e8055742e Added fix for discarding core protocols as subprotocols 2019-06-05 23:15:06 +02:00
lucaderi 3979c28cac Added missing antimalware category 2019-06-03 19:50:18 +02:00
Luca Deri e6813846b8 Adds CUSTOM_CATEGORY_ANTIMALWARE category referenced by #710. 2019-06-03 08:18:24 +02:00
Luca Deri 165decdf6c Merge pull request #691 from pallas/fix-double-strdup
Fix double-strdup memory leak in ndpi_handle_rule
2019-06-03 08:10:01 +02:00
Luca Deri 4441bc7033 Merge pull request #711 from dfranusic/dev
Added PUBLISH/SUBSCRIBE/MESSAGE methods to SIP
2019-06-03 08:05:26 +02:00
Damir Franusic a015cb7f48 Merge remote-tracking branch 'upstream/dev' into dev 2019-05-31 15:21:04 +02:00
Damir Franusic 5c7e0a0319 SIP Message extension
* RFC 3248
2019-05-31 15:19:07 +02:00
Luca Deri c43bec826d Updated results with the new SSL dissection
Added RDP dissector
2019-05-30 11:15:50 +02:00
Luca a3b564eb92 Warning fix 2019-05-29 18:54:17 +02:00
Damir Franusic 1b9955e9ef Added PUBLISH/SUBSCRIBE methods to SIP 2019-05-29 17:12:32 +02:00
Luca Deri 5da363cbde Fixed MySQL dissector
SSL dissector now reports the protocol version
Fixed bug in ndpiReader that ivalidates in some cases the protocl dissection and used to slow down the dissection
2019-05-28 23:35:49 +02:00
Luca Deri 53119e71f4 Added ndpi_is_safe_ssl_cipher(0 call 2019-05-23 00:16:05 +02:00
Luca Deri fcc9c76249 Disabled debug 2019-05-22 21:19:22 +02:00
Luca Deri f29f9bbb38 Update SSL server ciphers 2019-05-22 12:37:27 +02:00
Luca Deri 04b543caa9 SSL certificate analysis improvement 2019-05-20 22:30:53 +02:00
Luca Deri 3f9383c343 Added missing definitions 2019-05-20 22:13:21 +02:00
Luca Deri 0d2f8f4498 Implements #705 2019-05-20 22:02:21 +02:00
Luca Deri 53e64df8e2 Removed debug code 2019-05-20 15:40:09 +02:00
Luca Deri f97be61e8b Fixed JA3 decoding
Made ndpi_process_extra_packet() optional
2019-05-20 15:32:50 +02:00
Luca Deri 9604386698 Merge pull request #704 from TelecomsSansFrontieres/dev
Adding 2 missing Whatsapp IPs
2019-05-18 11:18:07 +02:00
Luca Deri 7b2d9adbdf Merge pull request #707 from zyingp/xcode_fix
Fix the Xcode project
2019-05-18 11:17:47 +02:00
Luca d592902553 JA3 hardeding code 2019-05-15 17:55:01 +02:00
Yingpei Zeng 08ca25c9c8 Fix the Xcode project 2019-05-15 09:56:10 +08:00
Luca Deri e5a95cf92e Skept GREASE in SSL JA3 fingerprint 2019-05-13 23:22:19 +02:00
Clément BRUGUERA 1a2b8a98a6 Adding 2 missing Whatsapp IPs 2019-05-13 17:26:19 +02:00
Luca Deri 0d0d6893fc JA3 fixes 2019-05-12 15:25:14 +02:00
Luca Deri 3b185a00fa Disabled debug traces 2019-05-11 00:53:02 +02:00
Luca Deri a00ad9fc92 Initial JA3 support (https://github.com/salesforce/ja3) for SSL 2019-05-11 00:50:56 +02:00
Luca Deri b96e6a9e2d Merge pull request #696 from pallas/avoid-hyperscan-leak
Avoid leaking hyperscan struct
2019-05-08 12:13:23 +02:00
emanuele-f ea1ea99ce1 Add allowed site category 2019-05-06 12:01:53 +02:00
Luca Deri e99a0abfba Hardening fixes for packer parsing 2019-05-03 18:08:12 +02:00
cardigliano 361ab030bc ndpi_handle_rule accepted formats 2019-04-29 09:44:39 +02:00
Derrick Lyndon Pallas 33d17dbf1f Avoid leaking hyperscan struct 2019-04-22 17:02:11 +00:00
Alfredo Cardigliano 8a09ca2180 Fixed RPM pkgconfig path 2019-04-19 11:44:10 +02:00
Alfredo Cardigliano 1bbb992ca6 Fixed pkgconfig path (installing libndpi.pc in the default location) 2019-04-19 11:38:34 +02:00
emanuele-f 4dd51a165c Fix DNS rsp_addr missing in some tiny responses 2019-04-15 19:54:17 +02:00
Luca Deri 8365afee8d Merge pull request #688 from Dark-Vex/whatsapp
Added new Whatsapp addresses ntop/nDPI issue #683
2019-04-12 19:39:20 +02:00
emanuele-f 0961caec1b Add missing fclose in ndpiReader 2019-04-12 19:39:01 +02:00
Luca Deri 1bf9351a67 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-04-12 19:33:17 +02:00
Luca Deri 3cb0b3fc7b Fixes #692 2019-04-12 19:32:44 +02:00
Luca Deri ffb1b9c14f Merge pull request #690 from pallas/make-path-const
Make path const in ndpi_load_protocols_file
2019-04-12 19:25:27 +02:00
Luca Deri 82817c1cac Merge pull request #687 from Dark-Vex/viber
Added Viber IPs issue #684
2019-04-12 19:25:00 +02:00
Luca Deri 173a04007f Merge pull request #682 from chiehmin/dev
Parse HTTP PATCH method
2019-04-12 19:24:14 +02:00
Luca Deri 83d5627c4d Merge pull request #694 from pallas/avoid-csgo-short-read
csgo: fix invalid read on short packet
2019-04-12 19:20:14 +02:00
Luca Deri 6f8a01ca18 Merge pull request #695 from pallas/avoid-memcached-short-read
memcached: fix invalid read on short packet
2019-04-12 19:19:46 +02:00
emanuele-f 5b6526cc5a Add missing newlines 2019-04-12 17:25:38 +02:00
emanuele-f 5e24b32467 Fix category detection 2019-04-12 17:08:32 +02:00
Luca Deri 2f14b8abbf Added test file for FTP 2019-04-12 12:19:11 +02:00
Derrick Lyndon Pallas 74715b12b0 memcached: fix invalid read on short packet 2019-04-06 01:00:44 +00:00
Derrick Lyndon Pallas 7415af5086 csgo: fix invalid read on short packet 2019-04-06 00:31:41 +00:00
Derrick Lyndon Pallas 85776a532d Fix double-strdup memory leak in ndpi_handle_rule
proto is being strdup'd both in the call to ndpi_set_proto_defaults and
inside of that function as well, leaking the memory.
2019-04-05 19:00:39 +00:00
Derrick Lyndon Pallas bb2f35fe79 Make path const in ndpi_load_protocols_file 2019-04-05 18:48:42 +00:00
Luca 1290706fad Tests result fix
Merge branch 'dev' of https://github.com/ntop/nDPI into dev
2019-04-05 12:51:59 +02:00
Luca 4e7fa82aff Fixed false positive with FTP_DATA protocol
Added coherency in application protol guess by exploiting the host server name
Various protocol optimizations
2019-04-05 12:47:58 +02:00
emanuele-f 796472cf84 Fix category detection due to missing initialization 2019-04-05 10:11:17 +02:00
Luca Deri a455e0d8d4 Improved flow category guess 2019-04-02 23:01:03 +02:00
Dark-Vex 55c4108d8b [FIX] Added new whatsapp addresses ntop/nDPI issue #683 2019-04-02 16:47:49 +02:00
Daniele De Lorenzi 2ef19c7e49 [FIX] Added IPs reported in ntop/nDPI issue #684 2019-04-02 16:04:01 +02:00
Daniele De Lorenzi e27022b698 Merge pull request #11 from ntop/dev
Add all dev branch modifications
2019-04-02 15:49:54 +02:00
Luca Deri 153c77c2cd Improvements with category detection 2019-04-01 18:40:14 +02:00
Luca Deri 6693151052 Added custom category support to ndpi_get_partial_detection() 2019-04-01 16:12:44 +02:00
Luca Deri 1915a63cf2 Implemented ndpi_process_partial_detection() API call to handle partial matches due to the nDPI specified configuration 2019-04-01 12:30:51 +02:00
emanuele-f c496c7975f Add DNS response address 2019-03-29 19:58:10 +01:00
Luca Deri 8dbe7818eb Improvments for AmazonVideo 2019-03-27 07:00:11 +01:00
chiehminw 1df5b453cb Parse HTTP PATCH method
HTTP PATCH is introduced in RFC 5789 (https://tools.ietf.org/html/rfc5789)

Signed-off-by: chiehminw <chiehminw@synology.com>
2019-03-26 11:46:57 +08:00
Luca Deri 0b5e5a5f82 SSL cleanup 2019-03-25 22:08:39 +01:00
Luca Deri f47be6ef60 Added SSL organization support 2019-03-23 10:32:18 +01:00
Luca Deri f592b9fc31 Merge pull request #681 from chiehmin/certificate-parsing
Parse server certificate organization
2019-03-23 09:58:54 +01:00
Luca Deri 6b1f158322 Merge pull request #675 from chiehmin/dev
Respect CXX variable during configure
2019-03-23 09:54:17 +01:00
Luca Deri 99748cddcc Merge pull request #679 from chiehmin/link-use-relative-path
Use relative path for library link
2019-03-23 09:53:35 +01:00
Luca Deri e2cd89e354 Merge pull request #678 from madpilot78/FreeBSD_endian.h
The le32toh() function used in some places on BSD OSes requires sys/en…
2019-03-23 09:53:05 +01:00
Luca Deri e5f6f68cd6 Merge pull request #677 from chiehmin/add-http-method-prefix
Add NDPI prefix for HTTP_METHOD enum to avoid name collisions
2019-03-23 09:52:34 +01:00
Luca Deri e2ad6bf79f Merge pull request #673 from vel21ripn/dns_fix_name
More accurate hostname verification in a DNS query.
2019-03-23 09:51:53 +01:00
Luca Deri ef9f395cb6 Merge pull request #665 from vel21ripn/whatsapp
Fix whatsapp signature detecting.
2019-03-23 09:49:35 +01:00
Luca Deri e6f8a66197 Merge pull request #662 from bmwiedemann/date
Use ChangeLog date instead of build date
2019-03-23 09:49:06 +01:00
Luca 5656a41f69 Improved snapchat detection 2019-03-22 12:36:42 +01:00
chiehminw 96ed31874d we only need one dot to confirm it is a valid domain name
github.com is valid but can not be retreive by server certificate
parsing

Signed-off-by: chiehminw <chiehminw@synology.com>
2019-03-20 17:47:51 +08:00
chiehminw db91837647 retreive ssl certificate origanization
Signed-off-by: chiehminw <chiehminw@synology.com>
2019-03-20 17:47:48 +08:00
emanuele-f 6c9fbc2ddb Fix invalid categories labels array length and add check 2019-03-18 13:29:59 +01:00
Luca Deri 7237f7081f Improved FTP dissection 2019-03-14 22:07:21 +01:00
Luca Deri 54f90c7556 Added fix to avoid FTP false positives 2019-03-14 21:50:09 +01:00
chiehminw 43890b31fc Use relative path for library link
relative link path can preserve link relation after packaging and
doplying to new machine

ex:
$ make DESTDIR=/tmp/ndpi install
$ tar czf ndpi.tar.gz /tmp/ndpi
$ tar xf ndpi.tar.gz -C /lib

Orignal install script will caused the /lib/libndpi.so.2 links to
/tmp/ndpi/libndpi.so.2.9.0 which is not intended

Signed-off-by: chiehminw <chiehminw@synology.com>
2019-03-13 15:04:10 +08:00
Guido Falsi b1282da542 The le32toh() function used in some places on BSD OSes require sys/endian.h to be included. 2019-03-12 18:12:18 +01:00
Luca 22e431ca67 Sporify fix 2019-03-12 18:01:14 +01:00
chiehminw b1bd7d6f8c Add NDPI prefix for HTTP_METHOD enum to avoid name collisions
ref: https://stackoverflow.com/questions/35380279/avoid-name-collisions-with-enum-in-c-c99

Signed-off-by: chiehminw <chiehminw@synology.com>
2019-03-12 16:11:33 +08:00
Luca Deri 6c1d236a03 Category cleanup 2019-03-10 21:44:11 +01:00
Luca Deri 89d548f9d3 Removed categories based on file content 2019-03-10 21:18:19 +01:00
Luca fde4380422 Proto cleanup 2019-03-08 20:17:11 +01:00
Luca Deri aaa686b9fe Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-03-08 15:59:26 +00:00
Luca Deri 03b0aa7185 Added new categories
- NDPI_PROTOCOL_CATEGORY_MUSIC
- NDPI_PROTOCOL_CATEGORY_VIDEO
- NDPI_PROTOCOL_CATEGORY_SHOPPING
- NDPI_PROTOCOL_CATEGORY_PRODUCTIVITY
- NDPI_PROTOCOL_CATEGORY_FILE_SHARING

Protocol vs category rework
2019-03-08 15:58:21 +00:00
chiehminw 518dbbc96b Respect CXX variable during configure
commit 6ac83ce7eb use CXX to link ndpiReader however CXX is not
properly set in configure step

Fixes: 6ac83ce7eb ("Fixes broken hyperscan compilation")
Signed-off-by: chiehminw <chiehminw@synology.com>
2019-03-06 15:27:50 +08:00
Simone Mainardi 59f683858b Fixes possibly broken dissection of invalid DNS responses 2019-03-04 18:48:38 +01:00
Luca Deri c339211ac7 Re-Added TikTok/Musical.ly protocol 2019-03-03 21:07:54 +01:00
Simone Mainardi 93582a4204 Bump to version 2.9 2019-03-01 18:06:28 +01:00
Simone Mainardi 5bb53cf995 Changelog update 2019-03-01 18:02:24 +01:00
Luca 05ef62781f Fixes for wireshark 3 2019-03-01 15:19:05 +01:00
Luca d283538146 Fixed false positive mining detection 2019-03-01 12:56:33 +01:00
Vitaly Lavrov a99754d88b More accurate hostname verification in a DNS query. 2019-02-27 15:26:11 +03:00
Luca Deri de16b01bb2 Improved MDNS dissection 2019-02-24 11:03:06 +01:00
Luca Deri 47669abd44 Added extra check to avoid nDPI wrong matches 2019-02-21 23:29:06 +01:00
emanuele-f ab3833a708 Fix invalid TCP DNS dissection 2019-02-19 17:17:02 +01:00
Luca Deri dc8d582b18 Fixes #671 2019-02-14 10:31:42 +01:00
emanuele-f a035763afd Change ndpi_fill_ip_protocol_category to pass IPs explicitly 2019-02-12 17:28:30 +01:00
Luca Deri 0c4fada265 Fix for avoid wrong substring match to happen 2019-02-10 23:52:24 +01:00
Luca Deri ddf0066c11 Aligned DNS to HTTP dissection 2019-02-07 22:44:48 +01:00
Vitaly Lavrov 476fbbfe4e Fix whatsapp signature detecting. 2019-01-31 11:27:40 +03:00
cardigliano 2ec41c1732 Releasing old buffer if realloc fails 2019-01-31 09:12:04 +01:00
Alfredo Cardigliano 6a98aec2ca Support for protocol file files of arbitrary length 2019-01-30 08:44:32 +00:00
Bernhard M. Wiedemann e91123e17a Use ChangeLog date instead of build date
in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good.

This date call works with GNU date and BSD date.
Also use UTC/gmtime to be independent of timezone.
2019-01-24 14:27:10 +01:00
Luca Deri e2ffcd7229 Improved HTTP response code handling 2019-01-23 00:53:56 +01:00
Luca Deri efa96da3e0 Fixes #657 2019-01-20 23:47:24 +01:00
Luca Deri b9ae650146 Merge pull request #659 from cavedon/direction-endianness
Compute packet_direction consistently independently from endianness
2019-01-20 23:18:46 +01:00
Luca Deri 72edc508eb Merge pull request #661 from pcein/propagate-prefix
Propagate prefix settings to Makefiles
2019-01-20 23:17:46 +01:00
Pramode 81649d9979 Propagate prefix settings to Makefiles
A "make install" was failing because the --prefix flag
setting was not being propagated to the Makefiles.
2019-01-20 19:09:07 +05:30
Luca Deri 7efe1f06ee Removed debug code 2019-01-17 22:03:39 +01:00
Luca Deri 85155d5899 Removed debug code 2019-01-17 00:42:45 +01:00
Luca Deri d088a968a9 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2019-01-17 00:41:05 +01:00
Luca Deri efef99cbad Removed this party LRU and replaced with home grown 2019-01-17 00:40:28 +01:00
Luca Deri f3b0878a37 Warnign fixes
Updated test results
2019-01-17 00:39:45 +01:00
Luca Deri c856e0a563 Disabled ookla statistics: needs to be improved 2019-01-16 22:30:55 +01:00
Ludovico Cavedon 2c672a4ea2 Compute packet_direction consistently independently from endianness
Ensure packet_direction is computed in the same way on little endian and
big endian architectures.
This change will convert IP addresses and port from little endian to host
endian (instead of converting from network endian to host endian) so
that it does not change the behavior on little endian architecture where
ndpi is usually developed.
A better (but more invasive) change would be to use the ntoh*()
functions and then adjust all affected tests.
2019-01-16 01:15:43 -08:00
Ludovico Cavedon 0cb4bae275 QUIC: convert little endian offsets to host endianness
Offset in the QUIC protocol are little endian. Reading them as uint32_t
works on little endian architectures, but breaks on big endian ones.
This change applies the proper conversion and fixes running the
http_ipv6 and quic tests on big endian architectures.
2019-01-15 23:49:26 -08:00
Simone Mainardi 2ade0be365 Fixes ookla lru cache use with IPv6 2019-01-15 09:56:33 +01:00
Luca Deri f2f2dbe381 Fix for IPv6 HTTP traffic 2019-01-14 20:03:06 +01:00
Luca Deri 60eee5f9e9 Merge pull request #649 from Dark-Vex/dev
Bank website detected as TOR from SSL Dissector (bigram check)
2019-01-13 11:12:12 +01:00
Luca Deri 4a6b0d7de5 Merge pull request #654 from u-devel/patch-1
Update radius.c to RFC2865
2019-01-13 11:11:10 +01:00
Luca Deri f41ffe136a Merge pull request #655 from u-devel/dev
FIX H.323 broken detection
2019-01-13 11:10:36 +01:00
u-devel 1d155ab2eb FIX H.323 broken detection
TPKT header length field can have value more then 255, and in fact in all of the cases I've met it is more then 255.
Thus checking real H.323 packet like this:
(packet->payload[2] == 0x00)
stop detecting H.323 conversation at all.
2019-01-13 00:07:45 +06:00
u-devel 396f794bf4 Update radius.c to RFC2865
According to RFC2865 code can have value up to 13, also payload length ranges should be applied.
2019-01-12 23:49:24 +06:00
Luca Deri 97bdfe295d nDPi now finally honours dissection of HTTP responses 2019-01-07 00:28:29 +01:00
Luca Deri 5241c9f3cf Added Modbus over TCP dissector 2018-12-21 18:25:44 +01:00
Luca Deri 91da00f470 Updated results 2018-12-21 17:31:51 +01:00
Alfredo Cardigliano c7260b6436 Moved to 2.7 2018-12-21 10:50:23 +01:00
Daniele De Lorenzi c51405e99b Bank website detected as TOR from SSL Dissector (bigram check)
Commented "vp" for vpbank.com
2018-12-20 11:11:32 +01:00
Daniele De Lorenzi 2aea4da9ad Merge pull request #10 from ntop/dev
Repo sync
2018-12-20 11:04:03 +01:00
Daniele De Lorenzi 3b1047b0c8 Merge pull request #9 from ntop/dev
updates from dev
2018-05-31 16:29:04 +02:00
Daniele De Lorenzi 7989b8d969 Merge pull request #8 from Dark-Vex/rapidvideo
Added RapidVideo
2018-05-25 22:03:14 +02:00
559 changed files with 54785 additions and 17728 deletions
+17
View File
@@ -0,0 +1,17 @@
version: 3.1.{build}
branches:
only:
- dev
environment:
matrix:
- COMPILER: mingw
MINGW_DIR: c:\msys64\mingw32
before_build:
- set Path=%MINGW_DIR%\bin;%Path%
build_script:
- set Path=%MINGW_DIR%\bin;c:\msys64\usr\bin;
- bash autogen.sh
- cd src/lib
- make
+3
View File
@@ -0,0 +1,3 @@
*.sh -crlf
*.ac -crlf
*.am -crlf
+23
View File
@@ -0,0 +1,23 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'ndpi'
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'ndpi'
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure()
with:
name: artifacts
path: ./out/artifacts
@@ -0,0 +1,83 @@
/**
* @name Suspicious packet->payload based integer arithmetic
* @description An arithmetic operation influenced array access is suspicious
* if it uses an integer value that is likely to be network-controlled, and
* may require a closer manual audit.
* @kind problem
* @problem.severity warning
* @id cpp/packet-payload-integer-arithmetic
* @tags audit security
*/
import cpp
import semmle.code.cpp.dataflow.TaintTracking
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
/** A source of an integer value that is likely to come from the network.
* This is produced by an invocation of a macro of the form `ntoh*` or `get_u_int*_t`,
* called with `packet->payload` as an argument.
*/
class NetworkMacro extends Macro {
NetworkMacro() { this.getName().regexpMatch("^ntoh(ll|l|s)") }
}
class NetworkIntegerSource extends Expr {
NetworkIntegerSource() {
exists(MacroInvocation mi |
this = mi.getExpr() and
mi.getUnexpandedArgument(0).regexpMatch(".*packet->payload.*") |
// catch all get_u_int*_t(x)
mi.getMacroName().regexpMatch("^get_u_int(64|32|16|8)_t") and
// dedup ntoh*(get_u_int*_t(x)) since we'll catch those in the next case
not mi.getOutermostMacroAccess().getMacro() instanceof NetworkMacro
or
// catch all ntoh*(x) ... this will also catch the nested cases
mi.getMacro() instanceof NetworkMacro
)
}
}
class ArithmeticOperation extends Operation {
ArithmeticOperation() {
this instanceof UnaryArithmeticOperation or this instanceof BinaryArithmeticOperation
}
}
class NetworkToArrayAccess extends TaintTracking::Configuration {
NetworkToArrayAccess() { this = "NetworkToArrayAccess" }
override predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof NetworkIntegerSource
}
override predicate isSink(DataFlow::Node sink) {
exists(ArrayExpr ae | sink.asExpr() = ae.getArrayOffset())
}
}
class NetworkToArithmetic extends TaintTracking::Configuration {
NetworkToArithmetic() { this = "NetworkToArithmetic" }
override predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof NetworkIntegerSource
}
override predicate isSink(DataFlow::Node sink) {
exists (Assignment assign |
sink.asExpr() = assign.getRValue().(ArithmeticOperation) or
sink.asExpr() = assign.(AssignArithmeticOperation)
) or
exists(LocalVariable var |
sink.asExpr() = var.getInitializer().getExpr().(ArithmeticOperation)
)
}
}
// find audit candidates based on suspicious network integer use
from NetworkIntegerSource source, Expr sink1, Expr sink2, NetworkToArithmetic config1, NetworkToArrayAccess config2
where config1.hasFlow(DataFlow::exprNode(source), DataFlow::exprNode(sink1))
// or this if you want integer arithmeric _OR_ array accesses
and config2.hasFlow(DataFlow::exprNode(source), DataFlow::exprNode(sink2))
select source, "Suspicious use of network integer arithmetic."
+186 -21
View File
@@ -1,38 +1,203 @@
language: c
os:
- osx
- linux
compiler:
- clang
- gcc
matrix:
exclude:
# osx use always clang for build...
- os: osx
compiler: gcc
include:
- os: osx
compiler: clang
install:
#macos
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi
#linux
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update || true; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install build-essential; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libpcap-dev libtool autoconf automake autogen; fi
- os: linux
compiler: gcc
dist: bionic
addons:
apt:
packages:
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
- os: linux
compiler: clang
dist: bionic
addons:
apt:
packages:
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
- os: linux
compiler: gcc
dist: bionic
arch: arm64
addons:
apt:
packages:
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
- os: linux
compiler: clang
dist: bionic
arch: arm64
addons:
apt:
packages:
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
# Targets below have been disabled as we have no way
# to debug on tsuch platforms at the moment
# - os: linux
# compiler: gcc
# dist: bionic
# arch: s390x
# addons:
# apt:
# packages:
# - libpcap-dev
# - libjson-c-dev
# - autogen
#
# - os: linux
# compiler: clang
# dist: bionic
# arch: s390x
# addons:
# apt:
# packages:
# - libpcap-dev
# - libjson-c-dev
# - autogen
- os: linux
compiler: gcc-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-8
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
env:
- MATRIX_EVAL="CC=gcc-8"
- os: linux
compiler: gcc-9
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-9
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
env:
- MATRIX_EVAL="CC=gcc-9"
- os: linux
compiler: clang-8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
packages:
- clang-8
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
env:
- MATRIX_EVAL="CC=clang-8"
- os: linux
compiler: clang-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
packages:
- clang-7
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
env:
- MATRIX_EVAL="CC=clang-7"
- name: fuzza
env: CXXFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" CFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=address" QA_FUZZ=asan CC=clang-7 && CXX=clang++-7 ASAN_SYMBOLIZER_PATH=/usr/local/clang-7.0.0/bin/llvm-symbolizer
os: linux
compiler: clang-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
packages:
- clang-7
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
- name: fuzzm
env: CXXFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" CFLAGS="-g3 -O0 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize=fuzzer-no-link" LDFLAGS="-g3 -O0 -fsanitize=memory" QA_FUZZ=msan CC=clang && CXX=clang++
os: linux
compiler: clang
dist: bionic
addons:
apt:
packages:
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
- name: fuzzu
env: CXXFLAGS="-g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fsanitize=fuzzer-no-link -fno-sanitize=alignment" CFLAGS="-g3 -Og -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=undefined -fno-sanitize-recover=undefined,integer -fsanitize=fuzzer-no-link -fno-sanitize=alignment" LDFLAGS="-g3 -Og -fsanitize=undefined -fno-sanitize=alignment" QA_FUZZ=ubsan CC=clang-7 && CXX=clang++-7
os: linux
compiler: clang-7
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
packages:
- clang-7
- libpcap-dev
- libgcrypt20-dev
- libjson-c-dev
- autogen
before_install:
- eval "${MATRIX_EVAL}"
before_script:
- ./autogen.sh
# - lcov --directory . --zerocounters
script:
- ./configure
- if [ -n "$QA_FUZZ" ]; then ./configure --enable-fuzztargets ; else ./configure ; fi
- make
- make -C example ndpiSimpleIntegration
- make dist
after_script:
#after_script:
- cd tests
- ./do.sh
- ./do-unit.sh
#after_success:
#- cd ${TRAVIS_BUILD_DIR}
+245 -5
View File
@@ -1,5 +1,245 @@
# CHANGELOG
#### nDPI 3.4 (October 2020)
## New Features
* Completely reworked and extended QUIC dissector
* Added flow risk concept to move nDPI towards result interpretation
* Added ndpi_dpi2json() API call
* Added DGA risk for names that look like a DGA
* Added HyperLogLog cardinality estimator API calls
* Added ndpi_bin_XXX API calls to handle bin handling
* Fully fuzzy tested code that has greatly improved reliability and robustness
## New Supported Protocols and Services
* QUIC
* SMBv1
* WebSocket
* TLS: added ESNI support
* SOAP
* DNScrypt
## Improvements
* Python CFFI bindings
* Various TLS extensions and fixes including extendede metadata support
* Added various pcap files for testing corner cases in protocols
* Various improvements in JSON/Binary data serialization
* CiscoVPN
* H323
* MDNS
* MySQL 8
* IEC 60870-5-104
* DoH/DoT dissection improvements
* Office365 renamed to Microsoft365
* Major protocol dissection improvement in particular with unknwon traffic
* Improvement in Telegram v6 protocol support
* HTTP improvements to detect file download/upload and binary files
* BitTorrent and WhatsApp dissection improvement
* Spotify
* Added detection of malformed packets
* Fuzzy testing support has been greatly improved
* SSH code cleanup
## Fixes
* Fixed various memory leaks and race conditions in protocol decoding
* NATS, CAPWAP dissector
* Removed HyperScan support that greatly simplified the code
* ARM platform fixes on memory alignment
* Wireshark extcap support
* DPDK support
* OpenWRT, OpenBSD support
* MINGW compiler support
## MISC
* Created demo app for nDPI newcomers
* Removed obsolete pplive and pando protocols
#### nDPI 3.2 (February 2020)
## New Features
* New API calls
* Protocol detection: ndpi_is_protocol_detected
* Categories: ndpi_load_categories_file / ndpi_load_category
* JSON/TLV serialization: ndpi_serialize_string_boolean / ndpi_serialize_uint32_boolean
* Patricia tree: ndpi_load_ipv4_ptree
* Module initialization: ndpi_init_detection_module / ndpi_finalize_initalization
* Base64 encoding: ndpi_base64_encode
* JSON exprot: ndpi_flow2json
* Print protocol: ndpi_get_l4_proto_name / ndpi_get_l4_proto_info
* Libfuzz integration
* Implemented Community ID hash (API call ndpi_flowv6_flow_hash and ndpi_flowv4_flow_hash)
* Detection of RCE in HTTP GET requests via PCRE
* Integration of the libinjection library to detect SQL injections and XSS type attacks in HTTP requests
## New Supported Protocols and Services
* TLS
* Added ALPN support
* Added export of supported version in TLS header
* Added Telnet dissector with metadata extraction
* Added Zabbix dissector
* Added POP3/IMAP metadata extraction
* Added FTP user/password extraction
* Added NetBIOS metadata extraction
* Added Kerberos metadata extraction
* Implemented SQL Injection and XSS attack detection
* Host-based detection improvements and changes
* Added Microsoft range
* Added twitch.tv website
* Added brasilbandalarga.com.br and .eaqbr.com.br as EAQ
* Added 20.180.0.0/14, 20.184.0.0/13 range as Skype
* Added 52.84.0.0/14 range as Amazon
* Added ^pastebin.com
* Changed 13.64.0.0/11 range from Skype to Microsoft
* Refreshed Whatsapp server list, added *whatsapp-*.fbcdn.net IPs
* Added public DNSoverHTTPS servers
## Improvements
* Reworked and improved the TLS dissector
* Reworked Kerberos dissector
* Improved DNS response decoding
* Support for DNS continuous flow dissection
* Improved Python bindings
* Improved Ethereum support
* Improved categories detection with streaming and HTTP
* Support for IP-based detection to compute the application protocol
* Renamed protocol 104 to IEC60870 (more meaningful)
* Added failed authentication support with FTP
* Renamed DNSoverHTTPS to handle bot DoH and DoT
* Implemented stacked DPI decoding
* Improvements for CapWAP and Bloomberg
* Improved SMB dissection
* Improved SSH dissection
* Added capwap support
* Modified API signatures for ndpi_ssl_version2str / ndpi_detection_giveup
* Removed ndpi_pref_http_dont_dissect_response / ndpi_pref_dns_dont_dissect_response (replaced by ndpi_extra_dissection_possible)
## Fixes
* Fixed memory invalid access in SMTP and leaks in TLS
* Fixed a few memory leaks
* Fixrd invalid memory access in a few protocol dissectors (HTTP, memcached, Citrix, STUN, DNS, Amazon Video, TLS, Viber)
* Fixed IPv6 address format across the various platforms/distributions
* Fixed infinite loop in ndpi_workflow_process_packet
* Fixed SHA1 certificate detection
* Fixed custom protocol detection
* Fixed SMTP dissection (including email)
* Fixed Telnet dissection and invalid password report
* Fixed invalid category matching in HTTP
* Fixed Skype and STUN false positives
* Fixed SQL Injection detection
* Fixed invalid SMBv1 detection
* Fixed SSH dissection
* Fixed ndpi_ssl_version2str
* Fixed ndpi_extra_dissection_possible
* Fixed out of bounds read in ndpi_match_custom_category
## Misc
* ndpiReader
* CSV output enhancements
* Added tunnelling decapsulation
* Improved HTTP reporting
------------------------------------------------------------------------
#### nDPI 3.0 (October 2019)
## New Features
* nDPI now reports the protocol ASAP even when specific fields have not yet been dissected because such packets have not yet been observed. This is important for inline applications that can immediately act on traffic. Applications that need full dissection need to call the new API function ndpi_extra_dissection_possible() to check if metadata dissection has been completely performed or if there is more to read before declaring it completed.
* TLS (formerly identified as SSL in nDPI v2.x) is now dissected more deeply, certificate validity is extracted as well certificate SHA-1.
* nDPIreader can now export data in CSV format with option `-C`
* Implemented Sequence of Packet Length and Time (SPLT) and Byte Distribution (BD) as specified by Cisco Joy (https://github.com/cisco/joy). This allows malware activities on encrypted TLS streams. Read more at https://blogs.cisco.com/security/detecting-encrypted-malware-traffic-without-decryption
* Available as library and in `ndpiReader` with option `-J`
* Promoted usage of protocol categories rather than protocol identifiers in order to classify protocols. This allows application protocols to be clustered in families and thus better managed by users/developers rather than using hundred of protocols unknown to most of the people.
* Added Inter-Arrival Time (IAT) calculation used to detect protocol misbehaviour (e.g. slow-DoS detection)
* Added data analysis features for computign metrics such as entropy, average, stddev, variance on a single and consistent place that will prevent when possible. This should ease traffic analysis on monitoring/security applications. New API calls have been implemented such as ndpi_data_XXX() to handle these calculations.
* Initial release of Python bindings available under nDPI/python.
* Implemented search of human readable strings for promoting data exfiltration detection
* Available as library and in `ndpiReader` with option `-e`
* Fingerprints
* JA3 (https://github.com/salesforce/ja3)
* HASSH (https://github.com/salesforce/hassh)
* DHCP
* Implemented a library to serialize/deserialize data in both Type-Length-Value (TLV) and JSON format
* Used by nProbe/ntopng to exchange data via ZMQ
## New Supported Protocols and Services
* DTLS (i.e. TLS over UDP)
* Hulu
* TikTok/Musical.ly
* WhatsApp Video
* DNSoverHTTPS
* Datasaver
* Line protocol
* Google Duo and Hangout merged
* WireGuard VPN
* IMO
* Zoom.us
## Improvements
* TLS
* Organizations
* Ciphers
* Certificate analysis
* Added PUBLISH/SUBSCRIBE methods to SIP
* Implemented STUN cache to enhance matching of STUN-based protocols
* Dissection improvements
* Viber
* WhatsApp
* AmazonVideo
* SnapChat
* FTP
* QUIC
* OpenVPN support for UDP-based VPNs
* Facebook Messenger mobile
* Various improvements for STUN, Hangout and Duo
* Added new categories: CUSTOM_CATEGORY_ANTIMALWARE, NDPI_PROTOCOL_CATEGORY_MUSIC, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_CATEGORY_SHOPPING, NDPI_PROTOCOL_CATEGORY_PRODUCTIVITY and NDPI_PROTOCOL_CATEGORY_FILE_SHARING
* Added NDPI_PROTOCOL_DANGEROUS classification
## Fixes
* Fixed the dissection of certain invalid DNS responses
* Fixed Spotify dissection
* Fixed false positives with FTP and FTP_DATA
* Fix to discard STUN over TCP flows
* Fixed MySQL dissector
* Fix category detection due to missing initialization
* Fix DNS rsp_addr missing in some tiny responses
* Various hardening fixes
------------------------------------------------------------------------
#### nDPI 2.8 (March 2019)
## New Supported Protocols and Services
* Added Modbus over TCP dissector
## Improvements
* Wireshark Lua plugin compatibility with Wireshark 3
* Improved MDNS dissection
* Improved HTTP response code handling
* Full dissection of HTTP responses
## Fixes
* Fixed false positive mining detection
* Fixed invalid TCP DNS dissection
* Releasing buffers upon `realloc` failures
* ndpiReader: Prevents references after free
* Endianness fixes
* Fixed IPv6 HTTP traffic dissection
* Fixed H.323 detection
## Other
* Disabled ookla statistics which need to be improved
* Support for custom protocol files of arbitrary length
* Update radius.c to RFC2865
------------------------------------------------------------------------
#### nDPI 2.6 (December 2018)
## New Supported Protocols and Services
@@ -42,12 +282,12 @@
## Other
* Deb and RPM packages: ndpi with shared libraries and binaries, ndpi-dev with headers and static libraries
* Protocols now have an optional subprotocol: Spotify cannot have subprotocols, DNS can (DNS.Spotify)
* Protocols now have an optional subprotocol: Spotify cannot have subprotocols, DNS can (DNS.Spotify)
* New API functions:
- ndpi_fill_ip_protocol_category to handle ICMP flows category
- ndpi_flowv4_flow_hash and ndpi_flowv6_flow_hash to support the Community ID Flow Hashing (https://github.com/corelight/community-id-spec)
- ndpi_protocol2id to print the protocol as ID
- ndpi_get_custom_category_match to search host in custom categories
* ndpi_fill_ip_protocol_category to handle ICMP flows category
* ndpi_flowv4_flow_hash and ndpi_flowv6_flow_hash to support the Community ID Flow Hashing (https://github.com/corelight/community-id-spec)
* ndpi_protocol2id to print the protocol as ID
* ndpi_get_custom_category_match to search host in custom categories
* Changed ndpi_detection_giveup API: guess is now part of the call
* Added DPDK support to ndpiReader
* Removed Musical.ly protocol (service no longer used)
+27
View File
@@ -0,0 +1,27 @@
# How to contribute
Please keep all code, comments, issues and pull requests in English, otherwise they will be **removed**.
## Found a bug?
- First, check there are no already open issues for the bug. See [here](https://github.com/ntop/nDPI/issues).
- If there is not open issue addressing the bug, [open a new one](https://github.com/ntop/nDPI/issues/new).
- Make sure to include a **descriptive and clear title and description**, including the **version of nDPI** being used.
- Try to include steps to reproduce the bug.
- If applicable, try to provide a stacktrace.
- Providing a simple test case which shows the bug would help resolve the issue faster.
## Written a new protocol dissector?
- Ensure you have followed the guide in the [README](https://github.com/ntop/nDPI#how-to-add-a-new-protocol-dissector).
- Open a new pull request with a **clear, descriptive** title.
- Ensure the pull request passes CI testing. Any pull request which fails CI will be **ignored**.
- If possible, add a new test for the new protocol. See [existing tests](https://github.com/ntop/nDPI/tree/dev/tests) for examples.
## Written a fix for a bug?
- Open a new pull request with a **clear, descriptive** title.
- If there is an open issue for the bug, ensure the description of the pull request contains `Fixes #issue_number`.
- Ensure the pull request passes CI testing. Any pull request which fails CI will be **ignored**.
Finally, thank you for your contributions.
+10 -3
View File
@@ -1,7 +1,14 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src/lib example tests
SUBDIRS = src/lib @EXTRA_TARGETS@
pkgconfigdir = $(prefix)/libdata/pkgconfig
if BUILD_FUZZTARGETS
SUBDIRS += fuzz
endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libndpi.pc
EXTRA_DIST = autogen.sh
EXTRA_DIST = README.md CHANGELOG.md CONTRIBUTING.md README.protocols autogen.sh configure.seed wireshark python windows utils packages doc/nDPI_QuickStartGuide.pages doc/nDPI_QuickStartGuide.pdf example/MacOS example/Win32
changelog:
git log --since={`curl -s https://github.com/ntop/ndpi/releases | grep datetime | head -n1 | egrep -o "[0-9]+\-[0-9]+\-[0-9]+"`} --name-only --pretty=format:" - %s" | grep "^ " > Changelog.latest
+6 -11
View File
@@ -4,10 +4,11 @@
[![Build Status](https://travis-ci.org/ntop/nDPI.png?branch=dev)](https://travis-ci.org/ntop/nDPI)
[![Code Quality: Cpp](https://img.shields.io/lgtm/grade/cpp/g/ntop/nDPI.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ntop/nDPI/context:cpp)
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/ntop/nDPI.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ntop/nDPI/alerts)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/ndpi.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:ndpi)
## What is nDPI ?
nDPI is an open source LGPLv3 library for deep-packet inspection. Based on OpenDPI it includes ntop extensions. We have tried to push them into the OpenDPI source tree but nobody answered emails so we have decided to create our own source tree
nDPI® is an open source LGPLv3 library for deep-packet inspection. Based on OpenDPI it includes ntop extensions. We have tried to push them into the OpenDPI source tree but nobody answered emails so we have decided to create our own source tree
### How To Compile nDPI
@@ -41,21 +42,15 @@ The entire procedure of adding new protocols in detail:
10. make check
### How to use nDPI to Block Selected Traffic
You can use nDPI to selectively block selected Internet traffic by embedding it onto an application (remember that nDPI is just a library). Both [ntopng](https://github.com/ntop/ntopng) and [nProbe cento](http://www.ntop.org/products/netflow/nprobe-cento/) can do this.
### nDPI-Related Projects
- [nfstream](https://github.com/aouinizied/nfstream)
### DISCLAIMER
While we do our best to detect network protocols, we cannot guarantee that our software is error free and 100% accurate in protocol detection. Please make sure that you respect the privacy of users and you have proper authorization to listen, capture and inspect network traffic.
### Creating A Source File Tar Ball
If you want to distribute a source tar file of nDPI do:
- make dist
To ensure that a tar file includes all necessary files and to run tests on distribution do:
- make distcheck
nDPI is a registered trademark in the US and EU.
[ntopng_logo]: https://camo.githubusercontent.com/0f789abcef232035c05e0d2e82afa3cc3be46485/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031312f30382f6e746f706e672d69636f6e2d313530783135302e706e67
+5 -4
View File
@@ -5,17 +5,18 @@ Prerequisites
- GNU autotools/libtool
- libpcap or PF_RING (optional but recommended)
- apt-get install libjson-c-dev (for JSON support)
- libgcrypt20-dev (for QUIC support)
On Ubuntu/Debian
- apt-get install build-essential
- apt-get install git autoconf automake autogen libpcap-dev libtool
- apt-get install git autoconf automake autogen libpcap-dev libtool libgcrypt20-dev
On Fedora/CentOS
- yum groupinstall "Development tools"
- yum install git autoconf automake autogen libpcap-devel libtool
- yum install git autoconf automake autogen libpcap-devel libtool libgcrypt-devel
On MacOSX (using http://brew.sh)
brew install autoconf automake libtool git
brew install autoconf automake libtool git libgcrypt
On FreeBSD
- pkg install autoconf automake libtool gmake git
- pkg install autoconf automake libtool gmake git libgcrypt
+17 -3
View File
@@ -1,7 +1,7 @@
#!/bin/sh
NDPI_MAJOR="2"
NDPI_MINOR="5"
NDPI_MAJOR="3"
NDPI_MINOR="4"
NDPI_PATCH="0"
NDPI_VERSION_SHORT="$NDPI_MAJOR.$NDPI_MINOR.$NDPI_PATCH"
@@ -12,10 +12,17 @@ AUTOMAKE=$(command -v automake)
LIBTOOL=$(command -v libtool)
LIBTOOLIZE=$(command -v libtoolize)
AUTORECONF=$(command -v autoreconf)
PKG_CONFIG=$(command -v pkg-config)
FUZZY=
if test -z $AUTOCONF; then
echo "autoconf is missing: please install it and try again"
exit
else
V=`autoconf --version | head -1 | cut -d ' ' -f 4`
if [ "$V" = '2.63' ]; then
FUZZY="dnl> "
fi
fi
if test -z $AUTOMAKE; then
@@ -33,11 +40,17 @@ if test -z $AUTORECONF; then
exit
fi
if test -z $PKG_CONFIG; then
echo "pkg-config is missing: please install it (apt-get install pkg-config) and try again"
exit
fi
cat configure.seed | sed \
-e "s/@NDPI_MAJOR@/$NDPI_MAJOR/g" \
-e "s/@NDPI_MINOR@/$NDPI_MINOR/g" \
-e "s/@NDPI_PATCH@/$NDPI_PATCH/g" \
-e "s/@NDPI_VERSION_SHORT@/$NDPI_VERSION_SHORT/g" \
-e "s/@FUZZY@/$FUZZY/g" \
> configure.ac
autoreconf -ivf
@@ -45,4 +58,5 @@ cat configure | sed "s/#define PACKAGE/#define NDPI_PACKAGE/g" | sed "s/#define
cat configure.tmp > configure
chmod +x configure
./configure $*
./configure $@
+137 -91
View File
@@ -1,13 +1,40 @@
AC_INIT([libndpi], [@NDPI_VERSION_SHORT@])
AC_CONFIG_AUX_DIR([.])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects])
EXTRA_TARGETS="example tests tests/unit"
AC_ARG_WITH(only-libndpi, AS_HELP_STRING([--with-only-libndpi], [Build only libndpi (no examples, tests etc)]))
AS_IF([test "${with_only_libndpi+set}" = set],[
EXTRA_TARGETS=""
])
AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer]))
AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no])
AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"])
AS_IF([test "${with_sanitizer+set}" = set],[
CFLAGS="${CFLAGS} -g3 -O0 -Wno-unused-value -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak -fno-omit-frame-pointer"
LDFLAGS="${LDFLAGS} -fsanitize=address -fsanitize=undefined -fno-sanitize=alignment -fsanitize=leak"
])
LT_INIT
AC_PROG_CC
AM_PROG_CC_C_O
SYSTEM=`uname -s`
if test $SYSTEM = "Darwin"; then
dnl> AC_PROG_CC(clang gcc)
AM_PROG_CC_C_O(clang gcc)
AC_PROG_CXX(clang++ g++)
AC_PROG_CC_STDC(clang gcc)
else
dnl> AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
AC_PROG_CC_STDC
fi
AC_LANG_WERROR
AX_PTHREAD
NDPI_VERSION_SHORT="@NDPI_VERSION_SHORT@"
@@ -24,33 +51,45 @@ if test -d ".git"; then :
GIT_DATE=`git log -1 --format=%cd`
#
# On CentOS 6 `git rev-list HEAD --count` does not work
#
#
#
GIT_NUM=`git log --pretty=oneline | wc -l | tr -d '[[:space:]]'`
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_NUM}-${GIT_TAG}"
A=`git log src/include/ndpi_typedefs.h|wc -l`
B=`git log src/include/ndpi_protocol_ids.h|wc -l`
C=`git log src/include/ndpi_api.h.in|wc -l`
NDPI_API_VERSION=$((A+B+C))
else
GIT_RELEASE="${PACKAGE_VERSION}"
GIT_DATE=`date`
GIT_DATE=`date -u -r CHANGELOG.md`
NDPI_API_VERSION=`date +%s | cut -c7-10`
fi
NDPI_API_VERSION=`echo $NDPI_API_VERSION | sed 's/^0*//'`
AC_DEFINE_UNQUOTED(NDPI_GIT_RELEASE, "${GIT_RELEASE}", [GIT Release])
AC_DEFINE_UNQUOTED(NDPI_GIT_DATE, "${GIT_DATE}", [Last GIT change])
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h])
dnl> used by json-c
JSONC_INC=`pkg-config --cflags json-c`
CFLAGS="${CFLAGS} ${JSONC_INC}"
AC_CHECK_HEADERS([netinet/in.h stdint.h stdlib.h string.h unistd.h json.h])
ADDITIONAL_LIBS=
PCAP_HOME=$HOME/PF_RING/userland
DPDK_TARGET=
AC_MSG_CHECKING([DPDK (used by ndpiReader)])
if test -d $HOME/DPDK; then :
echo "Enabling DPDK support in ndpiReader"
AC_MSG_RESULT(yes)
DPDK_TARGET=dpdk
else
echo "DPDK support disabled (missing $HOME/DPDK)"
AC_MSG_RESULT([no (missing $HOME/DPDK)])
fi
if test -d $PCAP_HOME; then :
echo -n ""
else
if ! test -d $PCAP_HOME; then :
PCAP_HOME=`pwd`/../../PF_RING/userland
fi
SHORT_MACHINE=`uname -m | cut -b1-3`
@@ -61,107 +100,114 @@ else
fi
MACHINE=`uname -m`
SYSTEM=`uname -s`
if test $SYSTEM = "Darwin"; then
CC=clang
fi
if test $ax_cv_PTHREAD_CLANG = "yes"; then
CC=clang
fi
HS_LIB=
HS_INC=
AC_ARG_WITH(hyperscan, [ --with-hyperscan Enable nDPI build with Intel Hyperscan])
CUSTOM_NDPI=
if test "${with_hyperscan+set}" = set; then
BKP=$LIBS
LIBS="$LIBS -lstdc++ -lm"
AC_CHECK_LIB([hs], [hs_compile_multi], AC_DEFINE_UNQUOTED(HAVE_HYPERSCAN, 1, [Intel Hyperscan is present]))
LIBS=$BKP
if test "x$ac_cv_lib_hs_hs_compile_multi" = xyes; then :
AC_CHECK_LIB([m], [pow])
AC_CHECK_LIB([stdc++], [main])
HS_INC=`pkg-config --cflags libhs`
HS_LIB=`pkg-config --libs libhs`
LDFLAGS="$LDFLAGS $HS_LIB"
AC_MSG_RESULT([compiling with Intel Hyperscan])
else
AC_MSG_RESULT([Intel Hyperscan not found, exiting. See https://github.com/intel/hyperscan/blob/master/doc/dev-reference/getting_started.rst for install/build instructions])
exit 1
fi
if test -d ../nDPI-custom; then :
CUSTOM_NDPI="-DCUSTOM_NDPI_PROTOCOLS"
AC_MSG_RESULT([Compiling with custom nDPI protocols])
fi
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
echo "Using libpcap from $PCAP_HOME"
PCAP_INC="-I $PCAP_HOME/libpcap"
PCAP_LIB="$PCAP_HOME/libpcap/libpcap.a $PCAP_HOME/lib/libpfring.a $LIBNUMA `$PCAP_HOME/lib/pfring_config --libs`"
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"])
# The dlopen() function is in libdl on GLIBC-based systems
# and in the C library for *BSD systems
AC_CHECK_LIB([dl], [dlopen, dlsym], [DL_LIB="-ldl"],
[AC_CHECK_LIB([c], [dlopen, dlsym], [DL_LIB="-lc"],
[AC_MSG_ERROR([unable to find the dlopen(), dlsym() functions]) ]) ])
else
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
if test $ac_cv_lib_pcap_pcap_open_live = "no"; then :
echo ""
echo "ERROR: Missing libpcap(-dev) library required to compile the example application"
echo "ERROR: Please install it and try again"
exit
fi
fi
dnl> https://github.com/json-c/json-c
AC_ARG_ENABLE([json-c],
AS_HELP_STRING([--disable-json-c], [Disable json-c support]))
AS_IF([test "x$enable_json_c" != "xno"], [
PKG_CONFIG_PATH=/usr/local/share/pkgconfig:$PKG_CONFIG_PATH
pkg-config --exists json-c
AS_IF([test "$?" == "0"],
[
CFLAGS="$CFLAGS $(pkg-config --cflags json-c)"
LDFLAGS="$LDFLAGS $(pkg-config --libs json-c)"
AC_CHECK_LIB(json-c, json_object_new_object, AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present]))
],
[
JSONC_HOME="$HOME/json-c"
if test -d "$JSONC_HOME"; then :
CFLAGS="$CFLAGS -I $JSONC_HOME"
LDFLAGS="$LDFLAGS $JSONC_HOME/.libs/libjson-c.a"
AC_MSG_RESULT([Found json-c in $JSONC_HOME])
AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present])
fi
])
])
case "$host" in
*-*-mingw32*|*-*-msys)
CFLAGS="${CFLAGS} -DOS_WIN32"
LDFLAGS="${LDFLAGS} -lws2_32 -lucrtbase"
BUILD_MINGW=1
;;
*)
if test -f $PCAP_HOME/libpcap/libpcap.a; then :
echo "Using libpcap from $PCAP_HOME"
PCAP_INC="-I $PCAP_HOME/libpcap"
PCAP_LIB="$PCAP_HOME/libpcap/libpcap.a $PCAP_HOME/lib/libpfring.a $LIBNUMA `$PCAP_HOME/lib/pfring_config --libs`"
AC_CHECK_LIB([rt], [clock_gettime], [PCAP_LIB="$PCAP_LIB -lrt"])
AC_CHECK_LIB([nl], [nl_handle_alloc], [PCAP_LIB="$PCAP_LIB -lnl"])
# The dlopen() function is in libdl on GLIBC-based systems
# and in the C library for *BSD systems
AC_CHECK_LIB([dl], [dlopen, dlsym], [DL_LIB="-ldl"],[AC_CHECK_LIB([c], [dlopen, dlsym], [DL_LIB="-lc"],[AC_MSG_ERROR([unable to find the dlopen(), dlsym() functions]) ]) ])
else
AC_CHECK_LIB([pcap], [pcap_open_live], [PCAP_LIB="-lpcap"])
if test $ac_cv_lib_pcap_pcap_open_live = "no"; then :
echo ""
echo "ERROR: Missing libpcap(-dev) library required to compile the example application"
echo "ERROR: Please install it and try again"
exit
fi
fi
;;
esac
AC_ARG_ENABLE([debug-messages],
AS_HELP_STRING([--enable-debug-messages], [Define NDPI_ENABLE_DEBUG_MESSAGES=1]), [
AC_DEFINE(NDPI_ENABLE_DEBUG_MESSAGES, 1, [Enable ndpi_debug_messages]) ])
@FUZZY@ AS_IF([test "x$enable_fuzztargets" = "xyes"], [
@FUZZY@ AC_PROG_CXX
@FUZZY@ AC_LANG_PUSH(C++)
@FUZZY@ tmp_saved_flags=$[]_AC_LANG_PREFIX[]FLAGS
@FUZZY@ AX_CHECK_COMPILE_FLAG([-fsanitize=fuzzer],,
@FUZZY@ [AC_MSG_ERROR([--enable-fuzztargets requires -fsanitize=fuzzer which is only supported by LLVM])],
@FUZZY@ [-Werror])
@FUZZY@ AS_IF([test "x$LIB_FUZZING_ENGINE" = "x"], [
@FUZZY@ LIB_FUZZING_ENGINE=-fsanitize=fuzzer
@FUZZY@ AC_SUBST(LIB_FUZZING_ENGINE)
@FUZZY@ ])
@FUZZY@ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $LIB_FUZZING_ENGINE"
@FUZZY@ AC_MSG_CHECKING([whether $CXX accepts $LIB_FUZZING_ENGINE])
@FUZZY@ AC_LINK_IFELSE([AC_LANG_SOURCE([[
@FUZZY@ #include <sys/types.h>
@FUZZY@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size);
@FUZZY@ extern "C" int LLVMFuzzerTestOneInput(const unsigned char *Data, size_t Size) {
@FUZZY@ (void)Data;
@FUZZY@ (void)Size;
@FUZZY@ return 0;
@FUZZY@ }
@FUZZY@ ]])],
@FUZZY@ [ AC_MSG_RESULT(yes)
@FUZZY@ has_sanitizefuzzer=yes],
@FUZZY@ [ AC_MSG_RESULT(no) ]
@FUZZY@ )
@FUZZY@ _AC_LANG_PREFIX[]FLAGS=$tmp_saved_flags
@FUZZY@ AC_LANG_POP()
@FUZZY@ ])
AM_CONDITIONAL([HAS_FUZZLDFLAGS], [test "x$has_sanitizefuzzer" = "xyes"])
AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np]))
AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile])
dnl> GCRYPT
AC_ARG_ENABLE([gcrypt],
[AS_HELP_STRING([--disable-gcrypt], [Avoid compiling with libgcrypt/libgpg-error, even if they are present. QUIC sub-classification may be missing])],
[:],
[AC_CHECK_LIB(gcrypt, gcry_cipher_checktag)
AC_CHECK_LIB(gpg-error, gpg_strerror_r)])
if test "x$ac_cv_lib_gcrypt_gcry_cipher_checktag" = xyes; then :
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lgcrypt"
fi
dnl> PCRE
AC_ARG_WITH(pcre, [ --with-pcre Enable nDPI build with libpcre])
if test "${with_pcre+set}" = set; then :
AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE_UNQUOTED(HAVE_PCRE, 1, [libpcre(-dev) is present]))
if test "x$ac_cv_lib_pcre_pcre_compile" = xyes; then :
ADDITIONAL_LIBS="${ADDITIONAL_LIBS} -lpcre"
fi
fi
AC_CONFIG_FILES([Makefile example/Makefile example/Makefile.dpdk tests/Makefile tests/unit/Makefile libndpi.pc src/include/ndpi_define.h src/lib/Makefile python/Makefile fuzz/Makefile src/include/ndpi_api.h])
AC_CONFIG_HEADERS(src/include/ndpi_config.h)
AC_SUBST(GIT_RELEASE)
AC_SUBST(NDPI_MAJOR)
AC_SUBST(NDPI_MINOR)
AC_SUBST(NDPI_PATCH)
AC_SUBST(NDPI_VERSION_SHORT)
AC_SUBST(SVN_DATE)
AC_SUBST(JSON_C_LIB)
AC_SUBST(PCAP_INC)
AC_SUBST(PCAP_LIB)
AC_SUBST(ADDITIONAL_LIBS)
AC_SUBST(DL_LIB)
AC_SUBST(HS_LIB)
AC_SUBST(HS_INC)
AC_SUBST(DPDK_TARGET)
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
AC_SUBST(CUSTOM_NDPI)
AC_SUBST(NDPI_API_VERSION)
AC_SUBST(EXTRA_TARGETS)
AC_SUBST(BUILD_MINGW)
AC_OUTPUT
Binary file not shown.
Binary file not shown.
@@ -8,17 +8,26 @@
/* Begin PBXBuildFile section */
E32F1ECB20844620005739B7 /* whatsapp.c in Sources */ = {isa = PBXBuildFile; fileRef = E32F1ECA20844620005739B7 /* whatsapp.c */; };
E35D5510228BA70600A80DED /* ajp.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D5506228BA70400A80DED /* ajp.c */; };
E35D5511228BA70600A80DED /* snmp_proto.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D5507228BA70400A80DED /* snmp_proto.c */; };
E35D5512228BA70600A80DED /* modbus.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D5508228BA70400A80DED /* modbus.c */; };
E35D5513228BA70600A80DED /* ookla.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D5509228BA70400A80DED /* ookla.c */; };
E35D5514228BA70600A80DED /* upnp.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D550A228BA70400A80DED /* upnp.c */; };
E35D5515228BA70600A80DED /* memcached.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D550B228BA70500A80DED /* memcached.c */; };
E35D5516228BA70600A80DED /* mdns_proto.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D550C228BA70500A80DED /* mdns_proto.c */; };
E35D5517228BA70600A80DED /* fbzero.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D550D228BA70500A80DED /* fbzero.c */; };
E35D5518228BA70600A80DED /* nest_log_sink.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D550E228BA70500A80DED /* nest_log_sink.c */; };
E35D5519228BA70600A80DED /* mining.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D550F228BA70600A80DED /* mining.c */; };
E35D551D228BA80000A80DED /* sha1-fast.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D551B228BA80000A80DED /* sha1-fast.c */; };
E35D551E228BA80000A80DED /* ht_hash.c in Sources */ = {isa = PBXBuildFile; fileRef = E35D551C228BA80000A80DED /* ht_hash.c */; };
E35D551F228BA88700A80DED /* ndpi_patricia.c in Sources */ = {isa = PBXBuildFile; fileRef = E395430820255354000BBA0D /* ndpi_patricia.c */; };
E3953F5420254989000BBA0D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E3953F5320254989000BBA0D /* AppDelegate.m */; };
E3953F5720254989000BBA0D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E3953F5620254989000BBA0D /* ViewController.m */; };
E3953F5920254989000BBA0D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E3953F5820254989000BBA0D /* Assets.xcassets */; };
E3953F5C2025498A000BBA0D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E3953F5A2025498A000BBA0D /* Main.storyboard */; };
E3953F5F2025498A000BBA0D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E3953F5E2025498A000BBA0D /* main.m */; };
E395430B20255354000BBA0D /* Makefile.am in Resources */ = {isa = PBXBuildFile; fileRef = E39540A520255353000BBA0D /* Makefile.am */; };
E395430C20255354000BBA0D /* ndpi_define.h.in in Resources */ = {isa = PBXBuildFile; fileRef = E39540A720255353000BBA0D /* ndpi_define.h.in */; };
E395431720255354000BBA0D /* Makefile in Sources */ = {isa = PBXBuildFile; fileRef = E39540BC20255353000BBA0D /* Makefile */; };
E395431820255354000BBA0D /* Makefile.am in Resources */ = {isa = PBXBuildFile; fileRef = E39540BD20255353000BBA0D /* Makefile.am */; };
E395431920255354000BBA0D /* Makefile.in in Resources */ = {isa = PBXBuildFile; fileRef = E39540BE20255353000BBA0D /* Makefile.in */; };
E395431A20255354000BBA0D /* Makefile.simple in Resources */ = {isa = PBXBuildFile; fileRef = E39540BF20255353000BBA0D /* Makefile.simple */; };
E395431B20255354000BBA0D /* ndpi_content_match.c.inc in Sources */ = {isa = PBXBuildFile; fileRef = E39540C020255353000BBA0D /* ndpi_content_match.c.inc */; };
E395431C20255354000BBA0D /* ndpi_main.c in Sources */ = {isa = PBXBuildFile; fileRef = E39540C120255353000BBA0D /* ndpi_main.c */; };
E39543A320255354000BBA0D /* afp.c in Sources */ = {isa = PBXBuildFile; fileRef = E395414B20255353000BBA0D /* afp.c */; };
@@ -60,7 +69,6 @@
E39543C720255354000BBA0D /* edonkey.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417120255353000BBA0D /* edonkey.c */; };
E39543C820255354000BBA0D /* fasttrack.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417220255353000BBA0D /* fasttrack.c */; };
E39543C920255354000BBA0D /* fiesta.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417320255353000BBA0D /* fiesta.c */; };
E39543CA20255354000BBA0D /* filetopia.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417420255353000BBA0D /* filetopia.c */; };
E39543CB20255354000BBA0D /* fix.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417520255353000BBA0D /* fix.c */; };
E39543CC20255354000BBA0D /* florensia.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417620255353000BBA0D /* florensia.c */; };
E39543CD20255354000BBA0D /* ftp_control.c in Sources */ = {isa = PBXBuildFile; fileRef = E395417720255353000BBA0D /* ftp_control.c */; };
@@ -90,10 +98,8 @@
E39544ED20255354000BBA0D /* mail_pop.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429720255354000BBA0D /* mail_pop.c */; };
E39544EE20255354000BBA0D /* mail_smtp.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429820255354000BBA0D /* mail_smtp.c */; };
E39544EF20255354000BBA0D /* maplestory.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429920255354000BBA0D /* maplestory.c */; };
E39544F020255354000BBA0D /* mdns.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429A20255354000BBA0D /* mdns.c */; };
E39544F120255354000BBA0D /* megaco.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429B20255354000BBA0D /* megaco.c */; };
E39544F220255354000BBA0D /* mgcp.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429C20255354000BBA0D /* mgcp.c */; };
E39544F320255354000BBA0D /* mms.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429D20255354000BBA0D /* mms.c */; };
E39544F420255354000BBA0D /* mpegts.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429E20255354000BBA0D /* mpegts.c */; };
E39544F520255354000BBA0D /* mqtt.c in Sources */ = {isa = PBXBuildFile; fileRef = E395429F20255354000BBA0D /* mqtt.c */; };
E39544F620255354000BBA0D /* msn.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542A020255354000BBA0D /* msn.c */; };
@@ -134,9 +140,7 @@
E395451920255354000BBA0D /* skype.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C320255354000BBA0D /* skype.c */; };
E395451A20255354000BBA0D /* smb.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C420255354000BBA0D /* smb.c */; };
E395451B20255354000BBA0D /* smpp.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C520255354000BBA0D /* smpp.c */; };
E395451C20255354000BBA0D /* snmp.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C620255354000BBA0D /* snmp.c */; };
E395451D20255354000BBA0D /* socks45.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C720255354000BBA0D /* socks45.c */; };
E395451E20255354000BBA0D /* socrates.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C820255354000BBA0D /* socrates.c */; };
E395451F20255354000BBA0D /* someip.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542C920255354000BBA0D /* someip.c */; };
E395452020255354000BBA0D /* sopcast.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542CA20255354000BBA0D /* sopcast.c */; };
E395452120255354000BBA0D /* soulseek.c in Sources */ = {isa = PBXBuildFile; fileRef = E39542CB20255354000BBA0D /* soulseek.c */; };
@@ -189,6 +193,19 @@
/* Begin PBXFileReference section */
E32F1ECA20844620005739B7 /* whatsapp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = whatsapp.c; sourceTree = "<group>"; };
E35D5506228BA70400A80DED /* ajp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ajp.c; sourceTree = "<group>"; };
E35D5507228BA70400A80DED /* snmp_proto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = snmp_proto.c; sourceTree = "<group>"; };
E35D5508228BA70400A80DED /* modbus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = modbus.c; sourceTree = "<group>"; };
E35D5509228BA70400A80DED /* ookla.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ookla.c; sourceTree = "<group>"; };
E35D550A228BA70400A80DED /* upnp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = upnp.c; sourceTree = "<group>"; };
E35D550B228BA70500A80DED /* memcached.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = memcached.c; sourceTree = "<group>"; };
E35D550C228BA70500A80DED /* mdns_proto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mdns_proto.c; sourceTree = "<group>"; };
E35D550D228BA70500A80DED /* fbzero.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fbzero.c; sourceTree = "<group>"; };
E35D550E228BA70500A80DED /* nest_log_sink.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nest_log_sink.c; sourceTree = "<group>"; };
E35D550F228BA70600A80DED /* mining.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mining.c; sourceTree = "<group>"; };
E35D551A228BA7DF00A80DED /* ht_hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ht_hash.h; sourceTree = "<group>"; };
E35D551B228BA80000A80DED /* sha1-fast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "sha1-fast.c"; sourceTree = "<group>"; };
E35D551C228BA80000A80DED /* ht_hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ht_hash.c; sourceTree = "<group>"; };
E3953F4F20254989000BBA0D /* ndpiExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ndpiExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
E3953F5220254989000BBA0D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
E3953F5320254989000BBA0D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -212,7 +229,6 @@
E39540BC20255353000BBA0D /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
E39540BD20255353000BBA0D /* Makefile.am */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Makefile.am; sourceTree = "<group>"; };
E39540BE20255353000BBA0D /* Makefile.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Makefile.in; sourceTree = "<group>"; };
E39540BF20255353000BBA0D /* Makefile.simple */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Makefile.simple; sourceTree = "<group>"; };
E39540C020255353000BBA0D /* ndpi_content_match.c.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; path = ndpi_content_match.c.inc; sourceTree = "<group>"; };
E39540C120255353000BBA0D /* ndpi_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ndpi_main.c; sourceTree = "<group>"; };
E395414B20255353000BBA0D /* afp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = afp.c; sourceTree = "<group>"; };
@@ -255,7 +271,6 @@
E395417120255353000BBA0D /* edonkey.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = edonkey.c; sourceTree = "<group>"; };
E395417220255353000BBA0D /* fasttrack.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fasttrack.c; sourceTree = "<group>"; };
E395417320255353000BBA0D /* fiesta.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fiesta.c; sourceTree = "<group>"; };
E395417420255353000BBA0D /* filetopia.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = filetopia.c; sourceTree = "<group>"; };
E395417520255353000BBA0D /* fix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fix.c; sourceTree = "<group>"; };
E395417620255353000BBA0D /* florensia.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = florensia.c; sourceTree = "<group>"; };
E395417720255353000BBA0D /* ftp_control.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftp_control.c; sourceTree = "<group>"; };
@@ -285,10 +300,8 @@
E395429720255354000BBA0D /* mail_pop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mail_pop.c; sourceTree = "<group>"; };
E395429820255354000BBA0D /* mail_smtp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mail_smtp.c; sourceTree = "<group>"; };
E395429920255354000BBA0D /* maplestory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = maplestory.c; sourceTree = "<group>"; };
E395429A20255354000BBA0D /* mdns.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mdns.c; sourceTree = "<group>"; };
E395429B20255354000BBA0D /* megaco.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = megaco.c; sourceTree = "<group>"; };
E395429C20255354000BBA0D /* mgcp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mgcp.c; sourceTree = "<group>"; };
E395429D20255354000BBA0D /* mms.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mms.c; sourceTree = "<group>"; };
E395429E20255354000BBA0D /* mpegts.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mpegts.c; sourceTree = "<group>"; };
E395429F20255354000BBA0D /* mqtt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mqtt.c; sourceTree = "<group>"; };
E39542A020255354000BBA0D /* msn.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msn.c; sourceTree = "<group>"; };
@@ -329,9 +342,7 @@
E39542C320255354000BBA0D /* skype.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = skype.c; sourceTree = "<group>"; };
E39542C420255354000BBA0D /* smb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smb.c; sourceTree = "<group>"; };
E39542C520255354000BBA0D /* smpp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smpp.c; sourceTree = "<group>"; };
E39542C620255354000BBA0D /* snmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = snmp.c; sourceTree = "<group>"; };
E39542C720255354000BBA0D /* socks45.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = socks45.c; sourceTree = "<group>"; };
E39542C820255354000BBA0D /* socrates.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = socrates.c; sourceTree = "<group>"; };
E39542C920255354000BBA0D /* someip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = someip.c; sourceTree = "<group>"; };
E39542CA20255354000BBA0D /* sopcast.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sopcast.c; sourceTree = "<group>"; };
E39542CB20255354000BBA0D /* soulseek.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = soulseek.c; sourceTree = "<group>"; };
@@ -482,7 +493,6 @@
E39540BC20255353000BBA0D /* Makefile */,
E39540BD20255353000BBA0D /* Makefile.am */,
E39540BE20255353000BBA0D /* Makefile.in */,
E39540BF20255353000BBA0D /* Makefile.simple */,
E39540C020255353000BBA0D /* ndpi_content_match.c.inc */,
E39540C120255353000BBA0D /* ndpi_main.c */,
E39540C220255353000BBA0D /* protocols */,
@@ -530,7 +540,6 @@
E395417120255353000BBA0D /* edonkey.c */,
E395417220255353000BBA0D /* fasttrack.c */,
E395417320255353000BBA0D /* fiesta.c */,
E395417420255353000BBA0D /* filetopia.c */,
E395417520255353000BBA0D /* fix.c */,
E395417620255353000BBA0D /* florensia.c */,
E395417720255353000BBA0D /* ftp_control.c */,
@@ -560,10 +569,8 @@
E395429720255354000BBA0D /* mail_pop.c */,
E395429820255354000BBA0D /* mail_smtp.c */,
E395429920255354000BBA0D /* maplestory.c */,
E395429A20255354000BBA0D /* mdns.c */,
E395429B20255354000BBA0D /* megaco.c */,
E395429C20255354000BBA0D /* mgcp.c */,
E395429D20255354000BBA0D /* mms.c */,
E395429E20255354000BBA0D /* mpegts.c */,
E395429F20255354000BBA0D /* mqtt.c */,
E39542A020255354000BBA0D /* msn.c */,
@@ -604,9 +611,7 @@
E39542C320255354000BBA0D /* skype.c */,
E39542C420255354000BBA0D /* smb.c */,
E39542C520255354000BBA0D /* smpp.c */,
E39542C620255354000BBA0D /* snmp.c */,
E39542C720255354000BBA0D /* socks45.c */,
E39542C820255354000BBA0D /* socrates.c */,
E39542C920255354000BBA0D /* someip.c */,
E39542CA20255354000BBA0D /* sopcast.c */,
E39542CB20255354000BBA0D /* soulseek.c */,
@@ -647,6 +652,16 @@
E39542EE20255354000BBA0D /* zattoo.c */,
E39542EF20255354000BBA0D /* zeromq.c */,
E32F1ECA20844620005739B7 /* whatsapp.c */,
E35D5506228BA70400A80DED /* ajp.c */,
E35D550D228BA70500A80DED /* fbzero.c */,
E35D550C228BA70500A80DED /* mdns_proto.c */,
E35D550B228BA70500A80DED /* memcached.c */,
E35D550F228BA70600A80DED /* mining.c */,
E35D5508228BA70400A80DED /* modbus.c */,
E35D550E228BA70500A80DED /* nest_log_sink.c */,
E35D5509228BA70400A80DED /* ookla.c */,
E35D5507228BA70400A80DED /* snmp_proto.c */,
E35D550A228BA70400A80DED /* upnp.c */,
);
path = protocols;
sourceTree = "<group>";
@@ -675,6 +690,7 @@
E39542F120255354000BBA0D /* include */ = {
isa = PBXGroup;
children = (
E35D551A228BA7DF00A80DED /* ht_hash.h */,
E39542F220255354000BBA0D /* actypes.h */,
E39542F320255354000BBA0D /* ahocorasick.h */,
E39542F420255354000BBA0D /* libcache.h */,
@@ -688,6 +704,8 @@
E39542F820255354000BBA0D /* src */ = {
isa = PBXGroup;
children = (
E35D551C228BA80000A80DED /* ht_hash.c */,
E35D551B228BA80000A80DED /* sha1-fast.c */,
E395430020255354000BBA0D /* ahocorasick.c */,
E395430120255354000BBA0D /* libcache.c */,
E395430820255354000BBA0D /* ndpi_patricia.c */,
@@ -769,14 +787,10 @@
buildActionMask = 2147483647;
files = (
E395430C20255354000BBA0D /* ndpi_define.h.in in Resources */,
E395431A20255354000BBA0D /* Makefile.simple in Resources */,
E395430B20255354000BBA0D /* Makefile.am in Resources */,
E395431920255354000BBA0D /* Makefile.in in Resources */,
E3953F5920254989000BBA0D /* Assets.xcassets in Resources */,
E39547942026B2AA000BBA0D /* capture.pcap in Resources */,
E395455D202558E6000BBA0D /* protos.txt in Resources */,
E3953F5C2025498A000BBA0D /* Main.storyboard in Resources */,
E395431820255354000BBA0D /* Makefile.am in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -787,20 +801,20 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E39544F320255354000BBA0D /* mms.c in Sources */,
E39544F220255354000BBA0D /* mgcp.c in Sources */,
E39543B420255354000BBA0D /* checkmk.c in Sources */,
E39543D720255354000BBA0D /* http.c in Sources */,
E39543A420255354000BBA0D /* aimini.c in Sources */,
E39543DD20255354000BBA0D /* jabber.c in Sources */,
E35D5510228BA70600A80DED /* ajp.c in Sources */,
E395452820255354000BBA0D /* steam.c in Sources */,
E39543C720255354000BBA0D /* edonkey.c in Sources */,
E39543B520255354000BBA0D /* ciscovpn.c in Sources */,
E35D5511228BA70600A80DED /* snmp_proto.c in Sources */,
E39543B120255354000BBA0D /* bittorrent.c in Sources */,
E395452E20255354000BBA0D /* telegram.c in Sources */,
E39543DA20255354000BBA0D /* icecast.c in Sources */,
E395450620255354000BBA0D /* postgres.c in Sources */,
E395451E20255354000BBA0D /* socrates.c in Sources */,
E395450B20255354000BBA0D /* quic.c in Sources */,
E39543A820255354000BBA0D /* armagetron.c in Sources */,
E39543D120255354000BBA0D /* gtp.c in Sources */,
@@ -811,7 +825,6 @@
E395452620255354000BBA0D /* starcraft.c in Sources */,
E39543B620255354000BBA0D /* citrix.c in Sources */,
E395451320255354000BBA0D /* rtsp.c in Sources */,
E39543CA20255354000BBA0D /* filetopia.c in Sources */,
E39544F120255354000BBA0D /* megaco.c in Sources */,
E39543A920255354000BBA0D /* flash.c in Sources */,
E39544F820255354000BBA0D /* mysql.c in Sources */,
@@ -832,10 +845,12 @@
E395451420255354000BBA0D /* rx.c in Sources */,
E39543DC20255354000BBA0D /* irc.c in Sources */,
E395450320255354000BBA0D /* oscar.c in Sources */,
E35D551D228BA80000A80DED /* sha1-fast.c in Sources */,
E39543BC20255354000BBA0D /* dcerpc.c in Sources */,
E395454020255355000BBA0D /* world_of_warcraft.c in Sources */,
E39543A620255354000BBA0D /* apple_push.c in Sources */,
E395451920255354000BBA0D /* skype.c in Sources */,
E35D551E228BA80000A80DED /* ht_hash.c in Sources */,
E39543AC20255354000BBA0D /* popo.c in Sources */,
E39543BF20255354000BBA0D /* diameter.c in Sources */,
E39544FF20255354000BBA0D /* ntp.c in Sources */,
@@ -847,7 +862,6 @@
E39544EC20255354000BBA0D /* mail_imap.c in Sources */,
E395450C20255354000BBA0D /* radius.c in Sources */,
E395455F202558E6000BBA0D /* ndpiReader.c in Sources */,
E395451C20255354000BBA0D /* snmp.c in Sources */,
E395452520255354000BBA0D /* ssl.c in Sources */,
E39543D420255354000BBA0D /* halflife2_and_mods.c in Sources */,
E39544F920255354000BBA0D /* netbios.c in Sources */,
@@ -870,11 +884,13 @@
E395450D20255354000BBA0D /* rdp.c in Sources */,
E39544EA20255354000BBA0D /* lisp.c in Sources */,
E39544EF20255354000BBA0D /* maplestory.c in Sources */,
E35D5519228BA70600A80DED /* mining.c in Sources */,
E39544EB20255354000BBA0D /* lotus_notes.c in Sources */,
E395451F20255354000BBA0D /* someip.c in Sources */,
E39543DF20255354000BBA0D /* kerberos.c in Sources */,
E39543A720255354000BBA0D /* applejuice.c in Sources */,
E395452020255354000BBA0D /* sopcast.c in Sources */,
E35D5517228BA70600A80DED /* fbzero.c in Sources */,
E39543AD20255354000BBA0D /* secondlife.c in Sources */,
E395450720255354000BBA0D /* pplive.c in Sources */,
E395453120255354000BBA0D /* tftp.c in Sources */,
@@ -883,6 +899,7 @@
E39543D620255354000BBA0D /* hep.c in Sources */,
E39543E020255354000BBA0D /* kontiki.c in Sources */,
E39544FA20255354000BBA0D /* netflow.c in Sources */,
E35D5513228BA70600A80DED /* ookla.c in Sources */,
E395454220255355000BBA0D /* xdmcp.c in Sources */,
E39544F720255354000BBA0D /* mssql_tds.c in Sources */,
E395451A20255354000BBA0D /* smb.c in Sources */,
@@ -890,11 +907,12 @@
E395450520255354000BBA0D /* pcanywhere.c in Sources */,
E39547902026A51A000BBA0D /* ahocorasick.c in Sources */,
E395452320255354000BBA0D /* ssdp.c in Sources */,
E35D5518228BA70600A80DED /* nest_log_sink.c in Sources */,
E395431B20255354000BBA0D /* ndpi_content_match.c.inc in Sources */,
E395450120255354000BBA0D /* openvpn.c in Sources */,
E395453920255354000BBA0D /* vhua.c in Sources */,
E39544F020255354000BBA0D /* mdns.c in Sources */,
E39543C920255354000BBA0D /* fiesta.c in Sources */,
E35D5514228BA70600A80DED /* upnp.c in Sources */,
E395454120255355000BBA0D /* xbox.c in Sources */,
E395453D20255355000BBA0D /* warcraft3.c in Sources */,
E39543D220255354000BBA0D /* guildwars.c in Sources */,
@@ -902,12 +920,14 @@
E395450E20255354000BBA0D /* redis_net.c in Sources */,
E395455420255355000BBA0D /* node.c in Sources */,
E39543CE20255354000BBA0D /* ftp_data.c in Sources */,
E35D551F228BA88700A80DED /* ndpi_patricia.c in Sources */,
E395451D20255354000BBA0D /* socks45.c in Sources */,
E395451820255354000BBA0D /* skinny.c in Sources */,
E395453620255354000BBA0D /* tvuplayer.c in Sources */,
E39543CC20255354000BBA0D /* florensia.c in Sources */,
E3953F5720254989000BBA0D /* ViewController.m in Sources */,
E39544F520255354000BBA0D /* mqtt.c in Sources */,
E35D5516228BA70600A80DED /* mdns_proto.c in Sources */,
E39543C220255354000BBA0D /* dns.c in Sources */,
E39543B920255354000BBA0D /* corba.c in Sources */,
E39543B320255354000BBA0D /* btlib.c in Sources */,
@@ -927,6 +947,7 @@
E395453E20255355000BBA0D /* whoisdas.c in Sources */,
E39543BB20255354000BBA0D /* csgo.c in Sources */,
E395450A20255354000BBA0D /* qq.c in Sources */,
E35D5512228BA70600A80DED /* modbus.c in Sources */,
E395431C20255354000BBA0D /* ndpi_main.c in Sources */,
E39543BD20255354000BBA0D /* dhcp.c in Sources */,
E395454520255355000BBA0D /* zeromq.c in Sources */,
@@ -935,6 +956,7 @@
E395451120255354000BBA0D /* rtmp.c in Sources */,
E39544FE20255354000BBA0D /* non_tcp_udp.c in Sources */,
E39543C020255354000BBA0D /* directconnect.c in Sources */,
E35D5515228BA70600A80DED /* memcached.c in Sources */,
E39543D020255354000BBA0D /* gnutella.c in Sources */,
E39543D320255354000BBA0D /* h323.c in Sources */,
E395453720255354000BBA0D /* ubntac2.c in Sources */,
@@ -1087,6 +1109,7 @@
"$(inherited)",
"APP_HAS_OWN_MAIN=1",
"NDPI_LOG_DEBUG2=NDPI_LOG_DEBUG2_XCODE_PROJ",
NDPI_LIB_COMPILATION,
);
INFOPLIST_FILE = ndpiExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
@@ -1105,6 +1128,7 @@
GCC_PREPROCESSOR_DEFINITIONS = (
"APP_HAS_OWN_MAIN=1",
"NDPI_LOG_DEBUG2=NDPI_LOG_DEBUG2_XCODE_PROJ",
NDPI_LIB_COMPILATION,
);
INFOPLIST_FILE = ndpiExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+2 -2
View File
@@ -17,11 +17,11 @@ include $(RTE_SDK)/mk/rte.vars.mk
APP = ndpiReader.dpdk
LIBNDPI = $(PWD)/../src/lib/libndpi.a
SRCS-y := ndpi_util.c ndpiReader.c
SRCS-y := reader_util.c intrusion_detection.c ndpiReader.c
CFLAGS += -g
CFLAGS += -Wno-strict-prototypes -Wno-missing-prototypes -Wno-missing-declarations -Wno-unused-parameter -I $(PWD)/../src/include @CFLAGS@ -DUSE_DPDK
LDLIBS = $(LIBNDPI) @PCAP_LIB@ -lpthread @LDFLAGS@
LDLIBS = $(LIBNDPI) @PCAP_LIB@ @LIBS@ -lpthread -lm @LDFLAGS@
include $(RTE_SDK)/mk/rte.extapp.mk
+40 -8
View File
@@ -1,33 +1,65 @@
CC=@CC@
CFLAGS=-g -I../src/include @CFLAGS@
LIBNDPI=../src/lib/libndpi.a
LDFLAGS=$(LIBNDPI) @PCAP_LIB@ -lpthread @LDFLAGS@
OBJS=ndpiReader.o ndpi_util.o
PREFIX?=/usr/local
CXX=@CXX@
BUILD_MINGW=@BUILD_MINGW@
SRCHOME=../src
CFLAGS=-g -fPIC -DPIC -I$(SRCHOME)/include @PCAP_INC@ @CFLAGS@
LIBNDPI=$(SRCHOME)/lib/libndpi.a
LDFLAGS=$(LIBNDPI) @PCAP_LIB@ @LIBS@ @ADDITIONAL_LIBS@ -lpthread -lm @LDFLAGS@
HEADERS=intrusion_detection.h reader_util.h $(SRCHOME)/include/ndpi_api.h \
$(SRCHOME)/include/ndpi_typedefs.h $(SRCHOME)/include/ndpi_protocol_ids.h
OBJS=ndpiReader.o reader_util.o intrusion_detection.o
PREFIX?=@prefix@
ifneq ($(BUILD_MINGW),)
all:
@echo 'Examples disabled due to mingw build.'
else
all: ndpiReader @DPDK_TARGET@
ndpiReader: $(OBJS) $(LIBNDPI)
$(CXX) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
EXECUTABLE_SOURCES := ndpiReader.c ndpiSimpleIntegration.c
COMMON_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard *.c ))
libndpiReader.a: $(COMMON_SOURCES:%.c=%.o) $(LIBNDPI)
ar rsv libndpiReader.a $(COMMON_SOURCES:%.c=%.o)
ndpiReader: libndpiReader.a $(LIBNDPI) ndpiReader.o
$(CC) $(CFLAGS) ndpiReader.o libndpiReader.a -o $@ $(LDFLAGS)
ndpiSimpleIntegration: ndpiSimpleIntegration.o
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -c $< -o $@
install:
install: ndpiReader
mkdir -p $(DESTDIR)$(PREFIX)/bin/
mkdir -p $(DESTDIR)$(PREFIX)/share/ndpi
cp ndpiReader $(DESTDIR)$(PREFIX)/bin/
cp protos.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiProtos.txt
cp mining_hosts.txt $(DESTDIR)$(PREFIX)/share/ndpi/ndpiCustomCategory.txt
[ -f build/app/ndpiReader.dpdk ] && cp build/app/ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
[ -f ndpiReader.dpdk ] && cp ndpiReader.dpdk $(DESTDIR)$(PREFIX)/bin/ || true
dpdk:
make -f Makefile.dpdk
check:
cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I$(SRCHOME)/include *.c
clean:
/bin/rm -f *.o ndpiReader ndpiReader.dpdk
/bin/rm -f .*.dpdk.cmd .*.o.cmd *.dpdk.map .*.o.d
/bin/rm -f _install _postbuild _postinstall _preinstall
/bin/rm -rf build
distdir:
cp categories.txt mining_hosts.txt protos.txt README.DPDK '$(distdir)/'
find . -maxdepth 1 -type f -name '*.c' -o -name '*.h' -o -name '*.py' | xargs -I'{}' cp '{}' '$(distdir)/{}'
distclean: clean
/bin/rm -f Makefile.dpdk
/bin/rm -f Makefile
endif
+3
View File
@@ -0,0 +1,3 @@
# Format: name\tcategory_id
internetbadguys.com 100
144.139.247.220 100
+462
View File
@@ -0,0 +1,462 @@
/*
* intrusion_detection.c
*
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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 "intrusion_detection.h"
double normalize(ndpi_norm_value* tresholds){
if(tresholds->upper_bound != tresholds->lower_bound){
tresholds->norm_value = (tresholds->value - tresholds->lower_bound) / (tresholds->upper_bound - tresholds->lower_bound);
}else{
if(tresholds->value > tresholds->upper_bound){
tresholds->norm_value = 1 + (tresholds->value - tresholds->lower_bound) / tresholds->upper_bound;
}else{
tresholds->norm_value = 1 - (tresholds->value - tresholds->lower_bound) / tresholds->upper_bound;
}
}
if(tresholds->norm_value >= 0){
return tresholds->norm_value * tresholds->weight;
}
else{
return (1 - tresholds->norm_value) * tresholds->weight;
}
}
double get_flow_score(ndpi_norm_value* scores, int n_metrics){
double flow_score = 0;
for(int i=0; i<n_metrics; i++){
flow_score += normalize(&scores[i]);
}
return flow_score;
}
/* ********************************** */
double Ddos_score(struct ndpi_flow_info* flow){
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_c_to_s_avg */
int i = 0;
scores[i].lower_bound = 70.0;
scores[i].upper_bound = 263.4799999999999;
scores[i].weight = 0.21257330032661592;
scores[i].value = ndpi_data_average(flow->pktlen_c_to_s);
/* pktlen_s_to_c_max */
i++;
scores[i].lower_bound = 90.0;
scores[i].upper_bound = 2974.0;
scores[i].weight = 0.21073785073559176;
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
/* pktlen_s_to_c_avg */
i++;
scores[i].lower_bound = 72.7;
scores[i].upper_bound = 1130.4199999999996;
scores[i].weight = 0.21257330032661592;
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
/* pktlen_s_to_c_stddev */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 906.0;
scores[i].weight = 0.20990954527912953;
scores[i].value = ndpi_data_stddev(flow->pktlen_s_to_c);
/* fin */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.07710300166602348;
scores[i].value = flow->fin_count;
/* s_to_c_fin */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.07710300166602348;
scores[i].value = flow->dst2src_fin_count;
// sum = 1.0
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Dos_goldeneye_score(struct ndpi_flow_info* flow){
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_s_to_c_max */
int i = 0;
scores[i].lower_bound = 74.0;
scores[i].upper_bound = 3292.6699999999764;
scores[i].weight = 0.3123007140611667;
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
/* pktlen_s_to_c_avg */
i++;
scores[i].lower_bound = 68.7;
scores[i].upper_bound = 1354.0569999999987;
scores[i].weight = 0.23802038891633356;
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
/* pktlen_s_to_c_stddev */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 959.4469999999993;
scores[i].weight = 0.3111779763775991;
scores[i].value = ndpi_data_stddev(flow->pktlen_s_to_c);
/* syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.0464364305923564;
scores[i].value = flow->syn_count;
/* c_to_s_syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 1.0;
scores[i].weight = 0.04562805946018772;
scores[i].value = flow->src2dst_syn_count;
/* s_to_c_syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.0464364305923564;
scores[i].value = flow->dst2src_syn_count;
// sum = 0.9999999999999998
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Dos_hulk_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen_ms/1000.0, l = (double)flow->last_seen_ms/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* duration */
int i = 0;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 539.40668006422;
scores[i].weight = 0.16666666666666666;
scores[i].value = (l - f);
/* src2dst_packets */
i++;
scores[i].lower_bound = 2.0;
scores[i].upper_bound = 41.0;
scores[i].weight = 0.16666666666666666;
scores[i].value = flow->src2dst_packets;
/* dst2src_packets */
i++;
scores[i].lower_bound = 2.0;
scores[i].upper_bound = 45.0;
scores[i].weight = 0.16666666666666666;
scores[i].value = flow->dst2src_packets;
/* src2dst_bytes */
i++;
scores[i].lower_bound = 146.0;
scores[i].upper_bound = 6306.300000000001;
scores[i].weight = 0.16666666666666666;
scores[i].value = flow->src2dst_bytes;
/* ack */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 82.0;
scores[i].weight = 0.16666666666666666;
scores[i].value = flow->ack_count;
/* syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.16666666666666666;
scores[i].value = flow->syn_count;
// sum = 0.9999999999999999
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Dos_slow_score(struct ndpi_flow_info* flow){
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_s_to_c_max */
int i = 0;
scores[i].lower_bound = 90.0;
scores[i].upper_bound = 3135.0;
scores[i].weight = 0.1760747755022144;
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
/* pktlen_s_to_c_avg */
i++;
scores[i].lower_bound = 80.37100000000001;
scores[i].upper_bound = 1292.5900000000008;
scores[i].weight = 0.17600137023171597;
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
/* dst2src_bytes */
i++;
scores[i].lower_bound = 262.0;
scores[i].upper_bound = 53227.80000000002;
scores[i].weight = 0.16919914849886225;
scores[i].value = flow->dst2src_bytes;
/* syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.168000195747388;
scores[i].value = flow->syn_count;
/* c_to_s_syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 1.0;
scores[i].weight = 0.14272431427243143;
scores[i].value = flow->src2dst_syn_count;
/* s_to_c_syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.168000195747388;
scores[i].value = flow->dst2src_syn_count;
// sum = 1.0
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Ftp_patator_score(struct ndpi_flow_info* flow){
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* iat_flow_min */
int i = 0;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 24.0;
scores[i].weight = 0.002732919254658385;
scores[i].value = ndpi_data_min(flow->iat_flow);
/* pktlen_s_to_c_max */
i++;
scores[i].lower_bound = 90.0;
scores[i].upper_bound = 3393.0;
scores[i].weight = 0.007453416149068323;
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
/* pktlen_s_to_c_avg */
i++;
scores[i].lower_bound = 81.3;
scores[i].upper_bound = 1315.021;
scores[i].weight = 0.9833540372670807;
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
/* dst2src_bytes */
i++;
scores[i].lower_bound = 256.0;
scores[i].upper_bound = 56434.0;
scores[i].weight = 0.0034782608695652175;
scores[i].value = flow->dst2src_bytes;
/* fin */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.0014906832298136647;
scores[i].value = flow->fin_count;
/* rst */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.0014906832298136647;
scores[i].value = flow->rst_count;
// sum = 1.0
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Hearthbleed_score(struct ndpi_flow_info* flow){
double f = (double)flow->first_seen_ms/1000.0, l = (double)flow->last_seen_ms/1000.0;
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* iat_flow_max */
int i = 0;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 595213.3999999999;
scores[i].weight = 0.16666666666666666;
scores[i].value = ndpi_data_max(flow->iat_flow);
/* iat_flow_stddev */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 245377.74799999973;
scores[i].weight = 0.16666666666666666;
scores[i].value = ndpi_data_stddev(flow->iat_flow);
/* pktlen_s_to_c_max */
i++;
scores[i].lower_bound = 74.0;
scores[i].upper_bound = 3380.0;
scores[i].weight = 0.16666666666666666;
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
/* pktlen_s_to_c_avg */
i++;
scores[i].lower_bound = 70.0;
scores[i].upper_bound = 1344.6399999999996;
scores[i].weight = 0.16666666666666666;
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
/* pktlen_s_to_c_stddev */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 944.6399999999996;
scores[i].weight = 0.16666666666666666;
scores[i].value = ndpi_data_stddev(flow->pktlen_s_to_c);
/* duration */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 711.6677598000391;
scores[i].weight = 0.16666666666666666;
scores[i].value = (l - f);
// sum = 0.9999999999999999
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Infiltration_score(struct ndpi_flow_info* flow){
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* pktlen_c_to_s_max */
int i = 0;
scores[i].lower_bound = 72.0;
scores[i].upper_bound = 1840.739999999998;
scores[i].weight = 0.11937557392102846;
scores[i].value = ndpi_data_max(flow->pktlen_c_to_s);
/* pktlen_c_to_s_avg */
i++;
scores[i].lower_bound = 70.0;
scores[i].upper_bound = 296.56599999999816;
scores[i].weight = 0.12526782981328435;
scores[i].value = ndpi_data_average(flow->pktlen_c_to_s);
/* pktlen_s_to_c_max */
i++;
scores[i].lower_bound = 90.0;
scores[i].upper_bound = 3496.1399999999776;
scores[i].weight = 0.13927150290786652;
scores[i].value = ndpi_data_max(flow->pktlen_s_to_c);
/* pktlen_s_to_c_avg */
i++;
scores[i].lower_bound = 72.6;
scores[i].upper_bound = 1367.7959999999991;
scores[i].weight = 0.12182430364248545;
scores[i].value = ndpi_data_average(flow->pktlen_s_to_c);
/* src2dst_bytes */
i++;
scores[i].lower_bound = 144.0;
scores[i].upper_bound = 7847.69999999999;
scores[i].weight = 0.12059993878175697;
scores[i].value = flow->src2dst_bytes;
/* dst2src_bytes */
i++;
scores[i].lower_bound = 236.0;
scores[i].upper_bound = 74486.7799999998;
scores[i].weight = 0.3736608509335782;
scores[i].value = flow->dst2src_bytes;
// sum = 1.0
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
double Ssh_patator_score(struct ndpi_flow_info* flow){
int n_metrics = 6;
ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value));
/* fin */
int i = 0;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.0033738191632928477;
scores[i].value = flow->fin_count;
/* psh */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 30.0;
scores[i].weight = 0.33076923076923076;
scores[i].value = flow->psh_count;
/* c_to_s_syn */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 1.0;
scores[i].weight = 0.0004048582995951417;
scores[i].value = flow->src2dst_syn_count;
/* c_to_s_psh */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 12.0;
scores[i].weight = 0.33130904183535764;
scores[i].value = flow->src2dst_psh_count;
/* s_to_c_fin */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 2.0;
scores[i].weight = 0.0033738191632928477;
scores[i].value = flow->dst2src_fin_count;
/* s_to_c_psh */
i++;
scores[i].lower_bound = 0.0;
scores[i].upper_bound = 30.0;
scores[i].weight = 0.33076923076923076;
scores[i].value = flow->dst2src_psh_count;
// sum = 1.0
double flow_score = get_flow_score(scores, n_metrics);
free(scores);
return flow_score;
}
+69
View File
@@ -0,0 +1,69 @@
/*
* intrusion_detection.h
*
* Copyright (C) 2011-19 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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/>.
*
*/
#ifndef _INTRUSION_DETECTION_H_
#define _INTRUSION_DETECTION_H_
/*
Code to detect attacks reported in
https://www.unb.ca/cic/datasets/ids-2017.html
https://www.unb.ca/cic/datasets/ids-2018.html
*/
#include <stdio.h>
#include <stdlib.h>
#include "reader_util.h"
#include "ndpi_api.h"
typedef struct norm_values{
double upper_bound;
double lower_bound;
double weight;
double value;
double norm_value;
}ndpi_norm_value;
double normalize(ndpi_norm_value* tresholds);
double get_flow_score(ndpi_norm_value* scores, int n_metrics);
/* ********************************** */
double Ddos_score(struct ndpi_flow_info* flow);
double Dos_goldeneye_score(struct ndpi_flow_info* flow);
double Dos_hulk_score(struct ndpi_flow_info* flow);
double Dos_slow_score(struct ndpi_flow_info* flow);
double Ftp_patator_score(struct ndpi_flow_info* flow);
double Hearthbleed_score(struct ndpi_flow_info* flow);
double Infiltration_score(struct ndpi_flow_info* flow);
double Ssh_patator_score(struct ndpi_flow_info* flow);
#endif /* _INTRUSION_DETECTION_H_ */
+136
View File
@@ -0,0 +1,136 @@
#!/usr/bin/env python
#
# Copyright (C) 2019 - 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/>.
#
#
# Usage
#
# 1) Generate a CSV file using the ndpiReader tool. Example:
# ./ndpiReader -C sample.json -i sample.pcap
#
# 2) Open Google Chrome and type in the URL 'chrome://tracing/'
#
# 3) Inside Chrome click on 'Load' or drop sample.json in the
# Chrome window to visualize the output
#
import sys
import json
protos = {}
lastId = 1
def get_timestamp(seen):
tok = seen.split(".")
return int(tok[0]) * 1000 + int(tok[1])
def get_record(toks, csv_fields):
global protos
global lastId
if len(toks) < 11:
return None
record = dict()
ndpiProtocol = toks[10]
ndpi_protos = ndpiProtocol.split(".")
if(len(ndpi_protos) == 1):
app_proto = ndpi_protos[0]
else:
app_proto = ndpi_protos[1]
id = protos.get(ndpiProtocol)
if(id == None):
lastId = lastId + 1
protos[ndpiProtocol] = lastId
id = lastId
#print(ndpiProtocol+"="+str(id))
ip_address = toks[5]
server_name = toks[11]
record["cat"] = "flow"
record["pid"] = ip_address
record["tid"] = ndpiProtocol # id
record["ts"] = get_timestamp(toks[2])
record["ph"] = "X"
record["name"] = app_proto
if(server_name == ""):
args = {}
else:
args = { "name": server_name }
record["args"] = args
record["dur"] = get_timestamp(toks[3]) - record["ts"]
# if we do not have the legend we just return
if csv_fields is None:
return record
# Otherwise we just add everything we find as a string
if(0):
idx = 0
for tok in toks:
name = csv_fields[idx]
idx += 1
record["args"][name] = str(tok)
return record
def get_record_dict(filename):
csv_fields = None
records = []
fin = open(filename, "r");
for line in fin:
line = line.replace("\n","")
# Get the legend if present
if line[0] == '#':
csv_fields = []
line = line.replace("#", "")
toks = line.split(",")
for tok in toks:
csv_fields.append(tok)
continue
toks = line.split(",")
flow_id = int(toks[0])
record = get_record(toks, csv_fields)
if record is None:
print("Error while parsing " + line)
continue
records.append(record)
json_dict = dict()
json_dict["traceEvents"] = records
return json_dict
if __name__ == "__main__":
if len(sys.argv) != 3:
print("ndpi2json <csv_file> <json_file>")
sys.exit(0)
record_dict = get_record_dict(sys.argv[1])
#print(record_dict)
#json_string = json.dumps(json_dict)
#print(json_string)
with open(sys.argv[2], 'w') as fp:
json.dump(record_dict, fp)
print("Written " + str(len(record_dict["traceEvents"])) + " records")
+1522 -1273
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-1133
View File
File diff suppressed because it is too large Load Diff
+23 -6
View File
@@ -10,15 +10,32 @@ tcp:3000@ntop
# Format:
# host:"<value>",host:"<value>",.....@<subproto>
host:"googlesyndication.com"@Google
host:"venere.com"@Venere
host:"kataweb.it",host:"repubblica.it"@Repubblica
host:"ntop"@ntop
host:"disneyplus.com"host:"cdn.registerdisney.go.com",host:"disney-portal.my.onetrust.com",host:"disneyplus.bn5x.net",host:"disney-plus.net"@DisneyPlus
host:"*.lvlt.dash.us.aiv-cdn.net.c.footprint.net"@AmazonVideo
host:"api-global.netflix.com"@Netflix
# IP based Subprotocols
# Format:
# ip:<value>,ip:<value>,.....@<subproto>
ip:213.75.170.11@CustomProtocol
#
# NOTES
# 1) the port of a custom protocol is optional but if
# specified it must match the port.
# 2) you can specify up to 1 port per IP address
# 3) if you specify a custom ip:<IP>:<PORT> rule,
# even if the <PORT> doesn't match the <IP>
# (if best match during the search) will
# have priority as best match. Example if
# you specify a <Google IP>:<port 9999> and
# in your traffic have match for such IP but
# with a port other than 9999, the IP address
# begin a best match will hve preference over
# <Google IP> so this protocol will not be
# detected as <L7 proto>.Google but only
# as <L7 proto>
#
ip:213.75.170.11/32:443@CustomProtocol
ip:8.248.73.247:443@AmazonPrime
ip:54.80.47.130@AmazonPrime
File diff suppressed because it is too large Load Diff
+157 -9
View File
@@ -1,7 +1,7 @@
/*
* ndpi_util.h
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-19 - 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
@@ -29,7 +29,11 @@
#ifndef __NDPI_UTIL_H__
#define __NDPI_UTIL_H__
#include "uthash.h"
#include <pcap.h>
#include "ndpi_includes.h"
#include "ndpi_classify.h"
#include "ndpi_typedefs.h"
#ifdef USE_DPDK
#include <rte_eal.h>
@@ -47,8 +51,17 @@
#define PREFETCH_OFFSET 3
extern int dpdk_port_init(int port, struct rte_mempool *mbuf_pool);
extern int dpdk_port_deinit(int port);
#endif
/* ETTA Spec defiintions for feature readiness */
#define ETTA_MIN_PACKETS 10
#define ETTA_MIN_OCTETS 4000
/** maximum line length */
#define LINEMAX 512
#define MAX_BYTE_COUNT_ARRAY_LENGTH 256
#define MAX_NUM_PKTS 10
#define MAX_NUM_READER_THREADS 16
#define IDLE_SCAN_PERIOD 10 /* msec (use TICK_RESOLUTION = 1000) */
#define MAX_IDLE_TIME 30000
@@ -73,8 +86,76 @@ extern int dpdk_port_init(int port, struct rte_mempool *mbuf_pool);
#define MAX_TABLE_SIZE_2 8192
#define INIT_VAL -1
// inner hash table (ja3 -> security state)
typedef struct ndpi_ja3_info {
char * ja3;
ndpi_cipher_weakness unsafe_cipher;
UT_hash_handle hh;
} ndpi_ja3_info;
// external hash table (host ip -> <ip string, hash table ja3c, hash table ja3s>)
// used to aggregate ja3 fingerprints by hosts
typedef struct ndpi_host_ja3_fingerprints {
u_int32_t ip;
char *ip_string;
char *dns_name;
ndpi_ja3_info *host_client_info_hasht;
ndpi_ja3_info *host_server_info_hasht;
UT_hash_handle hh;
} ndpi_host_ja3_fingerprints;
//inner hash table
typedef struct ndpi_ip_dns{
u_int32_t ip;
char *ip_string;
char *dns_name; //server name if any;
UT_hash_handle hh;
} ndpi_ip_dns;
//hash table ja3 -> <host, ip, security>, used to aggregate host by ja3 fingerprints
typedef struct ndpi_ja3_fingerprints_host{
char *ja3; //key
ndpi_cipher_weakness unsafe_cipher;
ndpi_ip_dns *ipToDNS_ht;
UT_hash_handle hh;
} ndpi_ja3_fingerprints_host;
struct flow_metrics {
float entropy, average, stddev;
};
struct ndpi_entropy {
// Entropy fields
pkt_timeval src2dst_last_pkt_time, dst2src_last_pkt_time, flow_last_pkt_time;
u_int16_t src2dst_pkt_len[MAX_NUM_PKTS]; /*!< array of packet appdata lengths */
pkt_timeval src2dst_pkt_time[MAX_NUM_PKTS]; /*!< array of arrival times */
u_int16_t dst2src_pkt_len[MAX_NUM_PKTS]; /*!< array of packet appdata lengths */
pkt_timeval dst2src_pkt_time[MAX_NUM_PKTS]; /*!< array of arrival times */
pkt_timeval src2dst_start; /*!< first packet arrival time */
pkt_timeval dst2src_start; /*!< first packet arrival time */
u_int32_t src2dst_opackets; /*!< non-zero packet counts */
u_int32_t dst2src_opackets; /*!< non-zero packet counts */
u_int16_t src2dst_pkt_count; /*!< packet counts */
u_int16_t dst2src_pkt_count; /*!< packet counts */
u_int32_t src2dst_l4_bytes; /*!< packet counts */
u_int32_t dst2src_l4_bytes; /*!< packet counts */
u_int32_t src2dst_byte_count[MAX_BYTE_COUNT_ARRAY_LENGTH]; /*!< number of occurences of each byte */
u_int32_t dst2src_byte_count[MAX_BYTE_COUNT_ARRAY_LENGTH]; /*!< number of occurences of each byte */
u_int32_t src2dst_num_bytes;
u_int32_t dst2src_num_bytes;
double src2dst_bd_mean;
double src2dst_bd_variance;
double dst2src_bd_mean;
double dst2src_bd_variance;
float score;
};
// flow tracking
typedef struct ndpi_flow_info {
u_int32_t flow_id;
u_int32_t hashval;
u_int32_t src_ip;
u_int32_t dst_ip;
@@ -82,25 +163,78 @@ typedef struct ndpi_flow_info {
u_int16_t dst_port;
u_int8_t detection_completed, protocol, bidirectional, check_extra_packets;
u_int16_t vlan_id;
ndpi_packet_tunnel tunnel_type;
struct ndpi_flow_struct *ndpi_flow;
char src_name[48], dst_name[48];
u_int8_t ip_version;
u_int64_t last_seen;
u_int32_t cwr_count, src2dst_cwr_count, dst2src_cwr_count;
u_int32_t ece_count, src2dst_ece_count, dst2src_ece_count;
u_int32_t urg_count, src2dst_urg_count, dst2src_urg_count;
u_int32_t ack_count, src2dst_ack_count, dst2src_ack_count;
u_int32_t psh_count, src2dst_psh_count, dst2src_psh_count;
u_int32_t syn_count, src2dst_syn_count, dst2src_syn_count;
u_int32_t fin_count, src2dst_fin_count, dst2src_fin_count;
u_int32_t rst_count, src2dst_rst_count, dst2src_rst_count;
u_int32_t c_to_s_init_win, s_to_c_init_win;
u_int64_t first_seen_ms, last_seen_ms;
u_int64_t src2dst_bytes, dst2src_bytes;
u_int64_t src2dst_goodput_bytes, dst2src_goodput_bytes;
u_int32_t src2dst_packets, dst2src_packets;
u_int32_t has_human_readeable_strings;
char human_readeable_string_buffer[32];
// result only, not used for flow identification
ndpi_protocol detected_protocol;
char info[96];
char host_server_name[256];
// Flow data analysis
struct ndpi_analyze_struct *iat_c_to_s, *iat_s_to_c, *iat_flow,
*pktlen_c_to_s, *pktlen_s_to_c;
char info[160];
char flow_extra_info[16];
char host_server_name[240];
char bittorent_hash[41];
char dhcp_fingerprint[48];
ndpi_risk risk;
struct {
char client_info[64], server_info[64];
} ssh_ssl;
u_int16_t ssl_version;
char client_requested_server_name[64], server_info[64],
client_hassh[33], server_hassh[33], *server_names,
*tls_alpn, *tls_supported_versions,
*tls_issuerDN, *tls_subjectDN,
ja3_client[33], ja3_server[33],
sha1_cert_fingerprint[20];
u_int8_t sha1_cert_fingerprint_set;
struct {
u_int16_t cipher_suite;
char *esni;
} encrypted_sni;
time_t notBefore, notAfter;
u_int16_t server_cipher;
ndpi_cipher_weakness client_unsafe_cipher, server_unsafe_cipher;
} ssh_tls;
struct {
char url[256], content_type[64], user_agent[128];
u_int response_status_code;
} http;
struct {
char username[32], password[32];
} telnet;
void *src_id, *dst_id;
struct ndpi_entropy entropy;
struct ndpi_entropy last_entropy;
/* Payload lenght bins */
#ifdef DIRECTION_BINS
struct ndpi_bin payload_len_bin_src2dst, payload_len_bin_dst2src;
#else
struct ndpi_bin payload_len_bin;
#endif
} ndpi_flow_info_t;
@@ -154,7 +288,7 @@ typedef struct ndpi_workflow {
void **ndpi_flows_root;
struct ndpi_detection_module_struct *ndpi_struct;
u_int32_t num_allocated_flows;
} ndpi_workflow_t;
} ndpi_workflow_t;
/* TODO: remove wrappers parameters and use ndpi global, when their initialization will be fixed... */
@@ -175,7 +309,8 @@ void ndpi_free_flow_info_half(struct ndpi_flow_info *flow);
/* Process a packet and update the workflow */
struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
const struct pcap_pkthdr *header,
const u_char *packet);
const u_char *packet,
FILE * csv_fp);
/* flow callbacks for complete detected flow
@@ -194,10 +329,23 @@ static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow *
/* compare two nodes in workflow */
int ndpi_workflow_node_cmp(const void *a, const void *b);
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow, FILE * csv_fp);
u_int32_t ethernet_crc32(const void* data, size_t n_bytes);
void ndpi_flow_info_free_data(struct ndpi_flow_info *flow);
void ndpi_flow_info_freer(void *node);
const char* print_cipher_id(u_int32_t cipher);
float ndpi_flow_get_byte_count_entropy(const uint32_t byte_count[256], unsigned int num_bytes);
extern int nDPI_LogLevel;
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
#define LOG(log_level, args...) \
{ \
if(log_level <= nDPI_LogLevel) \
printf(args); \
}
#else
#define LOG(...) {}
#endif
#endif
+43
View File
@@ -0,0 +1,43 @@
bin_PROGRAMS = fuzz_process_packet fuzz_ndpi_reader fuzz_ndpi_reader_with_main
fuzz_process_packet_SOURCES = fuzz_process_packet.c
fuzz_process_packet_CFLAGS =
fuzz_process_packet_LDADD = ../src/lib/libndpi.a
fuzz_process_packet_LDFLAGS = $(ADDITIONAL_LIBS) $(LIBS)
if HAS_FUZZLDFLAGS
fuzz_process_packet_CFLAGS += $(LIB_FUZZING_ENGINE)
fuzz_process_packet_LDFLAGS += $(LIB_FUZZING_ENGINE)
endif
# force usage of CXX for linker
fuzz_process_packet_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(fuzz_process_packet_LDFLAGS) $(LDFLAGS) -o $@
fuzz_ndpi_reader_SOURCES = fuzz_ndpi_reader.c
fuzz_ndpi_reader_CFLAGS = -I../example/
fuzz_ndpi_reader_LDADD = ../src/lib/libndpi.a
fuzz_ndpi_reader_LDFLAGS = ../example/libndpiReader.a $(PCAP_LIB) $(ADDITIONAL_LIBS) $(LIBS)
if HAS_FUZZLDFLAGS
fuzz_ndpi_reader_CFLAGS += $(LIB_FUZZING_ENGINE)
fuzz_ndpi_reader_LDFLAGS += $(LIB_FUZZING_ENGINE)
endif
# force usage of CXX for linker
fuzz_ndpi_reader_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(fuzz_ndpi_reader_LDFLAGS) $(LDFLAGS) -o $@
fuzz_ndpi_reader_with_main_SOURCES = fuzz_ndpi_reader.c
fuzz_ndpi_reader_with_main_CFLAGS = -I../example/ -DBUILD_MAIN
fuzz_ndpi_reader_with_main_LDADD = ../src/lib/libndpi.a
fuzz_ndpi_reader_with_main_LDFLAGS = ../example/libndpiReader.a $(PCAP_LIB) $(ADDITIONAL_LIBS) $(LIBS)
# force usage of CXX for linker
fuzz_ndpi_reader_with_main_LINK=$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(fuzz_ndpi_reader_with_main_LDFLAGS) $(LDFLAGS) -o $@
# required for Google oss-fuzz
# see https://github.com/google/oss-fuzz/tree/master/projects/ndpi
testpcaps := $(wildcard ../tests/pcap/*.pcap)
fuzz_ndpi_reader_seed_corpus.zip: $(testpcaps)
zip -r fuzz_ndpi_reader_seed_corpus.zip $(testpcaps)
+163
View File
@@ -0,0 +1,163 @@
#include "reader_util.h"
#include "ndpi_api.h"
#include <pcap/pcap.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
struct ndpi_workflow_prefs *prefs = NULL;
int nDPI_LogLevel = 0;
char *_debug_protocols = NULL;
u_int32_t current_ndpi_memory = 0, max_ndpi_memory = 0;
u_int8_t enable_protocol_guess = 1, enable_payload_analyzer = 0;
u_int8_t enable_joy_stats = 0;
u_int8_t human_readeable_string_len = 5;
u_int8_t max_num_udp_dissected_pkts = 16 /* 8 is enough for most protocols, Signal requires more */, max_num_tcp_dissected_pkts = 80 /* due to telnet */;
int bufferToFile(const char * name, const uint8_t *Data, size_t Size) {
FILE * fd;
if (remove(name) != 0) {
if (errno != ENOENT) {
perror("remove failed");
return -1;
}
}
fd = fopen(name, "wb");
if (fd == NULL) {
perror("open failed");
return -2;
}
if (fwrite (Data, 1, Size, fd) != Size) {
fclose(fd);
return -3;
}
fclose(fd);
return 0;
}
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
pcap_t * pkts;
const u_char *pkt;
struct pcap_pkthdr *header;
int r;
char errbuf[PCAP_ERRBUF_SIZE];
NDPI_PROTOCOL_BITMASK all;
char * pcap_path = tempnam("/tmp", "fuzz-ndpi-reader");
if (prefs == NULL) {
prefs = calloc(sizeof(struct ndpi_workflow_prefs), 1);
if (prefs == NULL) {
//should not happen
return 1;
}
prefs->decode_tunnels = 1;
prefs->num_roots = 16;
prefs->max_ndpi_flows = 1024;
prefs->quiet_mode = 0;
}
bufferToFile(pcap_path, Data, Size);
pkts = pcap_open_offline(pcap_path, errbuf);
if (pkts == NULL) {
remove(pcap_path);
free(pcap_path);
return 0;
}
struct ndpi_workflow * workflow = ndpi_workflow_init(prefs, pkts);
// enable all protocols
NDPI_BITMASK_SET_ALL(all);
ndpi_set_protocol_detection_bitmask2(workflow->ndpi_struct, &all);
memset(workflow->stats.protocol_counter, 0,
sizeof(workflow->stats.protocol_counter));
memset(workflow->stats.protocol_counter_bytes, 0,
sizeof(workflow->stats.protocol_counter_bytes));
memset(workflow->stats.protocol_flows, 0,
sizeof(workflow->stats.protocol_flows));
ndpi_finalize_initalization(workflow->ndpi_struct);
r = pcap_next_ex(pkts, &header, &pkt);
while (r > 0) {
if(header->caplen >= 42 /* ARP+ size */) {
/* allocate an exact size buffer to check overflows */
uint8_t *packet_checked = malloc(header->caplen);
if(packet_checked) {
memcpy(packet_checked, pkt, header->caplen);
ndpi_workflow_process_packet(workflow, header, packet_checked, NULL);
free(packet_checked);
}
}
r = pcap_next_ex(pkts, &header, &pkt);
}
ndpi_workflow_free(workflow);
pcap_close(pkts);
remove(pcap_path);
free(pcap_path);
return 0;
}
#ifdef BUILD_MAIN
int main(int argc, char ** argv)
{
FILE * pcap_file;
long pcap_file_size;
uint8_t * pcap_buffer;
int test_retval;
if (argc != 2) {
fprintf(stderr, "usage: %s: [pcap-file]\n",
(argc > 0 ? argv[0] : "fuzz_ndpi_reader_with_main"));
return 1;
}
pcap_file = fopen(argv[1], "r");
if (pcap_file == NULL) {
perror("fopen failed");
return 1;
}
if (fseek(pcap_file, 0, SEEK_END) != 0) {
perror("fseek(SEEK_END) failed");
fclose(pcap_file);
return 1;
}
pcap_file_size = ftell(pcap_file);
if (pcap_file_size < 0) {
perror("ftell failed");
fclose(pcap_file);
return 1;
}
if (fseek(pcap_file, 0, SEEK_SET) != 0) {
perror("fseek(0, SEEK_SET) failed");
fclose(pcap_file);
return 1;
}
pcap_buffer = malloc(pcap_file_size);
if (pcap_buffer == NULL) {
perror("malloc failed");
fclose(pcap_file);
return 1;
}
if (fread(pcap_buffer, sizeof(*pcap_buffer), pcap_file_size, pcap_file) != pcap_file_size) {
perror("fread failed");
fclose(pcap_file);
return 1;
}
test_retval = LLVMFuzzerTestOneInput(pcap_buffer, pcap_file_size);
fclose(pcap_file);
free(pcap_buffer);
return test_retval;
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#include "ndpi_api.h"
#include <stdint.h>
#include <stdio.h>
struct ndpi_detection_module_struct *ndpi_info_mod = NULL;
struct ndpi_id_struct *src;
struct ndpi_id_struct *dst;
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (ndpi_info_mod == NULL) {
ndpi_info_mod = ndpi_init_detection_module(ndpi_no_prefs);
NDPI_PROTOCOL_BITMASK all;
NDPI_BITMASK_SET_ALL(all);
ndpi_set_protocol_detection_bitmask2(ndpi_info_mod, &all);
src = ndpi_malloc(SIZEOF_ID_STRUCT);
dst = ndpi_malloc(SIZEOF_ID_STRUCT);
}
struct ndpi_flow_struct *ndpi_flow = ndpi_flow_malloc(SIZEOF_FLOW_STRUCT);
memset(ndpi_flow, 0, SIZEOF_FLOW_STRUCT);
memset(src, 0, SIZEOF_ID_STRUCT);
memset(dst, 0, SIZEOF_ID_STRUCT);
ndpi_detection_process_packet(ndpi_info_mod, ndpi_flow, Data, Size, 0, src, dst);
ndpi_free_flow(ndpi_flow);
return 0;
}
+1 -1
View File
@@ -6,5 +6,5 @@ includedir=@includedir@
Name: libndpi
Description: deep packet inspection library
Version: @VERSION@
Libs: -L${libdir} -lndpi
Libs: -L${libdir} -lndpi @ADDITIONAL_LIBS@
Cflags: -I${includedir}/ndpi
+53
View File
@@ -0,0 +1,53 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
+6 -8
View File
@@ -1,22 +1,22 @@
#
# Copyright (C) 2018 - ntop.org
# Copyright (C) 2018-20 - ntop.org
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libndpi
PKG_VERSION:=1333.ab2f3ce
PKG_VERSION:=17022020
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/ntop/nDPI.git
PKG_SOURCE_VERSION:=ab2f3cefc89017d73e67faa4eb4011e7e3f2044d
PKG_SOURCE_VERSION:=1f921562d1d7962f1d23ca5b59c25f9b65073460
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_PROTO:=git
PKG_MAINTAINER:=Emanuele Faranda <faranda@ntop.org>
PKG_MAINTAINER:=Luca Deri <deri@ntop.org>
PKG_LICENSE:=GPL3
PKG_BUILD_DEPENDS:=+libpcap
PKG_BUILD_DEPENDS:=
PKG_BUILD_PARALLEL:=1
# autogen fix
@@ -27,7 +27,6 @@ include $(INCLUDE_DIR)/package.mk
define Package/libndpi
SECTION:=network
CATEGORY:=Network
#DEPENDS:=+libc +libjson-c +libpthread
TITLE:=nDPI Deep Packet Inspection Library
URL:=https://www.ntop.org
endef
@@ -37,8 +36,7 @@ define Package/libndpi/description
endef
CONFIGURE_ARGS += \
--with-pic \
--disable-json-c \
--with-only-libndpi
define Build/Prepare
$(call Build/Prepare/Default)
+25
View File
@@ -0,0 +1,25 @@
Howto Compile lindpi on OpenWRT
-------------------------------
cd myopenwrt_directory
mkdir package/network/services/libndpi
cd package/network/services/libndpi
cp ~/nDPI/packages/openwrt/Makefile .
cd myopenwrt_directory
make menuconfig
Go under network and select
<M> libndpi.............................. nDPI Deep Packet Inspection Library
Build Commands
--------------
If you want to build just libndpi do:
make -j1 V=s package/network/services/libndpi/clean
make -j1 V=s package/network/services/libndpi/compile
Other Documents
---------------
https://openwrt.org/packages/pkgdata/libndpi
+2 -2
View File
@@ -29,8 +29,8 @@ build-rpm: build-src cleanup-rpm
tar cvfz $(HOME)/rpmbuild/SOURCES/ndpi-@PACKAGE_VERSION@.tgz ndpi-@PACKAGE_VERSION@
@rm -f $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE)
@rpmbuild -bb ./$(APPL).spec --define "buildnumber $(GIT_REVISION)"
@if [[ $EUID -ne 0 ]]; then ./rpm-sign.exp $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE); fi
@if [[ $EUID -ne 0 ]]; then ./rpm-sign.exp $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(DEV_PACKAGE); fi
@if [[ $EUID -ne 0 ]]; then @RPM_SIGN_CMD@ $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE); fi
@if [[ $EUID -ne 0 ]]; then @RPM_SIGN_CMD@ $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(DEV_PACKAGE); fi
@echo ""
@echo "Package contents:"
@rpm -qpl $(HOME)/rpmbuild/RPMS/$(PLATFORM)/$(PACKAGE)
+12
View File
@@ -583,6 +583,7 @@ PACKAGE_URL=''
ac_subst_vars='LTLIBOBJS
LIBOBJS
RPM_SIGN_CMD
MAJOR_RELEASE
GIT_REVISION
KERNEL
@@ -1698,6 +1699,16 @@ PACKAGE_VERSION=`../version.sh --release`
MAJOR_RELEASE=`../version.sh --major-release`
GIT_REVISION=`../version.sh --revision`
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 3|cut -d '.' -f 1`
if test $CENTOS_RELEASE = "release"; then
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 4|cut -d '.' -f 1`
fi
RPM_SIGN_CMD="rpm --addsign"
if test "$CENTOS_RELEASE" -ne 8; then
RPM_SIGN_CMD="./rpm-sign.exp"
fi
ac_config_files="$ac_config_files Makefile ndpi.spec"
@@ -1710,6 +1721,7 @@ ac_config_files="$ac_config_files Makefile ndpi.spec"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
+11
View File
@@ -29,6 +29,16 @@ PACKAGE_VERSION=`../version.sh --release`
MAJOR_RELEASE=`../version.sh --major-release`
GIT_REVISION=`../version.sh --revision`
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 3|cut -d '.' -f 1`
if test $CENTOS_RELEASE = "release"; then
CENTOS_RELEASE=`cat /etc/centos-release | cut -d ' ' -f 4|cut -d '.' -f 1`
fi
RPM_SIGN_CMD="rpm --addsign"
if test "$CENTOS_RELEASE" -ne 8; then
RPM_SIGN_CMD="./rpm-sign.exp"
fi
AC_CONFIG_FILES([Makefile ndpi.spec])
AC_SUBST(PACKAGE_VERSION)
@@ -39,6 +49,7 @@ AC_SUBST(DATE)
AC_SUBST(KERNEL)
AC_SUBST(GIT_REVISION)
AC_SUBST(MAJOR_RELEASE)
AC_SUBST(RPM_SIGN_CMD)
AC_OUTPUT
+7 -2
View File
@@ -4,7 +4,6 @@ Version: @PACKAGE_VERSION@
Release: %{buildnumber}
License: LGPL
Group: Networking/Utilities
Conflicts: nprobe-dev
URL: http://www.ntop.org/products/deep-packet-inspection/ndpi/
Source: ndpi-%{version}.tgz
Packager: Luca Deri <deri@ntop.org>
@@ -13,6 +12,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-root
%{?el6:Requires: glibc >= 2.3.4 numactl coreutils }
AutoReqProv: no
%define debug_package %{nil}
%description
nDPI Open and Extensible LGPLv3 Deep Packet Inspection Library.
@@ -61,8 +62,10 @@ cd $RPM_BUILD_ROOT%{libdir}/; ln -s libndpi.so.@PACKAGE_VERSION@ libndpi.so.@MAJ
cd $RPM_BUILD_ROOT%{libdir}/; ln -s libndpi.so.@PACKAGE_VERSION@ libndpi.so; cd -
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
cp $HOME/nDPI/packages/etc/ld.so.conf.d/ndpi.conf $RPM_BUILD_ROOT/etc/ld.so.conf.d
rm -rf $RPM_BUILD_ROOT/usr/local/sbin/ndpi
strip $RPM_BUILD_ROOT%{bindir}/*
rm -fr %{buildroot}%{includedir}/ndpi_win32.h
#sed -i -e "s/#include \"ndpi_win32.h\"//g" %{buildroot}%{includedir}/ndpi_main.h
%clean
rm -fr $RPM_BUILD_ROOT
@@ -74,8 +77,10 @@ rm -fr $RPM_BUILD_ROOT
/usr/local/lib/libndpi.so.@MAJOR_RELEASE@
/usr/local/lib/libndpi.so.@PACKAGE_VERSION@
/usr/local/bin/ndpiReader
/usr/local/share/ndpi/ndpiCustomCategory.txt
/usr/local/share/ndpi/ndpiProtos.txt
/etc/ld.so.conf.d/ndpi.conf
/usr/local/libdata/pkgconfig/libndpi.pc
%{libdir}/pkgconfig/libndpi.pc
%preun
+26
View File
@@ -0,0 +1,26 @@
CC=@CC@
CFLAGS=-I. -I../src/include -I./src/lib/third_party/include @CFLAGS@ @CUSTOM_NDPI@ -shared
#LIBNDPI=../src/lib/libndpi.so.@NDPI_VERSION_SHORT@
LIBNDPI=../src/lib/libndpi.a
LDFLAGS=$(CFILE) $(LIBNDPI) -lpcap @ADDITIONAL_LIBS@
SHARE = -soname,ndpi_wrap
SO=ndpi_wrap.so
OBJS = ndpi_wrap.o
CFILE = ndpi_wrap.c
PIC = -fPIC
PREFIX?=/usr/local
.PHONY: all
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)#do something for linux
SHARE=-install_name,ndpiReader.so
endif
all: $(SO)
$(SO): $(CFILE) $(LIBNDPI) Makefile
$(CC) $(CFLAGS) -Wl,$(SHARE) -o $@ $(PIC) $(LDFLAGS)
# ln -s $(LIBNDPI) .
clean:
/bin/rm -f $(SO)
+43
View File
@@ -0,0 +1,43 @@
nDPI Python bindings
--------------------
This directory contains the Python3 bindings for nDPI. We provide both cffi and ctypes based bindings.
**cffi bindings**
Files:
* ndpi.py
Example (using `nfstream <https://github.com/aouinizied/nfstream>`_ package):
.. code-block:: bash
pip3 install nfstream
python3 flow_printer.py <interface>
python3 flow_printer.py <pcap_file>
Code courtesy:
* Zied Aouini
**ctypes bindings**
Files:
* ndpi_typestruct.py
* ndpi_wrap.c
* Makefile.in
Example:
.. code-block:: bash
pip3 install scapy
python3 ndpi_example.py <interface>
python3 ndpi_example.py <pcap_file>
Code courtesy:
* Massimo Puddu
* Zied Aouini
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------------------------------------------------
flow_printer.py
Copyright (C) 2019-20 - NFStream Developers
This file is part of NFStream, a Flexible Network Data Analysis Framework (https://www.nfstream.org/).
NFStream 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.
NFStream 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 NFStream.
If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------------------------------------------------------
"""
from nfstream import NFStreamer
import sys
# Example must run with nfstream >= 6.1.1
path = sys.argv[1]
flow_streamer = NFStreamer(source=path, statistical_analysis=False, performance_report=1)
result = {}
try:
for flow in flow_streamer:
print(flow)
try:
result[flow.application_name] += flow.bidirectional_packets
except KeyError:
result[flow.application_name] = flow.bidirectional_packets
print("\nSummary (Application Name: Packets):")
print(result)
except KeyboardInterrupt:
print("\nSummary (Application Name: Packets):")
print(result)
print("Terminated.")
+1459
View File
File diff suppressed because it is too large Load Diff
+273
View File
@@ -0,0 +1,273 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
file: ndpi_example.py
This file is part of nDPI.
Copyright (C) 2011-19 - ntop.org
Copyright (C) 2019 - Zied Aouini <aouinizied@gmail.com> (Incremental improvements)
nDPI is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with nDPI.
If not, see <http://www.gnu.org/licenses/>.
"""
from ndpi_typestruct import *
from ctypes import *
from scapy.all import *
import sys
# ------- return type & pcapstruct to declare -------
class WorkFlow(Structure):
_fields_ = [("src_ip", c_uint32),
("dst_ip", c_uint32),
("src_port", c_uint16),
("dst_port", c_uint16),
("protocol", c_uint8),
("packets", c_uint32),
("detected_protocol", NDPIProtocol),
("detection_completed", c_uint8),
("id", c_uint32),
("src_id", POINTER(NDPIIdStruct)),
("dst_id", POINTER(NDPIIdStruct)),
("flow", POINTER(NDPIFlowStruct))]
CMCFUN = CFUNCTYPE(c_int, c_void_p, c_void_p)
GUESS = CFUNCTYPE(None, c_void_p, c_int32, c_int, c_void_p)
FREE = CFUNCTYPE(None, c_void_p)
def node_proto_guess_walker(nodo, which, depth, user_data):
global ndpi_info_mod
flow = cast(nodo, POINTER(POINTER(WorkFlow))).contents.contents
if which == 0 or which == 3: # execute only preorder operation of the tree
if flow.detection_completed == 0: # order for tree operation
flow.detected_protocol = ndpi.ndpi_detection_giveup(ndpi_info_mod,
flow.flow,
1,
cast(addressof(c_uint8(0)), POINTER(c_uint8)))
count_protocol[flow.detected_protocol.app_protocol] += flow.packets
def py_cmp_fun(a, b):
fa = cast(a, POINTER(WorkFlow))
fb = cast(b, POINTER(WorkFlow))
if fa.contents.src_ip < fb.contents.src_ip: return -1
elif fa.contents.src_ip > fb.contents.src_ip: return 1
if fa.contents.src_port < fb.contents.src_port: return -1
elif fa.contents.src_port > fb.contents.src_port: return 1
if fa.contents.dst_ip < fb.contents.dst_ip: return -1
elif fa.contents.dst_ip > fb.contents.dst_ip: return 1
if fa.contents.dst_port < fb.contents.dst_port: return -1
elif fa.contents.dst_port > fb.contents.dst_port: return 1
if fa.contents.protocol < fb.contents.protocol: return -1
elif fa.contents.protocol > fb.contents.protocol: return 1
return 0
def freer(a):
pass
cmp_func = CMCFUN(py_cmp_fun)
guess_walker = GUESS(node_proto_guess_walker)
free_walk = FREE(freer)
# --------------------------------------
# number of analyzed packet
packet_number = 0
flow_count = 0
max_num_udp_dissected_pkts = 16
max_num_tcp_dissected_pkts = 10
flows_root = c_void_p(None)
flows_root_ref = pointer(flows_root)
count_protocol = (c_int32 * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + ndpi.ndpi_wrap_ndpi_max_num_custom_protocols() + 1))()
lista = [] # used to avoid impropriate memory deallocation from python
# check ndpi version
if ndpi.ndpi_get_api_version() != ndpi.ndpi_wrap_get_api_version():
print("nDPI Library version mismatch: please make sure this code and the nDPI library are in sync\n")
sys.exit(-1)
# create data structure of ndpi
ndpi_info_mod = ndpi.ndpi_init_detection_module()
if ndpi_info_mod is None:
sys.exit(-1)
else:
ndpi_ndpi_finalize_initalization(ndpi_info_mod)
def ip2int(ip):
"""
Convert an IP string to long and then c_uint32
"""
packedIP = socket.inet_aton(ip)
return int(struct.unpack("!I", packedIP)[0])
def get_flow(pkt):
global flows_root
global flows_root_ref
global flow_count
ip_packet = pkt[1]
ip_protocol = ip_packet.proto
transport_packet = None
if ip_protocol == 6 or ip_protocol == 17:
transport_packet = pkt[2]
if transport_packet is not None:
# to avoid two nodes in one binary tree for a flow
ip_src = ip2int(ip_packet.src)
ip_dst = ip2int(ip_packet.dst)
src_port = transport_packet.sport
dst_port = transport_packet.dport
else:
return None
# set flows to correct type and data
ndpi_flow = pointer(NDPIFlowStruct())
memset(ndpi_flow, 0, sizeof(NDPIFlowStruct))
if ip_src > ip_dst:
flow = WorkFlow(ip_src, ip_dst, src_port, dst_port, int(ip_packet.proto), 0, NDPIProtocol(), 0, 0,
pointer(NDPIIdStruct()), pointer(NDPIIdStruct()), ndpi_flow)
else:
flow = WorkFlow(ip_dst, ip_src, dst_port, src_port, int(ip_packet.proto), 0, NDPIProtocol(), 0, 0,
pointer(NDPIIdStruct()), pointer(NDPIIdStruct()), ndpi_flow)
flow_ref = pointer(flow)
res = ndpi.ndpi_tfind(flow_ref, flows_root_ref, cmp_func)
if res is None:
ndpi.ndpi_tsearch(flow_ref, pointer(flows_root), cmp_func) # add
lista.append(flow)
flow_count += 1
return pointer(flow)
flow = cast(res, POINTER(POINTER(WorkFlow))).contents
return flow
def packetcaptured(pkt):
global packet_number
global ndpi_info_mod
flow = None
h = PcapPktHdr()
# getting flow
try:
flow = get_flow(pkt)
except AttributeError:
pass # ignore packet
if flow is None: return
# filling pcap_pkthdr
h.len = h.caplen = len(pkt)
h.ts.tv_sec = int(pkt["IP"].time/1000000)
h.ts.tv_usec = int(pkt["IP"].time)
# real work
if int(pkt[1].frag) == 0: # not fragmented packet
flow.contents.packets += 1
packet_number += 1
# get ndpi_iphdr address
iphdr_addr = cast(c_char_p(pkt[1].build()), c_void_p)
ndpi_flow = flow.contents.flow
if flow.contents.detection_completed is 0:
flow.contents.detected_protocol = ndpi.ndpi_detection_process_packet(ndpi_info_mod,
ndpi_flow,
cast(iphdr_addr, POINTER(c_uint8)),
int(pkt[1].len),
h.ts.tv_usec,
flow.contents.src_id,
flow.contents.dst_id)
flow1 = flow.contents.detected_protocol
valid = False
if flow.contents.protocol == 6: valid = flow.contents.packets > max_num_tcp_dissected_pkts
elif flow.contents.protocol == 17: valid = flow.contents.packets > max_num_udp_dissected_pkts
# should we continue anylizing packet or not?
if valid or flow1.app_protocol is not 0:
if valid or flow1.master_protocol is not 91: # or # 91 is NDPI_PROTOCOL_TLS
flow.contents.detection_completed = 1 # protocol found
if flow1.app_protocol is 0:
flow.contents.detected_protocol = ndpi.ndpi_detection_giveup(ndpi_info_mod,
ndpi_flow,
1,
cast(addressof(c_uint8(0)),
POINTER(c_uint8)))
def result():
global flows_root_ref
global ndpi_info_mod
print('\nnumber of analyzed packet: ' + str(packet_number))
print('number of flows: ' + str(flow_count))
ndpi.ndpi_twalk(flows_root_ref.contents, guess_walker, None)
print('\nDetected protocols:')
for i in range(0, ndpi.ndpi_get_num_supported_protocols(ndpi_info_mod)):
if count_protocol[i] > 0:
print("{}: {} packets".format(
cast(ndpi.ndpi_get_proto_name(ndpi_info_mod, i), c_char_p).value.decode('utf-8'),
str(count_protocol[i])))
def free(ndpi_struct):
ndpi.ndpi_tdestroy(flows_root, free_walk)
ndpi.ndpi_exit_detection_module(ndpi_struct)
def initialize(ndpi_struct):
all = NDPIProtocolBitMask()
ndpi.ndpi_wrap_NDPI_BITMASK_SET_ALL(pointer(all))
ndpi.ndpi_set_protocol_detection_bitmask2(ndpi_struct, pointer(all))
print('Using nDPI ' + cast(ndpi.ndpi_revision(), c_char_p).value.decode("utf-8"))
initialize(ndpi_info_mod)
if len(sys.argv) != 2:
print("\nUsage: ndpi_example.py <device>")
sys.exit(0)
if "." in sys.argv[1]:
print('Reading pcap from file ' + sys.argv[1] + '...')
scapy_cap = None
try:
scapy_cap = rdpcap(sys.argv[1])
except FileNotFoundError:
print("\nFile not found")
except Scapy_Exception:
print("\nBad pcap")
else:
for packet in scapy_cap:
packetcaptured(packet)
else:
print('Capturing live traffic from device ' + sys.argv[1] + '...')
try:
sniff(iface=sys.argv[1], prn=packetcaptured)
except KeyboardInterrupt:
print('\nInterrupted\n')
except PermissionError:
sys.exit('\nRoot privilege required for live capture on interface: {}\n'.format(sys.argv[1]))
result()
free(ndpi_info_mod)
+864
View File
@@ -0,0 +1,864 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
file: ndpi_typestruct.py
This file is part of nDPI.
Copyright (C) 2011-19 - ntop.org
Copyright (C) 2019 - Zied Aouini <aouinizied@gmail.com> (Incremental improvements)
nDPI is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with nDPI.
If not, see <http://www.gnu.org/licenses/>.
"""
from ctypes import CDLL, Structure, c_uint16, c_int, c_ulong, c_uint32, CFUNCTYPE, c_void_p, POINTER, c_char_p, c_uint8
from ctypes import c_char, c_uint, c_int16, c_longlong, c_size_t, Union, c_ubyte, c_uint64, c_int32, c_ushort, cast
from os.path import abspath, dirname
ndpi = CDLL(dirname(abspath(__file__)) + '/ndpi_wrap.so')
# ----------------------------------------------- Structures -----------------------------------------------------------
class NDPIDetectionModuleStruct(Structure):
pass
class NDPIFlowStruct(Structure):
pass
class NDPIProtocol(Structure):
_fields_ = [
("master_protocol", c_uint16),
("app_protocol", c_uint16),
("category", c_int)
]
class TimeVal(Structure):
_fields_ = [("tv_sec", c_ulong), ("tv_usec", c_ulong)]
class PcapPktHdr(Structure):
_fields_ = [("ts", TimeVal), ("caplen", c_uint32), ("len", c_uint32)]
class NDPIMask(Structure):
_fields_ = [("fds_bits", c_uint32)]
class NDPIProtocolBitMask(Structure):
_fields_ = [("fds_bits", NDPIMask * ndpi.ndpi_wrap_ndpi_num_fds_bits())]
class NDPISubprotocolConfStruct(Structure):
_fields_ = [("func", CFUNCTYPE(c_void_p, POINTER(NDPIDetectionModuleStruct), c_char_p, c_char_p, c_int))]
class NDPIAutoma(Structure):
_fields_ = [
("ac_automa", c_void_p),
("ac_automa_finalized", c_uint8)
]
class NDPINode(Structure):
pass
NDPINode._fields_ = [
('key', POINTER(c_char)),
('left', POINTER(NDPINode)),
('right', POINTER(NDPINode)),
]
class NDPICallFunctionStruct(Structure):
_fields_ = [
("detection_bitmask", NDPIProtocolBitMask),
("excluded_protocol_bitmask", NDPIProtocolBitMask),
("ndpi_selection_bitmask", c_uint32),
("func", CFUNCTYPE(None, POINTER(NDPIDetectionModuleStruct), POINTER(NDPIFlowStruct))),
("detection_feature", c_uint8)
]
class NDPIProtoDefaultsT(Structure):
_fields_ = [
("protoName", c_char_p),
("protoCategory", c_uint),
("can_have_a_subprotocol", c_uint8),
("protoId", c_uint16),
("protoIdx", c_uint16),
("master_tcp_protoId", c_uint16 * 2),
("master_udp_protoId", c_uint16 * 2),
("protoBreed", c_uint),
("func", CFUNCTYPE(None, POINTER(NDPIDetectionModuleStruct), POINTER(NDPIFlowStruct))),
]
class NDPIDefaultsPortsTreeNodeT(Structure):
_fields_ = [
("proto", NDPIProtoDefaultsT),
("customUserProto", c_uint8),
("default_port", c_int16)
]
class SpinlockT(Structure):
_fields_ = [("val", c_int)]
class AtomicT(Structure):
_fields_ = [("counter", c_int)]
class TimeT(Structure):
_fields_ = [("counter", c_longlong)]
class HashIp4pNode(Structure):
pass
HashIp4pNode._fields_ = [
("next", POINTER(HashIp4pNode)),
("prev", POINTER(HashIp4pNode)),
("lchg", TimeT),
("port", c_uint16),
("count", c_uint16, 12),
("flag", c_uint16, 4),
("ip", c_uint32)
]
class HashIp4p(Structure):
_fields_ = [
("top", POINTER(HashIp4pNode)),
("lock",SpinlockT),
("len", c_size_t)
]
class HashIp4pTable(Structure):
_fields_ = [
("size", c_size_t),
("ipv6", c_int),
("lock", SpinlockT),
("count", AtomicT),
("tbl", HashIp4p)
]
class BtAnnounce(Structure):
_fields_ = [
("hash", c_uint32 * 5),
("ip", c_uint32 * 4),
("time", c_uint32),
("port", c_uint16),
("name_len", c_uint8),
("name", c_uint8 * 149)
]
class NDPILruCacheEntry(Structure):
_fields_ = [
("key", c_uint32),
("is_full", c_uint32, 1),
("value", c_uint32, 16),
("pad", c_uint32, 15)
]
class NDPILruCache(Structure):
_fields_ = [
("num_entries", c_uint32),
("entries", POINTER(NDPILruCacheEntry)),
]
class CacheEntry(Structure):
pass
CacheEntry._fields_ = [
("item", c_void_p),
("item_size", c_uint32),
("prev", POINTER(CacheEntry)),
("next", POINTER(CacheEntry))
]
class CacheEntryMap(Structure):
pass
CacheEntryMap._fields_ = [
("entry", POINTER(CacheEntry)),
("next", POINTER(CacheEntryMap)),
]
class Cache(Structure):
_fields_ = [
("size", c_uint32),
("max_size", c_uint32),
("head", POINTER(CacheEntry)),
("tail", POINTER(CacheEntry)),
("map", POINTER(POINTER(CacheEntryMap)))
]
class CustomCategories(Structure):
_fields_ = [
("hostnames", NDPIAutoma),
("hostnames_shadow", NDPIAutoma),
("ipAddresses", c_void_p),
("ipAddresses_shadow", c_void_p),
("categories_loaded", c_uint8),
]
NDPIDetectionModuleStruct._fields_ = [
("detection_bitmask", NDPIProtocolBitMask),
("generic_http_packet_bitmask", NDPIProtocolBitMask),
("current_ts", c_uint32),
("ticks_per_second", c_uint32),
("custom_category_labels",
(c_char * ndpi.ndpi_wrap_num_custom_categories()) * ndpi.ndpi_wrap_custom_category_label_len()),
("callback_buffer", NDPICallFunctionStruct * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + 1)),
("callback_buffer_size", c_uint32),
("callback_buffer_tcp_no_payload", NDPICallFunctionStruct * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + 1)),
("callback_buffer_size_tcp_no_payload", c_uint32),
("callback_buffer_tcp_payload", NDPICallFunctionStruct * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + 1)),
("callback_buffer_size_tcp_payload", c_uint32),
("callback_buffer_udp", NDPICallFunctionStruct * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + 1)),
("callback_buffer_size_udp", c_uint32),
("callback_buffer_non_tcp_udp", NDPICallFunctionStruct * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + 1)),
("callback_buffer_size_non_tcp_udp", c_uint32),
("tcpRoot", POINTER(NDPIDefaultsPortsTreeNodeT)),
("udpRoot", POINTER(NDPIDefaultsPortsTreeNodeT)),
("ndpi_log_level", c_uint),
("tcp_max_retransmission_window_size", c_uint32),
("directconnect_connection_ip_tick_timeout", c_uint32),
("subprotocol_conf", NDPISubprotocolConfStruct * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() + 1)),
("ndpi_num_supported_protocols", c_uint),
("ndpi_num_custom_protocols", c_uint),
("host_automa", NDPIAutoma),
("content_automa", NDPIAutoma),
("subprotocol_automa", NDPIAutoma),
("bigrams_automa", NDPIAutoma),
("impossible_bigrams_automa", NDPIAutoma),
("custom_categories", CustomCategories),
("protocols_ptree", c_void_p),
("irc_timeout", c_uint32),
("gnutella_timeout", c_uint32),
("battlefield_timeout", c_uint32),
("thunder_timeout", c_uint32),
("soulseek_connection_ip_tick_timeout", c_uint32),
("rtsp_connection_timeout", c_uint32),
("tvants_connection_timeout", c_uint32),
("orb_rstp_ts_timeout", c_uint32),
("yahoo_detect_http_connections", c_uint8),
("yahoo_lan_video_timeout", c_uint32),
("zattoo_connection_timeout", c_uint32),
("jabber_stun_timeout", c_uint32),
("jabber_file_transfer_timeout", c_uint32),
("ip_version_limit", c_uint8),
("bt_ht", POINTER(HashIp4pTable)),
("bt6_ht", POINTER(HashIp4pTable)),
("bt_ann", POINTER(BtAnnounce)),
("bt_ann_len", c_int),
("ookla_cache", POINTER(NDPILruCache)),
("tinc_cache", POINTER(Cache)),
("proto_defaults", NDPIProtoDefaultsT * (ndpi.ndpi_wrap_ndpi_max_supported_protocols() +
ndpi.ndpi_wrap_ndpi_max_num_custom_protocols())),
("http_dont_dissect_response", c_uint8, 1),
("dns_dont_dissect_response", c_uint8, 1),
("direction_detect_disable", c_uint8, 1),
("disable_metadata_export", c_uint8, 1),
("hyperscan", c_void_p)
]
class U6Addr(Union):
_fields_ = [
("u6_addr8", c_uint8 * 16),
("u6_addr16", c_uint16 * 8),
("u6_addr32", c_uint32 * 4),
("u6_addr64", c_uint64 * 2)
]
class NDPIIn6Addr(Structure):
_pack_ = 1
_fields_ = [("u6_addr", U6Addr)]
class NDPIIpAddrT(Union):
_fields_ = [
('ipv4', c_uint32),
('ipv4_u_int8_t', c_uint8 * 4),
('ipv6', NDPIIn6Addr),
]
class NDPIIdStruct(Structure):
_fields_ = [
('detected_protocol_bitmask', NDPIProtocolBitMask),
('rtsp_ip_address', NDPIIpAddrT),
('yahoo_video_lan_timer', c_uint32),
('irc_port', c_uint16 * 8),
('last_time_port_used', c_uint32 * 8),
('irc_ts', c_uint32),
('gnutella_ts', c_uint32),
('battlefield_ts', c_uint32),
('thunder_ts', c_uint32),
('rtsp_timer', c_uint32),
('oscar_last_safe_access_time', c_uint32),
('zattoo_ts', c_uint32),
('jabber_stun_or_ft_ts', c_uint32),
('directconnect_last_safe_access_time', c_uint32),
('soulseek_last_safe_access_time', c_uint32),
('detected_directconnect_port', c_uint16),
('detected_directconnect_udp_port', c_uint16),
('detected_directconnect_ssl_port', c_uint16),
('bt_port_t', c_uint16 * 8),
('bt_port_u', c_uint16 * 8),
('jabber_voice_stun_port', c_uint16 * 6),
('jabber_file_transfer_port', c_uint16 * 2),
('detected_gnutella_port', c_uint16),
('detected_gnutella_udp_port1', c_uint16),
('detected_gnutella_udp_port2', c_uint16),
('soulseek_listen_port', c_uint16),
('irc_number_of_port', c_uint8),
('oscar_ssl_session_id', c_uint8 * 33),
('jabber_voice_stun_used_ports', c_uint8),
('yahoo_video_lan_dir', c_uint32, 1),
('yahoo_conf_logged_in', c_uint32, 1),
('yahoo_voice_conf_logged_in', c_uint32, 1),
('rtsp_ts_set', c_uint32, 1),
]
class NDPIFlowTcpStruct(Structure):
_pack_ = 1
_fields_ = [
('smtp_command_bitmask', c_uint16),
('pop_command_bitmask', c_uint16),
('qq_nxt_len', c_uint16),
('wa_matched_so_far', c_uint8),
('tds_login_version', c_uint8),
('irc_stage', c_uint8),
('irc_port', c_uint8),
('h323_valid_packets', c_uint8),
('gnutella_msg_id', c_uint8 * 3),
('irc_3a_counter', c_uint32, 3),
('irc_stage2', c_uint32, 5),
('irc_direction', c_uint32, 2),
('irc_0x1000_full', c_uint32, 1),
('soulseek_stage', c_uint32, 2),
('tds_stage', c_uint32, 3),
('usenet_stage', c_uint32, 2),
('imesh_stage', c_uint32, 4),
('http_setup_dir', c_uint32, 2),
('http_stage', c_uint32, 2),
('http_empty_line_seen', c_uint32, 1),
('http_wait_for_retransmission', c_uint32, 1),
('gnutella_stage', c_uint32, 2),
('mms_stage', c_uint32, 2),
('yahoo_sip_comm', c_uint32, 1),
('yahoo_http_proxy_stage', c_uint32, 2),
('msn_stage', c_uint32, 3),
('msn_ssl_ft', c_uint32, 2),
('ssh_stage', c_uint32, 3),
('vnc_stage', c_uint32, 2),
('telnet_stage', c_uint32, 2),
('tls_srv_cert_fingerprint_ctx', c_void_p),
('tls_seen_client_cert', c_uint8, 1),
('tls_seen_server_cert', c_uint8, 1),
('tls_seen_certificate', c_uint8, 1),
('tls_srv_cert_fingerprint_found', c_uint8, 1),
('tls_srv_cert_fingerprint_processed', c_uint8, 1),
('tls_stage', c_uint8, 2),
('tls_record_offset', c_int16),
('tls_fingerprint_len', c_int16),
('tls_sha1_certificate_fingerprint', c_uint8 * 20),
('postgres_stage', c_uint32, 3),
('ddlink_server_direction', c_uint32, 1),
('seen_syn', c_uint32, 1),
('seen_syn_ack', c_uint32, 1),
('seen_ack', c_uint32, 1),
('icecast_stage', c_uint32, 1),
('dofus_stage', c_uint32, 1),
('fiesta_stage', c_uint32, 2),
('wow_stage', c_uint32, 2),
('veoh_tv_stage', c_uint32, 2),
('shoutcast_stage', c_uint32, 2),
('rtp_special_packets_seen', c_uint32, 1),
('mail_pop_stage', c_uint32, 2),
('mail_imap_stage', c_uint32, 3),
('mail_imap_starttls', c_uint32, 2),
('skype_packet_id', c_uint8),
('citrix_packet_id', c_uint8),
('lotus_notes_packet_id', c_uint8),
('teamviewer_stage', c_uint8),
('prev_zmq_pkt_len', c_uint8),
('prev_zmq_pkt', c_char * 10),
('ppstream_stage', c_uint32, 3),
('memcached_matches', c_uint8),
('nest_log_sink_matches', c_uint8),
]
class NDPIFlowUdpStruct(Structure):
_pack_ = 1
_fields_ = [
('battlefield_msg_id', c_uint32),
('snmp_msg_id', c_uint32),
('battlefield_stage', c_uint32, 3),
('snmp_stage', c_uint32, 2),
('ppstream_stage', c_uint32, 3),
('halflife2_stage', c_uint32, 2),
('tftp_stage', c_uint32, 1),
('aimini_stage', c_uint32, 5),
('xbox_stage', c_uint32, 1),
('wsus_stage', c_uint32, 1),
('skype_packet_id', c_uint8),
('teamviewer_stage', c_uint8),
('eaq_pkt_id', c_uint8),
('eaq_sequence', c_uint32),
('rx_conn_epoch', c_uint32),
('rx_conn_id', c_uint32),
('memcached_matches', c_uint8),
('wireguard_stage', c_uint8),
('wireguard_peer_index', c_uint32 * 2),
]
class L4(Union):
_fields_ = [("tcp", NDPIFlowTcpStruct), ("udp", NDPIFlowUdpStruct)]
class Http(Structure):
_fields_ = [
("method", c_int),
("url", c_char_p),
("content_type", c_char_p),
("num_request_headers", c_uint8),
("num_response_headers", c_uint8),
("request_version", c_uint8),
("response_status_code", c_uint16),
]
class Dns(Structure):
_fields_ = [
("num_queries", c_uint8),
("num_answers", c_uint8),
("reply_code", c_uint8),
("is_query", c_uint8),
("query_type", c_uint16),
("query_class", c_uint16),
("rsp_type", c_uint16),
("rsp_addr", NDPIIpAddrT)
]
class Ntp(Structure):
_fields_ = [("request_code", c_uint8),
("version", c_uint8)]
class Kerberos(Structure):
_fields_ = [("cname", c_char * 24),
("realm", c_char * 24)]
class Ssl(Structure):
_fields_ = [
("ssl_version", c_uint16),
("client_certificate", c_char * 64),
("server_certificate", c_char * 64),
("server_organization", c_char * 64),
('notBefore', c_uint32),
('notAfter', c_uint32),
("ja3_client", c_char * 33),
("ja3_server", c_char * 33),
("server_cipher", c_uint16),
("server_unsafe_cipher", c_int)
]
class Stun(Structure):
_fields_ = [
("num_udp_pkts", c_uint8),
("num_processed_pkts", c_uint8),
("num_binding_requests", c_uint8),
]
class StunSsl(Structure):
_fields_ = [("ssl", Ssl), ("stun", Stun)]
class Ssh(Structure):
_fields_ = [
("client_signature", c_char * 48),
("server_signature", c_char * 48),
("hassh_client", c_char * 33),
("hassh_server", c_char * 33)
]
class Imo(Structure):
_fields_ = [
("last_one_byte_pkt", c_uint8),
("last_byte", c_uint8)
]
class Mdns(Structure):
_fields_ = [("answer", c_char * 96)]
class Ubntac2(Structure):
_fields_ = [("version", c_char * 32)]
class Http2(Structure):
_fields_ = [
("detected_os", c_char * 32),
("nat_ip", c_char * 24)
]
class Bittorrent(Structure):
_fields_ = [("hash", c_char * 20)]
class Dhcp(Structure):
_fields_ = [
("fingerprint", c_char * 48),
("class_ident", c_char * 48)
]
class Protos(Union):
_fields_ = [
("dns", Dns),
("kerberos", Kerberos),
("stun_ssl", StunSsl),
("ssh", Ssh),
("imo", Imo),
("mdns", Mdns),
("ubntac2", Ubntac2),
("http", Http2),
("bittorrent", Bittorrent),
("dhcp", Dhcp)
]
class TincCacheEntry(Structure):
_pack_ = 1
_fields_ = [
('src_address', c_uint32),
('dst_address', c_uint32),
('dst_port', c_uint16),
]
class NDPIIntOneLineStruct(Structure):
_fields_ = [
('ptr', POINTER(c_uint8)),
('len', c_uint16),
]
class NDPIIphdr(Structure):
_pack_ = 1
_fields_ = [
('ihl', c_uint8, 4),
('version', c_uint8, 4),
('tos', c_uint8),
('tot_len', c_uint16),
('id', c_uint16),
('frag_off', c_uint16),
('ttl', c_uint8),
('protocol', c_uint8),
('check', c_uint16),
('saddr', c_uint32),
('daddr', c_uint32)]
class NDPIIp6Hdrctl(Structure):
_pack_ = 1
_fields_ = [
('ip6_un1_flow', c_uint32),
('ip6_un1_plen', c_uint16),
('ip6_un1_nxt', c_uint8),
('ip6_un1_hlim', c_uint8),
]
class NDPIIpv6hdr(Structure):
_pack_ = 1
_fields_ = [
('ip6_hdr', NDPIIp6Hdrctl),
('ip6_src', NDPIIn6Addr),
('ip6_dst', NDPIIn6Addr),
]
class NDPITcpHdr(Structure):
_pack_ = 1
_fields_ = [
('source', c_uint16),
('dest', c_uint16),
('seq', c_uint32),
('ack_seq', c_uint32),
('res1', c_uint16, 4),
('doff', c_uint16, 4),
('fin', c_uint16, 1),
('syn', c_uint16, 1),
('rst', c_uint16, 1),
('psh', c_uint16, 1),
('ack', c_uint16, 1),
('urg', c_uint16, 1),
('ece', c_uint16, 1),
('cwr', c_uint16, 1),
('window', c_uint16),
('check', c_uint16),
('urg_ptr', c_uint16),
]
class NDPIUdpHdr(Structure):
_pack_ = 1
_fields_ = [
('source', c_uint16),
('dest', c_uint16),
('len', c_uint16),
('check', c_uint16),
]
class NDPIPacketStructStack(Structure):
_pack_ = 1
_fields_ = [
('detected_subprotocol_stack', c_uint8 * ndpi.ndpi_wrap_ndpi_procol_size()),
('protocol_stack_info', c_uint16)
]
class NDPIPacketStruct(Structure):
_fields_ = [
('iph', POINTER(NDPIIphdr)),
('iphv6', POINTER(NDPIIpv6hdr)),
('tcp', POINTER(NDPITcpHdr)),
('udp', POINTER(NDPIUdpHdr)),
('generic_l4_ptr', POINTER(c_uint8)),
('payload', POINTER(c_uint8)),
('tick_timestamp', c_uint32),
('tick_timestamp_l', c_uint64),
('detected_protocol_stack', c_uint16 * ndpi.ndpi_wrap_ndpi_procol_size()),
('ndpi_packet_stack', NDPIPacketStructStack),
('line', NDPIIntOneLineStruct * 64),
('host_line', NDPIIntOneLineStruct),
('forwarded_line', NDPIIntOneLineStruct),
('referer_line', NDPIIntOneLineStruct),
('content_line', NDPIIntOneLineStruct),
('accept_line', NDPIIntOneLineStruct),
('user_agent_line', NDPIIntOneLineStruct),
('http_url_name', NDPIIntOneLineStruct),
('http_encoding', NDPIIntOneLineStruct),
('http_transfer_encoding', NDPIIntOneLineStruct),
('http_contentlen', NDPIIntOneLineStruct),
('http_cookie', NDPIIntOneLineStruct),
('http_origin', NDPIIntOneLineStruct),
('http_x_session_type', NDPIIntOneLineStruct),
('server_line', NDPIIntOneLineStruct),
('http_method', NDPIIntOneLineStruct),
('http_response', NDPIIntOneLineStruct),
('http_num_headers', c_uint8),
('l3_packet_len', c_uint16),
('l4_packet_len', c_uint16),
('payload_packet_len', c_uint16),
('actual_payload_len', c_uint16),
('num_retried_bytes', c_uint16),
('parsed_lines', c_uint16),
('parsed_unix_lines', c_uint16),
('empty_line_position', c_uint16),
('tcp_retransmission', c_uint8),
('l4_protocol', c_uint8),
('ssl_certificate_detected', c_uint8, 4),
('ssl_certificate_num_checks', c_uint8, 4),
('packet_lines_parsed_complete', c_uint8, 1),
('packet_direction', c_uint8, 1),
('empty_line_position_set', c_uint8, 1),
('pad', c_uint8, 5),
]
class NDPIFlowStructStack(Structure):
_pack_ = 1
_fields_ = [
("detected_protocol_stack", c_uint16 * ndpi.ndpi_wrap_ndpi_procol_size()),
("protocol_stack_info", c_uint16)
]
NDPIFlowStruct._fields_ = [
("ndpi_flow_stack", NDPIFlowStructStack),
("guessed_protocol_id", c_uint16),
("guessed_host_protocol_id", c_uint16),
("guessed_category", c_uint16),
("guessed_header_category", c_uint16),
("l4_proto", c_uint8),
("protocol_id_already_guessed", c_uint8, 1),
("host_already_guessed", c_uint8, 1),
("init_finished", c_uint8, 1),
("setup_packet_direction", c_uint8, 1),
("packet_direction", c_uint8, 1),
("check_extra_packets", c_uint8, 1),
("next_tcp_seq_nr", c_uint32 * 2),
("max_extra_packets_to_check", c_uint8),
("num_extra_packets_checked", c_uint8),
("num_processed_pkts", c_uint8),
("extra_packets_func", CFUNCTYPE(c_int, POINTER(NDPIDetectionModuleStruct), POINTER(NDPIFlowStruct))),
("l4", L4),
("server_id", POINTER(NDPIIdStruct)),
("host_server_name", c_ubyte * 256),
("http", Http),
("protos", Protos),
("excluded_protocol_bitmask", NDPIProtocolBitMask),
("category", c_int),
('redis_s2d_first_char', c_uint8),
('redis_d2s_first_char', c_uint8),
('packet_counter', c_uint16),
('packet_direction_counter', c_uint16 * 2),
('byte_counter', c_uint16 * 2),
('bittorrent_stage', c_uint8),
('directconnect_stage', c_uint8, 2),
('sip_yahoo_voice', c_uint8, 1),
('http_detected', c_uint8, 1),
('http_upper_protocol', c_uint16),
('http_lower_protocol', c_uint16),
('rtsprdt_stage', c_uint8, 2),
('rtsp_control_flow', c_uint8, 1),
('yahoo_detection_finished', c_uint8, 2),
('zattoo_stage', c_uint8, 3),
('qq_stage', c_uint8, 3),
('thunder_stage', c_uint8, 2),
('oscar_ssl_voice_stage', c_uint8, 3),
('oscar_video_voice', c_uint8, 1),
('florensia_stage', c_uint8, 1),
('socks5_stage', c_uint8, 2),
('socks4_stage', c_uint8, 2),
('edonkey_stage', c_uint8, 2),
('ftp_control_stage', c_uint8, 2),
('rtmp_stage', c_uint8, 2),
('pando_stage', c_uint8, 3),
('steam_stage1', c_uint16, 3),
('steam_stage2', c_uint16, 2),
('steam_stage3', c_uint16, 2),
('pplive_stage1', c_uint8, 3),
('pplive_stage2', c_uint8, 2),
('pplive_stage3', c_uint8, 2),
('starcraft_udp_stage', c_uint8, 3),
('ovpn_session_id', c_uint8 * 8),
('ovpn_counter', c_uint8),
('tinc_state', c_uint8),
('TincCacheEntry', TincCacheEntry),
('csgo_strid', c_uint8 * 18),
('csgo_state', c_uint8),
('csgo_s2', c_uint8),
('csgo_id2', c_uint32),
('kxun_counter', c_uint16),
('iqiyi_counter', c_uint16),
('packet', NDPIPacketStruct),
('flow', POINTER(NDPIFlowStruct)),
('src', POINTER(NDPIIdStruct)),
('dst', POINTER(NDPIIdStruct))
]
# ----------------------------------------------- nDPI APIs ------------------------------------------------------------
""" ndpi_detection_giveup: Function to be called before we give up with detection for a given flow.
This function reduces the NDPI_UNKNOWN_PROTOCOL detection. """
ndpi.ndpi_detection_giveup.restype = NDPIProtocol
ndpi.ndpi_detection_giveup.argtypes = [POINTER(NDPIDetectionModuleStruct),
POINTER(NDPIFlowStruct), c_uint8,
POINTER(c_uint8)]
""" ndpi_detection_process_packet: Processes one packet and returns the ID of the detected protocol.
This is the MAIN PACKET PROCESSING FUNCTION. """
ndpi.ndpi_detection_process_packet.restype = NDPIProtocol
ndpi.ndpi_detection_process_packet.argtypes = [POINTER(NDPIDetectionModuleStruct),
POINTER(NDPIFlowStruct),
POINTER(c_ubyte),
c_ushort,
c_uint64,
POINTER(NDPIIdStruct),
POINTER(NDPIIdStruct)]
""" ndpi_ssl_version2str : Converts ssl version to readable string """
ndpi.ndpi_ssl_version2str.restype = c_char_p
ndpi.ndpi_ssl_version2str.argtypes = [c_int16, POINTER(c_uint8)]
""" ndpi_init_detection_module: Returns a new initialized detection module.
Note that before you can use it you can still load hosts and do other things. As soon as you are ready to use
it do not forget to call first ndpi_finalize_initalization() """
ndpi.ndpi_init_detection_module.restype = POINTER(NDPIDetectionModuleStruct)
def ndpi_ndpi_finalize_initalization(detection_module):
""" ndpi_finalize_initalization: Completes the initialization (ndpi_revision >= 3.1)"""
if cast(ndpi.ndpi_revision(), c_char_p).value.decode("utf-8")[:3] >= '3.1':
ndpi.ndpi_finalize_initalization.restype = c_void_p
ndpi.ndpi_finalize_initalization.argtypes = [POINTER(NDPIDetectionModuleStruct)]
return ndpi.ndpi_finalize_initalization(detection_module)
else:
# ignore it
return None
""" ndpi_tfind: find a node, or return 0. """
ndpi.ndpi_tfind.restype = c_void_p
""" ndpi_tsearch: ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/src/lib/libc/stdlib/tsearch.c
find or insert datum into search tree. """
ndpi.ndpi_tsearch.restype = c_void_p
ndpi.ndpi_tsearch.argtypes = [c_void_p, POINTER(c_void_p), CFUNCTYPE(c_int, c_void_p, c_void_p)]
""" ndpi_revision: Get the nDPI version release. """
ndpi.ndpi_revision.restype = c_void_p
""" ndpi_get_proto_name: Get the protocol name associated to the ID."""
ndpi.ndpi_get_proto_name.restype = c_void_p
""" ndpi_category_get_name: Get protocol category as string."""
ndpi.ndpi_category_get_name.restype = c_void_p
""" ndpi_get_num_supported_protocols: Get the total number of the supported protocols."""
ndpi.ndpi_get_num_supported_protocols.restype = c_uint
""" ndpi_wrap_NDPI_BITMASK_SET_ALL: memset((char *)(p), 0xFF, sizeof(*(p)))"""
ndpi.ndpi_wrap_NDPI_BITMASK_SET_ALL.argtypes = [POINTER(NDPIProtocolBitMask)]
""" ndpi_set_protocol_detection_bitmask2: Sets the protocol bitmask2."""
ndpi.ndpi_set_protocol_detection_bitmask2.argtypes = [POINTER(NDPIDetectionModuleStruct),
POINTER(NDPIProtocolBitMask)]
""" ndpi_twalk: Walk the nodes of a tree. """
ndpi.ndpi_twalk.argtypes = [c_void_p, CFUNCTYPE(None, c_void_p, c_int32, c_int, c_void_p), c_void_p]
""" ndpi_tdestroy: node destroy. """
ndpi.ndpi_tdestroy.argtypes = [c_void_p, CFUNCTYPE(None, c_void_p)]
+60
View File
@@ -0,0 +1,60 @@
/*
* ndpi_wrap.c
*
* Copyright (C) 2011-19 - 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 "sys/types.h"
#include "ndpi_config.h"
#include "ndpi_main.h"
int ndpi_wrap_get_api_version(){
return NDPI_API_VERSION;
}
int ndpi_wrap_ndpi_num_fds_bits(){
return NDPI_NUM_FDS_BITS;
}
int ndpi_wrap_num_custom_categories(){
return NUM_CUSTOM_CATEGORIES;
}
int ndpi_wrap_custom_category_label_len(){
return CUSTOM_CATEGORY_LABEL_LEN;
}
int ndpi_wrap_ndpi_max_supported_protocols(){
return NDPI_MAX_SUPPORTED_PROTOCOLS;
}
int ndpi_wrap_ndpi_max_num_custom_protocols(){
return NDPI_MAX_NUM_CUSTOM_PROTOCOLS;
}
int ndpi_wrap_ndpi_procol_size(){
return NDPI_PROTOCOL_SIZE;
}
void ndpi_wrap_NDPI_BITMASK_SET_ALL(NDPI_PROTOCOL_BITMASK* bitmask){
NDPI_ONE(bitmask);
}
void dummy() {
/* Dummy call just to cause linker to include the ndpi library */
ndpi_tfind(NULL, NULL, NULL);
}
Binary file not shown.
-10
View File
@@ -1,10 +0,0 @@
library_includedir=$(includedir)/libndpi-@VERSION@/libndpi
library_include_HEADERS = ndpi_api.h \
ndpi_define.h \
ndpi_typedefs.h \
ndpi_main.h \
ndpi_protocol_ids.h \
ndpi_protocols.h \
ndpi_win32.h \
ndpi_includes.h
-794
View File
@@ -1,794 +0,0 @@
/*
* ndpi_api.h
*
* Copyright (C) 2011-17 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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/>.
*
*/
#ifndef __NDPI_API_H__
#define __NDPI_API_H__
#include "ndpi_main.h"
#ifdef __cplusplus
extern "C" {
#endif
/* The #define below is used for apps that dynamically link with nDPI to make
sure that datastructures and in sync across versions
*/
#define NDPI_API_VERSION 1
#define SIZEOF_ID_STRUCT ( sizeof(struct ndpi_id_struct) )
#define SIZEOF_FLOW_STRUCT ( sizeof(struct ndpi_flow_struct) )
#define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 )
#define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 )
#define ADD_TO_DETECTION_BITMASK 1
#define NO_ADD_TO_DETECTION_BITMASK 0
#define SAVE_DETECTION_BITMASK_AS_UNKNOWN 1
#define NO_SAVE_DETECTION_BITMASK_AS_UNKNOWN 0
/**
* Check if a string is encoded with punycode
* ( https://tools.ietf.org/html/rfc3492 )
*
* @par buff = pointer to the string to ckeck
* @par len = len of the string
* @return 1 if the string is punycoded;
* else 0
*
*/
int check_punycode_string(char *buff, int len);
/**
* Get the size of the flow struct
*
* @return the size of the flow struct
*
*/
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void);
/**
* Get the size of the id struct
*
* @return the size of the id struct
*
*/
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
/**
* nDPI personal allocation and free functions
**/
void * ndpi_malloc(size_t size);
void * ndpi_calloc(unsigned long count, size_t size);
void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
char * ndpi_strdup(const char *s);
void ndpi_free(void *ptr);
void * ndpi_flow_malloc(size_t size);
void ndpi_flow_free(void *ptr);
/**
* Search the first occurrence of substring -find- in -s-
* The search is limited to the first -slen- characters of the string
*
* @par s = string to parse
* @par find = string to match with -s-
* @par slen = max length to match between -s- and -find-
* @return a pointer to the beginning of the located substring;
* NULL if the substring is not found
*
*/
char* ndpi_strnstr(const char *s, const char *find, size_t slen);
/**
* Same as ndpi_strnstr but case insensitive
*
* @par s = string to parse
* @par find = string to match with -s-
* @par slen = max length to match between -s- and -find-
* @return a pointer to the beginning of the located substring;
* NULL if the substring is not found
*
*/
char* ndpi_strncasestr(const char *s, const char *find, size_t slen);
/**
* Returns the nDPI protocol id for IP-based protocol detection
*
* @par ndpi_struct = the struct created for the protocol detection
* @par pin = IP host address (MUST BE in network byte order):
* See man(7) ip for details
* @return the nDPI protocol ID
*
*/
u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct,
struct in_addr *pin);
/**
* Init single protocol match
*
* @par ndpi_mod = the struct created for the protocol detection
* @par match = the struct passed to match the protocol
*
*/
void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_match *match);
/**
* Returns a new initialized detection module
*
* @return the initialized detection module
*
*/
struct ndpi_detection_module_struct *ndpi_init_detection_module(void);
/**
* Frees the memory allocated in the specified flow
*
* @par flow = the flow to deallocate
*
*/
void ndpi_free_flow(struct ndpi_flow_struct *flow);
/**
* Enables cache support.
* In nDPI is used for some protocol (i.e. Skype)
*
* @par ndpi_mod = the struct created for the protocol detection
* @par host = string for the host name
* @par port = unsigned int for the port number
*
*/
void ndpi_enable_cache(struct ndpi_detection_module_struct *ndpi_mod,
char* host, u_int port);
/**
* Destroys the detection module
*
* @par ndpi_struct = the struct to clearing for the detection module
*
*/
void ndpi_exit_detection_module(struct ndpi_detection_module_struct *ndpi_struct);
/**
* Sets a single protocol bitmask
* This function does not increment the index of the callback_buffer
*
* @par label = string for the protocol name
* @par ndpi_struct = the detection module
* @par detection_bitmask = the protocol bitmask
* @par idx = the index of the callback_buffer
* @par func = function pointer of the protocol search
* @par ndpi_selection_bitmask = the protocol selected bitmask
* @par b_save_bitmask_unknow = if set as "true" save the detection bitmask as unknow
* @par b_add_detection_bitmask = if set as "true" add the protocol bitmask to the detection bitmask
*
*/
void ndpi_set_bitmask_protocol_detection(char *label,
struct ndpi_detection_module_struct *ndpi_struct,
const NDPI_PROTOCOL_BITMASK *detection_bitmask,
const u_int32_t idx,
u_int16_t ndpi_protocol_id,
void (*func) (struct ndpi_detection_module_struct *,
struct ndpi_flow_struct *flow),
const NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask,
u_int8_t b_save_bitmask_unknow,
u_int8_t b_add_detection_bitmask);
/**
* Sets the protocol bitmask2
*
* @par ndpi_struct = the detection module
* @par detection_bitmask = the protocol bitmask to set
*
*/
void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
const NDPI_PROTOCOL_BITMASK * detection_bitmask);
/**
* Function to be called before we give up with detection for a given flow.
* This function reduces the NDPI_UNKNOWN_PROTOCOL detection
*
* @par ndpi_struct = the detection module
* @par flow = the flow given for the detection module
* @par enable_guess = guess protocol if unknown
* @return the detected protocol even if the flow is not completed;
*
*/
ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int8_t enable_guess);
/**
* Processes an extra packet in order to get more information for a given protocol
* (like SSL getting both client and server certificate even if we already know after
* seeing the client certificate what the protocol is)
*
* @par ndpi_struct = the detection module
* @par flow = pointer to the connection state machine
* @par packet = unsigned char pointer to the Layer 3 (IP header)
* @par packetlen = the length of the packet
* @par current_tick = the current timestamp for the packet
* @par src = pointer to the source subscriber state machine
* @par dst = pointer to the destination subscriber state machine
* @return void
*
*/
void ndpi_process_extra_packet(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
const unsigned char *packet,
const unsigned short packetlen,
const u_int64_t current_tick,
struct ndpi_id_struct *src,
struct ndpi_id_struct *dst);
/**
* Processes one packet and returns the ID of the detected protocol.
* This is the MAIN PACKET PROCESSING FUNCTION.
*
* @par ndpi_struct = the detection module
* @par flow = pointer to the connection state machine
* @par packet = unsigned char pointer to the Layer 3 (IP header)
* @par packetlen = the length of the packet
* @par current_tick = the current timestamp for the packet
* @par src = pointer to the source subscriber state machine
* @par dst = pointer to the destination subscriber state machine
* @return the detected ID of the protocol
*
*/
ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
const unsigned char *packet,
const unsigned short packetlen,
const u_int64_t current_tick,
struct ndpi_id_struct *src,
struct ndpi_id_struct *dst);
/**
* Get the main protocol of the passed flows for the detected module
*
*
* @par ndpi_struct = the detection module
* @par flow = the flow given for the detection module
* @return the ID of the master protocol detected
*
*/
u_int16_t ndpi_get_flow_masterprotocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow);
/**
* API call that is called internally by ndpi_detection_process_packet or by apps
* that want to avoid calling ndpi_detection_process_packet as they have already
* parsed the packet and thus want to avoid this.
*
*
* @par ndpi_struct = the detection module
* @par flow = the flow given for the detection module
* @par ndpi_selection_bitmask = the protocol selected bitmask
*
*/
void ndpi_check_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet);
/**
* Query the pointer to the layer 4 packet
*
* @par l3 = pointer to the layer 3 data
* @par l3_len = length of the layer 3 data
* @par l4_return = address to the pointer of the layer 4 data if return value == 0, else undefined
* @par l4_len_return = length of the layer 4 data if return value == 0, else undefined
* @par l4_protocol_return = protocol of the layer 4 data if return value == 0, undefined otherwise
* @par flags = limit operation on ipv4 or ipv6 packets. Possible values: NDPI_DETECTION_ONLY_IPV4 - NDPI_DETECTION_ONLY_IPV6 - 0 (any)
* @return 0 if layer 4 data could be found correctly;
else != 0
*
*/
u_int8_t ndpi_detection_get_l4(const u_int8_t *l3, u_int16_t l3_len, const u_int8_t **l4_return, u_int16_t *l4_len_return,
u_int8_t *l4_protocol_return, u_int32_t flags);
/**
* Search and return the protocol based on matched ports
*
* @par ndpi_struct = the detection module
* @par shost = source address in host byte order
* @par sport = source port number
* @par dhost = destination address in host byte order
* @par dport = destination port number
* @return the struct ndpi_protocol that match the port base protocol
*
*/
ndpi_protocol ndpi_find_port_based_protocol(struct ndpi_detection_module_struct *ndpi_struct/* , u_int8_t proto */,
u_int32_t shost,
u_int16_t sport,
u_int32_t dhost,
u_int16_t dport);
/**
* Search and return the protocol guessed that is undetected
*
* @par ndpi_struct = the detection module
* @par flow = the flow we're trying to guess, NULL if not available
* @par proto = the l4 protocol number
* @par shost = source address in host byte order
* @par sport = source port number
* @par dhost = destination address in host byte order
* @par dport = destination port number
* @return the struct ndpi_protocol that match the port base protocol
*
*/
ndpi_protocol ndpi_guess_undetected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int8_t proto,
u_int32_t shost,
u_int16_t sport,
u_int32_t dhost,
u_int16_t dport);
/**
* Check if the string passed match with a protocol
*
* @par ndpi_struct = the detection module
* @par string_to_match = the string to match
* @par string_to_match_len = the length of the string
* @par ret_match = completed returned match information
* @par is_host_match = value of the second field of struct ndpi_automa
* @return the ID of the matched subprotocol
*
*/
int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
char *string_to_match,
u_int string_to_match_len,
ndpi_protocol_match_result *ret_match,
u_int8_t is_host_match);
/**
* Check if the host passed match with a protocol
*
* @par ndpi_struct = the detection module
* @par flow = the flow where match the host
* @par string_to_match = the string to match
* @par string_to_match_len = the length of the string
* @par ret_match = completed returned match information
* @par master_protocol_id = value of the ID associated to the master protocol detected
* @return the ID of the matched subprotocol
*
*/
int ndpi_match_host_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
char *string_to_match,
u_int string_to_match_len,
ndpi_protocol_match_result *ret_match,
u_int16_t master_protocol_id);
/**
* Check if the string content passed match with a protocol
*
* @par ndpi_struct = the detection module
* @par flow = the flow where match the host
* @par string_to_match = the string to match
* @par string_to_match_len = the length of the string
* @par ret_match = completed returned match information
* @par master_protocol_id = value of the ID associated to the master protocol detected
* @return the ID of the matched subprotocol
*
*/
int ndpi_match_content_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
char *string_to_match,
u_int string_to_match_len,
ndpi_protocol_match_result *ret_match,
u_int16_t master_protocol_id);
/**
* Exclude protocol from search
*
* @par ndpi_struct = the detection module
* @par flow = the flow where match the host
* @par master_protocol_id = value of the ID associated to the master protocol detected
*
*/
void ndpi_exclude_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int16_t master_protocol_id,
const char *_file, const char *_func,int _line);
/**
* Check if the string -bigram_to_match- match with a bigram of -automa-
*
* @par ndpi_mod = the detection module
* @par automa = the struct ndpi_automa for the bigram
* @par bigram_to_match = the bigram string to match
* @return 0
*
*/
int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_automa *automa,
char *bigram_to_match);
/**
* Write the protocol name in the buffer -buf- as master_protocol.protocol
*
* @par ndpi_mod = the detection module
* @par proto = the struct ndpi_protocol contain the protocols name
* @par buf = the buffer to write the name of the protocols
* @par buf_len = the length of the buffer
* @return the buffer contains the master_protocol and protocol name
*
*/
char* ndpi_protocol2name(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol proto, char *buf, u_int buf_len);
/**
* Same as ndpi_protocol2name() with the difference that the numeric protocol
* name is returned
*
* @par ndpi_mod = the detection module
* @par proto = the struct ndpi_protocol contain the protocols name
* @par buf = the buffer to write the name of the protocols
* @par buf_len = the length of the buffer
* @return the buffer contains the master_protocol and protocol name
*
*/
char* ndpi_protocol2id(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol proto, char *buf, u_int buf_len);
/**
* Find out if a given category is custom/user-defined
*
* @par category = the category associated to the protocol
* @return 1 if this is a custom user category, 0 otherwise
*
*/
int ndpi_is_custom_category(ndpi_protocol_category_t category);
/**
* Overwrite a protocol category defined by nDPI with the custom category
*
* @par ndpi_mod = the detection module
* @par protoId = the protocol identifier to overwrite
* @par breed = the breed to be associated to the protocol
*
*/
void ndpi_set_proto_breed(struct ndpi_detection_module_struct *ndpi_mod,
u_int16_t protoId, ndpi_protocol_breed_t breed);
/**
* Overwrite a protocol category defined by nDPI with the custom category
*
* @par ndpi_mod = the detection module
* @par protoId = the protocol identifier to overwrite
* @par category = the category associated to the protocol
*
*/
void ndpi_set_proto_category(struct ndpi_detection_module_struct *ndpi_mod,
u_int16_t protoId, ndpi_protocol_category_t protoCategory);
/**
* Check if subprotocols of the specified master protocol are just
* informative (and not real)
*
* @par mod = the detection module
* @par protoId = the (master) protocol identifier to query
* @return 1 = the subprotocol is informative, 0 otherwise.
*
*/
u_int8_t ndpi_is_subprotocol_informative(struct ndpi_detection_module_struct *ndpi_mod,
u_int16_t protoId);
/**
* Get protocol category as string
*
* @par mod = the detection module
* @par category = the category associated to the protocol
* @return the string name of the category
*
*/
const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_category_t category);
/**
* Set protocol category string
*
* @par mod = the detection module
* @par category = the category associated to the protocol
* @paw name = the string name of the category
*
*/
void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol_category_t category, char *name);
/**
* Get protocol category
*
* @par ndpi_mod = the detection module
* @par proto = the struct ndpi_protocol contain the protocols name
* @return the protocol category
*/
ndpi_protocol_category_t ndpi_get_proto_category(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_protocol proto);
/**
* Get the protocol name associated to the ID
*
* @par mod = the detection module
* @par proto_id = the ID of the protocol
* @return the buffer contains the master_protocol and protocol name
*
*/
char* ndpi_get_proto_name(struct ndpi_detection_module_struct *mod, u_int16_t proto_id);
/**
* Return the protocol breed ID associated to the protocol
*
* @par ndpi_struct = the detection module
* @par proto = the ID of the protocol
* @return the breed ID associated to the protocol
*
*/
ndpi_protocol_breed_t ndpi_get_proto_breed(struct ndpi_detection_module_struct *ndpi_struct,
u_int16_t proto);
/**
* Return the string name of the protocol breed
*
* @par ndpi_struct = the detection module
* @par breed_id = the breed ID associated to the protocol
* @return the string name of the breed ID
*
*/
char* ndpi_get_proto_breed_name(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_protocol_breed_t breed_id);
/**
* Return the ID of the protocol
*
* @par ndpi_mod = the detection module
* @par proto = the protocol name
* @return the ID of the protocol
*
*/
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
/**
* Return the ID of the category
*
* @par ndpi_mod = the detection module
* @par proto = the category name
* @return the ID of the category
*
*/
int ndpi_get_category_id(struct ndpi_detection_module_struct *ndpi_mod, char *cat);
/**
* Write the list of the supported protocols
*
* @par ndpi_mod = the detection module
*/
void ndpi_dump_protocols(struct ndpi_detection_module_struct *mod);
/**
* Read a file and load the protocols
*
* Format: <tcp|udp>:<port>,<tcp|udp>:<port>,.....@<proto>
*
* Example:
* tcp:80,tcp:3128@HTTP
* udp:139@NETBIOS
*
* @par ndpi_mod = the detection module
* @par path = the path of the file
* @return 0 if the file is loaded correctly;
* -1 else
*
*/
int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod,
char* path);
/**
* Get the total number of the supported protocols
*
* @par ndpi_mod = the detection module
* @return the number of protocols
*
*/
u_int ndpi_get_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod);
/**
* Get the nDPI version release
*
* @return the NDPI_GIT_RELEASE
*
*/
char* ndpi_revision(void);
/**
* Set the automa for the protocol search
*
* @par ndpi_struct = the detection module
* @par automa = the automa to match
*
*/
void ndpi_set_automa(struct ndpi_detection_module_struct *ndpi_struct,
void* automa);
/* NDPI_PROTOCOL_HTTP */
/**
* Retrieve information for HTTP flows
*
* @par ndpi_mod = the detection module
* @par flow = the detected flow
* @return the HTTP method information about the flow
*
*/
ndpi_http_method ndpi_get_http_method(struct ndpi_detection_module_struct *ndpi_mod,
struct ndpi_flow_struct *flow);
/**
* Get the HTTP url
*
* @par ndpi_mod = the detection module
* @par flow = the detected flow
* @return the HTTP method information about the flow
*
*/
char* ndpi_get_http_url(struct ndpi_detection_module_struct *ndpi_mod,
struct ndpi_flow_struct *flow);
/**
* Get the HTTP content-type
*
* @par ndpi_mod = the detection module
* @par flow = the detected flow
* @return the HTTP method information about the flow
*
*/
char* ndpi_get_http_content_type(struct ndpi_detection_module_struct *ndpi_mod,
struct ndpi_flow_struct *flow);
/* NDPI_PROTOCOL_TOR */
/**
* Check if the flow could be detected as TOR protocol
*
* @par ndpi_struct = the detection module
* @par flow = the detected flow
* @par certificate = the ssl certificate
* @return 1 if the flow is TOR;
* 0 else
*
*/
int ndpi_is_ssl_tor(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow, char *certificate);
/* Wrappers functions */
/**
* Init Aho-Corasick automata
*
* @return The requested automata, or NULL if an error occurred
*
*/
void* ndpi_init_automa(void);
/**
* Free Aho-Corasick automata allocated with ndpi_init_automa();
*
* @par The automata initialized with ndpi_init_automa();
*
*/
void ndpi_free_automa(void *_automa);
/**
* Add a string to match to an automata
*
* @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search
* @par The number associated with this string
* @return 0 in case of no error, or -1 if an error occurred.
*
*/
int ndpi_add_string_value_to_automa(void *_automa, char *str, unsigned long num);
/**
* Add a string to match to an automata. Same as ndpi_add_string_value_to_automa() with num set to 1
*
* @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search
* @return 0 in case of no error, or -1 if an error occurred.
*
*/
int ndpi_add_string_to_automa(void *_automa, char *str);
/**
* Finalize the automa (necessary before start searching)
*
* @par The automata initialized with ndpi_init_automa();
*
*/
void ndpi_finalize_automa(void *_automa);
/**
* Add a string to match to an automata
*
* @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search
* @return 0 in case of match, or -1 if no match, or -2 if an error occurred.
*
*/
int ndpi_match_string(void *_automa, char *string_to_match);
void ndpi_load_ip_category(struct ndpi_detection_module_struct *ndpi_struct,
char *ip_address_and_mask, ndpi_protocol_category_t category);
int ndpi_load_hostname_category(struct ndpi_detection_module_struct *ndpi_struct,
char *name, ndpi_protocol_category_t category);
int ndpi_enable_loaded_categories(struct ndpi_detection_module_struct *ndpi_struct);
int ndpi_fill_ip_protocol_category(struct ndpi_detection_module_struct *ndpi_struct,
const struct ndpi_iphdr *iph,
ndpi_protocol *ret);
void ndpi_fill_protocol_category(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
ndpi_protocol *ret);
int ndpi_get_custom_category_match(struct ndpi_detection_module_struct *ndpi_struct,
char *name_or_ip, unsigned long *id);
int ndpi_set_detection_preferences(struct ndpi_detection_module_struct *ndpi_mod,
ndpi_detection_preference pref,
int value);
ndpi_proto_defaults_t* ndpi_get_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod);
u_int ndpi_get_ndpi_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod);
u_int ndpi_get_ndpi_num_custom_protocols(struct ndpi_detection_module_struct *ndpi_mod);
u_int ndpi_get_ndpi_detection_module_size();
void ndpi_set_log_level(struct ndpi_detection_module_struct *ndpi_mod, u_int l);
/**
* Add a string to match to an automata
*
* @par The automata initialized with ndpi_init_automa();
* @par The (sub)string to search
* @par The id associated with the matched string or 0 id not found.
* @return 0 in case of match, or -1 if no match, or -2 if an error occurred.
*
*/
int ndpi_match_string_id(void *_automa, char *string_to_match, unsigned long *id);
/* Utility functions to set ndpi malloc/free/print wrappers */
void set_ndpi_malloc(void* (*__ndpi_malloc)(size_t size));
void set_ndpi_free(void (*__ndpi_free)(void *ptr));
void set_ndpi_flow_malloc(void* (*__ndpi_flow_malloc)(size_t size));
void set_ndpi_flow_free(void (*__ndpi_flow_free)(void *ptr));
void set_ndpi_debug_function(struct ndpi_detection_module_struct *ndpi_str,
ndpi_debug_function_ptr ndpi_debug_printf);
void * ndpi_malloc(size_t size);
void * ndpi_calloc(unsigned long count, size_t size);
void ndpi_free(void *ptr);
u_int8_t ndpi_get_api_version();
/* https://github.com/corelight/community-id-spec */
int ndpi_flowv4_flow_hash(u_int8_t l4_proto, u_int32_t src_ip, u_int32_t dst_ip, u_int16_t src_port, u_int16_t dst_port,
u_int8_t icmp_type, u_int8_t icmp_code, u_char *hash_buf, u_int8_t hash_buf_len);
int ndpi_flowv6_flow_hash(u_int8_t l4_proto, struct ndpi_in6_addr *src_ip, struct ndpi_in6_addr *dst_ip,
u_int16_t src_port, u_int16_t dst_port, u_int8_t icmp_type, u_int8_t icmp_code,
u_char *hash_buf, u_int8_t hash_buf_len);
#ifdef __cplusplus
}
#endif
#endif /* __NDPI_API_H__ */
File diff suppressed because it is too large Load Diff
+92
View File
@@ -0,0 +1,92 @@
/*
*
* Copyright (c) 2016 Cisco Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
* \file ndpi_classify.h
*
* \brief header file for inline Classification functionality
*/
#ifndef NDPI_CLASSIFY_H
#define NDPI_CLASSIFY_H
#include "ndpi_includes.h"
/* constants */
#define NUM_PARAMETERS_SPLT_LOGREG 208
#define NUM_PARAMETERS_BD_LOGREG 464
#define MC_BINS_LEN 10
#define MC_BINS_TIME 10
#define MC_BIN_SIZE_TIME 50
#define MC_BIN_SIZE_LEN 150
#define MAX_BIN_LEN 1500
#define NUM_BD_VALUES 256
#define NDPI_TIMESTAMP_LEN 64
/** Classifier parameter type codes */
typedef enum {
SPLT_PARAM_TYPE = 0,
BD_PARAM_TYPE = 1
} classifier_type_codes_t;
extern float parameters_bd[NUM_PARAMETERS_BD_LOGREG];
extern float parameters_splt[NUM_PARAMETERS_SPLT_LOGREG];
/* Classifier functions */
float ndpi_classify(const unsigned short *pkt_len, const pkt_timeval *pkt_time,
const unsigned short *pkt_len_twin, const pkt_timeval *pkt_time_twin,
pkt_timeval start_time, pkt_timeval start_time_twin, uint32_t max_num_pkt_len,
uint16_t sp, uint16_t dp, uint32_t op, uint32_t ip, uint32_t np_o, uint32_t np_i,
uint32_t ob, uint32_t ib, uint16_t use_bd, const uint32_t *bd, const uint32_t *bd_t);
void ndpi_merge_splt_arrays(const uint16_t *pkt_len, const pkt_timeval *pkt_time,
const uint16_t *pkt_len_twin, const pkt_timeval *pkt_time_twin,
pkt_timeval start_time, pkt_timeval start_time_twin,
uint16_t s_idx, uint16_t r_idx,
uint16_t *merged_lens, uint16_t *merged_times);
void ndpi_update_params(classifier_type_codes_t param_type, const char *param_file);
void ndpi_flow_info_freer(void *node);
unsigned int ndpi_timer_eq(const pkt_timeval *a, const pkt_timeval *b);
unsigned int ndpi_timer_lt(const pkt_timeval *a, const pkt_timeval *b);
void ndpi_timer_sub(const pkt_timeval *a, const pkt_timeval *b, pkt_timeval *result);
void ndpi_timer_clear(pkt_timeval *a);
unsigned int ndpi_timeval_to_milliseconds(pkt_timeval ts);
unsigned int ndpi_timeval_to_microseconds(pkt_timeval ts);
void ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len);
#endif /* NDPI_CLASSIFY_H */
+48 -8
View File
@@ -35,7 +35,9 @@
#include <endian.h>
#define __BYTE_ORDER BYTE_ORDER
#if BYTE_ORDER == LITTLE_ENDIAN
#ifndef __LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__
#endif /* __LITTLE_ENDIAN__ */
#else
#define __BIG_ENDIAN__
#endif/* BYTE_ORDER */
@@ -179,6 +181,8 @@
#define NDPI_JABBER_FT_TIMEOUT 5
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
#include "ndpi_config.h" /* To have access to NDPI_ENABLE_DEBUG_MESSAGES */
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
#define NDPI_LOG(proto, m, log_level, args...) \
{ \
@@ -187,7 +191,7 @@
(*(mod->ndpi_debug_printf))(proto, mod, log_level, __FILE__, __FUNCTION__, __LINE__, args); \
}
/* We must define NDPI_CURRENT_PROTO before include ndpi_main.h !!!
/* We must define NDPI_CURRENT_PROTO before include ndpi_main.h !!!
*
* #include "ndpi_protocol_ids.h"
* #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_XXXX
@@ -196,7 +200,7 @@
*/
#ifndef NDPI_CURRENT_PROTO
#define NDPI_CURRENT_PROTO NDPI_PROTO_UNKNOWN
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_UNKNOWN
#endif
#define NDPI_LOG_ERR(mod, args...) \
@@ -250,7 +254,7 @@
/** macro to compare 2 IPv6 addresses with each other to identify the "smaller" IPv6 address */
#define NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(x,y) \
((((u_int64_t *)(x))[0]) < (((u_int64_t *)(y))[0]) || ( (((u_int64_t *)(x))[0]) == (((u_int64_t *)(y))[0]) && (((u_int64_t *)(x))[1]) < (((u_int64_t *)(y))[1])) )
((x.u6_addr.u6_addr64[0] < y.u6_addr.u6_addr64[0]) || ((x.u6_addr.u6_addr64[0] == y.u6_addr.u6_addr64[0]) && (x.u6_addr.u6_addr64[1] < y.u6_addr.u6_addr64[1])))
#define NDPI_NUM_BITS 512
@@ -274,6 +278,12 @@
#define NDPI_BITMASK_SET_ALL(a) NDPI_ONE(&a)
#define NDPI_BITMASK_SET(a, b) { memcpy(&a, &b, sizeof(NDPI_PROTOCOL_BITMASK)); }
#define NDPI_SET_BIT(num, n) num |= 1UL << ( n )
#define NDPI_CLR_BIT(num, n) num &= ~(1UL << ( n ))
#define NDPI_CLR_BIT(num, n) num &= ~(1UL << ( n ))
#define NDPI_ISSET_BIT(num, n) (num & (1UL << ( n )))
#define NDPI_ZERO_BIT(num) num = 0
/* this is a very very tricky macro *g*,
* the compiler will remove all shifts here if the protocol is static...
*/
@@ -304,10 +314,10 @@
#define NDPI_ICMPV6_PROTOCOL_TYPE 0x3a
/* the get_uXX will return raw network packet bytes !! */
#define get_u_int8_t(X,O) (*(u_int8_t *)(((u_int8_t *)X) + O))
#define get_u_int16_t(X,O) (*(u_int16_t *)(((u_int8_t *)X) + O))
#define get_u_int32_t(X,O) (*(u_int32_t *)(((u_int8_t *)X) + O))
#define get_u_int64_t(X,O) (*(u_int64_t *)(((u_int8_t *)X) + O))
#define get_u_int8_t(X,O) (*(u_int8_t *)((&(((u_int8_t *)X)[O]))))
#define get_u_int16_t(X,O) (*(u_int16_t *)((&(((u_int8_t *)X)[O]))))
#define get_u_int32_t(X,O) (*(u_int32_t *)((&(((u_int8_t *)X)[O]))))
#define get_u_int64_t(X,O) (*(u_int64_t *)((&(((u_int8_t *)X)[O]))))
/* new definitions to get little endian from network bytes */
#define get_ul8(X,O) get_u_int8_t(X,O)
@@ -328,7 +338,7 @@
#define match_first_bytes(payload,st) (memcmp((payload),(st),(sizeof(st)-1))==0)
#if defined(WIN32) && !defined(snprintf)
#define snprintf _snprintf
#define snprintf _snprintf
#endif
#define NDPI_MAX_DNS_REQUESTS 16
@@ -338,4 +348,34 @@
#define NDPI_MINOR @NDPI_MINOR@
#define NDPI_PATCH @NDPI_PATCH@
/* IMPORTANT: order according to its severity */
#define NDPI_CIPHER_SAFE 0
#define NDPI_CIPHER_WEAK 1
#define NDPI_CIPHER_INSECURE 2
#define NDPI_OPTIMAL_HLL_NUM_BUCKETS 16
#define NDPI_MAX_NUM_TLS_APPL_BLOCKS 8
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)
#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
#endif /* __APPLE__ */
#endif /* __NDPI_DEFINE_INCLUDE_FILE__ */
+8 -1
View File
@@ -27,6 +27,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
@@ -56,7 +57,7 @@
#if defined __NetBSD__ || defined __OpenBSD__
#include <netinet/in_systm.h>
#ifdef __OpenBSD__
#if defined __OpenBSD__
#include <pthread.h>
#endif
@@ -66,4 +67,10 @@
#endif /* Win32 */
#if defined __OpenBSD__
#include "ndpi_includes_OpenBSD.h"
#else
typedef struct timeval pkt_timeval;
#endif /* __OpenBSD__ */
#endif /* __NDPI_INCLUDES_H__ */
+35
View File
@@ -0,0 +1,35 @@
/*
* ndpi_includes_OpenBSD.h
*
* Copyright (C) 2011-16 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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/>.
*
*/
#ifndef __NDPI_INCLUDES_OPENBSD_H__
#define __NDPI_INCLUDES_OPENBSD_H__
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif /* IPPROTO_SCTP */
#include <net/bpf.h>
typedef struct bpf_timeval pkt_timeval;
#endif /* __NDPI_INCLUDES_OPENBSD_H__ */
+11 -7
View File
@@ -1,7 +1,7 @@
/*
* ndpi_main.h
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -112,10 +112,10 @@ extern "C" {
extern void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip);
extern void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t * ip);
extern char *ndpi_get_ip_string(struct ndpi_detection_module_struct *ndpi_struct,
const ndpi_ip_addr_t * ip);
extern char *ndpi_get_packet_src_ip_string(struct ndpi_detection_module_struct *ndpi_struct,
const struct ndpi_packet_struct *packet);
extern int ndpi_parse_ip_string(const char *ip_str, ndpi_ip_addr_t *parsed_ip);
extern char *ndpi_get_ip_string(const ndpi_ip_addr_t * ip, char *buf, u_int buf_len);
extern u_int8_t ndpi_is_ipv6(const ndpi_ip_addr_t *ip);
extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id);
u_int16_t ndpi_get_proto_by_name(struct ndpi_detection_module_struct *ndpi_mod, const char *name);
@@ -124,7 +124,7 @@ extern "C" {
u_int8_t proto, u_int16_t sport, u_int16_t dport,
u_int8_t *user_defined_proto);
extern u_int8_t ndpi_is_proto(ndpi_protocol p, u_int16_t proto);
extern u_int8_t ndpi_is_proto(ndpi_protocol proto, u_int16_t p);
extern u_int16_t ndpi_get_lower_proto(ndpi_protocol p);
extern int ndpi_get_protocol_id_master_proto(struct ndpi_detection_module_struct *ndpi_struct,
@@ -132,7 +132,7 @@ extern "C" {
u_int16_t** tcp_master_proto,
u_int16_t** udp_master_proto);
#/* NDPI_PROTOCOL_NETBIOS */
int ndpi_netbios_name_interpret(char *in, char *out, u_int out_len);
int ndpi_netbios_name_interpret(char *in, size_t inlen, char *out, u_int out_len);
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
@@ -150,6 +150,10 @@ extern "C" {
#define ndpi_match_strprefix(payload, payload_len, str) \
ndpi_match_prefix((payload), (payload_len), (str), (sizeof(str)-1))
#ifdef NDPI_DETECTION_SUPPORT_IPV6
int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi_str, const u_int8_t ** l4ptr, u_int16_t * l4len, u_int8_t * nxt_hdr);
#endif
#ifdef __cplusplus
}
#endif
+47 -38
View File
@@ -1,8 +1,7 @@
/*
* ndpi_protocol_ids.h
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -23,12 +22,8 @@
*/
#ifndef __NDPI_API_H__
#endif
#ifndef __NDPI_PROTOCOLS_DEFAULT_H__
#define __NDPI_PROTOCOLS_DEFAULT_H__
#ifndef __NDPI_PROTOCOLS_IDS_H__
#define __NDPI_PROTOCOLS_IDS_H__
#define NDPI_DETECTION_SUPPORT_IPV6
#define NDPI_PROTOCOL_SIZE 2
@@ -75,39 +70,37 @@ typedef enum {
NDPI_PROTOCOL_SKYPE_CALL = 38, /* Skype call and videocalls */
NDPI_PROTOCOL_SIGNAL = 39,
NDPI_PROTOCOL_MEMCACHED = 40, /* Memcached - Darryl Sokoloski <darryl@egloo.ca> */
NDPI_PROTOCOL_SMBV23 = 41, /* SMB version 2/3 */
NDPI_PROTOCOL_SMBV23 = 41, /* SMB version 2/3 */
NDPI_PROTOCOL_MINING = 42, /* Bitcoin, Ethereum, ZCash, Monero */
NDPI_PROTOCOL_NEST_LOG_SINK = 43, /* Nest Log Sink (Nest Protect) - Darryl Sokoloski <darryl@egloo.ca> */
NDPI_PROTOCOL_FREE_44 = 44, /* Free */
NDPI_PROTOCOL_FREE_45 = 45, /* Free */
NDPI_PROTOCOL_FREE_46 = 46, /* Free */
NDPI_PROTOCOL_MODBUS = 44, /* Modbus */
NDPI_PROTOCOL_WHATSAPP_CALL = 45, /* WhatsApp video ad audio calls go here */
NDPI_PROTOCOL_DATASAVER = 46, /* Protocols used to save data on Internet communications */
NDPI_PROTOCOL_XBOX = 47,
NDPI_PROTOCOL_QQ = 48,
NDPI_PROTOCOL_FREE_49 = 49, /* Free */
NDPI_PROTOCOL_TIKTOK = 49,
NDPI_PROTOCOL_RTSP = 50,
NDPI_PROTOCOL_MAIL_IMAPS = 51,
NDPI_PROTOCOL_ICECAST = 52,
NDPI_PROTOCOL_PPLIVE = 53, /* Tomasz Bujlow <tomasz@skatnet.dk> */
NDPI_PROTOCOL_FREE_53 = 53,
NDPI_PROTOCOL_PPSTREAM = 54,
NDPI_PROTOCOL_ZATTOO = 55,
NDPI_PROTOCOL_SHOUTCAST = 56,
NDPI_PROTOCOL_SOPCAST = 57,
NDPI_PROTOCOL_TVANTS = 58,
NDPI_PROTOCOL_DISCORD = 58,
NDPI_PROTOCOL_TVUPLAYER = 59,
NDPI_PROTOCOL_HTTP_DOWNLOAD = 60,
NDPI_PROTOCOL_QQLIVE = 61,
NDPI_PROTOCOL_THUNDER = 62,
NDPI_PROTOCOL_SOULSEEK = 63,
NDPI_PROTOCOL_SSL_NO_CERT = 64,
NDPI_PROTOCOL_PS_VUE = 64,
NDPI_PROTOCOL_IRC = 65,
NDPI_PROTOCOL_AYIYA = 66,
NDPI_PROTOCOL_UNENCRYPTED_JABBER = 67,
NDPI_PROTOCOL_MSN = 68,
NDPI_PROTOCOL_OSCAR = 69,
NDPI_PROTOCOL_NATS = 68,
NDPI_PROTOCOL_FREE_69 = 69, /* Free */
NDPI_PROTOCOL_YAHOO = 70,
NDPI_PROTOCOL_BATTLEFIELD = 71,
NDPI_PROTOCOL_FREE_71 = 71, /* Free */
NDPI_PROTOCOL_GOOGLE_PLUS = 72,
NDPI_PROTOCOL_IP_VRRP = 73,
NDPI_PROTOCOL_STEAM = 74, /* Tomasz Bujlow <tomasz@skatnet.dk> */
@@ -126,8 +119,8 @@ typedef enum {
NDPI_PROTOCOL_RTP = 87,
NDPI_PROTOCOL_RDP = 88,
NDPI_PROTOCOL_VNC = 89,
NDPI_PROTOCOL_PCANYWHERE = 90,
NDPI_PROTOCOL_SSL = 91,
NDPI_PROTOCOL_FREE90 = 90, /* Free */
NDPI_PROTOCOL_TLS = 91,
NDPI_PROTOCOL_SSH = 92,
NDPI_PROTOCOL_USENET = 93,
NDPI_PROTOCOL_MGCP = 94,
@@ -173,7 +166,7 @@ typedef enum {
NDPI_PROTOCOL_LASTFM = 134,
NDPI_PROTOCOL_WAZE = 135,
NDPI_PROTOCOL_YOUTUBE_UPLOAD = 136, /* Upload files to youtube */
NDPI_PROTOCOL_GENERIC = 137, /* Generic protocol used for category matching */
NDPI_PROTOCOL_HULU = 137,
NDPI_PROTOCOL_CHECKMK = 138,
NDPI_PROTOCOL_AJP = 139, /* Leonn Paiva <leonn.paiva@gmail.com> */
NDPI_PROTOCOL_APPLE = 140,
@@ -219,32 +212,32 @@ typedef enum {
NDPI_PROTOCOL_CNN = 180, /* Tomasz Bujlow <tomasz@skatnet.dk> */
NDPI_PROTOCOL_MEGACO = 181, /* Gianluca Costa <g.costa@xplico.org> */
NDPI_PROTOCOL_REDIS = 182,
NDPI_PROTOCOL_PANDO = 183, /* Tomasz Bujlow <tomasz@skatnet.dk> */
NDPI_PROTOCOL_FREE_183 = 183,
NDPI_PROTOCOL_VHUA = 184,
NDPI_PROTOCOL_TELEGRAM = 185, /* Gianluca Costa <g.costa@xplico.org> */
NDPI_PROTOCOL_VEVO = 186,
NDPI_PROTOCOL_PANDORA = 187,
NDPI_PROTOCOL_QUIC = 188, /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */
NDPI_PROTOCOL_WHATSAPP_VOICE = 189,
NDPI_PROTOCOL_ZOOM = 189, /* Zoom video conference. */
NDPI_PROTOCOL_EAQ = 190,
NDPI_PROTOCOL_OOKLA = 191,
NDPI_PROTOCOL_AMQP = 192,
NDPI_PROTOCOL_KAKAOTALK = 193, /* KakaoTalk Chat (no voice call) */
NDPI_PROTOCOL_KAKAOTALK_VOICE = 194, /* KakaoTalk Voice */
NDPI_PROTOCOL_TWITCH = 195, /* Edoardo Dominici <edoaramis@gmail.com> */
NDPI_PROTOCOL_FREE_196 = 196, /* Free */
NDPI_PROTOCOL_DOH_DOT = 196, /* DoH (DNS over HTTPS), DoT (DNS over TLS) */
NDPI_PROTOCOL_WECHAT = 197,
NDPI_PROTOCOL_MPEGTS = 198,
NDPI_PROTOCOL_SNAPCHAT = 199,
NDPI_PROTOCOL_SINA = 200,
NDPI_PROTOCOL_HANGOUT = 201,
NDPI_PROTOCOL_HANGOUT_DUO = 201, /* Google Hangout ad Duo (merged as they are very similar) */
NDPI_PROTOCOL_IFLIX = 202, /* www.vizuamatix.com R&D team & M.Mallawaarachchie <manoj_ws@yahoo.com> */
NDPI_PROTOCOL_GITHUB = 203,
NDPI_PROTOCOL_BJNP = 204,
NDPI_PROTOCOL_FREE_205 = 205, /* Free */
NDPI_PROTOCOL_VIDTO = 206,
NDPI_PROTOCOL_FREE_205 = 205,
NDPI_PROTOCOL_WIREGUARD = 206,
NDPI_PROTOCOL_SMPP = 207, /* Damir Franusic <df@release14.org> */
NDPI_PROTOCOL_DNSCRYPT = 208,
NDPI_PROTOCOL_DNSCRYPT = 208, /* Toni Uhlig <matzeton@googlemail.com> */
NDPI_PROTOCOL_TINC = 209, /* William Guglielmo <william@deselmo.com> */
NDPI_PROTOCOL_DEEZER = 210,
NDPI_PROTOCOL_INSTAGRAM = 211, /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
@@ -252,10 +245,10 @@ typedef enum {
NDPI_PROTOCOL_STARCRAFT = 213, /* Matteo Bracci <matteobracci1@gmail.com> */
NDPI_PROTOCOL_TEREDO = 214,
NDPI_PROTOCOL_HOTSPOT_SHIELD = 215,
NDPI_PROTOCOL_HEP = 216, /* sipcapture.org QXIP BV */
NDPI_PROTOCOL_IMO = 216,
NDPI_PROTOCOL_GOOGLE_DRIVE = 217,
NDPI_PROTOCOL_OCS = 218,
NDPI_PROTOCOL_OFFICE_365 = 219,
NDPI_PROTOCOL_MICROSOFT_365 = 219,
NDPI_PROTOCOL_CLOUDFLARE = 220,
NDPI_PROTOCOL_MS_ONE_DRIVE = 221,
NDPI_PROTOCOL_MQTT = 222,
@@ -272,21 +265,36 @@ typedef enum {
NDPI_PROTOCOL_LINKEDIN = 233, /* Paulo Angelo <pa@pauloangelo.com> */
NDPI_PROTOCOL_SOUNDCLOUD = 234,
NDPI_PROTOCOL_CSGO = 235, /* Counter-Strike Global Offensive, Dota = 2 */
NDPI_PROTOCOL_LISP = 236,
NDPI_PROTOCOL_DIAMETER = 237,
NDPI_PROTOCOL_LISP = 236,
NDPI_PROTOCOL_DIAMETER = 237,
NDPI_PROTOCOL_APPLE_PUSH = 238,
NDPI_PROTOCOL_GOOGLE_SERVICES = 239,
NDPI_PROTOCOL_AMAZON_VIDEO = 240,
NDPI_PROTOCOL_GOOGLE_DOCS = 241,
NDPI_PROTOCOL_WHATSAPP_FILES = 242, /* Videos, pictures, voice messages... */
NDPI_PROTOCOL_TARGUS_GETDATA = 243,
NDPI_PROTOCOL_DNP3 = 244,
NDPI_PROTOCOL_IEC60870 = 245, /* https://en.wikipedia.org/wiki/IEC_60870-5 */
NDPI_PROTOCOL_BLOOMBERG = 246,
NDPI_PROTOCOL_CAPWAP = 247,
NDPI_PROTOCOL_ZABBIX = 248,
NDPI_PROTOCOL_S7COMM = 249,
NDPI_PROTOCOL_MSTEAMS = 250,
NDPI_PROTOCOL_WEBSOCKET = 251, /* Leonn Paiva <leonn.paiva@gmail.com> */
NDPI_PROTOCOL_ANYDESK = 252, /* Toni Uhlig <matzeton@googlemail.com> */
NDPI_PROTOCOL_SOAP = 253, /* Toni Uhlig <matzeton@googlemail.com> */
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"
#endif
/*
IMPORTANT
before allocating a new identifier please fill up
one of those named NDPI_PROTOCOL_FREE_XXX and not used
(placeholders to avoid protocol renumbering)
*/
/* IMPORTANT:NDPI_LAST_IMPLEMENTED_PROTOCOL MUST BE THE LAST ELEMENT */
NDPI_LAST_IMPLEMENTED_PROTOCOL
} ndpi_protocol_id_t;
@@ -294,4 +302,5 @@ typedef enum {
#define NDPI_PROTOCOL_NO_MASTER_PROTO NDPI_PROTOCOL_UNKNOWN
#define NDPI_MAX_SUPPORTED_PROTOCOLS NDPI_LAST_IMPLEMENTED_PROTOCOL
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
#endif
#endif /* __NDPI_PROTOCOL_IDS_H__ */
+17 -167
View File
@@ -1,7 +1,7 @@
/*
* ndpi_protocols.h
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -51,161 +51,6 @@ u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struc
void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
/* Applications and other protocols. */
void ndpi_search_diameter(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_lisp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_gnutella(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_directconnect(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_applejuice_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_i23v5(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_socrates(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_soulseek_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_msn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_yahoo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_oscar(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_jabber_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_irc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_sip(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_hep(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_direct_download_link_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mail_pop_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_http_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_http_subprotocol_conf(struct ndpi_detection_module_struct *ndpi_struct, char *attr, char *value, int protocol_id);
void ndpi_search_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_usenet_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rtsp_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_filetopia_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_vmware(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ssl_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mms_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_icecast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_shoutcast_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_veohtv_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_openft_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_stun(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tvants_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_sopcast(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ppstream(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_pplive(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mgcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_zattoo(struct ndpi_detection_module_struct*ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_qq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_feidian(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ssh_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_thunder(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_activesync(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_in_non_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_vnc_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_steam(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_halflife2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_xbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_smb_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_telnet_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ntp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_nfs(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rtp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ssdp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_worldofwarcraft(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_postgres_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mysql_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_quake(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_secondlife(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_pcanywhere(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_kontiki(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_syslog(struct ndpi_detection_module_struct*ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_netbios(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mdns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ipp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ldap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_warcraft3(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_xdmcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tftp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mssql_tds(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_pptp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_stealthnet(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_afp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_checkmk(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_florensia(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_maplestory(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_world_of_kung_fu(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_guildwars_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_netflow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_sflow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_radius(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_wsus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_teamview(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_lotus_notes(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_gtp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_spotify(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_openvpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_noe(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_viber(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_teamspeak(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_corba(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_oracle(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rsync(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rtcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_skinny(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tor(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_whois_das(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_socks5(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_socks4(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rtmp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_pando(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_megaco(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_redis(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_zmq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_vhua(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_telegram(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_kakaotalk_voice(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mpegts(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_starcraft(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_coap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_mqtt (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_someip (struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_rx(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_git(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_bjnp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_smpp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_tinc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_fix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_csgo(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_ajp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_memcached(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
void ndpi_search_nest_log_sink(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
/* --- INIT FUNCTIONS --- */
void init_diameter_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_aimini_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -213,7 +58,6 @@ void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct,
void init_armagetron_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ayiya_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_amqp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_bgp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_lisp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -258,12 +102,11 @@ void init_mail_imap_dissector(struct ndpi_detection_module_struct *ndpi_struct,
void init_mail_pop_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mail_smtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_maplestory_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mdns_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_megaco_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mgpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mining_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mms_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_msn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_nats_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mpegts_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mssql_tds_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mysql_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -276,11 +119,7 @@ void init_ntp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3
void init_openft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_openvpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_oracle_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_oscar_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_pando_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_pcanywhere_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_postgres_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_pplive_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ppstream_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_pptp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_qq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -297,7 +136,7 @@ void init_rtsp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int
void init_sflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_shoutcast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_sip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_hep_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_imo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_skinny_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_skype_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_smb_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -308,7 +147,7 @@ void init_soulseek_dissector(struct ndpi_detection_module_struct *ndpi_struct, u
void init_socks_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_spotify_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ssh_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ssl_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tls_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_starcraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_stealthnet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_steam_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -322,7 +161,6 @@ void init_telnet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_i
void init_tftp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_thunder_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tor_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tvants_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tvuplayer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_usenet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_upnp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -337,7 +175,6 @@ void init_world_of_warcraft_dissector(struct ndpi_detection_module_struct *ndpi_
void init_world_of_kung_fu_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_xbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_xdmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_yahoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_zattoo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_zmq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_stracraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
@@ -357,10 +194,23 @@ void init_nintendo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_checkmk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_apple_push_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_amazon_video_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_whatsapp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ajp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_fbzero_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_memcached_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_nest_log_sink_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ookla_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_modbus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_capwap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_zabbix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_wireguard_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_targus_getdata_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_dnp3_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_104_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_s7comm_dissector(struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_websocket_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_soap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_dnscrypt_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
#endif /* __NDPI_PROTOCOLS_H__ */
File diff suppressed because it is too large Load Diff
+24 -1
View File
@@ -31,6 +31,8 @@
#define __mingw_forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__))
#endif
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#include <winsock2.h>
#include <windows.h>
#include <ws2tcpip.h>
@@ -39,6 +41,7 @@
#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */
#include <process.h> /* for getpid() and the exec..() family */
#include <stdint.h>
#include <time.h>
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
@@ -48,6 +51,17 @@
#define IPVERSION 4 /* on *nix it is defined in netinet/ip.h */
#ifndef MIN
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#endif
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif
#undef gettimeofday
#define gettimeofday mingw_gettimeofday
extern char* strsep(char **sp, char *sep);
typedef unsigned char u_char;
@@ -75,6 +89,15 @@ typedef unsigned __int64 u_int64_t;
extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */);
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
#define strtok_r strtok_s
#define timegm _mkgmtime
static inline struct tm * localtime_r(const time_t *timep, struct tm * result)
{
struct tm *timeinfo;
timeinfo = localtime(timep);
return timeinfo;
}
#endif /* __NDPI_WIN32_H__ */
+26 -10
View File
@@ -10,14 +10,15 @@
#
# Installation directories
#
prefix = /usr/local
prefix = @prefix@
libdir = ${prefix}/lib
includedir = ${prefix}/include/ndpi
CC = @CC@
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -O2 -g
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION -Wall @CFLAGS@ @CUSTOM_NDPI@
LDFLAGS = @LDFLAGS@ @ADDITIONAL_LIBS@ @LIBS@
RANLIB = ranlib
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) ndpi_main.o
OBJECTS = $(patsubst protocols/%.c, protocols/%.o, $(wildcard protocols/*.c)) $(patsubst third_party/src/%.c, third_party/src/%.o, $(wildcard third_party/src/*.c)) $(patsubst ./%.c, ./%.o, $(wildcard ./*.c))
HEADERS = $(wildcard ../include/*.h)
NDPI_VERSION_MAJOR = @NDPI_MAJOR@
NDPI_LIB_STATIC = libndpi.a
@@ -28,13 +29,19 @@ NDPI_LIBS = $(NDPI_LIB_STATIC) $(NDPI_LIB_SHARED)
ifneq ($(OS),Windows_NT)
OS := $(shell uname)
endif
BUILD_MINGW = @BUILD_MINGW@
ifeq ($(OS),Darwin)
CC=clang
SONAME_FLAG=
else
ifneq ($(BUILD_MINGW),)
NDPI_LIB_SHARED_BASE = libndpi
NDPI_LIB_SHARED = $(NDPI_LIB_SHARED_BASE)-@NDPI_VERSION_SHORT@.dll
else
SONAME_FLAG=-Wl,-soname,$(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
endif
endif
all: $(NDPI_LIBS)
@@ -42,26 +49,35 @@ ndpi_main.c: ndpi_content_match.c.inc
$(NDPI_LIB_STATIC): $(OBJECTS)
ar rc $@ $(OBJECTS)
$(RANLIB) $@
$(RANLIB) $@
$(NDPI_LIB_SHARED): $(OBJECTS)
$(CC) -shared -fPIC $(SONAME_FLAG) -o $@ $(OBJECTS)
ln -Ffs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE)
ln -Ffs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
$(CC) -shared -fPIC $(SONAME_FLAG) -o $@ $(OBJECTS) $(LDFLAGS)
ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE)
ln -fs $(NDPI_LIB_SHARED) $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -c $< -o $@
clean:
/bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo $(NDPI_LIB_SHARED)
/bin/rm -f $(NDPI_LIB_STATIC) $(OBJECTS) *.o *.so *.lo libndpi.so*
distdir:
cp ndpi_content_match.c.inc '$(distdir)/'
find . -type d | xargs -I'{}' mkdir -p '$(distdir)/{}'
find ../include -type f -name '*.h' | xargs -I'{}' cp '{}' '$(distdir)/{}'
find . -type f -name '*.c' -o -name '*.h' | xargs -I'{}' cp '{}' '$(distdir)/{}'
distclean: clean
/bin/rm -f Makefile
cppcheck:
cppcheck --template='{file}:{line}:{severity}:{message}' --quiet --enable=all --force -I ../include *.c protocols/*.c
install: $(NDPI_LIBS)
mkdir -p $(DESTDIR)$(libdir)
cp $(NDPI_LIBS) $(DESTDIR)$(libdir)/
ln -Ffs $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED) $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED_BASE)
ln -Ffs $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED) $(DESTDIR)$(libdir)/$(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR)
cp -P $(NDPI_LIB_SHARED_BASE) $(DESTDIR)$(libdir)/
cp -P $(NDPI_LIB_SHARED_BASE).$(NDPI_VERSION_MAJOR) $(DESTDIR)$(libdir)/
mkdir -p $(DESTDIR)$(includedir)
cp ../include/*.h $(DESTDIR)$(includedir)
+817
View File
@@ -0,0 +1,817 @@
/*
* ndpi_analyze.c
*
* Copyright (C) 2019 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library.
*
* 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/>.
*
*/
#ifdef HAVE_CONFIG_H
#include "ndpi_config.h"
#endif
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <stdint.h>
#include <math.h>
#include <float.h> /* FLT_EPSILON */
#include "ndpi_api.h"
#include "ndpi_config.h"
/* ********************************************************************************* */
void ndpi_init_data_analysis(struct ndpi_analyze_struct *ret, u_int16_t _max_series_len) {
u_int32_t len;
memset(ret, 0, sizeof(struct ndpi_analyze_struct));
if(_max_series_len > MAX_SERIES_LEN) _max_series_len = MAX_SERIES_LEN;
ret->num_values_array_len = _max_series_len;
if(ret->num_values_array_len > 0) {
len = sizeof(u_int32_t)*ret->num_values_array_len;
if((ret->values = ndpi_malloc(len)) == NULL) {
ndpi_free(ret);
ret = NULL;
} else
memset(ret->values, 0, len);
} else
ret->values = NULL;
}
/* ********************************************************************************* */
struct ndpi_analyze_struct* ndpi_alloc_data_analysis(u_int16_t _max_series_len) {
struct ndpi_analyze_struct *ret = ndpi_malloc(sizeof(struct ndpi_analyze_struct));
if(ret != NULL)
ndpi_init_data_analysis(ret, _max_series_len);
return(ret);
}
/* ********************************************************************************* */
void ndpi_free_data_analysis(struct ndpi_analyze_struct *d) {
if(d->values) ndpi_free(d->values);
ndpi_free(d);
}
/* ********************************************************************************* */
void ndpi_reset_data_analysis(struct ndpi_analyze_struct *d) {
memset(d, 0, sizeof(struct ndpi_analyze_struct));
memset(d->values, 0, sizeof(u_int32_t)*d->num_values_array_len);
d->num_data_entries = 0;
}
/* ********************************************************************************* */
/*
Add a new point to analyze
*/
void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value) {
if(s->sum_total == 0)
s->min_val = s->max_val = value;
else {
if(value < s->min_val) s->min_val = value;
if(value > s->max_val) s->max_val = value;
}
s->sum_total += value, s->num_data_entries++;
if(s->num_values_array_len) {
s->values[s->next_value_insert_index] = value;
if(++s->next_value_insert_index == s->num_values_array_len)
s->next_value_insert_index = 0;
}
/*
Optimized stddev calculation
https://www.khanacademy.org/math/probability/data-distributions-a1/summarizing-spread-distributions/a/calculating-standard-deviation-step-by-step
https://math.stackexchange.com/questions/683297/how-to-calculate-standard-deviation-without-detailed-historical-data
http://mathcentral.uregina.ca/QQ/database/QQ.09.02/carlos1.html
*/
s->stddev.sum_square_total += value * value;
}
/* ********************************************************************************* */
/* Compute the average on all values */
float ndpi_data_average(struct ndpi_analyze_struct *s) {
return((s->num_data_entries == 0) ? 0 : ((float)s->sum_total / (float)s->num_data_entries));
}
/* ********************************************************************************* */
u_int32_t ndpi_data_last(struct ndpi_analyze_struct *s) {
if((s->num_data_entries == 0) || (s->sum_total == 0))
return(0);
if(s->next_value_insert_index == 0)
return(s->values[s->num_values_array_len-1]);
else
return(s->values[s->next_value_insert_index-1]);
}
/* Return min/max on all values */
u_int32_t ndpi_data_min(struct ndpi_analyze_struct *s) { return(s->min_val); }
u_int32_t ndpi_data_max(struct ndpi_analyze_struct *s) { return(s->max_val); }
/* ********************************************************************************* */
/* Compute the variance on all values */
float ndpi_data_variance(struct ndpi_analyze_struct *s) {
return(s->num_data_entries ? (float)(s->stddev.sum_square_total - ((s->sum_total * s->sum_total) / (s->num_data_entries))) / (float)s->num_data_entries : 0);
}
/* ********************************************************************************* */
/*
See the link below for "Population and sample standard deviation review"
https://www.khanacademy.org/math/statistics-probability/summarizing-quantitative-data/variance-standard-deviation-sample/a/population-and-sample-standard-deviation-review
In nDPI we use an approximate stddev calculation to avoid storing all data in memory
*/
/* Compute the standard deviation on all values */
float ndpi_data_stddev(struct ndpi_analyze_struct *s) {
return(sqrt(ndpi_data_variance(s)));
}
/* ********************************************************************************* */
/* Compute the average only on the sliding window */
float ndpi_data_window_average(struct ndpi_analyze_struct *s) {
if(s->num_values_array_len) {
float sum = 0.0;
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
if(n == 0)
return(0);
for(i=0; i<n; i++)
sum += s->values[i];
return((float)sum / (float)n);
} else
return(0);
}
/* ********************************************************************************* */
/* Compute the variance only on the sliding window */
float ndpi_data_window_variance(struct ndpi_analyze_struct *s) {
if(s->num_values_array_len) {
float sum = 0.0, avg = ndpi_data_window_average(s);
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
if(n == 0)
return(0);
for(i=0; i<n; i++)
sum += pow(s->values[i]-avg, 2);
return((float)sum / (float)n);
} else
return(0);
}
/* ********************************************************************************* */
/* Compute the variance only on the sliding window */
float ndpi_data_window_stddev(struct ndpi_analyze_struct *s) {
return(sqrt(ndpi_data_window_variance(s)));
}
/* ********************************************************************************* */
/*
Compute entropy on the last sliding window values
*/
float ndpi_data_entropy(struct ndpi_analyze_struct *s) {
if(s->num_values_array_len) {
int i;
float sum = 0.0, total = 0.0;
for(i=0; i<s->num_values_array_len; i++)
total += s->values[i];
for (i=0; i<s->num_values_array_len; i++) {
float tmp = (float)s->values[i] / (float)total;
if(tmp > FLT_EPSILON)
sum -= tmp * logf(tmp);
}
return(sum / logf(2.0));
} else
return(0);
}
/* ********************************************************************************* */
void ndpi_data_print_window_values(struct ndpi_analyze_struct *s) {
if(s->num_values_array_len) {
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
for(i=0; i<n; i++)
printf("[%u: %u]", i, s->values[i]);
printf("\n");
}
}
/* ********************************************************************************* */
/*
Upload / download ration
-1 Download
0 Mixed
1 Upload
*/
float ndpi_data_ratio(u_int32_t sent, u_int32_t rcvd) {
float s = (float)((int64_t)sent + (int64_t)rcvd);
float d = (float)((int64_t)sent - (int64_t)rcvd);
return((s == 0) ? 0 : (d/s));
}
/* ********************************************************************************* */
const char* ndpi_data_ratio2str(float ratio) {
if(ratio < -0.2) return("Download");
else if(ratio > 0.2) return("Upload");
else return("Mixed");
}
/* ********************************************************************************* */
/* ********************************************************************************* */
#include "third_party/src/hll/hll.c"
#include "third_party/src/hll/MurmurHash3.c"
int ndpi_hll_init(struct ndpi_hll *hll, u_int8_t bits) {
return(hll_init(hll, bits));
}
void ndpi_hll_destroy(struct ndpi_hll *hll) {
hll_destroy(hll);
}
void ndpi_hll_reset(struct ndpi_hll *hll) {
hll_reset(hll);
}
void ndpi_hll_add(struct ndpi_hll *hll, const char *data, size_t data_len) {
hll_add(hll, (const void *)data, data_len);
}
void ndpi_hll_add_number(struct ndpi_hll *hll, u_int32_t value) {
hll_add(hll, (const void *)&value, sizeof(value));
}
double ndpi_hll_count(struct ndpi_hll *hll) {
return(hll_count(hll));
}
/* ********************************************************************************* */
/* ********************************************************************************* */
int ndpi_init_bin(struct ndpi_bin *b, enum ndpi_bin_family f, u_int8_t num_bins) {
b->num_bins = num_bins, b->family = f, b->is_empty = 1;
switch(f) {
case ndpi_bin_family8:
if((b->u.bins8 = (u_int8_t*)ndpi_calloc(num_bins, sizeof(u_int8_t))) == NULL)
return(-1);
break;
case ndpi_bin_family16:
if((b->u.bins16 = (u_int16_t*)ndpi_calloc(num_bins, sizeof(u_int16_t))) == NULL)
return(-1);
break;
case ndpi_bin_family32:
if((b->u.bins32 = (u_int32_t*)ndpi_calloc(num_bins, sizeof(u_int32_t))) == NULL)
return(-1);
break;
}
return(0);
}
/* ********************************************************************************* */
void ndpi_free_bin(struct ndpi_bin *b) {
switch(b->family) {
case ndpi_bin_family8:
free(b->u.bins8);
break;
case ndpi_bin_family16:
free(b->u.bins16);
break;
case ndpi_bin_family32:
free(b->u.bins32);
break;
}
}
/* ********************************************************************************* */
struct ndpi_bin* ndpi_clone_bin(struct ndpi_bin *b) {
struct ndpi_bin *out = (struct ndpi_bin*)ndpi_malloc(sizeof(struct ndpi_bin));
if(!out) return(NULL);
out->num_bins = b->num_bins, out->family = b->family, out->is_empty = b->is_empty;
switch(out->family) {
case ndpi_bin_family8:
if((out->u.bins8 = (u_int8_t*)ndpi_calloc(out->num_bins, sizeof(u_int8_t))) == NULL) {
free(out);
return(NULL);
} else
memcpy(out->u.bins8, b->u.bins8, out->num_bins*sizeof(u_int8_t));
break;
case ndpi_bin_family16:
if((out->u.bins16 = (u_int16_t*)ndpi_calloc(out->num_bins, sizeof(u_int16_t))) == NULL) {
free(out);
return(NULL);
} else
memcpy(out->u.bins16, b->u.bins16, out->num_bins*sizeof(u_int16_t));
break;
case ndpi_bin_family32:
if((out->u.bins32 = (u_int32_t*)ndpi_calloc(out->num_bins, sizeof(u_int32_t))) == NULL) {
free(out);
return(NULL);
} else
memcpy(out->u.bins32, b->u.bins32, out->num_bins*sizeof(u_int32_t));
break;
}
return(out);
}
/* ********************************************************************************* */
void ndpi_set_bin(struct ndpi_bin *b, u_int8_t slot_id, u_int32_t val) {
if(slot_id >= b->num_bins) slot_id = 0;
switch(b->family) {
case ndpi_bin_family8:
b->u.bins8[slot_id] = (u_int8_t)val;
break;
case ndpi_bin_family16:
b->u.bins16[slot_id] = (u_int16_t)val;
break;
case ndpi_bin_family32:
b->u.bins32[slot_id] = (u_int32_t)val;
break;
}
}
/* ********************************************************************************* */
void ndpi_inc_bin(struct ndpi_bin *b, u_int8_t slot_id, u_int32_t val) {
b->is_empty = 0;
if(slot_id >= b->num_bins) slot_id = 0;
switch(b->family) {
case ndpi_bin_family8:
b->u.bins8[slot_id] += (u_int8_t)val;
break;
case ndpi_bin_family16:
b->u.bins16[slot_id] += (u_int16_t)val;
break;
case ndpi_bin_family32:
b->u.bins32[slot_id] += (u_int32_t)val;
break;
}
}
/* ********************************************************************************* */
u_int32_t ndpi_get_bin_value(struct ndpi_bin *b, u_int8_t slot_id) {
if(slot_id >= b->num_bins) slot_id = 0;
switch(b->family) {
case ndpi_bin_family8:
return(b->u.bins8[slot_id]);
break;
case ndpi_bin_family16:
return(b->u.bins16[slot_id]);
break;
case ndpi_bin_family32:
return(b->u.bins32[slot_id]);
break;
}
return(0);
}
/* ********************************************************************************* */
void ndpi_reset_bin(struct ndpi_bin *b) {
b->is_empty = 1;
switch(b->family) {
case ndpi_bin_family8:
memset(b->u.bins8, 0, sizeof(u_int8_t)*b->num_bins);
break;
case ndpi_bin_family16:
memset(b->u.bins16, 0, sizeof(u_int16_t)*b->num_bins);
break;
case ndpi_bin_family32:
memset(b->u.bins32, 0, sizeof(u_int32_t)*b->num_bins);
break;
}
}
/* ********************************************************************************* */
/*
Each bin slot is transformed in a % with respect to the value total
*/
void ndpi_normalize_bin(struct ndpi_bin *b) {
u_int8_t i;
u_int32_t tot = 0;
if(b->is_empty) return;
switch(b->family) {
case ndpi_bin_family8:
for(i=0; i<b->num_bins; i++) tot += b->u.bins8[i];
if(tot > 0) {
for(i=0; i<b->num_bins; i++)
b->u.bins8[i] = (b->u.bins8[i]*100) / tot;
}
break;
case ndpi_bin_family16:
for(i=0; i<b->num_bins; i++) tot += b->u.bins16[i];
if(tot > 0) {
for(i=0; i<b->num_bins; i++)
b->u.bins16[i] = (b->u.bins16[i]*100) / tot;
}
break;
case ndpi_bin_family32:
for(i=0; i<b->num_bins; i++) tot += b->u.bins32[i];
if(tot > 0) {
for(i=0; i<b->num_bins; i++)
b->u.bins32[i] = (b->u.bins32[i]*100) / tot;
}
break;
}
}
/* ********************************************************************************* */
char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf, u_int out_buf_len) {
u_int8_t i;
u_int len = 0;
if(!out_buf) return(out_buf); else out_buf[0] = '\0';
if(normalize_first)
ndpi_normalize_bin(b);
switch(b->family) {
case ndpi_bin_family8:
for(i=0; i<b->num_bins; i++) {
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
if(rc < 0) break;
len += rc;
}
break;
case ndpi_bin_family16:
for(i=0; i<b->num_bins; i++) {
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
if(rc < 0) break;
len += rc;
}
break;
case ndpi_bin_family32:
for(i=0; i<b->num_bins; i++) {
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
if(rc < 0) break;
len += rc;
}
break;
}
return(out_buf);
}
/* ********************************************************************************* */
// #define COSINE_SIMILARITY
/*
Determines how similar are two bins
Cosine Similiarity
0 = Very differet
... (gray zone)
1 = Alike
See https://en.wikipedia.org/wiki/Cosine_similarity for more details
---
Euclidean similarity
0 = alike
...
the higher the more different
*/
float ndpi_bin_similarity(struct ndpi_bin *b1, struct ndpi_bin *b2, u_int8_t normalize_first) {
u_int8_t i;
if(
// (b1->family != b2->family) ||
(b1->num_bins != b2->num_bins))
return(-1);
if(normalize_first)
ndpi_normalize_bin(b1), ndpi_normalize_bin(b2);
#ifdef COSINE_SIMILARITY
{
u_int32_t sumxx = 0, sumxy = 0, sumyy = 0;
for(i=0; i<b1->num_bins; i++) {
u_int32_t a = ndpi_get_bin_value(b1, i);
u_int32_t b = ndpi_get_bin_value(b2, i);
sumxx += a*a, sumyy += b*b, sumxy += a*b;
}
if((sumxx == 0) || (sumyy == 0))
return(0);
else
return((float)sumxy / sqrt((float)(sumxx * sumyy)));
}
#else
{
u_int32_t sum = 0;
for(i=0; i<b1->num_bins; i++) {
u_int32_t a = ndpi_get_bin_value(b1, i);
u_int32_t b = ndpi_get_bin_value(b2, i);
u_int32_t diff = (a > b) ? (a - b) : (b - a);
if(a != b) sum += pow(diff, 2);
// printf("[a: %u][b: %u][sum: %u]\n", a, b, sum);
}
/* The lower the more similar */
return(sqrt(sum));
}
#endif
}
/* ********************************************************************************* */
#define MAX_NUM_CLUSTERS 128
/*
Clusters bins into 'num_clusters'
- (in) bins: a vection 'num_bins' long of bins to cluster
- (in) 'num_clusters': number of desired clusters 0...(num_clusters-1)
- (out) 'cluster_ids': a vector 'num_bins' long containing the id's of each clustered bin
- (out) 'centroids': an optional 'num_clusters' long vector of (centroid) bins
See
- https://en.wikipedia.org/wiki/K-means_clustering
*/
int ndpi_cluster_bins(struct ndpi_bin *bins, u_int16_t num_bins,
u_int8_t num_clusters, u_int16_t *cluster_ids,
struct ndpi_bin *centroids) {
u_int16_t i, j, max_iterations = 25, num_iterations, num_moves;
u_int8_t verbose = 0, alloc_centroids = 0;
char out_buf[256];
float *bin_score;
u_int16_t num_cluster_elems[MAX_NUM_CLUSTERS] = { 0 };
srand(time(NULL));
if(num_clusters > num_bins) num_clusters = num_bins;
if(num_clusters > MAX_NUM_CLUSTERS) num_clusters = MAX_NUM_CLUSTERS;
if(verbose)
printf("Distributing %u bins over %u clusters\n", num_bins, num_clusters);
if((bin_score = (float*)ndpi_calloc(num_bins, sizeof(float))) == NULL)
return(-2);
if(centroids == NULL) {
alloc_centroids = 1;
if((centroids = (struct ndpi_bin*)ndpi_malloc(sizeof(struct ndpi_bin)*num_clusters)) == NULL) {
ndpi_free(bin_score);
return(-2);
} else {
for(i=0; i<num_clusters; i++)
ndpi_init_bin(&centroids[i], ndpi_bin_family32 /* Use 32 bit to avoid overlaps */, bins[0].num_bins);
}
}
/* Reset the id's */
memset(cluster_ids, 0, sizeof(u_int16_t) * num_bins);
/* Randomly pick a cluster id */
for(i=0; i<num_bins; i++) {
u_int cluster_id = rand() % num_clusters;
cluster_ids[i] = cluster_id;
if(verbose)
printf("Initializing cluster %u for bin %u: %s\n",
cluster_id, i,
ndpi_print_bin(&bins[i], 0, out_buf, sizeof(out_buf)));
num_cluster_elems[cluster_id]++;
}
num_iterations = 0;
/* Now let's try to find a better arrangement */
while(num_iterations++ < max_iterations) {
/* Compute the centroids for each cluster */
memset(bin_score, 0, num_bins*sizeof(float));
if(verbose) {
printf("\nIteration %u\n", num_iterations);
for(j=0; j<num_clusters; j++)
printf("Cluster %u: %u bins\n", j, num_cluster_elems[j]);
}
for(i=0; i<num_clusters; i++)
ndpi_reset_bin(&centroids[i]);
for(i=0; i<num_bins; i++) {
for(j=0; j<bins[i].num_bins; j++) {
ndpi_inc_bin(&centroids[cluster_ids[i]], j, ndpi_get_bin_value(&bins[i], j));
}
}
for(i=0; i<num_clusters; i++) {
ndpi_normalize_bin(&centroids[i]);
if(verbose)
printf("Centroid [%u] %s\n", i,
ndpi_print_bin(&centroids[i], 0, out_buf, sizeof(out_buf)));
}
/* Now let's check if there are bins to move across clusters */
num_moves = 0;
for(i=0; i<num_bins; i++) {
u_int16_t j;
float best_similarity, current_similarity = 0;
u_int8_t cluster_id = 0;
if(verbose)
printf("Analysing bin %u [cluster: %u]\n",
i, cluster_ids[i]);
#ifdef COSINE_SIMILARITY
best_similarity = -1;
#else
best_similarity = 99999999999;
#endif
for(j=0; j<num_clusters; j++) {
float similarity;
if(centroids[j].is_empty) continue;
similarity = ndpi_bin_similarity(&bins[i], &centroids[j], 0);
if(j == cluster_ids[i])
current_similarity = similarity;
if(verbose)
printf("Bin %u / centroid %u [similarity: %f]\n", i, j, similarity);
#ifdef COSINE_SIMILARITY
if(similarity > best_similarity) {
cluster_id = j, best_similarity = similarity;
}
#else
if(similarity < best_similarity) {
cluster_id = j, best_similarity = similarity;
}
#endif
}
if((best_similarity == current_similarity) && (num_cluster_elems[cluster_ids[i]] > 1)) {
/*
In case of identical similarity let's leave things as they are
this unless this is a cluster with only one element
*/
cluster_id = cluster_ids[i];
}
bin_score[i] = best_similarity;
if(cluster_ids[i] != cluster_id) {
if(verbose)
printf("Moved bin %u from cluster %u -> %u [similarity: %f]\n",
i, cluster_ids[i], cluster_id, best_similarity);
num_cluster_elems[cluster_ids[i]]--;
num_cluster_elems[cluster_id]++;
cluster_ids[i] = cluster_id;
num_moves++;
}
}
if(num_moves == 0)
break;
if(verbose) {
for(j=0; j<num_clusters; j++)
printf("Cluster %u: %u bins\n", j, num_cluster_elems[j]);
}
#if 0
for(j=0; j<num_clusters; j++) {
if(num_cluster_elems[j] == 0) {
u_int16_t candidate;
float score;
if(verbose)
printf("\nCluster %u is empty: need to rebalance\n", j);
#ifdef COSINE_SIMILARITY
score = 99999999999;
for(i=0; i<num_bins; i++) {
if((cluster_ids[i] != j) && (bin_score[i] < score) && (num_cluster_elems[cluster_ids[i]] > 1))
score = bin_score[i], candidate = i;
}
#else
score = 0;
for(i=0; i<num_bins; i++) {
if((cluster_ids[i] != j) && (bin_score[i] > score) && (num_cluster_elems[cluster_ids[i]] > 1))
score = bin_score[i], candidate = i;
}
#endif
if(verbose)
printf("Rebalance: moving bin %u from cluster %u -> %u [similarity: %f]\n",
candidate, cluster_ids[candidate], j, score);
num_cluster_elems[cluster_ids[candidate]]--;
num_cluster_elems[j]++;
cluster_ids[candidate] = j;
}
}
#endif
} /* while(...) */
if(alloc_centroids) {
for(i=0; i<num_clusters; i++)
ndpi_free_bin(&centroids[i]);
ndpi_free(centroids);
}
ndpi_free(bin_score);
return(0);
}
/* ********************************************************************************* */
+694
View File
@@ -0,0 +1,694 @@
/*
*
* Copyright (c) 2016 Cisco Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of the Cisco Systems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/**
* \file ndpi_classify.c
*
* \brief contains the functionality for inline classification
*
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <ctype.h>
// #include <sys/time.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "ndpi_main.h"
#include "ndpi_classify.h"
#include "ndpi_includes.h"
/** finds the minimum value between to inputs */
#ifndef min
#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#endif
//bias (1) + w (207)
//const float ndpi_parameters_splt[NUM_PARAMETERS_SPLT_LOGREG] = {
float ndpi_parameters_splt[NUM_PARAMETERS_SPLT_LOGREG] = {
-2.088057846500587456e+00, 7.763936238952200239e-05, 4.404309737393306595e-05, -9.467385027293546973e-02,
4.348947142638090457e-01, -2.091409170053043390e-04, -5.788902107267982974e-04, 4.481443450852441001e-10,
-3.136135459023654537e+00, -1.507730262127600751e+00, -1.204663669965535977e+00, -1.171839254318371104e+00,
4.329302247232582057e-01, 8.310653628092458334e+00, 3.299246725156660176e+00, 0.000000000000000000e+00,
1.847454931582027254e-02, -1.498024139966201096e+00, -7.660670007653060942e-01, -2.908130300830076731e+00,
-1.252564844610269734e+00, -1.910955328742287573e+00, 9.471710980110392697e-01, 2.352302758516665371e+00,
2.982269972214651954e+00, 4.280736383314343918e+00, 4.633629909719495288e+00, -2.198052637823726840e+00,
-1.150759637168392580e+00, 3.420433363184381292e+00, 1.857878113059351077e-02, -1.559806674919653746e+00,
4.197498183183401288e+00, 6.262186949633183453e+00, 1.100694844370524095e+01, 2.778688785515088000e+01,
3.679948298336883195e+00, -2.432801394376875592e+00, 5.133442052706843617e-01, 2.181172654073517680e+00,
-8.577551729671881731e-01, 7.013844214023315926e-01, 3.138233436228588857e+00, 7.319940508466630247e-01,
0.000000000000000000e+00, 3.529209394581482861e+00, 1.464585117707144413e+01, 8.506550226820598359e-01,
-9.060397326548508268e-01, 6.787474954688997641e+00, 8.125411068867387954e+00, 4.515740684104064151e+00,
5.372135582950940069e+00, 9.210951196799497254e-01, 4.802177410869620466e+00, 2.945445016176073594e+01,
1.575032253128311632e+00, -1.355276854364796946e-01, -3.322474764169629502e-01, 3.018397817188666732e+00,
1.186503569922195744e+00, 0.000000000000000000e+00, 8.883242370198487503e-01, 7.248276146728496627e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, -4.831246718433664711e+00, 6.124136970173365002e-01,
4.145693892559814686e-01, 2.683998941637626867e+00, 2.063906603639539039e+00, 2.989801217386735210e+00,
2.262965767379551962e-01, 2.240332214649647380e+00, 5.984550782416063086e+00, 4.587011255338186544e+00,
1.233118485315272039e+01, 1.115223490909697857e+00, -3.682686422016995476e+00, 6.096498453291562258e-01,
1.119275528656461516e+00, 1.377886278915177731e-01, 3.828176805973048324e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 1.442927634029647344e+01, 0.000000000000000000e+00, 5.719118583309401593e-01,
1.993632609731877392e-01, 3.047472271520709430e+00, 5.736784864911910198e+00, 6.677826247219391220e+00,
6.307175478564531090e+00, 3.150295169417364249e+01, 3.738597740702392258e+00, 1.129754590514236234e+01,
6.108506268573830056e+00, 1.605489516792866667e+00, 2.929631990348545489e+00, -2.832543082245212937e-02,
1.358286530670594461e+00, 1.655932469853677924e+00, 6.701964773769768513e-01, 2.131182050917533211e+00,
2.998351165769753468e+00, 7.772095996358327596e+00, 1.285014785269981141e+00, 4.407334784589962418e+00,
1.719858214230612026e+00, -1.012765674651314063e+00, -5.749271123172469133e-01, -3.559614093795681278e+00,
-3.073088477387719397e+00, -4.492469521371540431e+00, -3.753286990415885427e+00, -3.219255423324282273e+00,
-2.806436518181075090e+00, -2.697305948568419875e+00, -7.879608430851776646e-01, 4.625507221739111330e+00,
4.809280703883450414e+00, -3.435194026629848629e+00, -3.218943068168937049e+00, 3.335535704890596698e+00,
2.071359212435486263e+00, 4.538992059175040339e+00, -2.770772323566738038e+01, 2.903047708571506735e+00,
-4.436143805989154032e+00, -2.647991280011542381e-01, 1.737252348126810064e+00, -4.121989655995259128e+00,
3.209709099445720581e-01, 1.012758514896711759e+01, 3.313255624721038295e+00, 4.631467619785444967e+00,
7.668642402146534032e+00, 6.780938812710099128e+00, -3.256164342602652972e+00, 6.749565128319576779e-01,
0.000000000000000000e+00, -4.407265954524525853e+00, 0.000000000000000000e+00, -3.666522115024547901e+01,
-7.886029397826226273e+01, 0.000000000000000000e+00, 0.000000000000000000e+00, -2.261283814517791058e+01,
-4.024317426178160240e+00, 3.213063737030031342e-01, 5.079805145796887800e+00, 1.326813226475260343e+00,
1.233684078112145643e+00, 8.671852503871454232e+00, -2.041800256066371944e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -1.607347800380474823e+01, -4.430790279223246309e+00, 1.177552465851384511e+00,
6.342921220500139512e+00, -2.466913734548706327e-02, 3.451642566010713065e-01, -6.012767168531006234e+00,
7.328146570137336724e+00, 7.500088131707050465e+00, 0.000000000000000000e+00, -3.547913249211809017e+01,
-3.130964814607208879e+00, 8.247326544297072237e-01, 3.757262485775580418e-01, -2.136528302027558723e+00,
-2.631627236037529793e-01, -2.016718799388414141e+01, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -7.708602132869285528e-01, -2.602868328868111814e+00, 1.435184800833797958e+00,
0.000000000000000000e+00, -2.080420864280113413e+00, 1.169498351211070819e+00, -1.798334115637199560e+01,
-1.193885252696202670e+01, 0.000000000000000000e+00, 0.000000000000000000e+00, 4.304089297965300709e+00,
-3.020893216686394656e+00, -1.234427481614708721e+00, 0.000000000000000000e+00, 1.853340741926325697e+00,
-2.686000064995862147e+01, -1.672275139058893600e+01, -2.826268691607605987e+01, 0.000000000000000000e+00,
0.000000000000000000e+00, -1.547397429377200817e+00, -4.018181657009961327e+00, -7.289186736637049968e+00,
-7.458655219230571731e+00, -9.625538282761622710e+00, -1.103039457077456298e+01, -6.262675161142102809e+01,
-9.265912629799268885e+00, -8.961543476816615339e+00, -9.622764435629340696e+00, -1.097978292092879826e+01,
};
//bias (1) + w (207)
//const float ndpi_parameters_bd[NUM_PARAMETERS_BD_LOGREG] = {
float ndpi_parameters_bd[NUM_PARAMETERS_BD_LOGREG] = {
-1.678134053325450292e+00, 1.048946534609769413e-04, 9.608725756967682636e-05, -7.515489355100658797e-02,
2.089554874872663892e-01, -1.012058874142656513e-04, -2.917652723373885169e-04, 1.087540461196068741e-10,
-2.594688448425090055e+00, -2.071803573048482061e+00, -1.399303273236228939e+00, -2.089300736641718004e+00,
-8.842347826063630123e-01, 6.476433717022786141e+00, 3.114501282249810377e+00, -2.239127990932460399e+00,
-4.667574389646080291e-01, -2.200651610813817438e+00, -1.674926704401964894e+00, -3.894420410398949706e+00,
-1.232376502509682004e+00, -2.231027070413975189e+00, 7.691948448668822769e-01, 3.222335181407633531e+00,
1.430983188964249919e+00, 2.144317250116257956e+00, 6.596745231472220361e+00, -2.464580889153460852e+00,
-1.923337901965658681e+00, 2.910328594745831943e+00, -3.123244869063500073e-01, -1.683345539896562659e+00,
3.785795988845424898e+00, 5.235473328290667361e+00, 8.512526402199654285e+00, 1.393475907195251473e+01,
1.673386027437856916e+00, -2.910729265724139925e+00, 2.969886703676111184e-01, 1.700051266957717466e+00,
-5.472121114836264733e-01, 1.716354591332415469e-01, 3.177884264837486317e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 1.924354871334499062e-01, 6.568439271753665487e+00, 2.102316342451608644e-01,
-1.132124603237853355e+00, 7.329625148148498859e+00, 6.606460464951361189e+00, 2.844223241371105271e+00,
3.078771172794853683e+00, 0.000000000000000000e+00, 2.656884613648917703e+00, 1.779697712165259205e+01,
0.000000000000000000e+00, -3.457017935109325535e-01, 2.157595478838472414e-01, 3.829196175023549031e+00,
0.000000000000000000e+00, 1.650776974765602867e-01, 1.357223085191380796e-02, 3.946357663253555081e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, -2.155616432815957495e+00, 8.213633570666911687e-01,
1.125480801049912050e-01, 2.684005418659722420e+00, 5.769541257304295900e-01, 1.060883870466023948e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 3.413708974045502664e+00, 2.275281553961784553e+00,
5.176725998383044924e+00, 1.019445219242678835e+00, -1.848344450190015698e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 1.491820649409327126e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 9.379741891282449728e+00, 0.000000000000000000e+00, 5.444605374840002510e-01,
-9.654403640632221173e-02, 2.642171746731144744e+00, 4.626416118226488905e+00, 3.654642208477139498e+00,
3.427412899258296619e+00, 1.490784083593987397e+01, 2.322393214516801141e+00, 6.511453713852694669e+00,
6.949721651828602020e+00, 1.186838154505042375e+00, 2.072129970488261197e+00, 0.000000000000000000e+00,
1.598928631178261561e+00, 5.926083912988970859e-01, -1.612886287403501873e-01, 9.452951868724716045e-01,
2.145707914290207352e+00, 5.391610489831286657e+00, 8.454389313314318866e-01, 2.372736567215404602e+00,
-3.130110237826235764e-01, -2.994989290166069740e+00, -2.571950567149417832e+00, -5.018016256298333921e+00,
-4.851489154898488643e+00, -7.101788768628541249e+00, -5.227281714666618839e+00, -6.351346048086286444e+00,
-4.558191218464671124e+00, -5.293990544168526213e+00, -2.920034449434862345e-01, 5.166915658100844411e+00,
4.642130303354632836e+00, -5.246106907306949951e-01, -3.120281208300208498e+00, 1.544764033379846691e+00,
0.000000000000000000e+00, 3.721469736246234561e+00, -1.083434721745241625e+01, 2.901590918368040395e+00,
-3.602037909234679258e+00, 0.000000000000000000e+00, 2.736307835089097917e+00, -5.037400262764839987e+00,
-1.163050013241316849e+00, 6.565863507998260573e+00, 1.872406036485896097e+00, 2.249439295570562880e+00,
3.276076277814265136e+00, 5.747730113795930684e+00, -2.084335807954610154e+00, 1.812930768433161921e+00,
0.000000000000000000e+00, -4.068875727535363751e+00, -4.509432609364653205e-02, -1.424182063303933710e+01,
-1.743400430675688639e+01, 0.000000000000000000e+00, 0.000000000000000000e+00, -8.986019040369217947e+00,
-2.005955598483518898e+00, 1.514163405869717538e+00, 4.060752357984299010e+00, 1.405971170124569403e+00,
1.383171915541985708e+00, 4.654452090729912506e+00, -3.395023560174311950e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -8.562968788250293173e+00, -1.939561462845156514e+00, 2.627499899415196793e+00,
4.949794698120698833e+00, 4.355655772643094448e-01, 0.000000000000000000e+00, -1.055190553626396577e+00,
4.757318838337171840e+00, 3.966536148163406938e+00, 0.000000000000000000e+00, -1.190662117721104352e+01,
-1.673945042186458121e+00, 0.000000000000000000e+00, -1.203943763219820356e-02, -1.411827841131889194e+00,
-7.623501643009024109e-01, -6.774873775798392117e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, -1.755294779557688090e+00, 1.542887322103192238e+00,
0.000000000000000000e+00, -8.228978371972577310e-01, 0.000000000000000000e+00, -5.379142925264499553e+00,
-1.144060263986041326e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 4.731108583634047626e+00,
-1.569393147397664556e+00, -3.449886418134247568e-01, 0.000000000000000000e+00, 1.658412661295906920e+00,
-5.077151059809188460e+00, -7.326467579034271260e+00, -1.190177296658179840e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, -1.914781807241187739e+00, -5.438446604150855457e+00,
-5.988893208768400811e+00, -7.886849112491050029e+00, -9.355574940159534947e+00, -1.682361325340106006e+01,
-7.609538696398503888e+00, -7.363350786768400269e+00, -7.366039984795356155e+00, -7.051111570136543882e+00,
2.337391373249395610e+00, -4.374845402801011574e+01, -3.610863365629191080e+00, 7.684297617701028571e+01,
2.162851395732025139e+01, 1.066280518306870562e+01, 8.109257308306457901e+01, 5.149561395669890906e+00,
0.000000000000000000e+00, 3.219993054481156136e+00, 0.000000000000000000e+00, 2.093519725422254396e+01,
-5.225298528278367272e+00, 0.000000000000000000e+00, 2.159597932230871820e+00, -5.205637201784965384e+01,
1.601979388461561982e+01, 6.945290207097973401e+00, 8.036724740759808583e-01, 4.712266457087280536e+00,
2.146353485778652370e+01, 3.470089369007970248e+01, 9.468591086256607170e+00, 9.760488656497257054e-01,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 9.008837970422939323e-01,
0.000000000000000000e+00, 1.462843531299845168e+01, 0.000000000000000000e+00, 0.000000000000000000e+00,
-1.179406942091425847e+01, 0.000000000000000000e+00, 1.642473653464513816e+01, 1.387228776263151175e+01,
0.000000000000000000e+00, 1.613129141280310108e+01, 0.000000000000000000e+00, -1.077318890268341045e+00,
4.189407459072477802e-01, 0.000000000000000000e+00, -1.570052145651456899e+00, 0.000000000000000000e+00,
1.120834605828141939e+01, 4.286417457736029490e+01, 0.000000000000000000e+00, 2.938378293327098945e+01,
1.194087082487160956e+01, 0.000000000000000000e+00, -9.951431855637998813e-02, 3.844291513997798448e-01,
2.362333099868798669e+01, -1.002532136112976957e+01, 2.427817537309562823e+01, 0.000000000000000000e+00,
1.076329692188489773e+01, 1.760895870067486157e+00, 2.080295785135324849e+01, -4.335217053626006134e+01,
-6.272369476984676062e-01, 5.165768790797590881e+00, -4.507215926635629311e-01, 0.000000000000000000e+00,
-4.242472062530233679e+00, -4.931831554080153168e+00, -2.806203935735193777e+00, -2.670377941558885126e+01,
0.000000000000000000e+00, -2.124688439238133242e+01, 0.000000000000000000e+00, 0.000000000000000000e+00,
2.452415244698852970e+00, -1.173727222080745092e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
-1.458125295680756039e+01, -1.757703406512062827e+01, 0.000000000000000000e+00, 3.943626521423988951e+00,
0.000000000000000000e+00, -4.006095410470026152e+00, 1.727171067402430538e+01, -3.412620901789366457e+01,
0.000000000000000000e+00, 1.760073934312834254e+01, 3.266082201875645552e+01, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 1.514535424913179362e+01, 0.000000000000000000e+00,
0.000000000000000000e+00, -3.100487758075622935e-01, 0.000000000000000000e+00, 2.387863228159451978e+01,
1.237098847411416891e+01, 1.154430573879687560e-02, 7.976366278729441817e+00, 0.000000000000000000e+00,
-6.296727640787388447e-01, 1.406230674131906255e+01, 1.430275589872723430e+01, -2.231764570537816184e+00,
0.000000000000000000e+00, 5.003869692542436631e+00, 0.000000000000000000e+00, -5.482127427587509594e+00,
-8.830547931126154992e+00, -5.376776036224484301e+01, -2.918517871695104304e+01, -1.009022417771788049e+01,
-4.811775051355994037e+00, -1.188016976215758547e+01, -2.055483647266791536e+01, -2.482333959706277327e+01,
-1.048392515070836950e+01, -3.837352144714887459e+01, 0.000000000000000000e+00, -9.298440675063780247e+00,
0.000000000000000000e+00, 3.584086297861655890e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 1.184271790014085113e+00,
1.594266439891793219e+01, 0.000000000000000000e+00, 8.473235161049382569e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 6.748879951595517568e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -1.057534737660506430e+01, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -3.179879192807419841e+01, 0.000000000000000000e+00, 5.000324879565139824e+00,
0.000000000000000000e+00, 1.229183419446936654e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
4.127983063177185663e+00, 6.616705680943091750e+00, 5.848245769217652601e+00, -1.818944631334333550e+01,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
2.694838778746875274e+00, 0.000000000000000000e+00, 1.463145767737777625e+01, -4.924734438569850603e+00,
0.000000000000000000e+00, 1.877377621310543088e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
1.971941442729244764e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 1.732809836566829187e+00, 2.700285877421266534e+01,
2.915978562591383216e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, -6.999629705176019456e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 1.089611710258455268e+01,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
2.121018958070171934e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
-7.416250358067024706e+00, -1.263327458973565065e+01, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 2.241612733384156897e+01,
0.000000000000000000e+00, 8.607688079645482659e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 1.750217629228628269e+01, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, -1.957769005108392690e+01, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -3.242393079195928784e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, 0.000000000000000000e+00, 1.348338590741638932e+01, 0.000000000000000000e+00,
-2.000312276678208392e-02, -7.776608146776987640e-01, 0.000000000000000000e+00, 0.000000000000000000e+00,
0.000000000000000000e+00, -5.387825733845168941e+00, 0.000000000000000000e+00, 2.153516224136292934e+01,
0.000000000000000000e+00, 0.000000000000000000e+00, -9.635140703414636576e+00, 2.603288107669730511e+00,
};
/**
* \fn void ndpi_merge_splt_arrays (const uint16_t *pkt_len, const pkt_timeval *pkt_time,
const uint16_t *pkt_len_twin, const pkt_timeval *pkt_time_twin,
pkt_timeval start_time, pkt_timeval start_time_twin,
uint16_t s_idx, uint16_t r_idx,
uint16_t *merged_lens, uint16_t *merged_times,
uint32_t max_num_pkt_len, uint32_t max_merged_num_pkts)
* \param pkt_len length of the packet
* \param pkt_time time of the packet
* \param pkt_len_twin length of the twin packet
* \param pkt_time_twin time of the twin packet
* \param start_time start time
* \param start_time_twin start time of twin
* \param s_idx s index in the merge
* \param r_idx r index in the merge
* \param merged_lens length of the merge
* \param merged_times time of the merge
* \param max_merged_num_pkts number of packets merged
* \return none
*/
void
ndpi_merge_splt_arrays (const uint16_t *pkt_len, const pkt_timeval *pkt_time,
const uint16_t *pkt_len_twin, const pkt_timeval *pkt_time_twin,
pkt_timeval start_time, pkt_timeval start_time_twin,
uint16_t s_idx, uint16_t r_idx,
uint16_t *merged_lens, uint16_t *merged_times)
{
int s,r;
pkt_timeval ts_start = { 0, 0 }; /* initialize to avoid spurious warnings */
pkt_timeval tmp, tmp_r;
pkt_timeval start_m;
if(r_idx + s_idx == 0) {
return ;
} else if(r_idx == 0) {
ts_start = pkt_time[0];
tmp = pkt_time[0];
ndpi_timer_sub(&tmp, &start_time, &start_m);
} else if(s_idx == 0) {
ts_start = pkt_time_twin[0];
tmp = pkt_time_twin[0];
ndpi_timer_sub(&tmp, &start_time_twin, &start_m);
} else {
if(ndpi_timer_lt(&start_time, &start_time_twin)) {
ts_start = pkt_time[0];
tmp = pkt_time[0];
ndpi_timer_sub(&tmp, &start_time, &start_m);
} else {
// ts_start = pkt_time_twin[0];
tmp = pkt_time_twin[0];
ndpi_timer_sub(&tmp, &start_time_twin, &start_m);
}
}
s = r = 0;
while ((s < s_idx) || (r < r_idx)) {
if(s >= s_idx) {
merged_lens[s+r] = pkt_len_twin[r];
tmp = pkt_time_twin[r];
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
if(merged_times[s+r] == 0)
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
ts_start = tmp;
r++;
} else if(r >= r_idx) {
merged_lens[s+r] = pkt_len[s];
tmp = pkt_time[s];
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
if(merged_times[s+r] == 0)
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
ts_start = tmp;
s++;
} else {
if(ndpi_timer_lt(&pkt_time[s], &pkt_time_twin[r])) {
merged_lens[s+r] = pkt_len[s];
tmp = pkt_time[s];
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
if(merged_times[s+r] == 0)
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
ts_start = tmp;
s++;
} else {
merged_lens[s+r] = pkt_len_twin[r];
tmp = pkt_time_twin[r];
ndpi_timer_sub(&tmp, &ts_start, &tmp_r);
merged_times[s+r] = ndpi_timeval_to_milliseconds(tmp_r);
if(merged_times[s+r] == 0)
merged_times[s+r] = ndpi_timeval_to_microseconds(tmp_r);
ts_start = tmp;
r++;
}
}
}
merged_times[0] = ndpi_timeval_to_milliseconds(start_m);
if(merged_times[0] == 0)
merged_times[0] = ndpi_timeval_to_microseconds(start_m);
}
/* transform lens array to Markov chain */
static void
ndpi_get_mc_rep_lens (uint16_t *lens, float *length_mc, uint16_t num_packets)
{
float row_sum;
int prev_packet_size = 0;
int cur_packet_size = 0;
int i, j;
for (i = 0; i < MC_BINS_LEN*MC_BINS_LEN; i++) { // init to 0
length_mc[i] = 0.0;
}
if(num_packets == 0) {
// nothing to do
} else if(num_packets == 1) {
cur_packet_size = (int)min(lens[0]/(float)MC_BIN_SIZE_LEN,(uint16_t)MC_BINS_LEN-1);
length_mc[cur_packet_size + cur_packet_size*MC_BINS_LEN] = 1.0;
} else {
for (i = 1; i < num_packets; i++) {
prev_packet_size = (int)min((uint16_t)(lens[i-1]/(float)MC_BIN_SIZE_LEN),(uint16_t)MC_BINS_LEN-1);
cur_packet_size = (int)min((uint16_t)(lens[i]/(float)MC_BIN_SIZE_LEN),(uint16_t)MC_BINS_LEN-1);
length_mc[prev_packet_size*MC_BINS_LEN + cur_packet_size] += 1.0;
}
// normalize rows of Markov chain
for (i = 0; i < MC_BINS_LEN; i++) {
// find sum
row_sum = 0.0;
for (j = 0; j < MC_BINS_LEN; j++) {
row_sum += length_mc[i*MC_BINS_LEN+j];
}
if(row_sum != 0.0) {
for (j = 0; j < MC_BINS_LEN; j++) {
length_mc[i*MC_BINS_LEN+j] /= row_sum;
}
}
}
}
}
/* transform times array to Markov chain */
void
ndpi_get_mc_rep_times (uint16_t *times, float *time_mc, uint16_t num_packets)
{
float row_sum;
int prev_packet_time = 0;
int cur_packet_time = 0;
int i, j;
for (i = 0; i < MC_BINS_TIME*MC_BINS_TIME; i++) { // init to 0
time_mc[i] = 0.0;
}
if(num_packets == 0) {
// nothing to do
} else if(num_packets == 1) {
cur_packet_time = (int)min(times[0]/(float)MC_BIN_SIZE_TIME,(uint16_t)MC_BINS_TIME-1);
time_mc[cur_packet_time + cur_packet_time*MC_BINS_TIME] = 1.0;
} else {
for (i = 1; i < num_packets; i++) {
prev_packet_time = (int)min((uint16_t)(times[i-1]/(float)MC_BIN_SIZE_TIME),(uint16_t)MC_BINS_TIME-1);
cur_packet_time = (int)min((uint16_t)(times[i]/(float)MC_BIN_SIZE_TIME),(uint16_t)MC_BINS_TIME-1);
time_mc[prev_packet_time*MC_BINS_TIME + cur_packet_time] += 1.0;
}
// normalize rows of Markov chain
for (i = 0; i < MC_BINS_TIME; i++) {
// find sum
row_sum = 0.0;
for (j = 0; j < MC_BINS_TIME; j++) {
row_sum += time_mc[i*MC_BINS_TIME+j];
}
if(row_sum != 0.0) {
for (j = 0; j < MC_BINS_TIME; j++) {
time_mc[i*MC_BINS_TIME+j] /= row_sum;
}
}
}
}
}
/**
* \fn float classify (const unsigned short *pkt_len, const pkt_timeval *pkt_time,
const unsigned short *pkt_len_twin, const pkt_timeval *pkt_time_twin,
pkt_timeval start_time, pkt_timeval start_time_twin, uint32_t max_num_pkt_len,
uint16_t sp, uint16_t dp, uint32_t op, uint32_t ip, uint32_t np_o, uint32_t np_i,
uint32_t ob, uint32_t ib, uint16_t use_bd, const uint32_t *bd, const uint32_t *bd_t)
* \param pkt_len length of the packet
* \param pkt_time time of the packet
* \param pkt_len_twin length of the packet twin
* \param pkt_time_twin time of the packet twin
* \param start_time start time
* \param start_time_twin start time of the twin
* \param max_num_pkt_len maximum len of number of packets
* \param sp
* \param dp
* \param op
* \param ip
* \param np_o
* \param np_i
* \param ob
* \param ib
* \param use_bd
* \param *bd pointer to bd
* \param *bd_t pointer to bd type
* \return float score
*/
float
ndpi_classify (const unsigned short *pkt_len, const pkt_timeval *pkt_time,
const unsigned short *pkt_len_twin, const pkt_timeval *pkt_time_twin,
pkt_timeval start_time, pkt_timeval start_time_twin, uint32_t max_num_pkt_len,
uint16_t sp, uint16_t dp, uint32_t op, uint32_t ip, uint32_t np_o, uint32_t np_i,
uint32_t ob, uint32_t ib, uint16_t use_bd, const uint32_t *bd, const uint32_t *bd_t)
{
float features[NUM_PARAMETERS_BD_LOGREG] = {1.0};
float mc_lens[MC_BINS_LEN*MC_BINS_LEN];
float mc_times[MC_BINS_TIME*MC_BINS_TIME];
uint32_t i;
float score = 0.0;
uint32_t op_n = min(np_o, max_num_pkt_len);
uint32_t ip_n = min(np_i, max_num_pkt_len);
uint16_t *merged_lens = NULL;
uint16_t *merged_times = NULL;
for (i = 1; i < NUM_PARAMETERS_BD_LOGREG; i++) {
features[i] = 0.0;
}
merged_lens = ndpi_calloc(1, sizeof(uint16_t)*(op_n + ip_n));
merged_times = ndpi_calloc(1, sizeof(uint16_t)*(op_n + ip_n));
if(!merged_lens || !merged_times) {
ndpi_free(merged_lens);
ndpi_free(merged_times);
return(score);
}
// fill out meta data
features[1] = (float)dp; // destination port
features[2] = (float)sp; // source port
features[3] = (float)ip; // inbound packets
features[4] = (float)op; // outbound packets
features[5] = (float)ib; // inbound bytes
features[6] = (float)ob; // outbound bytes
features[7] = 0.0;// skipping 7 until we process the pkt_time arrays
// find the raw features
ndpi_merge_splt_arrays(pkt_len, pkt_time, pkt_len_twin, pkt_time_twin, start_time, start_time_twin, op_n, ip_n,
merged_lens, merged_times);
// find new duration
for (i = 0; i < op_n+ip_n; i++) {
features[7] += (float)merged_times[i];
}
// get the Markov chain representation for the lengths
ndpi_get_mc_rep_lens(merged_lens, mc_lens, op_n+ip_n);
// get the Markov chain representation for the times
ndpi_get_mc_rep_times(merged_times, mc_times, op_n+ip_n);
// fill out lens/times in feature vector
for (i = 0; i < MC_BINS_LEN*MC_BINS_LEN; i++) {
features[i+8] = mc_lens[i]; // lengths
}
for (i = 0; i < MC_BINS_TIME*MC_BINS_TIME; i++) {
features[i+8+MC_BINS_LEN*MC_BINS_LEN] = mc_times[i]; // times
}
// fill out byte distribution features
if(ob+ib > 100 && use_bd) {
for (i = 0; i < NUM_BD_VALUES; i++) {
if(pkt_len_twin != NULL) {
features[i+8+MC_BINS_LEN*MC_BINS_LEN+MC_BINS_TIME*MC_BINS_TIME] = (bd[i]+bd_t[i])/((float)(ob+ib));
} else {
features[i+8+MC_BINS_LEN*MC_BINS_LEN+MC_BINS_TIME*MC_BINS_TIME] = bd[i]/((float)(ob));
}
}
score = ndpi_parameters_bd[0];
for (i = 1; i < NUM_PARAMETERS_BD_LOGREG; i++) {
score += features[i]*ndpi_parameters_bd[i];
}
} else {
for (i = 0; i < NUM_PARAMETERS_SPLT_LOGREG; i++) {
score += features[i]*ndpi_parameters_splt[i];
}
}
score = min(-score,500.0); // check b/c overflow
ndpi_free(merged_lens);
ndpi_free(merged_times);
return 1.0/(1.0+exp(score));
}
/**
* \fn void update_params (char *splt_params, char *bd_params)
* \brief if a user supplies new parameter files, update parameters splt/bd
* \param param_type type of new parameters to update
* \param params file name with new parameters
* \reutrn none
*/
void
ndpi_update_params (classifier_type_codes_t param_type, const char *param_file)
{
float param;
FILE *fp;
int count = 0;
switch (param_type) {
case (SPLT_PARAM_TYPE):
count = 0;
fp = fopen(param_file,"r");
if(fp != NULL) {
while (fscanf(fp, "%f", &param) != EOF) {
ndpi_parameters_splt[count] = param;
count++;
if(count >= NUM_PARAMETERS_SPLT_LOGREG) {
break;
}
}
fclose(fp);
}
break;
case (BD_PARAM_TYPE):
count = 0;
fp = fopen(param_file,"r");
if(fp != NULL) {
while (fscanf(fp, "%f", &param) != EOF) {
ndpi_parameters_bd[count] = param;
count++;
if(count >= NUM_PARAMETERS_BD_LOGREG) {
break;
}
}
fclose(fp);
}
break;
default:
printf("error: unknown paramerter type (%d)", param_type);
break;
}
}
/* *********************************************************************
* ---------------------------------------------------------------------
* Time functions
* For portability and static analysis, we define our own timer
* comparison functions (rather than use non-standard
* timercmp/timersub macros)
* ---------------------------------------------------------------------
* *********************************************************************
*/
/**
* \brief Compare two times to see if they are equal
* \param a First time value
* \param b Second time value
* \return 1 if equal, 0 otherwise
*/
unsigned int
ndpi_timer_eq(const pkt_timeval *a,
const pkt_timeval *b)
{
if(a->tv_sec == b->tv_sec && a->tv_usec == b->tv_usec) {
return 1;
}
return 0;
}
unsigned int
ndpi_timer_lt(const pkt_timeval *a,
const pkt_timeval *b)
{
return (a->tv_sec == b->tv_sec) ?
(a->tv_usec < b->tv_usec):(a->tv_sec < b->tv_sec);
}
/**
* \brief Calculate the difference betwen two times (result = a - b)
* \param a First time value
* \param b Second time value
* \param result The difference between the two time values
* \return none
*/
void
ndpi_timer_sub(const pkt_timeval *a,
const pkt_timeval *b,
pkt_timeval *result)
{
result->tv_sec = a->tv_sec - b->tv_sec;
result->tv_usec = a->tv_usec - b->tv_usec;
if(result->tv_usec < 0) {
--result->tv_sec;
result->tv_usec += 1000000;
}
}
/**
* \brief Zeroize a timeval.
* \param a Timeval to zero out
* \return none
*/
void
ndpi_timer_clear(pkt_timeval *a)
{
a->tv_sec = a->tv_usec = 0;
}
/**
* \brief Calculate the milliseconds representation of a timeval.
* \param ts Timeval
* \return unsigned int - Milliseconds
*/
unsigned int
ndpi_timeval_to_milliseconds(pkt_timeval ts)
{
unsigned int result = ts.tv_usec / 1000 + ts.tv_sec * 1000;
return result;
}
/**
* \brief Calculate the microseconds representation of a timeval.
* \param ts Timeval
* \return unsigned int - Milliseconds
*/
unsigned int
ndpi_timeval_to_microseconds(pkt_timeval ts)
{
unsigned int result = ts.tv_usec + ts.tv_sec * 1000 * 1000;
return result;
}
void
ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len)
{
pkt_timeval tv;
time_t nowtime;
struct tm nowtm_r;
char tmbuf[NDPI_TIMESTAMP_LEN];
gettimeofday(&tv, NULL);
nowtime = tv.tv_sec;
localtime_r(&nowtime, &nowtm_r);
strftime(tmbuf, NDPI_TIMESTAMP_LEN, "%H:%M:%S", &nowtm_r);
snprintf(log_ts, log_ts_len, "%s.%06ld", tmbuf, (long)tv.tv_usec);
}
+380
View File
@@ -0,0 +1,380 @@
/*
* ndpi_community_id.c
*
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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/>.
*
*/
#ifdef HAVE_CONFIG_H
#include "ndpi_config.h"
#endif
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include "ndpi_api.h"
#include "ndpi_config.h"
#include "ndpi_includes.h"
#include <time.h>
#ifndef WIN32
#include <unistd.h>
#endif
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
#include <sys/endian.h>
#endif
#include "ndpi_sha1.h"
#define NDPI_ICMP6_ECHO_REQUEST 128
#define NDPI_ICMP6_ECHO_REPLY 129
#define NDPI_MLD_LISTENER_QUERY 130
#define NDPI_MLD_LISTENER_REPORT 131
#define NDPI_ROUTER_SOLICIT 133
#define NDPI_ROUTER_ADVERT 134
#define NDPI_NEIGHBOR_SOLICIT 135
#define NDPI_NEIGHBOR_ADVERT 136
#define NDPI_ICMP_ECHOREPLY 0
#define NDPI_ICMP_ECHO 8
#define NDPI_ICMP_ROUTERADVERT 9
#define NDPI_ICMP_ROUTERSOLICIT 10
#define NDPI_ICMP_TIMESTAMP 13
#define NDPI_ICMP_TIMESTAMPREPLY 14
#define NDPI_ICMP_INFO_REQUEST 15
#define NDPI_ICMP_INFO_REPLY 16
#define NDPI_ICMP_MASKREQ 17
#define NDPI_ICMP_MASKREPLY 18
#define NDPI_ICMP6_WRUREQUEST 139
#define NDPI_ICMP6_WRUREPLY 140
/* **************************************************** */
static ssize_t ndpi_community_id_buf_copy(u_int8_t * const dst, const void * const src, ssize_t len) {
if(src)
memcpy(dst, src, len);
else
memset(dst, 0, len);
return len;
}
/* **************************************************** */
/*
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L56
*/
static u_int8_t ndpi_community_id_icmp_type_to_code_v4(u_int8_t icmp_type, u_int8_t icmp_code, int *is_one_way) {
*is_one_way = 0;
switch(icmp_type) {
case NDPI_ICMP_ECHO:
return NDPI_ICMP_ECHOREPLY;
case NDPI_ICMP_ECHOREPLY:
return NDPI_ICMP_ECHO;
case NDPI_ICMP_TIMESTAMP:
return NDPI_ICMP_TIMESTAMPREPLY;
case NDPI_ICMP_TIMESTAMPREPLY:
return NDPI_ICMP_TIMESTAMP;
case NDPI_ICMP_INFO_REQUEST:
return NDPI_ICMP_INFO_REPLY;
case NDPI_ICMP_INFO_REPLY:
return NDPI_ICMP_INFO_REQUEST;
case NDPI_ICMP_ROUTERSOLICIT:
return NDPI_ICMP_ROUTERADVERT;
case NDPI_ICMP_ROUTERADVERT:
return NDPI_ICMP_ROUTERSOLICIT;
case NDPI_ICMP_MASKREQ:
return NDPI_ICMP_MASKREPLY;
case NDPI_ICMP_MASKREPLY:
return NDPI_ICMP_MASKREQ;
default:
*is_one_way = 1;
return icmp_code;
}
}
/* **************************************************** */
/*
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L83
*/
static u_int8_t ndpi_community_id_icmp_type_to_code_v6(u_int8_t icmp_type, u_int8_t icmp_code, int *is_one_way) {
*is_one_way = 0;
switch(icmp_type) {
case NDPI_ICMP6_ECHO_REQUEST:
return NDPI_ICMP6_ECHO_REPLY;
case NDPI_ICMP6_ECHO_REPLY:
return NDPI_ICMP6_ECHO_REQUEST;
case NDPI_ROUTER_SOLICIT:
return NDPI_ROUTER_ADVERT;
case NDPI_ROUTER_ADVERT:
return NDPI_ROUTER_SOLICIT;
case NDPI_NEIGHBOR_SOLICIT:
return NDPI_NEIGHBOR_ADVERT;
case NDPI_NEIGHBOR_ADVERT:
return NDPI_NEIGHBOR_SOLICIT;
case NDPI_MLD_LISTENER_QUERY:
return NDPI_MLD_LISTENER_REPORT;
case NDPI_MLD_LISTENER_REPORT:
return NDPI_MLD_LISTENER_QUERY;
case NDPI_ICMP6_WRUREQUEST:
return NDPI_ICMP6_WRUREPLY;
case NDPI_ICMP6_WRUREPLY:
return NDPI_ICMP6_WRUREQUEST;
// Home Agent Address Discovery Request Message and reply
case 144:
return 145;
case 145:
return 144;
default:
*is_one_way = 1;
return icmp_code;
}
}
/* **************************************************** */
/*
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L164
*/
static int ndpi_community_id_peer_v4_is_less_than(u_int32_t ip1, u_int32_t ip2, u_int16_t p1, u_int16_t p2) {
int comp = memcmp(&ip1, &ip2, sizeof(u_int32_t));
return comp < 0 || (comp == 0 && p1 < p2);
}
/* **************************************************** */
static int ndpi_community_id_peer_v6_is_less_than(struct ndpi_in6_addr *ip1, struct ndpi_in6_addr *ip2, u_int16_t p1, u_int16_t p2) {
int comp = memcmp(ip1, ip2, sizeof(struct ndpi_in6_addr));
return comp < 0 || (comp == 0 && p1 < p2);
}
/* **************************************************** */
void ndpi_string_sha1_hash(const uint8_t *message, size_t len, u_char *hash /* 20-bytes */) {
SHA1_CTX ctx;
SHA1Init(&ctx);
SHA1Update(&ctx, message, len);
SHA1Final(hash, &ctx);
}
/* **************************************************** */
/*
https://github.com/corelight/community-id-spec/blob/bda913f617389df07cdaa23606e11bbd318e265c/community-id.py#L285
*/
static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int16_t off, u_int8_t l4_proto,
u_int16_t src_port, u_int16_t dst_port,
char *hash_buf, u_int8_t hash_buf_len) {
u_int8_t pad = 0;
uint32_t hash[5];
char *community_id;
/* L4 proto */
off += ndpi_community_id_buf_copy(&comm_buf[off], &l4_proto, sizeof(l4_proto));
/* Pad */
off += ndpi_community_id_buf_copy(&comm_buf[off], &pad, sizeof(pad));
/* Source and destination ports */
switch(l4_proto) {
case IPPROTO_ICMP:
case IPPROTO_ICMPV6:
case IPPROTO_SCTP:
case IPPROTO_UDP:
case IPPROTO_TCP:
off += ndpi_community_id_buf_copy(&comm_buf[off], &src_port, sizeof(src_port));
off += ndpi_community_id_buf_copy(&comm_buf[off], &dst_port, sizeof(dst_port));
break;
}
/* Compute SHA1 */
ndpi_string_sha1_hash(comm_buf, off, (u_char*)hash);
/* Base64 encoding */
community_id = ndpi_base64_encode((u_int8_t*)hash, sizeof(hash));
if(community_id == NULL)
return -1;
#if 0 /* Debug Info */
printf("Hex output: ");
for(int i = 0; i < off; i++)
printf("%.2x ", comm_buf[i]);
printf("\n");
printf("Sha1 sum: ");
for(int i = 0; i < 5; i++)
printf("%.2x ", ntohl(hash[i]));
printf("\n");
printf("Base64: %s\n", community_id);
#endif
if(hash_buf_len < 2 || hash_buf_len-2 < strlen(community_id)+1) {
ndpi_free(community_id);
return -1;
}
/* Writing hash */
hash_buf[0] = '1';
hash_buf[1] = ':';
strcpy(&hash_buf[2], community_id);
ndpi_free(community_id);
return 0;
}
/* **************************************************** */
/*
NOTE:
- Leave fields empty/zero when information is missing (e.g. with ICMP ports are zero)
- The hash_buf most be 30+1 bits or longer
- Return code: 0 = OK, -1 otherwise
*/
int ndpi_flowv4_flow_hash(u_int8_t l4_proto, u_int32_t src_ip, u_int32_t dst_ip,
u_int16_t src_port, u_int16_t dst_port,
u_int8_t icmp_type, u_int8_t icmp_code,
u_char *hash_buf, u_int8_t hash_buf_len) {
/*
Input buffer (40 bytes)
2 - Seed
16 - IPv6 src
16 - IPv6 dst
1 - L4 proto
1 - Pad
2 - Port src
2 - Port dst
*/
u_int8_t comm_buf[40] = { 0 };
u_int16_t off = 0;
u_int16_t seed = 0;
u_int32_t *ip_a_ptr, *ip_b_ptr;
u_int16_t port_a, port_b;
int icmp_one_way = 0;
/* Adjust the ports according to the specs */
switch(l4_proto) {
case IPPROTO_ICMP:
src_port = icmp_type;
dst_port = ndpi_community_id_icmp_type_to_code_v4(icmp_type, icmp_code, &icmp_one_way);
break;
case IPPROTO_SCTP:
case IPPROTO_UDP:
case IPPROTO_TCP:
/* src/dst port ok */
break;
default:
src_port = dst_port = 0;
break;
}
/* Convert tuple to NBO */
src_ip = htonl(src_ip);
dst_ip = htonl(dst_ip);
src_port = htons(src_port);
dst_port = htons(dst_port);
/*
The community id hash doesn't have the definition of client and server, it just sorts IP addresses
and ports to make sure the smaller ip address is the first. This performs this check and
possibly swap client ip and port.
*/
if(icmp_one_way || ndpi_community_id_peer_v4_is_less_than(src_ip, dst_ip, src_port, dst_port)) {
ip_a_ptr = &src_ip, ip_b_ptr = &dst_ip;
port_a = src_port, port_b = dst_port;
} else {
/* swap flow peers */
ip_a_ptr = &dst_ip, ip_b_ptr = &src_ip;
port_a = dst_port, port_b = src_port;
}
/* Seed */
off = ndpi_community_id_buf_copy(&comm_buf[off], &seed, sizeof(seed));
/* Source and destination IPs */
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_a_ptr, sizeof(src_ip));
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_b_ptr, sizeof(dst_ip));
return ndpi_community_id_finalize_and_compute_hash(comm_buf, off,
l4_proto, port_a, port_b, (char*)hash_buf, hash_buf_len);
}
/* **************************************************** */
int ndpi_flowv6_flow_hash(u_int8_t l4_proto, struct ndpi_in6_addr *src_ip, struct ndpi_in6_addr *dst_ip,
u_int16_t src_port, u_int16_t dst_port,
u_int8_t icmp_type, u_int8_t icmp_code,
u_char *hash_buf, u_int8_t hash_buf_len) {
u_int8_t comm_buf[40] = { 0 };
u_int16_t off = 0;
u_int16_t seed = 0;
struct ndpi_in6_addr *ip_a_ptr, *ip_b_ptr;
u_int16_t port_a, port_b;
int icmp_one_way = 0;
switch(l4_proto) {
case IPPROTO_ICMPV6:
src_port = icmp_type;
dst_port = ndpi_community_id_icmp_type_to_code_v6(icmp_type, icmp_code, &icmp_one_way);
break;
case IPPROTO_SCTP:
case IPPROTO_UDP:
case IPPROTO_TCP:
/* src/dst port ok */
break;
default:
src_port = dst_port = 0;
break;
}
/* Convert tuple to NBO */
src_port = htons(src_port);
dst_port = htons(dst_port);
if(icmp_one_way || ndpi_community_id_peer_v6_is_less_than(src_ip, dst_ip, src_port, dst_port)) {
ip_a_ptr = src_ip, ip_b_ptr = dst_ip;
port_a = src_port, port_b = dst_port;
} else {
ip_a_ptr = dst_ip, ip_b_ptr = src_ip;
port_a = dst_port, port_b = src_port;
}
/* Seed */
off = ndpi_community_id_buf_copy(&comm_buf[off], &seed, sizeof(seed));
/* Source and destination IPs */
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_a_ptr, sizeof(struct ndpi_in6_addr));
off += ndpi_community_id_buf_copy(&comm_buf[off], ip_b_ptr, sizeof(struct ndpi_in6_addr));
return ndpi_community_id_finalize_and_compute_hash(comm_buf, off,
l4_proto, port_a, port_b, (char*)hash_buf, hash_buf_len);
}
/* **************************************************** */
File diff suppressed because it is too large Load Diff
+4346 -3618
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1804
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2,7 +2,7 @@
* afp.c
*
* Copyright (C) 2009-11 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* aimini.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+7 -7
View File
@@ -47,11 +47,12 @@ enum ajp_packet_type {
AJP_BODY = 11
};
PACK_ON
struct ajp_header {
uint16_t magic;
uint16_t len;
uint8_t code;
};
} PACK_OFF;
static void set_ajp_detected(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
@@ -62,7 +63,7 @@ static void set_ajp_detected(struct ndpi_detection_module_struct *ndpi_struct,
/* If no custom protocol has been detected */
/* if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) */
ndpi_int_reset_protocol(flow);
ndpi_set_detected_protocol(ndpi_struct, flow, flow->guessed_host_protocol_id, NDPI_PROTOCOL_AJP);
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AJP, flow->guessed_host_protocol_id);
}
}
@@ -70,18 +71,17 @@ static void set_ajp_detected(struct ndpi_detection_module_struct *ndpi_struct,
/*************************************************************************************************/
static void ndpi_check_ajp(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_flow_struct *flow) {
struct ajp_header ajp_hdr;
struct ndpi_packet_struct *packet = &flow->packet;
if (packet->payload_packet_len < 5 /* ajp_header size*/) {
if (packet->payload_packet_len < sizeof(ajp_hdr)) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
ajp_hdr = *((struct ajp_header *) (packet->payload));
memcpy(&ajp_hdr, packet->payload, sizeof(struct ajp_header));
ajp_hdr.magic = ntohs(ajp_hdr.magic);
ajp_hdr.len = ntohs(ajp_hdr.len);
+80
View File
@@ -0,0 +1,80 @@
/*
* amazon_video.c
*
* Copyright (C) 2018-20 by ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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_AMAZON_VIDEO
#include "ndpi_api.h"
static void ndpi_check_amazon_video(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search Amazon Prime\n");
if(packet->payload_packet_len > 4) {
if((packet->tcp != NULL) &&
(packet->payload[0] == 0xFE &&
packet->payload[1] == 0xED &&
packet->payload[2] == 0xFA &&
packet->payload[3] == 0xCE)) {
NDPI_LOG_INFO(ndpi_struct, "found Amazon Video on TCP\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_UNKNOWN);
return;
} else if((packet->udp != NULL) &&
(packet->payload[0] == 0xDE &&
packet->payload[1] == 0xAD &&
packet->payload[2] == 0xBE &&
packet->payload[3] == 0xEF)) {
NDPI_LOG_INFO(ndpi_struct, "found Amazon Video on UDP\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void ndpi_search_amazon_video(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search amazon_video\n");
/* skip marked packets */
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_AMAZON_VIDEO)
ndpi_check_amazon_video(ndpi_struct, flow);
}
void init_amazon_video_dissector(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
ndpi_set_bitmask_protocol_detection("AMAZON_VIDEO", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_AMAZON_VIDEO,
ndpi_search_amazon_video,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* amqp.c
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - 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
+16 -14
View File
@@ -31,20 +31,22 @@ static void ndpi_check_apple_push(struct ndpi_detection_module_struct *ndpi_stru
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
/* https://support.apple.com/en-us/HT203609 */
if(((ntohl(packet->iph->saddr) & 0xFF000000 /* 255.0.0.0 */) == 0x11000000 /* 17.0.0.0/8 */)
|| ((ntohl(packet->iph->daddr) & 0xFF000000 /* 255.0.0.0 */) == 0x11000000 /* 17.0.0.0/8 */)) {
u_int16_t apple_push_port = ntohs(5223);
u_int16_t notification_apn_port = ntohs(2195);
u_int16_t apn_feedback_port = ntohs(2196);
if(((packet->tcp->source == apple_push_port) || (packet->tcp->dest == apple_push_port))
|| ((packet->tcp->source == notification_apn_port) || (packet->tcp->dest == notification_apn_port))
|| ((packet->tcp->source == apn_feedback_port) || (packet->tcp->dest == apn_feedback_port))
) {
NDPI_LOG_INFO(ndpi_struct, "found apple_push\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_APPLE_PUSH, NDPI_PROTOCOL_UNKNOWN);
return;
if(packet->iph) {
/* https://support.apple.com/en-us/HT203609 */
if(((ntohl(packet->iph->saddr) & 0xFF000000 /* 255.0.0.0 */) == 0x11000000 /* 17.0.0.0/8 */)
|| ((ntohl(packet->iph->daddr) & 0xFF000000 /* 255.0.0.0 */) == 0x11000000 /* 17.0.0.0/8 */)) {
u_int16_t apple_push_port = ntohs(5223);
u_int16_t notification_apn_port = ntohs(2195);
u_int16_t apn_feedback_port = ntohs(2196);
if(((packet->tcp->source == apple_push_port) || (packet->tcp->dest == apple_push_port))
|| ((packet->tcp->source == notification_apn_port) || (packet->tcp->dest == notification_apn_port))
|| ((packet->tcp->source == apn_feedback_port) || (packet->tcp->dest == apn_feedback_port))
) {
NDPI_LOG_INFO(ndpi_struct, "found apple_push\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_APPLE_PUSH, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
* applejuice.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* armagetron.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* flash.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* ftp.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* manolito.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* popo.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+1 -1
View File
@@ -2,7 +2,7 @@
* secondlife.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* ayiya.c
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -57,7 +57,7 @@ void ndpi_search_ayiya(struct ndpi_detection_module_struct *ndpi_struct, struct
u_int32_t epoch = ntohl(a->epoch), now;
u_int32_t fiveyears = 86400 * 365 * 5;
now = flow->packet.tick_timestamp;
now = flow->packet.current_time_ms;
if((epoch >= (now - fiveyears)) && (epoch <= (now+86400 /* 1 day */))) {
NDPI_LOG_INFO(ndpi_struct, "found AYIYA\n");
-126
View File
@@ -1,126 +0,0 @@
/*
* battlefield.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
*
* 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_BATTLEFIELD
#include "ndpi_api.h"
static void ndpi_int_battlefield_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
struct ndpi_id_struct *src = flow->src;
struct ndpi_id_struct *dst = flow->dst;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BATTLEFIELD, NDPI_PROTOCOL_UNKNOWN);
if (src != NULL) {
src->battlefield_ts = packet->tick_timestamp;
}
if (dst != NULL) {
dst->battlefield_ts = packet->tick_timestamp;
}
}
void ndpi_search_battlefield(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
struct ndpi_id_struct *src = flow->src;
struct ndpi_id_struct *dst = flow->dst;
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_BATTLEFIELD) {
if (src != NULL && ((u_int32_t)
(packet->tick_timestamp - src->battlefield_ts) < ndpi_struct->battlefield_timeout)) {
NDPI_LOG_DBG2(ndpi_struct,
"battlefield : save src connection packet detected\n");
src->battlefield_ts = packet->tick_timestamp;
} else if (dst != NULL && ((u_int32_t)
(packet->tick_timestamp - dst->battlefield_ts) < ndpi_struct->battlefield_timeout)) {
NDPI_LOG_DBG2(ndpi_struct,
"battlefield : save dst connection packet detected\n");
dst->battlefield_ts = packet->tick_timestamp;
}
return;
}
if (NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_BATTLEFIELD)) {
if (flow->l4.udp.battlefield_stage == 0 || flow->l4.udp.battlefield_stage == 1 + packet->packet_direction) {
if (packet->payload_packet_len > 8 && get_u_int16_t(packet->payload, 0) == htons(0xfefd)) {
flow->l4.udp.battlefield_msg_id = get_u_int32_t(packet->payload, 2);
flow->l4.udp.battlefield_stage = 1 + packet->packet_direction;
return;
}
} else if (flow->l4.udp.battlefield_stage == 2 - packet->packet_direction) {
if (packet->payload_packet_len > 8 && get_u_int32_t(packet->payload, 0) == flow->l4.udp.battlefield_msg_id) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield message and reply detected\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return;
}
}
}
if (flow->l4.udp.battlefield_stage == 0) {
if (packet->payload_packet_len == 46 && packet->payload[2] == 0 && packet->payload[4] == 0
&& get_u_int32_t(packet->payload, 7) == htonl(0x98001100)) {
flow->l4.udp.battlefield_stage = 3 + packet->packet_direction;
return;
}
} else if (flow->l4.udp.battlefield_stage == 4 - packet->packet_direction) {
if (packet->payload_packet_len == 7
&& (packet->payload[0] == 0x02 || packet->payload[packet->payload_packet_len - 1] == 0xe0)) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield message and reply detected\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return;
}
}
if (packet->payload_packet_len == 18 && memcmp(&packet->payload[5], "battlefield2\x00", 13) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield 2 hello packet detected\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return;
} else if (packet->payload_packet_len > 10 &&
(memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x50\xb9\x10\x11", 10) == 0
|| memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\x30\xb9\x10\x11", 10) == 0
|| memcmp(packet->payload, "\x11\x20\x00\x01\x00\x00\xa0\x98\x00\x11", 10) == 0)) {
NDPI_LOG_INFO(ndpi_struct, "found Battlefield safe pattern detected\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return;
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void init_battlefield_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("BattleField", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_BATTLEFIELD,
ndpi_search_battlefield,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* bgp.c
*
* Copyright (C) 2016-18 - ntop.org
* Copyright (C) 2016-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+38 -33
View File
@@ -2,7 +2,7 @@
* bittorrent.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -43,7 +43,7 @@ struct ndpi_utp_hdr {
u_int16_t sequence_nr, ack_nr;
};
static u_int8_t is_utp_pkt(const u_int8_t *payload, u_int payload_len) {
static u_int8_t is_utpv1_pkt(const u_int8_t *payload, u_int payload_len) {
struct ndpi_utp_hdr *h = (struct ndpi_utp_hdr*)payload;
if(payload_len < sizeof(struct ndpi_utp_hdr)) return(0);
@@ -52,6 +52,9 @@ static u_int8_t is_utp_pkt(const u_int8_t *payload, u_int payload_len) {
if(h->next_extension > 2) return(0);
if(ntohl(h->window_size) > 65565) return(0);
if((h->window_size == 0) && (payload_len != sizeof(struct ndpi_utp_hdr)))
return(0);
return(1);
}
@@ -62,7 +65,7 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
{
if(check_hash) {
const char *bt_hash = NULL; /* 20 bytes long */
if(bt_offset == -1) {
const char *bt_magic = ndpi_strnstr((const char *)flow->packet.payload,
"BitTorrent protocol", flow->packet.payload_packet_len);
@@ -72,9 +75,8 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc
} else
bt_hash = (const char*)&flow->packet.payload[28];
if(!ndpi_struct->disable_metadata_export) {
if(bt_hash) memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
}
if(bt_hash && (flow->packet.payload_packet_len >= (20 + (bt_hash-(const char*)flow->packet.payload))))
memcpy(flow->protos.bittorrent.hash, bt_hash, 20);
}
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN);
@@ -376,19 +378,30 @@ static void ndpi_int_search_bittorrent_tcp(struct ndpi_detection_module_struct *
return;
}
static u_int8_t is_port(u_int16_t a, u_int16_t b, u_int16_t what) {
return(((what == a) || (what == b)) ? 1 : 0);
}
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
char *bt_proto = NULL;
/* This is broadcast */
if(packet->iph
&& (((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF))
|| (packet->udp
&& ((ntohs(packet->udp->source) == 3544) /* teredo.c */
|| (ntohs(packet->udp->dest) == 3544))))) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
if(packet->iph) {
if((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF))
goto exclude_bt;
if(packet->udp) {
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
if(is_port(sport, dport, 3544) /* teredo */
|| is_port(sport, dport, 5246) || is_port(sport, dport, 5247)/* CAPWAP */) {
exclude_bt:
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
}
}
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_BITTORRENT) {
@@ -397,14 +410,16 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
if((packet->tcp != NULL)
&& (packet->tcp_retransmission == 0 || packet->num_retried_bytes)) {
ndpi_int_search_bittorrent_tcp(ndpi_struct, flow);
}
else if(packet->udp != NULL) {
} else if(packet->udp != NULL) {
/* UDP */
char *bt_search = "BT-SEARCH * HTTP/1.1\r\n";
if((ntohs(packet->udp->source) < 1024)
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */)
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
/*
Check for uTP http://www.bittorrent.org/beps/bep_0029.html
@@ -421,14 +436,10 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
u_int8_t v0_extension = packet->payload[17];
u_int8_t v0_flags = packet->payload[18];
/* Check if this is protocol v1 */
u_int8_t v1_version = packet->payload[0];
u_int8_t v1_extension = packet->payload[1];
u_int32_t v1_window_size = *((u_int32_t*)&packet->payload[12]);
if(is_utp_pkt(packet->payload, packet->payload_packet_len))
if(is_utpv1_pkt(packet->payload, packet->payload_packet_len)) {
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
goto bittorrent_found;
else if((packet->payload[0]== 0x60)
} else if((packet->payload[0]== 0x60)
&& (packet->payload[1]== 0x0)
&& (packet->payload[2]== 0x0)
&& (packet->payload[3]== 0x0)
@@ -436,14 +447,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
/* Heuristic */
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
goto bittorrent_found;
/* CSGO/DOTA conflict */
} else if(flow->packet_counter > 8 && ((v1_version & 0x0f) == 1)
&& ((v1_version >> 4) < 5 /* ST_NUM_STATES */)
&& (v1_extension < 3 /* EXT_NUM_EXT */)
&& (v1_window_size < 32768 /* 32k */)
) {
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
goto bittorrent_found;
/* CSGO/DOTA conflict */
} else if((v0_flags < 6 /* ST_NUM_STATES */) && (v0_extension < 3 /* EXT_NUM_EXT */)) {
u_int32_t ts = ntohl(*((u_int32_t*)&(packet->payload[4])));
u_int32_t now;
@@ -460,7 +464,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
flow->bittorrent_stage++;
if(flow->bittorrent_stage < 10) {
if(flow->bittorrent_stage < 5) {
/* We have detected bittorrent but we need to wait until we get a hash */
if(packet->payload_packet_len > 19 /* min size */) {
@@ -485,6 +489,7 @@ void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, st
return;
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
}
+11 -53
View File
@@ -1,7 +1,7 @@
/*
* btlib.c
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
* Contributed by Vitaly Lavrov <vel21ripn@gmail.com>
*
* This file is part of nDPI, an open source deep packet inspection
@@ -23,12 +23,13 @@
*/
#include "ndpi_api.h"
#if 0
#ifndef NDPI_NO_STD_INC
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#include <strings.h>
/*
@@ -39,59 +40,16 @@ typedef unsigned long long int u_int64_t;
#include <stdint.h>
#include <stdlib.h>
#ifndef WIN32
#include <arpa/inet.h>
#endif
#endif
#endif
#include "btlib.h"
int bt_parse_debug = 0;
static char *printXb(char *s,const u_int8_t *b,int l) {
int i;
for(i=0; i < l; i++)
snprintf(&s[i*2],41,"%02x",b[i]);
return s;
}
static char *print20b(char *s,const u_int8_t *b) {
snprintf(s,41,"%08x%08x%08x%08x%08x",
htonl(*(u_int32_t*)b),
htonl(*(u_int32_t*)(b+4)),
htonl(*(u_int32_t*)(b+8)),
htonl(*(u_int32_t*)(b+12)),
htonl(*(u_int32_t*)(b+16)));
return s;
}
static char *print_id_ip_p(char *s, const struct bt_nodes_data *b) {
u_int8_t *p = (void*)b;
print20b(s,b->id);
snprintf(s+40,39," %d.%d.%d.%d:%u",
p[20], p[21], p[22], p[23], htons(b->port));
return s;
}
static char *print_ip_p(char *s, const struct bt_ipv4p *b,int np) {
const u_int8_t *p = (const void*)b;
snprintf(s,39,!np ? "%d.%d.%d.%d:%u":"%d.%d.%d.%d",
p[0], p[1], p[2], p[3], htons(b->port));
return s;
}
static char *print_ip6_p(char *s, const struct bt_ipv6p *b,int np) {
u_int16_t *p = (void*)b;
snprintf(s,79,!np ? "%x:%x:%x:%x:%x:%x:%x:%x.%u":"%x:%x:%x:%x:%x:%x:%x:%x",
htons(p[0]), htons(p[1]), htons(p[2]), htons(p[3]),
htons(p[4]), htons(p[5]), htons(p[6]), htons(p[7]),
htons(b->port));
return s;
}
static char *print_id_ip6_p(char *s,const struct bt_nodes6_data *b) {
return print_ip6_p(s,(struct bt_ipv6p *)&b->ip,0);
}
#if 0
void dump_bt_proto_struct(struct bt_parse_protocol *p) {
char b20h[128];
@@ -204,8 +162,7 @@ void cb_data(bt_parse_data_cb_t *cbd,int *ret) {
if(cbd->t == 0) return;
if(cbd->t == 1) {
DEBUG_TRACE(printf("%s %lld\n",cbd->buf,cbd->v.i));
DEBUG_TRACE(printf("%s %lld\n",cbd->buf, (long long)cbd->v.i));
if(STREQ(cbd->buf,"a.port")) {
p->a.port = (u_int16_t)(cbd->v.i & 0xffff);
@@ -234,7 +191,7 @@ void cb_data(bt_parse_data_cb_t *cbd,int *ret) {
p->h_mint = 1;
return;
}
DEBUG_TRACE(printf("UNKNOWN %s %lld\n",cbd->buf,cbd->v.i));
DEBUG_TRACE(printf("UNKNOWN %s %lld\n",cbd->buf, (long long)cbd->v.i));
return;
}
if(cbd->t != 2) {
@@ -421,7 +378,7 @@ const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_
int64_t d = 0;
u_int8_t c;
if(*l == 0) return NULL;
if(!l || *l == 0) return NULL;
if(cbd->level > BDEC_MAXDEPT) goto bad_data;
c = *b++; (*l)--;
if(c == 'i') { // integer
@@ -508,6 +465,7 @@ const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_
cbd->level--;
return b;
}
bad_data:
*ret=-1;
return b;
+125
View File
@@ -0,0 +1,125 @@
/*
* capwap.c
*
* Copyright (C) 2019 - 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_CAPWAP
#include "ndpi_api.h"
#define NDPI_CAPWAP_CONTROL_PORT 5246
#define NDPI_CAPWAP_DATA_PORT 5247
static void ndpi_int_capwap_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CAPWAP, NDPI_PROTOCOL_UNKNOWN);
}
/* ************************************************** */
static void ndpi_search_setup_capwap(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t sport, dport;
if(!packet->iph) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
if((dport == NDPI_CAPWAP_CONTROL_PORT)
&& (packet->iph->daddr == 0xFFFFFFFF)
&& (packet->payload_packet_len >= 16)
&& (packet->payload[0] == 0x0)
&& (packet->payload[8] == 6 /* Mac len */)
)
goto capwap_found;
if(((sport == NDPI_CAPWAP_CONTROL_PORT) || (dport == NDPI_CAPWAP_CONTROL_PORT))
&& ((packet->payload[0] == 0x0) || (packet->payload[0] == 0x1))
) {
u_int16_t msg_len, offset, to_add;
if(packet->payload[0] == 0x0)
offset = 13, to_add = 13;
else
offset = 15, to_add = 17;
if (packet->payload_packet_len >= offset + sizeof(u_int16_t)) {
msg_len = ntohs(*(u_int16_t*)&packet->payload[offset]);
if((msg_len+to_add) == packet->payload_packet_len)
goto capwap_found;
}
}
if(
(((dport == NDPI_CAPWAP_DATA_PORT) && (packet->iph->daddr != 0xFFFFFFFF)) || (sport == NDPI_CAPWAP_DATA_PORT))
&& (packet->payload_packet_len >= 16)
&& (packet->payload[0] == 0x0)
) {
u_int8_t is_80211_data = (packet->payload[9] & 0x0C) >> 2;
if((sport == NDPI_CAPWAP_DATA_PORT) && (is_80211_data == 2 /* IEEE 802.11 Data */))
goto capwap_found;
else if(dport == NDPI_CAPWAP_DATA_PORT) {
u_int16_t msg_len = ntohs(*(u_int16_t*)&packet->payload[13]);
if((packet->payload[8] == 1 /* Mac len */)
|| (packet->payload[8] == 6 /* Mac len */)
|| (packet->payload[8] == 4 /* Wireless len */)
|| ((msg_len+15) == packet->payload_packet_len))
goto capwap_found;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
capwap_found:
ndpi_int_capwap_add_connection(ndpi_struct, flow);
}
void ndpi_search_capwap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
if(packet->udp && (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN))
ndpi_search_setup_capwap(ndpi_struct, flow);
}
void init_capwap_dissector(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("CAPWAP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CAPWAP,
ndpi_search_capwap,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* checkmk.c
*
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+73 -11
View File
@@ -1,6 +1,22 @@
/*
* ciscovpn.c
* Copyright (C) 2013 by Remy Mudingay <mudingay@ill.fr>
*
* Copyright (C) 2013-20 - 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/>.
*
* Dissector developed by Remy Mudingay <mudingay@ill.fr>
*
*/
@@ -10,12 +26,15 @@
#include "ndpi_api.h"
/* ****************************************************************** */
static void ndpi_int_ciscovpn_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_PROTOCOL_UNKNOWN);
}
/* ****************************************************************** */
void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
@@ -29,6 +48,7 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest);
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over tcp ports\n");
}
if(packet->udp != NULL) {
usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest);
NDPI_LOG_DBG2(ndpi_struct, "calculated CISCOVPN over udp ports\n");
@@ -36,23 +56,51 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
if((tdport == 10000 && tsport == 10000) ||
((tsport == 443 || tdport == 443) &&
(packet->payload_packet_len >= 4) &&
(packet->payload[0] == 0x17 &&
packet->payload[1] == 0x01 &&
packet->payload[2] == 0x00 &&
packet->payload[3] == 0x00)
)
)
) {
/* This is a good query 17010000*/
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
return;
}
else if(((tsport == 443 || tdport == 443) ||
(tsport == 80 || tdport == 80)) &&
(packet->payload_packet_len >= 5) &&
((packet->payload[0] == 0x17 &&
packet->payload[1] == 0x03 &&
packet->payload[2] == 0x03 &&
packet->payload[3] == 0x00 &&
packet->payload[4] == 0x3A)))
{
/* This is a good query 17010000*/
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
/* TLS signature of Cisco AnyConnect 0X170303003A */
NDPI_LOG_INFO(ndpi_struct, "found CISCO Anyconnect VPN\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
return;
}
}
else if(((tsport == 8009 || tdport == 8009) ||
(tsport == 8008 || tdport == 8008)) &&
(packet->payload_packet_len >= 5) &&
((packet->payload[0] == 0x17 &&
packet->payload[1] == 0x03 &&
packet->payload[2] == 0x03 &&
packet->payload[3] == 0x00 &&
packet->payload[4] == 0x69)))
{
/* TCP signature of Cisco AnyConnect 0X1703030069 */
NDPI_LOG_INFO(ndpi_struct, "found CISCO Anyconnect VPN\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
return;
}
else if(
(
(usport == 10000 && udport == 10000)
&&
(packet->payload_packet_len >= 4) &&
(packet->payload[0] == 0xfe &&
packet->payload[1] == 0x57 &&
packet->payload[2] == 0x7e &&
@@ -60,15 +108,29 @@ void ndpi_search_ciscovpn(struct ndpi_detection_module_struct *ndpi_struct, stru
)
)
{
/* This is a good query fe577e2b */
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
} else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
} else if(
(
(usport == 443 || udport == 443)
&&
(packet->payload_packet_len >= 5) &&
(packet->payload[0] == 0x17 &&
packet->payload[1] == 0x01 &&
packet->payload[2] == 0x00 &&
packet->payload[3] == 0x00 &&
packet->payload[4] == 0x01)
)
)
{
NDPI_LOG_INFO(ndpi_struct, "found CISCOVPN\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
return;
}
if(flow->num_processed_pkts > 5)
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* citrix.c
*
* Copyright (C) 2012-18 - ntop.org
* Copyright (C) 2012-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -51,7 +51,7 @@ static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
}
return;
} else if(payload_len > 4) {
} else if(payload_len > 22) {
char citrix_header[] = { 0x1a, 0x43, 0x47, 0x50, 0x2f, 0x30, 0x31 };
if((memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0)
+2 -2
View File
@@ -129,8 +129,8 @@ void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
// check values in header
if(h->version == 1) {
if(h->type == CON || h->type == NO_CON || h->type == ACK || h->type == RST ) {
if(h->tkl == 0 || h->tkl < 8) {
if((h->code >= 0 && h->code <= 5) || (h->code >= 65 && h->code <= 69) ||
if(h->tkl < 8) {
if((/* h->code >= 0 && */ h->code <= 5) || (h->code >= 65 && h->code <= 69) ||
(h->code >= 128 && h->code <= 134) || (h->code >= 140 && h->code <= 143) ||
(h->code >= 160 && h->code <= 165)) {
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* collectd.c
*
* Copyright (C) 2014-18 - ntop.org
* Copyright (C) 2014-20 - 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
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* crossfire.c
*
* Copyright (C) 2012-18 - ntop.org
* Copyright (C) 2012-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+51 -31
View File
@@ -29,62 +29,74 @@
void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct ndpi_flow_struct* flow) {
struct ndpi_packet_struct* packet = &flow->packet;
if (packet->udp != NULL) {
if(packet->udp != NULL) {
if(packet->payload_packet_len < sizeof(uint32_t)) {
NDPI_LOG_DBG2(ndpi_struct, "Short csgo packet\n");
return;
}
uint32_t w = htonl(get_u_int32_t(packet->payload, 0));
NDPI_LOG_DBG2(ndpi_struct, "CSGO: word %08x\n", w);
if (!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
if (!memcmp(packet->payload + 5, "connect0x", 9)) {
if(!flow->csgo_state && packet->payload_packet_len == 23 && w == 0xfffffffful) {
if(!memcmp(packet->payload + 5, "connect0x", 9)) {
flow->csgo_state++;
memcpy(flow->csgo_strid, packet->payload + 5, 18);
NDPI_LOG_DBG2(ndpi_struct, "Found csgo connect0x\n");
return;
}
}
if (flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
if (!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
if(flow->csgo_state == 1 && packet->payload_packet_len >= 42 && w == 0xfffffffful) {
if(!memcmp(packet->payload + 24, flow->csgo_strid, 18)) {
flow->csgo_state++;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
NDPI_LOG_INFO( ndpi_struct, "found csgo connect0x reply\n");
return;
}
}
if (packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
if(packet->payload_packet_len == 8 && ( w == 0x3a180000 || w == 0x39180000) ) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 8b\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if (packet->payload_packet_len >= 36 && w == 0x56533031ul) {
if(packet->payload_packet_len >= 36 && w == 0x56533031ul) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if (packet->payload_packet_len >= 36 && w == 0x01007364) {
if(packet->payload_packet_len >= 36 && w == 0x01007364) {
uint32_t w2 = htonl(get_u_int32_t(packet->payload, 4));
if (w2 == 0x70696e67) {
if(w2 == 0x70696e67) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp ping\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
if (flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
if(flow->csgo_s2 < 3 && (w & 0xffff0000ul) == 0x0d1d0000) {
uint32_t w2 = get_u_int32_t(packet->payload, 2);
if (packet->payload_packet_len == 13) {
if (!flow->csgo_s2) {
if(packet->payload_packet_len == 13) {
if(!flow->csgo_s2) {
flow->csgo_id2 = w2;
flow->csgo_s2 = 1;
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1\n");
return;
}
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
NDPI_LOG_DBG2( ndpi_struct, "Found csgo udp 0d1d step1 DUP\n");
return;
}
flow->csgo_s2 = 3;
return;
}
if (packet->payload_packet_len == 15) {
if (flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
if(packet->payload_packet_len == 15) {
if(flow->csgo_s2 == 1 && flow->csgo_id2 == w2) {
NDPI_LOG_INFO( ndpi_struct, "found csgo udp 0d1d\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
@@ -92,31 +104,39 @@ void ndpi_search_csgo(struct ndpi_detection_module_struct* ndpi_struct, struct n
}
flow->csgo_s2 = 3;
}
if (packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
if(packet->payload_packet_len >= 140 && (w == 0x02124c6c || w == 0x02125c6c) &&
!memcmp(&packet->payload[3], "lta\000mob\000tpc\000bhj\000bxd\000tae\000urg\000gkh\000", 32)) {
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
NDPI_LOG_INFO( ndpi_struct, "found csgo dictionary udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if (packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
if(packet->payload_packet_len >= 33 && packet->iph && packet->iph->daddr == 0xffffffff &&
!memcmp(&packet->payload[17], "LanSearch", 9)) {
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
NDPI_LOG_INFO( ndpi_struct, "found csgo LanSearch udp\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CSGO, NDPI_PROTOCOL_UNKNOWN);
return;
}
if(w == 0) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
}
if (flow->packet_counter > 20)
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
if(flow->packet_counter > 5)
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void init_csgo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CSGO,
ndpi_search_csgo,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
ndpi_set_bitmask_protocol_detection("CSGO", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CSGO,
ndpi_search_csgo,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
+30 -32
View File
@@ -1,7 +1,7 @@
/*
* dhcp.c
*
* Copyright (C) 2016-18 - ntop.org
* Copyright (C) 2016-20 - 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
@@ -89,8 +89,10 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
u_int8_t len = ndpi_min(dhcp->options[i+1] /* len as found in the packet */,
dhcp_options_size - (i+2) /* 1 for the type and 1 for the value */);
if(len == 0) break;
if(len == 0)
break;
#ifdef DHCP_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] Id=%d [len=%d]\n", id, len);
#endif
@@ -100,40 +102,36 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
if(msg_type <= 8) foundValidMsgType = 1;
} else if(id == 55 /* Parameter Request List / Fingerprint */) {
if(!ndpi_struct->disable_metadata_export) {
u_int idx, offset = 0;
u_int idx, offset = 0;
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
int rc = snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%s%u", (idx > 0) ? "," : "",
(unsigned int)dhcp->options[i+2+idx] & 0xFF);
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
sizeof(flow->protos.dhcp.fingerprint) - offset,
"%02X", dhcp->options[i+2+idx] & 0xFF);
offset += 2;
}
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
if(rc < 0) break; else offset += rc;
}
flow->protos.dhcp.fingerprint[sizeof(flow->protos.dhcp.fingerprint) - 1] = '\0';
} else if(id == 60 /* Class Identifier */) {
if(!ndpi_struct->disable_metadata_export) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
flow->protos.dhcp.class_ident[j] = '\0';
}
char *name = (char*)&dhcp->options[i+2];
int j = 0;
j = ndpi_min(len, sizeof(flow->protos.dhcp.class_ident)-1);
strncpy((char*)flow->protos.dhcp.class_ident, name, j);
flow->protos.dhcp.class_ident[j] = '\0';
} else if(id == 12 /* Host Name */) {
if(!ndpi_struct->disable_metadata_export) {
char *name = (char*)&dhcp->options[i+2];
int j = 0;
char *name = (char*)&dhcp->options[i+2];
int j = 0;
#ifdef DHCP_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
NDPI_LOG_DBG2(ndpi_struct, "[DHCP] '%.*s'\n",name,len);
// while(j < len) { printf( "%c", name[j]); j++; }; printf("\n");
#endif
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, name, j);
flow->host_server_name[j] = '\0';
}
j = ndpi_min(len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, name, j);
flow->host_server_name[j] = '\0';
}
i += len + 2;
@@ -154,8 +152,8 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
}
void init_dhcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
void init_dhcp_dissector(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
ndpi_set_bitmask_protocol_detection("DHCP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DHCP,
ndpi_search_dhcp_udp,
+1 -1
View File
@@ -2,7 +2,7 @@
* dhcpv6.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
+87 -89
View File
@@ -2,7 +2,7 @@
* directconnect.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -58,9 +58,9 @@ static u_int16_t parse_binf_message(struct ndpi_detection_module_struct
u_int16_t ssl_port = 0;
while (i < payload_len) {
i = skip_unknown_headers(payload, payload_len, i);
if ((i + 30) < payload_len) {
if (memcmp(&payload[i], "DCTM", 4) == 0) {
if (memcmp(&payload[i + 15], "ADCS", 4) == 0) {
if((i + 30) < payload_len) {
if(memcmp(&payload[i], "DCTM", 4) == 0) {
if(memcmp(&payload[i + 15], "ADCS", 4) == 0) {
ssl_port = ntohs_ndpi_bytestream_to_number(&payload[i + 25], 5, &bytes_read);
NDPI_LOG_DBG2(ndpi_struct, "DC ssl port parsed %d\n", ssl_port);
}
@@ -84,15 +84,15 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
if (src != NULL) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
if (connection_type == DIRECT_CONNECT_TYPE_PEER) {
if (packet->tcp != NULL
if(src != NULL) {
src->directconnect_last_safe_access_time = packet->current_time_ms;
if(connection_type == DIRECT_CONNECT_TYPE_PEER) {
if(packet->tcp != NULL
&& flow->setup_packet_direction != packet->packet_direction && src->detected_directconnect_port == 0) {
src->detected_directconnect_port = packet->tcp->source;
NDPI_LOG_DBG2(ndpi_struct, "DC tcp PORT %u for src\n", ntohs(src->detected_directconnect_port));
}
if (packet->udp != NULL && src->detected_directconnect_udp_port == 0) {
if(packet->udp != NULL && src->detected_directconnect_udp_port == 0) {
src->detected_directconnect_udp_port = packet->udp->source;
NDPI_LOG_DBG2(ndpi_struct, "DC udp PORT %u for src\n", ntohs(src->detected_directconnect_port));
@@ -100,10 +100,10 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
}
}
if (dst != NULL) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
if (connection_type == DIRECT_CONNECT_TYPE_PEER) {
if (packet->tcp != NULL
if(dst != NULL) {
dst->directconnect_last_safe_access_time = packet->current_time_ms;
if(connection_type == DIRECT_CONNECT_TYPE_PEER) {
if(packet->tcp != NULL
&& flow->setup_packet_direction == packet->packet_direction && dst->detected_directconnect_port == 0) {
/* DST PORT MARKING CAN LEAD TO PORT MISSDETECTIONS
* seen at large customer http servers, where someone has send faked DC tcp packets
@@ -121,35 +121,34 @@ static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_s
}
}
static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
struct ndpi_id_struct *src = flow->src;
struct ndpi_id_struct *dst = flow->dst;
if (flow->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) {
if (packet->payload_packet_len >= 40 && memcmp(&packet->payload[0], "BINF", 4) == 0) {
u_int16_t ssl_port = 0;
ssl_port = parse_binf_message(ndpi_struct, &packet->payload[4], packet->payload_packet_len - 4);
if (dst != NULL && ssl_port) {
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) {
if(packet->payload_packet_len >= 40 && memcmp(&packet->payload[0], "BINF", 4) == 0) {
u_int16_t ssl_port = parse_binf_message(ndpi_struct,
&packet->payload[4],
packet->payload_packet_len - 4);
if(dst != NULL && ssl_port)
dst->detected_directconnect_ssl_port = ssl_port;
}
if (src != NULL && ssl_port) {
if(src != NULL && ssl_port)
src->detected_directconnect_ssl_port = ssl_port;
}
}
if ((packet->payload_packet_len >= 38 && packet->payload_packet_len <= 42)
if((packet->payload_packet_len >= 38 && packet->payload_packet_len <= 42)
&& memcmp(&packet->payload[0], "DCTM", 4) == 0 && memcmp(&packet->payload[15], "ADCS", 4) == 0) {
u_int16_t bytes_read = 0;
if (dst != NULL) {
if(dst != NULL) {
dst->detected_directconnect_ssl_port =
ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read);
NDPI_LOG_DBG2(ndpi_struct, "DC ssl port parsed %d\n", ntohs(dst->detected_directconnect_ssl_port));
}
if (src != NULL) {
if(src != NULL) {
src->detected_directconnect_ssl_port =
ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read);
NDPI_LOG_DBG2(ndpi_struct, "DC ssl port parsed %d\n", ntohs(src->detected_directconnect_ssl_port));
@@ -160,12 +159,12 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
return;
}
if (src != NULL) {
if (src->detected_directconnect_port == packet->tcp->source) {
if ((u_int32_t)
(packet->tick_timestamp -
if(src != NULL) {
if(src->detected_directconnect_port == packet->tcp->source) {
if((u_int32_t)
(packet->current_time_ms -
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
src->directconnect_last_safe_access_time = packet->current_time_ms;
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(src->detected_directconnect_port));
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
return;
@@ -175,11 +174,11 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
return;
}
}
if (src->detected_directconnect_ssl_port == packet->tcp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
if(src->detected_directconnect_ssl_port == packet->tcp->dest) {
if((u_int32_t)
(packet->current_time_ms -
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
src->directconnect_last_safe_access_time = packet->current_time_ms;
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(src->detected_directconnect_ssl_port));
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
return;
@@ -192,12 +191,12 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
}
if (dst != NULL) {
if (dst->detected_directconnect_port == packet->tcp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
if(dst != NULL) {
if(dst->detected_directconnect_port == packet->tcp->dest) {
if((u_int32_t)
(packet->current_time_ms -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
dst->directconnect_last_safe_access_time = packet->current_time_ms;
NDPI_LOG_INFO(ndpi_struct, "found DC using port %d\n", ntohs(dst->detected_directconnect_port));
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
return;
@@ -207,11 +206,11 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
return;
}
}
if (dst->detected_directconnect_ssl_port == packet->tcp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
if(dst->detected_directconnect_ssl_port == packet->tcp->dest) {
if((u_int32_t)
(packet->current_time_ms -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
dst->directconnect_last_safe_access_time = packet->current_time_ms;
NDPI_LOG_DBG(ndpi_struct, "found DC using port %d\n", ntohs(dst->detected_directconnect_ssl_port));
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
return;
@@ -224,17 +223,17 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
}
if (flow->directconnect_stage == 0) {
if(flow->directconnect_stage == 0) {
if (packet->payload_packet_len > 6) {
if (packet->payload[0] == '$'
if(packet->payload_packet_len > 6) {
if(packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|'
&& (memcmp(&packet->payload[1], "Lock ", 5) == 0)) {
NDPI_LOG_DBG2(ndpi_struct, "maybe first dc connect to hub detected\n");
flow->directconnect_stage = 1;
return;
}
if (packet->payload_packet_len > 7
if(packet->payload_packet_len > 7
&& packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|'
&& (memcmp(&packet->payload[1], "MyNick ", 7) == 0)) {
@@ -244,15 +243,15 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
}
}
if (packet->payload_packet_len >= 11) {
if(packet->payload_packet_len >= 11) {
/* did not see this pattern in any trace */
if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
if(memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
|| memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC HSUP ADBAS0 E\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
return;
/* did not see this pattern in any trace */
} else if (memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 ||
} else if(memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 ||
memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC CSUP ADBAS0 E\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER);
@@ -262,16 +261,16 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
}
} else if (flow->directconnect_stage == 1) {
if (packet->payload_packet_len >= 11) {
} else if(flow->directconnect_stage == 1) {
if(packet->payload_packet_len >= 11) {
/* did not see this pattern in any trace */
if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
if(memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
|| memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC HSUP ADBAS E in second packet\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
return;
/* did not see this pattern in any trace */
} else if (memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 ||
} else if(memcmp(&packet->payload[0], "CSUP ADBAS0", 11) == 0 ||
memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC HSUP ADBAS0 E in second packet\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER);
@@ -280,8 +279,8 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
}
}
/* get client hello answer or server message */
if (packet->payload_packet_len > 6) {
if ((packet->payload[0] == '$' || packet->payload[0] == '<')
if(packet->payload_packet_len > 6) {
if((packet->payload[0] == '$' || packet->payload[0] == '<')
&& packet->payload[packet->payload_packet_len - 1] == '|') {
NDPI_LOG_INFO(ndpi_struct, "found DC second\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
@@ -291,10 +290,10 @@ static void ndpi_search_directconnect_tcp(struct ndpi_detection_module_struct *n
}
}
} else if (flow->directconnect_stage == 2) {
} else if(flow->directconnect_stage == 2) {
/* get client hello answer or server message */
if (packet->payload_packet_len > 6) {
if (packet->payload[0] == '$' && packet->payload[packet->payload_packet_len - 1] == '|') {
if(packet->payload_packet_len > 6) {
if(packet->payload[0] == '$' && packet->payload[packet->payload_packet_len - 1] == '|') {
NDPI_LOG_INFO(ndpi_struct, "found DC between peers\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return;
@@ -318,13 +317,12 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
struct ndpi_id_struct *dst = flow->dst;
int pos, count = 0;
if (dst != NULL && dst->detected_directconnect_udp_port == packet->udp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
if(dst != NULL && dst->detected_directconnect_udp_port == packet->udp->dest) {
if((u_int32_t)
(packet->current_time_ms -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
dst->directconnect_last_safe_access_time = packet->current_time_ms;
NDPI_LOG_INFO(ndpi_struct, "found DC using udp port %d\n", ntohs(dst->detected_directconnect_udp_port));
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
return;
@@ -335,21 +333,21 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
}
}
if (packet->payload_packet_len > 58) {
if (src != NULL
if(packet->payload_packet_len > 58) {
if(src != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT)) {
if (packet->payload[0] == '$'
if(packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|'
&& memcmp(&packet->payload[1], "SR ", 3) == 0) {
pos = packet->payload_packet_len - 2;
if (packet->payload[pos] == ')') {
if(packet->payload[pos] == ')') {
while (pos > 0 && packet->payload[pos] != '(' && count < 21) {
pos--;
count++;
}
if (packet->payload[pos] == '(') {
if(packet->payload[pos] == '(') {
pos = pos - 44;
if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
if(pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC udp\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return;
@@ -357,25 +355,25 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
}
}
flow->directconnect_stage++;
if (flow->directconnect_stage < 3)
if(flow->directconnect_stage < 3)
return;
}
}
if (dst != NULL
if(dst != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT)) {
if (packet->payload[0] == '$'
if(packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|'
&& memcmp(&packet->payload[1], "SR ", 3) == 0) {
pos = packet->payload_packet_len - 2;
if (packet->payload[pos] == ')') {
if(packet->payload[pos] == ')') {
while (pos > 0 && packet->payload[pos] != '(' && count < 21) {
pos--;
count++;
}
if (packet->payload[pos] == '(') {
if(packet->payload[pos] == '(') {
pos = pos - 44;
if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
if(pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
NDPI_LOG_INFO(ndpi_struct, "found DC udp\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return;
@@ -383,7 +381,7 @@ static void ndpi_search_directconnect_udp(struct ndpi_detection_module_struct
}
}
flow->directconnect_stage++;
if (flow->directconnect_stage < 3)
if(flow->directconnect_stage < 3)
return;
}
}
@@ -405,18 +403,18 @@ void ndpi_search_directconnect(struct ndpi_detection_module_struct
NDPI_LOG_DBG(ndpi_struct, "search DC\n");
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) {
if (src != NULL && ((u_int32_t)
(packet->tick_timestamp -
if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_DIRECTCONNECT) {
if(src != NULL && ((u_int32_t)
(packet->current_time_ms -
src->directconnect_last_safe_access_time) <
ndpi_struct->directconnect_connection_ip_tick_timeout)) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
src->directconnect_last_safe_access_time = packet->current_time_ms;
} else if (dst != NULL && ((u_int32_t)
(packet->tick_timestamp -
} else if(dst != NULL && ((u_int32_t)
(packet->current_time_ms -
dst->directconnect_last_safe_access_time) <
ndpi_struct->directconnect_connection_ip_tick_timeout)) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
dst->directconnect_last_safe_access_time = packet->current_time_ms;
} else {
packet->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
NDPI_LOG_DBG2(ndpi_struct, "skipping as unknown due to timeout\n");
@@ -424,9 +422,9 @@ void ndpi_search_directconnect(struct ndpi_detection_module_struct
return;
}
if (packet->tcp != NULL) {
if(packet->tcp != NULL) {
ndpi_search_directconnect_tcp(ndpi_struct, flow);
} else if (packet->udp != NULL) {
} else if(packet->udp != NULL) {
ndpi_search_directconnect_udp(ndpi_struct, flow);
}
}
+2 -2
View File
@@ -2,7 +2,7 @@
* directdownloadlink.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -56,7 +56,7 @@ u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, st
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t filename_start = 0;
u_int8_t i = 1;
u_int16_t i = 1;
u_int16_t host_line_len_without_port;
if (packet->payload_packet_len < 100) {
+67
View File
@@ -0,0 +1,67 @@
/*
* dnp3.c
*
* Copyright (C) 2011-20 - 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/>.
*
* Created by Cesar HM
*
*/
#include "ndpi_protocol_ids.h"
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DNP3
#include "ndpi_api.h"
/*
https://www.ixiacom.com/company/blog/scada-distributed-network-protocol-dnp3
*/
/* ******************************************************** */
void ndpi_search_dnp3_tcp(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG_DBG(ndpi_struct, "search DNP3\n");
if(packet->tcp) {
/* The payload of DNP3 is 10 bytes long.
* Header bytes: 0x0564
*/
if ((packet->payload_packet_len >= 10)
&& (packet->payload[0] == 0x05)
&& (packet->payload[1] == 0x64)) {
NDPI_LOG_INFO(ndpi_struct, "found DNP3\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DNP3, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
/* ******************************************************** */
void init_dnp3_dissector(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
ndpi_set_bitmask_protocol_detection("DNP3", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DNP3,
ndpi_search_dnp3_tcp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
+410 -157
View File
@@ -1,7 +1,7 @@
/*
* dns.c
*
* Copyright (C) 2012-18 - ntop.org
* Copyright (C) 2012-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH
@@ -27,219 +27,472 @@
#include "ndpi_api.h"
#define FLAGS_MASK 0x8000
/* #define DNS_DEBUG 1 */
#define DNS_PORT 53
#define LLMNR_PORT 5355
#define MDNS_PORT 5353
static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow);
/* *********************************************** */
static void ndpi_check_dns_type(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int16_t dns_type) {
/* https://en.wikipedia.org/wiki/List_of_DNS_record_types */
switch(dns_type) {
/* Obsolete record types */
case 3:
case 4:
case 254:
case 7:
case 8:
case 9:
case 14:
case 253:
case 11:
case 33:
case 10:
case 38:
case 30:
case 25:
case 24:
case 13:
case 17:
case 19:
case 20:
case 21:
case 22:
case 23:
case 26:
case 31:
case 32:
case 34:
case 42:
case 40:
case 27:
case 100:
case 101:
case 102:
case 103:
case 99:
case 56:
case 57:
case 58:
case 104:
case 105:
case 106:
case 107:
case 259:
NDPI_SET_BIT(flow->risk, NDPI_DNS_SUSPICIOUS_TRAFFIC);
break;
}
}
/* *********************************************** */
static u_int16_t checkPort(u_int16_t port) {
switch(port) {
case DNS_PORT:
return(NDPI_PROTOCOL_DNS);
break;
case LLMNR_PORT:
return(NDPI_PROTOCOL_LLMNR);
break;
case MDNS_PORT:
return(NDPI_PROTOCOL_MDNS);
break;
}
return(0);
}
/* *********************************************** */
static u_int16_t checkDNSSubprotocol(u_int16_t sport, u_int16_t dport) {
u_int16_t rc = checkPort(sport);
if(rc == 0)
return(checkPort(dport));
else
return(rc);
}
/* *********************************************** */
static u_int16_t get16(int *i, const u_int8_t *payload) {
u_int16_t v = *(u_int16_t*)&payload[*i];
(*i) += 2;
return(ntohs(v));
}
/* *********************************************** */
static u_int getNameLength(u_int i, const u_int8_t *payload, u_int payloadLen) {
if(payload[i] == 0x00)
if(i >= payloadLen)
return(0);
else if(payload[i] == 0x00)
return(1);
else if(payload[i] == 0xC0)
return(2);
else {
u_int8_t len = payload[i];
u_int8_t off = len + 1;
if(off == 0) /* Bad packet */
return(0);
else
return(off + getNameLength(i+off, payload, payloadLen));
}
}
/*
allowed chars for dns names A-Z 0-9 _ -
Perl script for generation map:
my @M;
for(my $ch=0; $ch < 256; $ch++) {
$M[$ch >> 5] |= 1 << ($ch & 0x1f) if chr($ch) =~ /[a-z0-9_-]/i;
}
print join(',', map { sprintf "0x%08x",$_ } @M),"\n";
*/
static uint32_t dns_validchar[8] =
{
0x00000000,0x03ff2000,0x87fffffe,0x07fffffe,0,0,0,0
};
/* *********************************************** */
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
int x;
static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
struct ndpi_dns_packet_header *dns_header,
int payload_offset, u_int8_t *is_query) {
int x = payload_offset;
memcpy(dns_header, (struct ndpi_dns_packet_header*)&flow->packet.payload[x],
sizeof(struct ndpi_dns_packet_header));
dns_header->tr_id = ntohs(dns_header->tr_id);
dns_header->flags = ntohs(dns_header->flags);
dns_header->num_queries = ntohs(dns_header->num_queries);
dns_header->num_answers = ntohs(dns_header->num_answers);
dns_header->authority_rrs = ntohs(dns_header->authority_rrs);
dns_header->additional_rrs = ntohs(dns_header->additional_rrs);
x += sizeof(struct ndpi_dns_packet_header);
/* 0x0000 QUERY */
if((dns_header->flags & FLAGS_MASK) == 0x0000)
*is_query = 1;
/* 0x8000 RESPONSE */
else if((dns_header->flags & FLAGS_MASK) == 0x8000)
*is_query = 0;
else {
NDPI_SET_BIT(flow->risk, NDPI_MALFORMED_PACKET);
return(1 /* invalid */);
}
if(*is_query) {
/* DNS Request */
if((dns_header->num_queries > 0) && (dns_header->num_queries <= NDPI_MAX_DNS_REQUESTS)
&& (((dns_header->flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|| ((dns_header->num_answers == 0) && (dns_header->authority_rrs == 0)))) {
/* This is a good query */
while(x+2 < flow->packet.payload_packet_len) {
if(flow->packet.payload[x] == '\0') {
x++;
flow->protos.dns.query_type = get16(&x, flow->packet.payload);
#ifdef DNS_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "query_type=%2d\n", flow->protos.dns.query_type);
printf("[DNS] [request] query_type=%d\n", flow->protos.dns.query_type);
#endif
break;
} else
x++;
}
} else {
NDPI_SET_BIT(flow->risk, NDPI_MALFORMED_PACKET);
return(1 /* invalid */);
}
} else {
/* DNS Reply */
flow->protos.dns.reply_code = dns_header->flags & 0x0F;
if((dns_header->num_queries > 0) && (dns_header->num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
&& ((((dns_header->num_answers > 0) && (dns_header->num_answers <= NDPI_MAX_DNS_REQUESTS))
|| ((dns_header->authority_rrs > 0) && (dns_header->authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|| ((dns_header->additional_rrs > 0) && (dns_header->additional_rrs <= NDPI_MAX_DNS_REQUESTS))))
) {
/* This is a good reply: we dissect it both for request and response */
/* Leave the statement below commented necessary in case of call to ndpi_get_partial_detection() */
x++;
if(x < flow->packet.payload_packet_len && flow->packet.payload[x] != '\0') {
while((x < flow->packet.payload_packet_len)
&& (flow->packet.payload[x] != '\0')) {
x++;
}
x++;
}
x += 4;
if(dns_header->num_answers > 0) {
u_int16_t rsp_type;
u_int16_t num;
for(num = 0; num < dns_header->num_answers; num++) {
u_int16_t data_len;
if((x+6) >= flow->packet.payload_packet_len) {
break;
}
if((data_len = getNameLength(x, flow->packet.payload,
flow->packet.payload_packet_len)) == 0) {
break;
} else
x += data_len;
if((x+2) >= flow->packet.payload_packet_len) {
break;
}
rsp_type = get16(&x, flow->packet.payload);
#ifdef DNS_DEBUG
printf("[DNS] [response] response_type=%d\n", rsp_type);
#endif
ndpi_check_dns_type(ndpi_struct, flow, rsp_type);
flow->protos.dns.rsp_type = rsp_type;
/* here x points to the response "class" field */
if((x+12) <= flow->packet.payload_packet_len) {
x += 6;
data_len = get16(&x, flow->packet.payload);
if((x + data_len) <= flow->packet.payload_packet_len) {
// printf("[rsp_type: %u][data_len: %u]\n", rsp_type, data_len);
if(rsp_type == 0x05 /* CNAME */) {
x += data_len;
continue; /* Skip CNAME */
}
if((((rsp_type == 0x1) && (data_len == 4)) /* A */
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|| ((rsp_type == 0x1c) && (data_len == 16)) /* AAAA */
#endif
)) {
memcpy(&flow->protos.dns.rsp_addr, flow->packet.payload + x, data_len);
}
}
}
break;
}
}
if((flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_DNS)
|| (flow->packet.detected_protocol_stack[1] == NDPI_PROTOCOL_DNS)) {
/* Request already set the protocol */
// flow->extra_packets_func = NULL; /* Removed so the caller can keep dissecting DNS flows */
} else {
/* We missed the request */
u_int16_t s_port = flow->packet.udp ? ntohs(flow->packet.udp->source) : ntohs(flow->packet.tcp->source);
ndpi_set_detected_protocol(ndpi_struct, flow, checkPort(s_port), NDPI_PROTOCOL_UNKNOWN);
}
}
}
/* Valid */
return(0);
}
/* *********************************************** */
static int search_dns_again(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
/* possibly dissect the DNS reply */
ndpi_search_dns(ndpi_struct, flow);
/* Possibly more processing */
return(1);
}
/* *********************************************** */
static void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
int payload_offset;
u_int8_t is_query;
u_int16_t s_port = 0, d_port = 0;
NDPI_LOG_DBG(ndpi_struct, "search DNS\n");
if(flow->packet.udp != NULL) {
s_port = ntohs(flow->packet.udp->source);
d_port = ntohs(flow->packet.udp->dest);
x = 0;
payload_offset = 0;
} else if(flow->packet.tcp != NULL) /* pkt size > 512 bytes */ {
s_port = ntohs(flow->packet.tcp->source);
d_port = ntohs(flow->packet.tcp->dest);
x = 2;
payload_offset = 2;
} else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
if((s_port == 53 || d_port == 53 || d_port == 5355)
&& (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header)+x)) {
if(((s_port == DNS_PORT) || (d_port == DNS_PORT)
|| (s_port == MDNS_PORT) || (d_port == MDNS_PORT)
|| (d_port == LLMNR_PORT))
&& (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header)+payload_offset)) {
struct ndpi_dns_packet_header dns_header;
int invalid = 0;
int j = 0, max_len, off;
int invalid = search_valid_dns(ndpi_struct, flow, &dns_header, payload_offset, &is_query);
ndpi_protocol ret;
u_int num_queries, idx;
memcpy(&dns_header, (struct ndpi_dns_packet_header*) &flow->packet.payload[x], sizeof(struct ndpi_dns_packet_header));
dns_header.tr_id = ntohs(dns_header.tr_id);
dns_header.flags = ntohs(dns_header.flags);
dns_header.num_queries = ntohs(dns_header.num_queries);
dns_header.num_answers = ntohs(dns_header.num_answers);
dns_header.authority_rrs = ntohs(dns_header.authority_rrs);
dns_header.additional_rrs = ntohs(dns_header.additional_rrs);
x += sizeof(struct ndpi_dns_packet_header);
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN;
ret.app_protocol = (d_port == LLMNR_PORT) ? NDPI_PROTOCOL_LLMNR : ((d_port == MDNS_PORT) ? NDPI_PROTOCOL_MDNS : NDPI_PROTOCOL_DNS);
/* 0x0000 QUERY */
if((dns_header.flags & FLAGS_MASK) == 0x0000)
is_query = 1;
/* 0x8000 RESPONSE */
else if((dns_header.flags & FLAGS_MASK) == 0x8000)
is_query = 0;
else
invalid = 1;
if(invalid) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
if(!invalid) {
if(is_query) {
/* DNS Request */
if((dns_header.num_queries > 0) && (dns_header.num_queries <= NDPI_MAX_DNS_REQUESTS)
&& (((dns_header.flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|| ((dns_header.num_answers == 0) && (dns_header.authority_rrs == 0)))) {
/* This is a good query */
/* extract host name server */
max_len = sizeof(flow->host_server_name)-1;
off = sizeof(struct ndpi_dns_packet_header) + payload_offset;
if(dns_header.num_queries > 0) {
while(x < flow->packet.payload_packet_len) {
if(flow->packet.payload[x] == '\0') {
x++;
flow->protos.dns.query_type = get16(&x, flow->packet.payload);
#ifdef DNS_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "query_type=%2d\n", flow->protos.dns.query_type);
#endif
break;
} else
x++;
}
}
} else
invalid = 1;
} else {
/* DNS Reply */
/* Before continuing let's dissect the following queries to see if they are valid */
for(idx=off, num_queries=0; (num_queries < dns_header.num_queries) && (idx < flow->packet.payload_packet_len);) {
u_int8_t name_len = flow->packet.payload[idx];
flow->protos.dns.reply_code = dns_header.flags & 0x0F;
if((dns_header.num_queries > 0) && (dns_header.num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
&& (((dns_header.num_answers > 0) && (dns_header.num_answers <= NDPI_MAX_DNS_REQUESTS))
|| ((dns_header.authority_rrs > 0) && (dns_header.authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|| ((dns_header.additional_rrs > 0) && (dns_header.additional_rrs <= NDPI_MAX_DNS_REQUESTS)))
) {
/* This is a good reply */
if(ndpi_struct->dns_dissect_response) {
x++;
if(flow->packet.payload[x] != '\0') {
while((x < flow->packet.payload_packet_len)
&& (flow->packet.payload[x] != '\0')) {
x++;
}
x++;
}
x += 4;
if(dns_header.num_answers > 0) {
u_int16_t rsp_type;
u_int16_t num;
for(num = 0; num < dns_header.num_answers; num++) {
u_int16_t data_len;
if((x+6) >= flow->packet.payload_packet_len) {
break;
}
if((data_len = getNameLength(x, flow->packet.payload, flow->packet.payload_packet_len)) == 0) {
break;
} else
x += data_len;
rsp_type = get16(&x, flow->packet.payload);
flow->protos.dns.rsp_type = rsp_type;
break;
}
}
}
}
}
if(invalid) {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
return;
}
/* extract host name server */
int j = 0, max_len = sizeof(flow->host_server_name)-1, off = sizeof(struct ndpi_dns_packet_header) + 1;
while(off < flow->packet.payload_packet_len && flow->packet.payload[off] != '\0') {
flow->host_server_name[j] = flow->packet.payload[off];
if(j < max_len) {
if(flow->host_server_name[j] < ' ')
flow->host_server_name[j] = '.';
j++;
} else
break;
off++;
}
if(is_query && ndpi_struct->dns_dissect_response)
return; /* The response will set the verdict */
flow->host_server_name[j] = '\0';
flow->protos.dns.num_queries = (u_int8_t)dns_header.num_queries,
flow->protos.dns.num_answers = (u_int8_t) (dns_header.num_answers + dns_header.authority_rrs + dns_header.additional_rrs);
if(j > 0) {
ndpi_protocol_match_result ret_match;
ndpi_match_host_subprotocol(ndpi_struct, flow,
(char *)flow->host_server_name,
strlen((const char*)flow->host_server_name),
&ret_match,
NDPI_PROTOCOL_DNS);
}
#ifdef DNS_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[num_queries=%d][num_answers=%d][reply_code=%u][rsp_type=%u][host_server_name=%s]\n",
flow->protos.dns.num_queries, flow->protos.dns.num_answers,
flow->protos.dns.reply_code, flow->protos.dns.rsp_type, flow->host_server_name
);
printf("[DNS] [name_len: %u]\n", name_len);
#endif
if(flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
/**
Do not set the protocol with DNS if ndpi_match_host_subprotocol() has
matched a subprotocol
**/
NDPI_LOG_INFO(ndpi_struct, "found DNS\n");
ndpi_set_detected_protocol(ndpi_struct, flow, (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_PROTOCOL_UNKNOWN);
} else {
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
if(name_len == 0) {
/* End of query */
num_queries++;
idx += 5;
continue;
}
if((name_len+idx) >= flow->packet.payload_packet_len) {
/* Invalid */
#ifdef DNS_DEBUG
printf("[DNS] Invalid query len [%u >= %u]\n",
(name_len+idx),
flow->packet.payload_packet_len);
#endif
NDPI_SET_BIT(flow->risk, NDPI_MALFORMED_PACKET);
break;
} else
idx += name_len+1;
}
while(j < max_len && off < flow->packet.payload_packet_len && flow->packet.payload[off] != '\0') {
uint8_t c, cl = flow->packet.payload[off++];
if( (cl & 0xc0) != 0 || // we not support compressed names in query
off + cl >= flow->packet.payload_packet_len) {
j = 0;
break;
}
if(j && j < max_len) flow->host_server_name[j++] = '.';
while(j < max_len && cl != 0) {
u_int32_t shift;
c = flow->packet.payload[off++];
shift = ((u_int32_t) 1) << (c & 0x1f);
flow->host_server_name[j++] = tolower((dns_validchar[c >> 5] & shift) ? c : '_');
cl--;
}
}
}
flow->host_server_name[j] = '\0';
if(j > 0) {
ndpi_protocol_match_result ret_match;
ndpi_check_dga_name(ndpi_struct, flow, (char*)flow->host_server_name, 1);
ret.app_protocol = ndpi_match_host_subprotocol(ndpi_struct, flow,
(char *)flow->host_server_name,
strlen((const char*)flow->host_server_name),
&ret_match,
NDPI_PROTOCOL_DNS);
if(ret_match.protocol_category != NDPI_PROTOCOL_CATEGORY_UNSPECIFIED)
flow->category = ret_match.protocol_category;
if(ret.app_protocol == NDPI_PROTOCOL_UNKNOWN)
ret.master_protocol = checkDNSSubprotocol(s_port, d_port);
else
ret.master_protocol = NDPI_PROTOCOL_DNS;
}
/* Report if this is a DNS query or reply */
flow->protos.dns.is_query = is_query;
if(is_query) {
/* In this case we say that the protocol has been detected just to let apps carry on with their activities */
ndpi_set_detected_protocol(ndpi_struct, flow, ret.app_protocol, ret.master_protocol);
/* This is necessary to inform the core to call this dissector again */
flow->check_extra_packets = 1;
/* Don't use just 1 as in TCP DNS more packets could be returned (e.g. ACK). */
flow->max_extra_packets_to_check = 5;
flow->extra_packets_func = search_dns_again;
return; /* The response will set the verdict */
}
flow->protos.dns.num_queries = (u_int8_t)dns_header.num_queries,
flow->protos.dns.num_answers = (u_int8_t) (dns_header.num_answers + dns_header.authority_rrs + dns_header.additional_rrs);
#ifdef DNS_DEBUG
NDPI_LOG_DBG2(ndpi_struct, "[num_queries=%d][num_answers=%d][reply_code=%u][rsp_type=%u][host_server_name=%s]\n",
flow->protos.dns.num_queries, flow->protos.dns.num_answers,
flow->protos.dns.reply_code, flow->protos.dns.rsp_type, flow->host_server_name
);
#endif
if(flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
/**
Do not set the protocol with DNS if ndpi_match_host_subprotocol() has
matched a subprotocol
**/
NDPI_LOG_INFO(ndpi_struct, "found DNS\n");
ndpi_set_detected_protocol(ndpi_struct, flow, ret.app_protocol, ret.master_protocol);
} else {
if((flow->packet.detected_protocol_stack[0] == NDPI_PROTOCOL_DNS)
|| (flow->packet.detected_protocol_stack[1] == NDPI_PROTOCOL_DNS))
;
else
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
}
if(flow->packet_counter > 3)
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void init_dns_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
void init_dns_dissector(struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask) {
ndpi_set_bitmask_protocol_detection("DNS", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DNS,
ndpi_search_dns,
+69
View File
@@ -0,0 +1,69 @@
/*
* dnscrypt.c
*
* Copyright (C) 2020 - 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_DNSCRYPT
#include "ndpi_api.h"
static void ndpi_int_dnscrypt_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DNSCRYPT, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_dnscrypt(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
static char const * const dnscrypt_initial = "2\rdnscrypt";
NDPI_LOG_DBG(ndpi_struct, "search dnscrypt\n");
if (flow->packet_counter > 2)
{
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
/* dnscrypt protocol version 1: check magic */
if (packet->payload_packet_len >= 64 &&
strncmp((char*)packet->payload, "r6fnvWj8", strlen("r6fnvWj8")) == 0)
{
ndpi_int_dnscrypt_add_connection(ndpi_struct, flow);
}
/* dnscrypt protocol version 1 and 2: resolver ping */
if (packet->payload_packet_len > 13 + strlen(dnscrypt_initial) &&
strncasecmp((char*)packet->payload + 13, dnscrypt_initial, strlen(dnscrypt_initial)) == 0)
{
ndpi_int_dnscrypt_add_connection(ndpi_struct, flow);
}
}
void init_dnscrypt_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection(
"DNScrypt", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DNSCRYPT, ndpi_search_dnscrypt, NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN, ADD_TO_DETECTION_BITMASK);
*id += 1;
}
+1 -1
View File
@@ -2,7 +2,7 @@
* dofus.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-18 - ntop.org
* Copyright (C) 2011-20 - ntop.org
*
* This file is part of nDPI, an open source deep packet inspection
* library based on the OpenDPI and PACE technology by ipoque GmbH

Some files were not shown because too many files have changed in this diff Show More