Compare commits

..
467 Commits
Author SHA1 Message Date
Luca Deri 6450ae256c Fix for loop on the git dissector 2016-07-13 10:33:06 +02:00
Simone Mainardi 72e3930e08 Fixes nDPI protocol initialization for Git
[NDPI] ndpi_init_protocol_defaults(missing protoId=226) INTERNAL ERROR: not all protocols have been initialized

This is actually a merge of branch 'dev' into 1.8-stable.
2016-07-08 15:23:45 +02:00
Simone Mainardi 31140c8da7 Fixes test cases for QUIC.Google 2016-07-08 15:03:40 +02:00
Luca Deri 47bb46176b Fix for #225 2016-07-05 19:07:16 +02:00
Campus 0e49eb1d17 added drda protocol - fix quic output after commit 87717dd77f 2016-07-02 18:29:02 +02:00
Luca Deri 87717dd77f Added QUICK subprotocol support 2016-06-30 17:03:36 +02:00
Luca Deri 6fb81f146e Refreshed DNS implementation 2016-06-27 11:19:47 +02:00
Campus ff6b193821 minor fixes - deleted useless part on git and quic protos 2016-06-24 13:45:43 +02:00
Campus 96623c0e4f Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2016-06-24 13:19:56 +02:00
Campus 0f089bd49a added git protocol dissector and pcap for test 2016-06-24 13:19:14 +02:00
Luca Deri b318d191a5 Removed variables not used 2016-06-23 23:53:03 +02:00
Luca Deri d0665bb301 Recomputed results due to the previous commit 2016-06-19 21:29:19 +02:00
Luca Deri adbba69988 Removed false positives from CoAP protocol
Improved DNS detection
Added misisng default DropBox port
Fix for #154
Added sample pcap of Tor traffic for regression testing
2016-06-19 21:25:58 +02:00
Luca Deri 539ab241cd Reverted https://github.com/ntop/nDPI/commit/392a14241fa68512099ea6096a640275461af7d0 that prevented Tor dissector to work 2016-06-19 20:48:05 +02:00
Luca Deri f18b7c5e14 Compilation fix 2016-06-15 06:04:07 +02:00
Luca Deri 19324f2904 Enhanced string boundary check to avoid crashes with malformed packets 2016-06-15 06:12:41 +02:00
Luca Deri 6c83cd627f Enhanced string boundary check to avoid crashes with malformed packets 2016-06-14 20:25:23 +02:00
Luca Deri ed09d78ed9 Added 1e100.net to Google 2016-06-12 21:01:59 +02:00
Luca Deri 0b7a392b30 Restored code harvested in
https://github.com/ntop/nDPI/commit/60e7e19dab72a37d57bc7854e702264e7d25886d#diff-0856ce19e6ed4e80946656d41f7edd65L135

DNS reply dissection can now be controlled by a preference as demonstrated in ndpiReader.c
2016-06-07 17:14:16 +02:00
Luca Deri 2379443ef5 Fix on multicast address check on teredo 2016-05-31 12:58:44 +02:00
Luca Deri 8c50b9692e Improved bigram detection (used by Tor) 2016-05-31 12:47:51 +02:00
Luca Deri 787be6ec08 Improved teredo detection by discarding packets sent towards multicast addresses 2016-05-31 12:32:47 +02:00
Luca Deri 72efa329db Enhanced fragments support in ndpiReader
Improved RX protocol dissection and removed port guess as it caused false positives.
2016-05-31 12:20:25 +02:00
Luca Deri a79b338208 Compilation fix due t pack/unpack 2016-05-30 09:09:00 +02:00
Luca Deri 08b2899676 Merge pull request #210 from mscherer/patch-1
Fix typo
2016-05-29 10:10:22 +02:00
Michael Scherer 074e489fe3 Fix typo 2016-05-29 10:09:07 +02:00
Luca Deri f8badefa90 Update homebrew 1.8 formula 2016-05-28 11:00:32 +02:00
Luca Deri d113f8db5a Moved to 1.8 release 2016-05-28 09:24:57 +02:00
Luca Deri db36040fe1 Merge pull request #207 from alagoutte/scan-build
ndpi_main: fix Value stored to 'saddr'/'daddr' is never read
2016-05-28 09:06:34 +02:00
Alexis La Goutte f0c1688b1b ndpi_main: fix Value stored to 'saddr'/'daddr' is never read
ndpi_main.c:3286:7: warning: Value stored to 'saddr' is never read
ndpi_main.c:3290:7: warning: Value stored to 'saddr' is never read
ndpi_main.c:3291:7: warning: Value stored to 'daddr' is never read
2016-05-26 19:52:25 +02:00
Campus 67d3c9e9c8 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2016-05-24 23:33:13 +02:00
Luca Deri ac664940da Merge pull request #206 from theirix/l4-api
Updated ndpi_l4_detection_process_packet
2016-05-24 23:32:53 +02:00
Luca Deri 8eb0829267 Merge pull request #205 from theirix/dns-overflow
Fixed dns buffer overflow
2016-05-24 23:31:54 +02:00
Campus f8ecdc004f added new fb detection - remove old bittorrent functions - fix rx warning 2016-05-24 23:28:43 +02:00
theirix c088672632 Synchronized ndpi_l4_detection_process_packet impl 2016-05-24 23:39:10 +03:00
theirix 552076a36c Fixed dns buffer overflow 2016-05-24 23:34:15 +03:00
Michele Campus a0fe6665b2 Merge pull request #203 from alagoutte/scan-build
fix warning found by Clang Analyzer (scan-build)
2016-05-24 22:04:33 +02:00
Michele Campus b05907f592 Merge pull request #204 from alagoutte/fix_warning
fix warning when use -Wdocumentation CFLAG (clang)
2016-05-24 16:54:13 +02:00
Alexis La Goutte bae6a09a7c ndpi_main(.c): fix Null pointer passed as an argument to a 'nonnull' parameter 2016-05-24 13:46:17 +02:00
Alexis La Goutte 8bc1ed7d86 ndpi_api(.h): fix '@return' command used in a comment that is attached to a function returning void [-Wdocumentation] 2016-05-24 13:19:53 +02:00
Alexis La Goutte 9935cb0e3b ndpi_util.c: fix The right operand of '+' is a garbage value 2016-05-24 08:12:36 +02:00
Alexis La Goutte 594f7074f7 ndpi_util: Value stored to 'fcs' is never read 2016-05-23 23:04:50 +02:00
Alexis La Goutte a6c9d33c09 ndpi_util: replace if / else by switch/case
Fix also
The left operand of '==' is a garbage value
Value stored to 'slarp' is never read
Value stored to 'cdp' is never read
2016-05-23 23:03:26 +02:00
Alexis La Goutte e0e1ed6936 rtcp: fix Value stored to 'sport'/'dport' is never read 2016-05-23 22:32:39 +02:00
Alexis La Goutte 7fb4b42092 bittorrent: fix Value stored to 'a' is never read 2016-05-23 22:30:47 +02:00
Alexis La Goutte 1b3055faef ndpi_main: fix Value stored to 'saddr'/'daddr' is never read 2016-05-23 22:21:50 +02:00
Alexis La Goutte cf905d0c7f FTP: fix Value stored to 'packet' during its initialization is never read 2016-05-23 22:19:05 +02:00
Luca Deri f084bbb6d0 Merge pull request #201 from alagoutte/scan-build
Fix missing break
2016-05-23 21:39:42 +02:00
Luca Deri a2843084d6 Merge pull request #200 from alagoutte/typo
Fix some typo
2016-05-23 21:38:36 +02:00
Alexis La Goutte 3d23ee0e23 RX: fix indent 2016-05-23 19:56:45 +02:00
Alexis La Goutte 92718c4def QUIC: fix typo 2016-05-23 19:56:45 +02:00
Alexis La Goutte e1d3a8ea7d QUIC: remove trailing whitespace 2016-05-23 19:56:45 +02:00
Alexis La Goutte 2f7a9bb789 Fix missing break 2016-05-23 08:01:51 +02:00
Luca Deri ef2cb860a3 Recodede QUIC from scratch to make it more robust and export SNI (server name) as with SSL/HTTP 2016-05-21 15:34:10 +02:00
Campus 1e37916156 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2016-05-17 23:44:05 +02:00
Campus f3fb445166 upgrade quic test pcap with version 33 2016-05-17 23:43:05 +02:00
Michele Campus ac55d8dd8b Merge pull request #193 from backer-and/dev
Fix QUIC
2016-05-17 23:40:01 +02:00
Andrea Buscarinu f517a6a373 Fix QUIC 2016-05-17 23:15:38 +02:00
Campus ccdcf9d82b added OpenDNS service 2016-05-17 18:28:54 +02:00
Campus b7863e2dc2 added Weibo service and pcap test 2016-05-13 01:05:13 +02:00
Campus 6edb280cc7 update test pcap due to modification of quic protocol - improved readability of code 2016-05-12 23:17:41 +02:00
Michele Campus 32847fcfd0 Merge pull request #190 from backer-and/dev
enhance/refactor quic.c
2016-05-12 22:53:41 +02:00
Luca 69bdc44441 Fix for invalid DNS reponse detection 2016-05-12 13:10:23 +02:00
Andrea Buscarinu 4d58e55781 enhance/refactor quic.c 2016-05-11 12:42:30 +02:00
Luca Deri 90843a4228 Merge pull request #188 from alagoutte/QUIC
Enhance QUIC support
2016-05-10 23:50:02 +02:00
Alexis La Goutte d233459195 QUIC: Remove a wrong heuritics
There is always the QUIC version on first frame
2016-05-10 22:21:50 +02:00
Alexis La Goutte 6dab2b8c62 QUIC: Fix trailing whitespace 2016-05-09 19:12:09 +02:00
Michele Campus 86893a2984 Merge pull request #187 from madpilot78/add_needed_symbols
Add symbols needed by ntopng to the shared library export list.
2016-05-09 13:22:23 +02:00
Guido Falsi 3618f066bb Add symbols needed by ntopng to the shared library export list. 2016-05-09 12:36:30 +02:00
Luca Deri 5c149e0363 Simplified ndpi_exit_detection_module() 2016-05-08 11:04:20 +02:00
Luca Deri 22e03ee98a Simplified nDPI initialization function 2016-05-08 10:55:46 +02:00
Luca Deri 18901ca4d6 Added wrappers for substring-search
ndpi_init_automa()
ndpi_free_automa()
ndpi_add_string_to_automa()
ndpi_finalize_automa()
ndpi_match_string()
set_ndpi_malloc()
set_ndpi_free()
2016-05-07 18:45:18 +02:00
Luca Deri d5f77e92f7 Fixed the travis link from master -> dev 2016-05-03 08:59:52 +02:00
Luca Deri d139c31972 Merge pull request #185 from alagoutte/QUIC
Fix test suite
2016-05-03 08:55:47 +02:00
Alexis La Goutte 53550d8bb4 Fix test suite
there is some change with IPv6 Address...
2016-05-03 08:00:57 +02:00
Alexis La Goutte 356f9914cc QUIC: fix test suite after typo change 2016-05-03 07:52:39 +02:00
Luca Deri 6e57c4618e Merge pull request #184 from alagoutte/QUIC
Enhance QUIC support
2016-04-29 11:34:32 +02:00
Alexis La Goutte 9b0bef50de QUIC: fix typo the protocol name is QUIC (and not Quic) 2016-04-29 09:25:28 +02:00
Alexis La Goutte c957a12742 QUIC: last version of QUIC is Q033
Look Recent Changes by Version from QUIC Wire Layout Specification
2016-04-29 09:21:42 +02:00
Campus 1b9aa2ab71 fixed rx protocol for better logic conditions 2016-04-26 18:49:52 +02:00
Campus 1d17ece9ce fix missing conditional and 2016-04-26 15:02:32 +02:00
Campus 34ce35dcfa minor fix makefile 2016-04-26 14:20:23 +02:00
Campus f66cfca2a9 fixed and improved rx protocol detection - there was error on detection when -d option was enabled 2016-04-26 13:48:43 +02:00
Campus 7c1e8ba2bf rework some stuffs - added missing comments on functions 2016-04-24 23:43:22 +02:00
Luca Deri e23446389c Reworked https://github.com/ntop/nDPI/commit/8a4c15ecf5c5c1430e8047324a5e336db2f503f1 to avoid adding (un-needed) pcap dependency in nDPI core 2016-04-24 23:17:18 +02:00
Luca Deri 8cb6172e4b Added #include <sys/types.h>
https://github.com/voidlinux/void-packages/blob/master/srcpkgs/ndpi/patches/types.patch
2016-04-24 22:59:05 +02:00
Luca Deri d427647ce7 Firxed warnings 2016-04-24 10:35:54 +02:00
Luca Deri 8a4c15ecf5 Merge pull request #180 from emanuele-f/dev
High level API and ndpiReader simplification
2016-04-24 10:29:26 +02:00
Luca Deri 1be9194734 Code hardening for #181 2016-04-21 12:04:33 +02:00
emanuele-f 792d2fc79a Remove floating stack pointer causing segmentation fault 2016-04-20 16:20:50 +02:00
emanuele-f 5386aede36 Integrate root flows free and little changes 2016-04-20 15:36:44 +02:00
emanuele-f 4e1317cd0f Fix inline travis complaining 2016-04-20 02:23:37 +02:00
emanuele-f 9ee6442004 Other util API stuff 2016-04-20 01:32:01 +02:00
emanuele-f 6f84b85358 Use calloc to force 0 initialization 2016-04-20 00:03:21 +02:00
emanuele-f d7548e72b2 Fix some issues 2016-04-19 23:35:35 +02:00
emanuele-f 7964e11c7f Add header stuff 2016-04-19 22:39:19 +02:00
emanuele-f a4d0af1f96 Move relevant functions to ndpi_util API module 2016-04-19 22:35:18 +02:00
emanuele-f 282bc16243 add malloc wrapper TODO 2016-04-19 22:19:06 +02:00
emanuele-f 4ba106a525 Change confusing "ndpi_flow" structure name to "ndpi_flow_info" 2016-04-19 19:25:42 +02:00
Michele Campus 1d54092c7d Merge pull request #177 from giomasce/dev
Support RX protocol (used by AFS).
2016-04-16 18:03:26 +02:00
Giovanni Mascellani 4b50045ecd Add file license. 2016-04-15 16:41:23 +02:00
Giovanni Mascellani a6e715f574 Add RX testcase. 2016-04-15 15:47:39 +02:00
Giovanni Mascellani 18f5362a34 Support RX protocol (used by AFS). 2016-04-15 15:21:02 +02:00
Michele Campus a71f525a2b Merge pull request #175 from theirix/reader-asan-2
Combined ASAN overflow detection and buffer modify
2016-04-13 11:06:32 +02:00
theirix efae85de84 Combined ASAN overflow detection and buffer modify
Combined approach from pull request #172 and commit 6a63ea4.
2016-04-13 11:42:59 +03:00
Michele Campus da811fbdd0 Merge pull request #173 from theirix/buffer-overflows
Fixed multiple buffer overflows
2016-04-12 23:41:02 +02:00
theirix d7a2515093 Fixed oscar buffer overflow 2016-04-12 22:26:10 +03:00
Luca Deri 885cc3864e Merge pull request #172 from theirix/reader-asan
Allocate exact-size buffer with address sanitizer
2016-04-12 21:22:38 +02:00
theirix c22d3d3cae Fixed more buffer overflows with small packets 2016-04-12 22:14:13 +03:00
theirix fb3fc0c6de Fixed buffer overflows with safe str search
1. Detected a lot of memory errors using address sanitizer
and ndpi-scapy tool.

2. Added ndpi_match_prefix function that compares strings
with taking care of payload packet len. Almost drop-in
replacement for match_first_bytes function.

3. Replaced unsafe match_first_bytes usage with a ndpi_match_prefix
and additional length checks.
2016-04-12 22:08:30 +03:00
theirix 624f61193c Allocate exact-size buffer with address sanitizer
Allows address sanitizer to detect buffer overflow by
using special packet buffer when compiled with address sanitizer
support (autodetected clang and gcc).
2016-04-12 22:04:47 +03:00
Luca Deri 5a37ee9976 Removed some Tor false positives (more work necessary) 2016-04-06 09:45:38 +02:00
Luca Deri 6a63ea46a4 Added check for alerting when nDPI modified packet payload (should not happen) 2016-04-04 21:40:23 +02:00
Campus f437fac412 fix for test pcap and output 2016-04-04 00:15:57 +02:00
Michele Campus afea67e303 Merge pull request #170 from srzamfir/dev
Mqtt dissector fix
2016-04-04 00:12:13 +02:00
Campus 3d46f3df61 fixed wrong dropbox detection 2016-04-04 00:10:43 +02:00
Michele Campus 697617622c Merge pull request #169 from theirix/build-json-c
Improved autogen.sh, json-c search
2016-04-03 23:58:51 +02:00
Sorin Zamfir 7e9e3903d8 Included test result for CoAP and Mqtt. 2016-04-03 15:05:38 +03:00
Sorin Zamfir 7b66fcff37 Merge remote-tracking branch 'upstream/dev' into dev 2016-04-03 14:45:39 +03:00
Sorin Zamfir 40b219c397 Fixed false positives on skype and KakaoTalk. Tests run smooth now. 2016-04-03 14:16:18 +03:00
Sorin Zamfir b5e74ee3f1 Solved invalid detection on tests. Needs further work to detect one of the flows.
Please enter the commit message for your changes. Lines starting
2016-04-03 02:00:36 +03:00
theirix 6f95182751 Improved detection of json-c package.
- Improved detection code for json-c package to use pkg-config
  with custom search path that includes /usr/local
- Added optional option --disable-json-c to disable json-c package for
  reducing runtime dependencies.
2016-04-01 17:18:33 +03:00
theirix 41d7430442 Call configure with args from autogen 2016-04-01 17:18:23 +03:00
Campus aa86387ba9 improved Microsoft detection (minor fix) 2016-04-01 02:17:58 +02:00
Campus 2a1f44610f improved Microsoft detection 2016-04-01 02:11:51 +02:00
Campus 4704f48daa minox fix dns 2016-03-29 15:07:16 +02:00
Campus 8dacc91d51 fixed dns check host name server 2016-03-29 15:04:15 +02:00
Campus a594273989 fixed coap.c and dropbox.c after detecting wrong detection - added test for dropbox 2016-03-29 00:05:56 +02:00
Campus d9264e415c fixed and improved bittorrent detection for issue https://github.com/ntop/nDPI/issues/164 2016-03-27 01:39:38 +01:00
Luca Deri b3df389bd6 Removed WinMX reference from Makefile 2016-03-23 08:46:24 +01:00
Campus 2998b78797 deleted winmx protocol due to abandoned development since July 2, 2004 2016-03-23 01:27:36 +01:00
Campus 46a526ce26 deleted mqtt.c 2016-03-23 00:35:22 +01:00
Campus 95fffec172 fix for pull request https://github.com/ntop/nDPI/pull/161 2016-03-20 16:10:26 +01:00
Michele Campus 323912371e Merge pull request #161 from srzamfir/dev
Add CoAP and Mqtt (IoT specific protocols) dissectors
2016-03-20 15:51:11 +01:00
Sorin Zamfir 3213d2205a Removed unused type definitions.
Disabled tracing in the example application.
2016-03-20 13:38:29 +02:00
Sorin Zamfir 3dde80ed0f Included test file for coap and mqtt dissectors. 2016-03-20 12:12:42 +02:00
Sorin Zamfir 6f428c03e2 Merge remote-tracking branch 'remotes/iot/dev' into dev
Conflicts:
	src/include/ndpi_protocol_ids.h
	src/lib/ndpi_main.c
2016-03-20 11:53:27 +02:00
Sorin Zamfir 2d5d39db7b Updated with mqtt callbacks. 2016-03-20 11:22:04 +02:00
Sorin Zamfir 28806f3187 Minor changes to a comment 2016-03-19 20:50:38 +02:00
Luca Deri 5349d33abf Fixed unitialized variable 2016-03-19 14:10:26 +01:00
Campus a499da00ba added tcp port 51413 for TCP BT detection 2016-03-19 01:18:48 +01:00
Luca Deri a4d9c8cc3b Fix for https://github.com/ntop/nDPI/issues/159 2016-03-18 11:00:11 +01:00
Luca Deri 27d09c33ce Fix for invalid DNS dissection that caused packet corruption 2016-03-17 08:28:24 +01:00
Campus 5b86186e85 deleted old and not yet good skype ip addr - added new Netflix and CloudFlare IP addr 2016-03-16 10:47:35 +01:00
Campus 3b399f62f4 improved Skype detection - redized Viber pcap for test 2016-03-15 15:03:06 +01:00
Campus 7c511fb2f2 add new detection of Viber (service) 2016-03-15 00:56:09 +01:00
Campus 4370781b49 rework API (part 1) - minor fixes functions 2016-03-14 01:04:50 +01:00
Luca Deri 1cf4926b4e Enhanced Google detection 2016-03-13 21:30:21 +01:00
Campus 7ae06a114d added check_punycode_string for issue https://github.com/ntop/nDPI/issues/157 2016-03-10 11:44:24 +01:00
Campus 8321b2fa66 added support for MS_OneDrive service 2016-03-08 01:49:48 +01:00
Luca Deri ba966634f5 Source code rename to avoid conflicts on Windows 2016-03-06 18:52:43 +01:00
Luca Deri dd12757493 Added check to harden code 2016-03-05 08:22:04 +01:00
Luca Deri 7ea37edfbf Improved protocol detection 2016-03-04 22:13:37 +01:00
Luca Deri 462368f959 Added new ndpi_detection_giveup() API call to call before giving up for a given flow
Code cleanup
2016-03-04 19:15:13 +01:00
Michele Campus 73833e0ef0 Merge pull request #153 from Timothyyy/dev
protocols: sip CANCEL packet detection fix
2016-03-02 11:54:05 +01:00
Timothy 7d699ade0c protocols: sip CANCEL packet detection fix 2016-03-02 11:04:36 +03:00
Luca bc52b8f310 Changed label case 2016-02-29 23:22:34 +01:00
Luca ecb8d117ac Reworked sockets support
Fixed TFTP support
2016-02-29 17:23:05 +01:00
Luca Deri ead8c4933e Removed VEOHTV protocol and replaced with HTTPDownload
Fixed bug that prevented content type to be properly detected
2016-02-28 23:19:13 +01:00
Luca Deri 20374b542d Fixed warning
Reworked protocol initialization
2016-02-27 09:00:02 +01:00
Campus 6df31099c2 typo fixed 2016-02-26 20:48:14 +01:00
Luca Deri b7e2d8f019 Minor BT optimization 2016-02-25 10:25:03 +01:00
Luca Deri 80a35226c5 Improve BT-uTP protocol dissection 2016-02-25 09:58:23 +01:00
Luca Deri e025d696f6 Added trace for BitTorrrent u-TP 2016-02-25 08:31:59 +01:00
Sorin Zamfir 245ca20eea Fixed the bug. Damn comparison. 2016-02-20 00:15:09 +02:00
Sorin Zamfir 8f60ad8874 We have a bug :(. 2016-02-19 21:18:28 +02:00
Sorin Zamfir d18a1edb67 Functional mqtt 2016-02-19 20:22:54 +02:00
Sorin Zamfir a8050635fa Improved Mqtt detection. 3 messages remain for identification 2016-02-19 19:55:03 +02:00
Campus 33fa1989bc improved netflix and amazon cloud detection 2016-02-19 02:00:23 +01:00
Sorin Zamfir 7d3ab6d0b4 Some filtering applied. Not yet functional. 2016-02-18 21:36:06 +02:00
Sorin Zamfir 237102b5f2 First draft of the Mqtt dissector. 2016-02-18 20:29:41 +02:00
Campus 407b4fd1d5 improved facebook detection adding host name match 2016-02-18 00:43:43 +01:00
Campus 882cbd8b4e Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2016-02-18 00:30:02 +01:00
Campus 4c3d9788dd added missing free for idle flow in ndpiReader.c 2016-02-18 00:29:06 +01:00
Luca Deri 59c65118e1 Updated readme 2016-02-17 10:58:52 +01:00
Campus 84976ed5dc fix for https://github.com/ntop/nDPI/issues/148 2016-02-16 12:23:56 +01:00
Luca Deri 15ccb70ae6 Improved WhatsAppVoice detection 2016-02-15 22:16:39 +01:00
Luca Deri e1481f3a90 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2016-02-15 12:00:56 +01:00
Luca Deri 01413c8d9f Disabled list of skype hosts: it looks outdated 2016-02-15 11:55:21 +01:00
Campus 392a14241f fixed ssl/tor bug for https://github.com/ntop/nDPI/issues/147 2016-02-15 11:02:40 +01:00
Luca Deri 16a5c6995c Added ability to extract BitTorrent hash (and eventually peerId) 2016-02-15 09:57:26 +01:00
Campus c7334e7c56 added cloudflare service - minor fixes for test pcap 2016-02-14 19:38:30 +01:00
Luca Deri cc4ceb88a0 Fix for #143 2016-02-12 22:07:37 +01:00
Sorin Zamfir 7ee464709b Functional dissector. Guestimative. 2016-02-11 23:55:21 +02:00
Sorin Zamfir ee5e7449ac First running example. No actual low-level detection.
* logging is now running
* included example capture
* included example log
* skeleton for coap detection
2016-02-08 23:01:22 +02:00
Sorin Zamfir 278a067d43 First skeleton for Coap dissector. 2016-02-07 19:29:30 +02:00
Luca e9f7df081f Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2016-01-21 16:33:20 +01:00
Luca d0b83a7196 Minor change to ndpi_protocol2name() 2016-01-21 13:52:52 +01:00
Luca bc48b770de Added ndpi_automa_match_string_subprotocol call
Fixed DNS dissector decoding bug
2016-01-21 13:25:55 +01:00
Campus e7cb3d324a fixed wrong dns detection for host name server that invalidated test pcaps 2016-01-12 17:21:04 +01:00
Luca Deri 0f3222e489 Fixed compilation errors due to previous commit 2016-01-06 18:11:57 +01:00
Luca Deri a08a0077e6 Hardened DNS dissector 2016-01-06 17:38:41 +01:00
Campus 5336aecde7 added ip range feature for file loaded with -p option to support custom protocols specified 2015-12-31 17:07:22 +01:00
Michele Campus a2c51a586e Merge pull request #132 from pavel-odintsov/dev
Made ndpi memory allocator type compatible with C++ on x686 platforms
2015-12-31 10:27:54 +01:00
Campus 3aa506eb1b added Office 365 URLs and IP address ranges (part 1) 2015-12-29 19:41:15 +01:00
Campus 60e7e19dab wrote new dns dissector - deleted useless part of dns to slim data structures used in nDPI and ntopng 2015-12-29 18:17:52 +01:00
Pavel Odintsov 1b2702df24 Made ndpi memory allocator type compatible with C++ on x686 platforms. Switch from unsigned long to size_t as allocation functions parameter. 2015-12-28 14:08:57 +03:00
Campus 6d37ee2970 added Google server address range 2015-12-24 00:26:31 +01:00
Campus 2aa007fbad Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-12-24 00:17:26 +01:00
Campus bfded90875 added OCS service and related pcap for testing 2015-12-24 00:16:33 +01:00
Luca e0c6d80c09 Fix for #131 2015-12-18 11:53:01 +01:00
Campus 237de95285 fixed makefile include header ndpi_includes.h 2015-12-13 17:21:47 +01:00
Luca Deri 357d8c98a3 Merge pull request #128 from lmangani/dev
minor fix for tests after d2c355bdb0
2015-12-10 10:24:25 +01:00
Lorenzo Mangani 5f40394501 minor fix for tests 2015-12-10 00:07:37 +01:00
Luca 41c6d2d031 Improvement for Dropbox detection
Fix for #124
2015-12-08 00:32:30 +08:00
Luca d2c355bdb0 Enhanced QQ support 2015-12-08 00:19:13 +08:00
Luca Deri 6f3d5a7b33 Win fixes 2015-11-30 14:38:16 +01:00
Luca Deri 34491f4be1 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-11-30 14:22:01 +01:00
Luca Deri 34e0a74c07 Win fixes 2015-11-30 14:21:50 +01:00
Campus 587f156557 reorganized header files - added ndpi_includes.h 2015-11-30 12:37:15 +01:00
Luca Deri f04c3c6acb Minor fix 2015-11-27 00:29:19 +01:00
Luca Deri 80171b7c54 Removed warning 2015-11-26 23:53:21 +01:00
Luca Deri cb68d4d00a Win32 compilation fixes 2015-11-26 23:47:55 +01:00
Luca Deri 98ef945d2e fixes for packing datastructures 2015-11-26 19:46:51 +01:00
Campus 12b47fece0 fixed missed library netinet/in.h under FreeBSD 2015-11-26 12:32:15 +01:00
Luca Deri bfb44934b7 Fixed IPv6 HTTPs support 2015-11-23 10:08:44 +01:00
Luca Deri 08ca34f5d0 Fix for #119 2015-11-23 10:07:19 +01:00
Luca Deri a46c12c014 Fixed string offset 2015-11-22 23:28:50 +01:00
Luca Deri d24093c4a6 Improvements on netbios name detection 2015-11-22 23:13:50 +01:00
Campus ec034da5c9 fixed potential buff overflow with sizeof control 2015-11-19 20:18:37 +01:00
Campus d5b9e4ccd5 fixed wrong output 6in4tunnel after updates in nDPI 2015-11-19 20:10:46 +01:00
Luca Deri 169c837613 Fix for https://github.com/ntop/nProbe/issues/7 for wrong RTP identification 2015-11-18 10:46:58 +01:00
Luca 33f38dd437 Added ndpi_l4_detection_process_packet function 2015-11-17 14:16:09 +01:00
Simone Mainardi bd7004ecd7 Fixes #116, adds extra #ifndef to prevent redefinitions
Extra #ifndef directives are added to prevent possible redefinitions
of __LITTLE_ENDIAN__ and __BIG_ENDIAN__
2015-11-15 22:44:06 +01:00
lucaderi 8babee0efb Fix for CentOS6 2015-11-12 16:25:12 +01:00
Luca a407da79a9 Update ndpi_ethernet definition 2015-11-12 15:32:44 +01:00
Luca 8399afa607 Removed legacy linux_compat.h file
Updated IPv6 address dump format
2015-11-12 15:23:00 +01:00
Luca 68091c7cdb Added missing prototype 2015-11-12 15:11:28 +01:00
Luca e62be406ce Added missing ndpi_detection_get_sizeof_ndpi_flow_struct(), ndpi_detection_get_sizeof_ndpi_id_struct() functions 2015-11-12 15:09:49 +01:00
Michele Campus dd3a79dac2 Merge pull request #114 from kYroL01/dev
Refactoring nDPI
2015-11-12 14:57:02 +01:00
Campus a4f170604c removed kernel support and #if 0s 2015-11-12 12:08:41 +01:00
Campus 349e0b6fd2 other changes related to refactoring, including Makefile.am modifications 2015-11-12 10:43:32 +01:00
Campus 78eceb43a1 deleted useless or not used functions and #ifdef 2015-11-10 01:12:00 +01:00
Campus 0cd8d939f1 deleted useless header 2015-11-09 14:36:49 +01:00
Campus 9fa2c7404f fixed mdns and tcp/udp protocols after changes 2015-11-09 13:44:23 +01:00
Campus 8cd0a8838a fixing ndpiReader.c after previous changes 2015-11-09 13:39:33 +01:00
Campus d92ffa6771 initial refactoring nDPI - typedef defined only in ndpi_typedef.h 2015-11-09 13:36:35 +01:00
Michele Campus 63cab68a96 Merge pull request #111 from xumjbn/dev
fix dissector QQ unkown bug
2015-10-27 10:33:05 +01:00
xumjbn f6eb2724e2 fix dissector QQ unkown bug 2015-10-28 15:07:26 +08:00
Luca Deri fc6980e0c9 Fix for #86 2015-10-26 13:43:38 +01:00
Luca Deri 7a95a21e09 Fix for #110 2015-10-26 13:21:39 +01:00
Luca Deri 8edd628973 Minor core reorganization 2015-10-26 01:34:39 +01:00
Luca Deri 50e7e959fe Updated test result 2015-10-25 23:26:03 +01:00
Luca Deri b5f70d02b2 Fixed IPv6-in-IPv4 implementation 2015-10-25 23:23:51 +01:00
Luca Deri 76c2fb3de7 Removed linux kernel support 2015-10-24 12:47:23 +02:00
Campus 27ea5c0026 added 6in4 tunneling pcap for test 2015-10-23 17:15:28 +02:00
Campus 59d0af33b8 added support for 6in4 tunneling in ndpiReader.c 2015-10-23 17:14:03 +02:00
Luca Deri 25631a25f7 Implemented MS Lync support 2015-10-22 00:32:48 +02:00
Luca ac9b4f8135 Removed non IP traffic to shrink pcaps 2015-10-20 16:20:59 +02:00
Campus 46694ece47 added new BGP pcap for detection of Cisco datalink layer 2015-10-19 01:58:03 +02:00
Campus 74b016c8b6 fixed BGP detection - added BGP pcap with Cisco hDLC and Cisco SLARP 2015-10-19 01:54:41 +02:00
Campus 7242b08609 deleted useless header 2015-10-16 19:28:53 +02:00
Campus ee0954c8cb Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-10-16 17:49:29 +02:00
Campus fd9f4753bb added cisco hdlc datalink type - fix MPLS header - added BGP pcap with cisco hdlc & MPLS header 2015-10-16 17:48:38 +02:00
Luca Deri dc9ad66fe2 Windows changes 2015-10-15 12:44:51 +02:00
Luca Deri 247acce949 Simplified IPv6 typedefs 2015-10-12 09:15:02 +02:00
Luca Deri 91b2e0bff2 Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-10-12 01:17:19 +02:00
Luca Deri 17ad351386 Changed to make sure IPv6 defines are properly defined 2015-10-12 01:16:28 +02:00
Luca Deri 72eafff843 Improvements for NetFlix detection 2015-10-11 22:27:03 +02:00
Luca Deri 4ec03b7e87 Added TZSP encapsulation support 2015-10-11 18:35:51 +02:00
Luca Deri 88d466e58e Added fix for Webex protol detection 2015-10-11 17:55:56 +02:00
Luca Deri cf2c59b1d7 Fixed travis link 2015-10-11 17:44:41 +02:00
Luca 93f02c08dc Fixed invalid indexes used in SMTP dissector.
See https://github.com/ntop/nDPI/commit/8c4fada42f8e6dcba42281fdc129e0a32b6050dc#commitcomment-13685139
2015-10-09 15:03:10 +02:00
Michele Campus efac255821 Merge pull request #101 from Tomasu/dev
NDPI_PROTOCOL_KAKAOTALK_VOICE was used instead of NDPI_SERVICE_KAKAOT…
2015-10-08 13:27:57 +02:00
Thomas Fjellstrom 06515b43d8 NDPI_PROTOCOL_KAKAOTALK_VOICE was used instead of NDPI_SERVICE_KAKAOTALK_VOICE 2015-10-08 05:04:16 -06:00
Luca 0e436e66de Reworked copyright to give credit to the developer 2015-10-06 16:24:03 +02:00
Luca Deri 3f2eec75c7 Merge pull request #98 from Tomasu/dev
Add Ubiquity AirControl 2 protocol detector
2015-10-06 16:09:59 +02:00
Thomas Fjellstrom 6519a1e326 add ndpi_malloc, ndpi_calloc and ndpi_set_detected_protocol to list of exported symbols 2015-10-04 20:04:39 -06:00
Thomas Fjellstrom a2ff20990c remove traces of DHCP detector from ubntac2.c 2015-10-04 19:53:25 -06:00
Thomas Fjellstrom 0a6d43c5f6 Add Ubiquity AirControl 2 protocol detection 2015-10-04 19:50:47 -06:00
Thomas Fjellstrom 64a368dd8e add Ubiquity AirControl 2 protocol detection 2015-10-04 19:48:26 -06:00
Campus 1dc03d5741 added radio tap header identification for ieee802.11 packets 2015-10-04 14:00:47 +02:00
Luca Deri e5c2fee022 Travis logo changes 2015-10-03 08:34:18 +02:00
Lorenzo Mangani 00bfba1d77 Update README.md 2015-09-29 01:04:46 +02:00
Luca Deri 76c963a70c Added support for pfring_config 2015-09-23 15:53:01 +02:00
valentina f78f6b59cc Added some tags in order to recognize ebay 2015-09-23 00:53:25 +02:00
Luca Deri faf3c81be3 Merge pull request #96 from mgigante/dbg_mgigante_freebsd81
Remove duplicated function declarations
2015-09-22 16:11:14 +02:00
Marco Gigante a994722bb1 Remove duplicated function declarations 2015-09-22 15:25:09 +02:00
valentina b383475282 Fixed DCE_RPC protocol when the port is different to default port (135) 2015-09-20 23:22:48 +02:00
Luca Deri ce7866a6a6 Added missing symbols
ndpi_get_lower_proto
ndpi_is_proto
2015-09-04 09:00:00 +02:00
Lorenzo Mangani 0dfd6d3986 Merge pull request #92 from lmangani/dev
Added HEP protocol detection support (sipcapture)
2015-09-01 18:11:52 +02:00
Lorenzo Mangani 50757e7afe Remove HEP2 match 2015-09-01 10:02:27 +02:00
Lorenzo Mangani df64a1069e Added HEP protocol detection support (sipcapture) 2015-08-30 23:07:31 +02:00
Luca Deri 9450226675 Merge pull request #91 from rs-dev/steam_NDPI_PARSE_PACKET_LINE_INFO
Make sure packet->user_agent_line.ptr is up to date before using it.
2015-08-30 22:42:33 +02:00
Martin Natano 8f8052735c Make sure packet->user_agent_line.ptr is up to date before using it.
Otherwise we might dereference a stale pointer.
2015-08-28 14:49:51 +02:00
Luca Deri aa6640e1c0 Merge pull request #84 from bcronje/dev
Ensure usage of struct in_addr is in network byte order.
2015-08-27 08:45:05 +02:00
Beyers Cronje 5f1b82d696 Ensure usage of struct in_addr is in network byte order.
Closes issue #81
2015-08-27 01:18:32 +02:00
Luca Deri 19e96f7dd2 Fixes #83. Critical fix: due to an invalid endianess conversion some protocol were not properly indetified 2015-08-26 16:09:24 +02:00
Luca Deri 591d6df489 Merge pull request #80 from bcronje/dev
Do not write to packet.iph, which should be readonly.
2015-08-26 01:18:45 +02:00
Beyers Cronje 8fe318495f Do not write to packet.iph, which should be readonly.
Resolves issue #77
2015-08-26 00:49:01 +02:00
Luca Deri 569c055389 Fir for #79 2015-08-26 00:29:18 +02:00
Luca Deri 26ce076f61 Merge pull request #76 from alagoutte/wdoc
Fix warning when use -Wdocumentation (Clang CFLAG)
2015-08-18 15:20:24 +02:00
Alexis La Goutte 07c7d63d44 Fix warning when use -Wdocumentation
src/include/ndpi_api.h:73:13: error: parameter 'ndpi_malloc' not found in the function declaration [-Werror,-Wdocumentation]
src/include/ndpi_api.h:91:13: error: parameter 'cache' not found in the function declaration [-Werror,-Wdocumentation]
src/include/ndpi_api.h:92:13: error: parameter 'cache' not found in the function declaration [-Werror,-Wdocumentation]
ndpiReader.c:152:22: error: not a Doxygen trailing comment [-Werror,-Wdocumentation]
ndpiReader.c:153:36: error: not a Doxygen trailing comment [-Werror,-Wdocumentation]
ndpiReader.c:156:39: error: not a Doxygen trailing comment [-Werror,-Wdocumentation]
2015-08-18 14:44:05 +02:00
Luca Deri 0a4c8e2959 Moved to 1.7.1 development branch 2015-08-18 11:58:57 +02:00
Luca Deri 5352c34ba5 Updated homebrew formula for 1.7 release 2015-08-18 11:58:23 +02:00
Luca Deri 41fcb7b1c1 Warning fix 2015-08-18 11:02:29 +02:00
Luca Deri a0bef995b6 Initial work for supporting HotspotShield VPN detection 2015-08-13 12:44:47 +02:00
Luca Deri d6b5d8e2c2 Added teredo protocol support. Fixed #74 2015-08-07 15:56:03 +02:00
Luca Deri 449742e69d Fixed a bug in the STUN dissector courtesy of Asher Yermiyahu
Fixed a bug in the NetFlow dissector that caused flows to be wrongly decoded as Netflow
Updated test results for starcraft and whatsapp
2015-08-03 14:35:31 +02:00
Luca Deri bc786b48fa Merge pull request #73 from c4stan/dev
battle.net removed
2015-07-30 14:33:52 +02:00
m.bracci 506b4e5f81 battle.net removed
battle.net removed, fixed a typo
2015-07-30 14:04:25 +02:00
Luca Deri 8365b127f2 Merge pull request #72 from pavel-odintsov/dev
Enhance NTP support, add protocol version identification; Add pcap ex…
2015-07-29 16:18:19 +02:00
Pavel Odintsov 471ea81594 Enhance NTP support, add protocol version identification; Add pcap examples for NTPv2, NTPv3, NTPv4; Fix bug with identification of NTP monlist packets as QUIC 2015-07-29 14:19:32 +03:00
Luca Deri b0ac39fe28 Various Instagram enhancements 2015-07-27 23:25:47 +02:00
Luca Deri aced1e9673 Improvements to WhatsApp voice 2015-07-25 10:13:47 +02:00
Luca e37be3b43d Fix to limit STUN to UDP only 2015-07-22 16:51:39 +02:00
Luca 6648d19239 Minor starcraft/WoW code cleanup 2015-07-21 17:30:47 +02:00
Luca Deri 8d8a204519 Cleaned up starcraft protocol code
Fixed false-positive in Skype dissector
2015-07-21 14:10:50 +02:00
Luca Deri 2ab10ec9b7 Merge pull request #66 from c4stan/dev
Starcraft 2/Battle.net support
2015-07-21 13:25:46 +02:00
Matteo Bracci 0ce34f341e Update starcraft2.c
Removed debug leftovers
2015-07-20 12:55:14 +02:00
Michele Campus 0d68f8ab5d added free for flow in get_ndpi_flow - deleted dead part in ndpi_typedef.c 2015-07-19 01:21:37 +02:00
Matteo Bracci 3ea5f2f0a6 Update ndpi_protocol_ids.h 2015-07-17 19:00:36 +02:00
Matteo Bracci 912c160ad3 Update ndpi_typedefs.h 2015-07-17 18:50:21 +02:00
Matteo Bracci d9745a2e2c Update ndpi_protocol_ids.h 2015-07-17 18:48:05 +02:00
Matteo Bracci deb96d83d3 Update ndpi_protocol_ids.h 2015-07-17 18:47:50 +02:00
Matteo Bracci e5f3d21f81 Update ndpi_protocol_ids.h 2015-07-17 18:47:31 +02:00
Matteo Bracci eb49f15453 Update ndpi_protocol_ids.h 2015-07-17 18:47:00 +02:00
Matteo Bracci 5165102f81 Update world_of_warcraft.c
Commented the first part of the dissector, as it steals traffic from other Battle.net based protocols.
2015-07-17 18:43:32 +02:00
Matteo Bracci d215d6d861 Update ndpi_protocols.h 2015-07-17 18:42:42 +02:00
Matteo Bracci 0739b577d4 Update starcraft2.c
starcraft2
2015-07-17 15:30:34 +02:00
Matteo Bracci c62e8dadb6 Update ndpi_main.c
starcraft2
2015-07-17 13:53:31 +02:00
Matteo Bracci e29bd2270f Update ndpi_content_match.c.inc
starcraft2
2015-07-17 13:44:50 +02:00
Matteo Bracci aa4bdebf40 Update starcraft2.c 2015-07-17 13:40:35 +02:00
Matteo Bracci 5f460c95cc Create starcraft2.c 2015-07-17 13:38:41 +02:00
Luca Deri 73358d5ec2 Added check for removing characters from nDPI custom-defined protocols that might cause apps to misbehave. 2015-07-16 21:01:30 +02:00
Luca Deri e98108a8be Updated guide courtesy of Sudeepta Bhuyan (#62) 2015-07-14 00:18:39 +02:00
Luca 5af906ad83 Enhanced FTP_DATA recognition (issue #28) 2015-07-13 16:41:51 +02:00
Luca 1d711d849d Added fix for #31 2015-07-13 16:16:58 +02:00
Luca 0b7af2dbbc Fixes for #27 2015-07-13 15:34:47 +02:00
Michele Campus 9d1e99ad0a added Oscar test 2015-07-13 15:01:51 +02:00
Luca Deri f948e76c45 Merge pull request #65 from kYroL01/dev
fixed Oscar family_type
2015-07-13 15:01:11 +02:00
Michele Campus e3e8b5c6e4 fixed Oscar protocol dissector (4) 2015-07-13 01:05:57 +02:00
Michele Campus e4f4cfb1de fixed Oscar protocol dissector (4) 2015-07-13 01:02:23 +02:00
Luca Deri 085d7f0ed4 Removed warnings
Added instagram to the list of tests
2015-07-13 00:05:04 +02:00
Luca Deri f3105f6c81 Merge pull request #64 from backer-and/dev
Added Instagram detection service
2015-07-12 23:54:59 +02:00
backer-and 5c55b970c6 Added Instagram pcap file 2015-07-12 23:38:55 +02:00
backer-and cad7e541b6 Added Instagram detection
Detected "instagram.c10r.facebook.com" host.  Omitted "*amazonaws.com",
"*akamai.com" and "*facebook.com" CDNs e.g. "a1408.dspw43.akamai.net"
2015-07-12 23:15:43 +02:00
Luca Deri 312c7ce1af Merge pull request #63 from kYroL01/dev
Fixed Oscar protocol dissector
2015-07-12 23:05:41 +02:00
backer-and c354ff85a6 Added Instagram as last implemented protocol 2015-07-12 22:49:24 +02:00
Luca fc12541e8a Added word version of the manual 2015-07-12 20:38:41 +02:00
Michele Campus e178653f48 fixed Oscar protocol dissector (3) 2015-07-12 18:30:08 +02:00
Michele Campus 05f2eb6270 fixed Oscar protocol dissector (2) 2015-07-12 18:03:44 +02:00
Michele Campus 0307c85bd3 fixed Oscar protocol dissector 2015-07-12 17:51:21 +02:00
Luca 71ed576e18 Fixed #46 (Deezer support) 2015-07-11 18:54:55 +02:00
Luca 2f347a33d8 Fixes for issues #40 -> #52
Implemented sub-protocol detection for SSL/HTTP/HTTPS
2015-07-11 16:04:58 +02:00
Luca Deri 436af982fd Merge pull request #60 from kYroL01/dev
fixed upper/lower name and init_non_tcp_udp_dissector
2015-07-09 00:29:03 -07:00
Michele Campus 1dd0c912c7 fixed upper/lower name and init_non_tcp_udp_dissector 2015-07-09 00:00:27 +02:00
Michele Campus 824c5f82d3 Merge remote-tracking branch 'upstream/dev' into dev
Conflicts:
	src/include/ndpi_protocols.h
	src/lib/ndpi_main.c
	src/lib/protocols/afp.c
	src/lib/protocols/aimini.c
	src/lib/protocols/applejuice.c
	src/lib/protocols/armagetron.c
	src/lib/protocols/ayiya.c
	src/lib/protocols/battlefield.c
	src/lib/protocols/bgp.c
	src/lib/protocols/bittorrent.c
	src/lib/protocols/ciscovpn.c
	src/lib/protocols/citrix.c
	src/lib/protocols/corba.c
	src/lib/protocols/crossfire.c
	src/lib/protocols/dcerpc.c
	src/lib/protocols/dhcp.c
	src/lib/protocols/dhcpv6.c
	src/lib/protocols/directconnect.c
	src/lib/protocols/directdownloadlink.c
	src/lib/protocols/dns.c
	src/lib/protocols/dofus.c
	src/lib/protocols/dropbox.c
	src/lib/protocols/eaq.c
	src/lib/protocols/edonkey.c
	src/lib/protocols/fasttrack.c
	src/lib/protocols/fiesta.c
	src/lib/protocols/filetopia.c
	src/lib/protocols/florensia.c
	src/lib/protocols/ftp_control.c
	src/lib/protocols/ftp_data.c
	src/lib/protocols/gnutella.c
	src/lib/protocols/gtp.c
	src/lib/protocols/guildwars.c
	src/lib/protocols/h323.c
	src/lib/protocols/halflife2_and_mods.c
	src/lib/protocols/http.c
	src/lib/protocols/http_activesync.c
	src/lib/protocols/iax.c
	src/lib/protocols/icecast.c
	src/lib/protocols/imesh.c
	src/lib/protocols/ipp.c
	src/lib/protocols/irc.c
	src/lib/protocols/jabber.c
	src/lib/protocols/kakaotalk_voice.c
	src/lib/protocols/kerberos.c
	src/lib/protocols/kontiki.c
	src/lib/protocols/ldap.c
	src/lib/protocols/lotus_notes.c
	src/lib/protocols/mail_imap.c
	src/lib/protocols/mail_pop.c
	src/lib/protocols/mail_smtp.c
	src/lib/protocols/maplestory.c
	src/lib/protocols/mdns.c
	src/lib/protocols/meebo.c
	src/lib/protocols/megaco.c
	src/lib/protocols/mgcp.c
	src/lib/protocols/mms.c
	src/lib/protocols/mpegts.c
	src/lib/protocols/msn.c
	src/lib/protocols/mssql.c
	src/lib/protocols/mysql.c
	src/lib/protocols/netbios.c
	src/lib/protocols/netflow.c
	src/lib/protocols/nfs.c
	src/lib/protocols/noe.c
	src/lib/protocols/ntp.c
	src/lib/protocols/openft.c
	src/lib/protocols/openvpn.c
	src/lib/protocols/oracle.c
	src/lib/protocols/oscar.c
	src/lib/protocols/pando.c
	src/lib/protocols/pcanywhere.c
	src/lib/protocols/postgres.c
	src/lib/protocols/pplive.c
	src/lib/protocols/ppstream.c
	src/lib/protocols/pptp.c
	src/lib/protocols/qq.c
	src/lib/protocols/quake.c
	src/lib/protocols/quic.c
	src/lib/protocols/radius.c
	src/lib/protocols/rdp.c
	src/lib/protocols/redis_net.c
	src/lib/protocols/rsync.c
	src/lib/protocols/rtcp.c
	src/lib/protocols/rtmp.c
	src/lib/protocols/rtp.c
	src/lib/protocols/rtsp.c
	src/lib/protocols/sflow.c
	src/lib/protocols/shoutcast.c
	src/lib/protocols/sip.c
	src/lib/protocols/skinny.c
	src/lib/protocols/skype.c
	src/lib/protocols/smb.c
	src/lib/protocols/snmp.c
	src/lib/protocols/socrates.c
	src/lib/protocols/sopcast.c
	src/lib/protocols/soulseek.c
	src/lib/protocols/spotify.c
	src/lib/protocols/ssdp.c
	src/lib/protocols/ssh.c
	src/lib/protocols/ssl.c
	src/lib/protocols/stealthnet.c
	src/lib/protocols/steam.c
	src/lib/protocols/stun.c
	src/lib/protocols/syslog.c
	src/lib/protocols/tds.c
	src/lib/protocols/teamspeak.c
	src/lib/protocols/teamviewer.c
	src/lib/protocols/telegram.c
	src/lib/protocols/telnet.c
	src/lib/protocols/tftp.c
	src/lib/protocols/thunder.c
	src/lib/protocols/tor.c
	src/lib/protocols/tvants.c
	src/lib/protocols/tvuplayer.c
	src/lib/protocols/twitter.c
	src/lib/protocols/usenet.c
	src/lib/protocols/veohtv.c
	src/lib/protocols/vhua.c
	src/lib/protocols/viber.c
	src/lib/protocols/vmware.c
	src/lib/protocols/vnc.c
	src/lib/protocols/warcraft3.c
	src/lib/protocols/whoisdas.c
	src/lib/protocols/winmx.c
	src/lib/protocols/world_of_kung_fu.c
	src/lib/protocols/world_of_warcraft.c
	src/lib/protocols/xbox.c
	src/lib/protocols/xdmcp.c
	src/lib/protocols/yahoo.c
	src/lib/protocols/zattoo.c
	src/lib/protocols/zeromq.c
2015-07-08 22:21:10 +02:00
Luca 5266c726f2 Reworked protocol initialization. Work in progress (more cleanup is needed) 2015-07-08 11:58:55 -07:00
Michele Campus a4b22a612e adding init protocol (2) - removed host_match proto defaults 2015-07-08 12:50:46 +02:00
Michele Campus e222345c85 Merge remote-tracking branch 'upstream/dev' into dev 2015-07-08 10:21:00 +02:00
Michele Campus 2b30cc8f2c adding init protocol (1) 2015-07-07 21:12:49 +02:00
Luca dc1d7bf47f Introduced ndpi_protocol datatype to handle master+subprotocol
Reworked protocol/master_protocol
Added new API call to print protocol/master_protocol
      - ndpi_protocol2name()
2015-07-07 10:50:49 -04:00
Luca f5d6cd511e Added support for Snapchat
Reworked code to better handle host-based protocols
2015-07-05 19:21:12 +02:00
Luca 09c137b27a Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-07-01 18:36:54 +02:00
Luca 151f74d596 Reworked skype code 2015-07-01 18:36:33 +02:00
Luca Deri 2ac44376cb Moved to version 1.7.0 2015-07-01 18:14:37 +02:00
Luca 7f807b81fe Added support for subprotocols
Modified ndpiReaded to print subprotocols
2015-07-01 18:12:47 +02:00
Luca 60884f9047 Split former protocol into upper and lower protocol 2015-07-01 17:40:14 +02:00
Luca 49ea23530f Code cleanup for improving readability 2015-07-01 16:57:32 +02:00
Luca 07ebed7fae Removed commented code
Renamed ndpi_int_add_connection() with ndpi_set_detected_protocol()
2015-07-01 16:45:29 +02:00
Luca 857020c475 Added missing type that defaulted to int 2015-07-01 16:40:43 +02:00
Luca Deri 68af5c221d Merge pull request #53 from kYroL01/dev
deleted protocol_type (real-correlated)
2015-07-01 16:32:34 +02:00
Michele Campus 4089227863 no_real for mpegts.c 2015-06-29 17:09:05 +02:00
Michele Campus a968718b52 no_real for mpegts.c 2015-06-29 17:06:04 +02:00
Michele Campus 83d46d02d4 Merge pull request #1 from kYroL01/no_real
No real
2015-06-29 16:56:54 +02:00
Michele Campus 32cdefb7d7 deleted protocol type (real-correlated)_1 2015-06-29 16:33:29 +02:00
Michele Campus 8da7af7b7b deleted protocol type (real-correlated) 2015-06-29 16:24:51 +02:00
Luca 276a35d36d Added test results for mpeg pcap 2015-06-25 03:59:17 -07:00
Luca 7e28cc0981 Added MPEG TS protocol
Fixed possible decoding loop in RTCP dissector
Added test pcap for mpegts
2015-06-25 03:57:50 -07:00
Luca Deri 40292a737a Merge pull request #38 from jnicholls/dns-fix
Account for the skipping of the DNS RR CLASS field by progressing the…
2015-06-24 17:42:00 -07:00
Luca Deri 8d5dda9d33 Merge pull request #36 from kYroL01/dev
fix quic.c
2015-06-24 17:40:21 -07:00
Jarred Nicholls 1d9d0b89ab Account for the skipping of the DNS RR CLASS field by progressing the payload index forward by an extra 2 octets. Remove commented code. 2015-06-24 20:38:01 -04:00
Michele Campus dd834c0eeb fix quic.c 2015-06-24 21:39:25 +02:00
Michele Campus 1d698899f6 fix quic.c 2015-06-24 19:36:35 +02:00
Luca 9bb99ed01d Added acknowldgement section 2015-06-24 08:03:53 -07:00
Luca ce94b7e545 Added support for TIM services generated by tim.com.br and tim.it 2015-06-24 07:57:09 -07:00
Luca 53c0b81dad Reverted fix in quic.c as apparently it invalidates protocol detection
Added testing files for quickplay
2015-06-24 07:49:02 -07:00
Luca 2be84d4d64 Added support for QuickPlay streaming service used by companies like hooq.tv 2015-06-24 07:34:57 -07:00
Luca 806c1a48d5 Added fix for fixing a crash when some CLI combination options are used 2015-06-23 07:06:09 -07:00
Luca Deri 4f691de0b5 Merge pull request #32 from kYroL01/dev
fix quic.c and add libtoolize option to autogen.sh
2015-06-20 18:51:27 +02:00
Michele Campus 37912b6045 fix quic.c and add libtoolize option to autogen.sh 2015-06-20 18:35:04 +02:00
Luca Deri d04979402c Added further check 2015-06-19 15:59:46 +02:00
Luca Deri 8a2493c26a Fixed crash caused by IPv6 traffic and KakaoTalk 2015-06-19 11:39:38 +02:00
Luca b2816d72da Disabled debug messages 2015-06-18 16:31:58 +02:00
Luca 9d361ec772 HTTP response is now dissected so we can match mime types on responses 2015-06-18 16:24:03 +02:00
Luca Deri 5b62fa3464 Merge pull request #29 from commsquare/dev
Allow Host IP based subprotocols to be added in protos.txt
2015-06-18 15:52:24 +02:00
Luca Deri 92e813cca4 Merge pull request #30 from sparkon/dev
Adding more Twitch.tv support
2015-06-18 15:51:59 +02:00
Edoardo Dominici a7b7254ac0 Added Twitch ingestion servers and JustinTV CDN
[ Fixed newline ]
2015-06-17 15:17:45 +02:00
sparkon 23048378d8 Added Twitch ingestion servers and JustinTV CDN 2015-06-17 14:55:07 +02:00
george.vakras@gmail.com b16ff0a3dc Fix ip based protocol example in protos.txt 2015-06-17 14:14:19 +02:00
Luca Deri f97fe9a7b5 Added pcap for SSL regression 2015-06-16 18:34:43 +02:00
Luca Deri 85db524a35 Added fix for detecting SSL certificate decoding. The old code did not discard non-SSL packets thus incrementing a counter when not necessary and thus terminating SSL decoding too early. This causes some SSL certificates not to be properly dissected and thus handled. 2015-06-16 18:31:01 +02:00
Luca 031f1709f2 Test file for mpeg detection 2015-06-15 16:48:50 +02:00
george.vakras@gmail.com 7391fe0c5e Allow loading host IP based protocols from protos.txt 2015-06-15 09:50:13 +02:00
Luca Deri 984eca8a27 Added support for Twitch detection
Minor cosmetic fix in test tool
2015-06-15 00:47:39 +02:00
Luca Deri 8b321fda41 Added testing files for EAQ, KakaoTalk, Torcedor, Meu 2015-06-14 12:28:59 +02:00
Luca Deri 702a9d0867 Improved RTCP decoder
Added detection of KakaoTalk Voice and Chat
2015-06-14 12:21:29 +02:00
Luca Deri 20740e1b68 Added Meu service detection 2015-06-14 11:04:31 +02:00
Luca Deri c4adefe75b Added EAQ protocol support 2015-06-14 10:37:34 +02:00
Luca Deri 11fb7e1796 Added missing L in license 2015-06-12 11:02:44 +02:00
Lorenzo Mangani 12f89fff49 Typo fix in README 2015-06-07 16:25:39 +02:00
Luca Deri f3bb7fb9c2 Added misisng symbols
ndpi_get_proto_by_id
ndpi_get_protocol_id_master_proto
ndpi_guess_protocol_id
2015-06-07 08:36:32 +02:00
Luca 72b205f5c1 Fixed bug that caused configure to generate GIT version information containing spaces
Modified ndpiReader to include flow details in dumps (used for testing)
Rebuilt all test results to include flow details
2015-06-04 19:07:23 +02:00
Luca 4ce9dec54e Reworked the STUN plugin
Added support for WhatsApp Voice vs WhatsApp (chat, no voice)
2015-06-04 18:44:09 +02:00
Luca Deri a31b0a3354 Added AS198015 Skype Communications Sarl to the list of skype networks 2015-05-31 19:50:52 +02:00
Luca Deri 5f74263717 Updated readme
Moved to version 1.6.0
2015-05-31 19:13:44 +02:00
Luca Deri 22dc2dcb05 GIT commit count fix that should work on all platforms (RedHat/CentOS included) 2015-05-27 09:20:51 +02:00
Luca Deri ca4fc876f8 Merge pull request #14 from ntop/master
Added readme containing package prerequisites
2015-05-26 21:27:12 +02:00
Luca Deri 22d6e4f7c2 Merge pull request #11 from pr0gg3d/dev
Add check for pthread_setaffinity_np
2015-05-25 09:53:15 +02:00
Francesco Del Degan e7c0d41dd2 Add check for pthread_setaffinity_np 2015-05-25 09:37:14 +02:00
Luca Deri 4cded5dc98 Added autoreconf check 2015-05-23 07:20:14 +02:00
Luca Deri 3caf906c9a Fixes to catch missing GNU tools 2015-05-23 07:15:24 +02:00
Luca Deri 43bf9df219 Improved testing application
Removed warning from the quic dissector
Travis now runs regression tests
2015-05-22 09:03:01 +02:00
Luca Deri dcf9af732d Merge pull request #10 from backer-and/dev
Update quic.c
2015-05-22 08:52:23 +02:00
Andrea Buscarinu 55f45d4716 Update quic.c
Fix warnings and 0xC2 mask
2015-05-21 23:10:13 +02:00
Andrea Buscarinu 12ac63684b Merge pull request #1 from ntop/dev
Update from original
2015-05-21 21:31:14 +02:00
Luca Deri de03e1efe4 Modified GIT version format as shown ndpiReader -r 2015-05-21 19:33:35 +02:00
Luca Deri 9542227f2e Merge pull request #9 from lucagiove/dev
Introduced incremental versioning from git tag and -r option to ndpiReader to print revision
2015-05-21 19:09:29 +02:00
Luca Giovenzana b3b0ce7237 Update ndpiReader.c: added -r to print used nDPI version and release 2015-05-21 01:51:36 +02:00
Luca Giovenzana e792ed6890 Update ndpiReader.c: autoremoved trailing slash 2015-05-21 01:39:56 +02:00
Luca Giovenzana b519f76d54 Update configure.ac: introduced git tag for version, incremental number of commits and release
1.5.2-43-gb3a292d-dirty
^     ^  ^        ^
|     |  |        |
|     |  |        if there are uncommitted changes
|     |  SHA of HEAD
|     number of commits since last tag
last tag
2015-05-21 01:39:45 +02:00
Luca e4923a589c Fixed warning 2015-05-20 16:48:36 +02:00
Luca Deri 8f3b8ff4df Added fix to harden quic detection and limit it to port 80/443 UDP 2015-05-20 09:27:04 +02:00
Luca Deri fd338a90c2 Merge pull request #6 from backer-and/dev
Added QUIC protocol
2015-05-20 08:54:10 +02:00
Andrea Buscarinu 57926cc97d Update quic.c
Fix version mask and syntax errors
2015-05-20 04:10:29 +02:00
Luca Deri 993665726a Fixed bug that prevented (due to endianess) to properly match hosts
Added tests for skype detection
2015-05-19 12:30:44 +02:00
Luca Deri ad28d5ff7b Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-05-19 08:14:52 +02:00
Luca Deri c6d09df884 Skype test files 2015-05-19 08:14:33 +02:00
Andrea Buscarinu 31b43b19f7 Update quic.c
Removed ports
2015-05-19 02:41:48 +02:00
Andrea Buscarinu bbb7091a58 Update quic.c
Added more SEQ and CID controls.
2015-05-19 02:20:57 +02:00
Luca Deri 167c831212 Fixed compilation warnings 2015-05-18 18:29:22 +02:00
Luca Deri fc1efb56ee Merge branch 'dev' of https://github.com/ntop/nDPI into dev 2015-05-18 18:26:52 +02:00
Luca Deri c6e9ad4309 Removed warning 2015-05-18 18:25:32 +02:00
Andrea Buscarinu 77999ce733 Update ndpi_protocol_ids.h 2015-05-18 17:56:45 +02:00
Andrea Buscarinu fe4914e715 Update ndpi_main.c 2015-05-18 17:54:35 +02:00
Andrea Buscarinu 2f120eff37 Update quic.c 2015-05-18 17:50:01 +02:00
Andrea Buscarinu 7ad38d6c20 Update quic.c 2015-05-18 17:47:39 +02:00
Luca Deri 64121162dd Win32 fix 2015-05-18 16:17:23 +02:00
Luca Deri 079a42c752 Minor code cleanup 2015-05-18 16:09:57 +02:00
Luca Deri 66394ba05e File renamed to avoid name clashes 2015-05-18 15:26:16 +02:00
Luca Deri 68ac979dc5 Win32 fixes 2015-05-18 13:00:02 +02:00
Luca Deri b22d1d8e6a File rename to avoid name clashes
Cleaned up autogen.sh
2015-05-18 12:48:13 +02:00
Andrea Buscarinu a18a877669 Update ndpi_main.c 2015-05-15 02:53:11 +02:00
Andrea Buscarinu efedc5e498 Update ndpi_protocols.h 2015-05-15 02:52:34 +02:00
Andrea Buscarinu 2933358c17 Update pcapExample.vcxproj.filters 2015-05-15 02:52:28 +02:00
Andrea Buscarinu bd2a5b7c2f Update ndpi_protocol_ids.h 2015-05-15 02:52:21 +02:00
Andrea Buscarinu 7c69760d43 Update pcapExample.vcxproj 2015-05-15 02:52:06 +02:00
Andrea Buscarinu 97e939d70b Update Makefile.am 2015-05-15 02:52:00 +02:00
Andrea Buscarinu 3ecb11b152 Create quic.c 2015-05-15 02:51:39 +02:00
Luca Deri 199193fb86 Added ability to run automatic tests (initial version) 2015-05-14 00:47:50 +02:00
Luca Deri bcd8380704 Added improvement for handling bit-torrent search on UDP
Added quic protocol sample
2015-05-13 23:37:31 +02:00
Luca 08c8fe7411 Added BitTorrent search pcap file 2015-05-13 19:01:01 +02:00
Luca fd25b3b84f Directory that will contain files for regression testing of nDPI 2015-05-13 18:46:07 +02:00
Luca Deri 56247814c1 Extended .gitignore (courtesy of Vitaly Lavrov) 2015-05-06 23:06:06 +02:00
Luca 07fdba2d14 Added .gitignore file 2015-05-06 18:03:54 +02:00
Luca Deri d3c979aa57 Added readme containing package prerequisites 2015-05-05 11:35:55 +02:00
Luca Deri 177fbee2c7 Added file for travis build 2015-05-02 15:17:03 +02:00
Luca ac4e2e3006 Updated git version variable 2015-04-30 13:53:33 +02:00
Luca 38943b2048 Removed FaceBook Chat as Facebook is now using SSL making it no longer detectable 2015-04-30 11:08:45 +02:00
Luca Deri 4ffabffcbb Code cleanup 2015-04-20 11:20:51 +02:00
Luca Deri ceda2179e6 Modified README with better markup 2015-04-20 09:04:31 +02:00
Luca Deri e66b440d35 Changed version id since we moved to git 2015-04-19 22:33:49 +02:00
Luca Deri 62f665ea7f Typi=o 2015-04-19 08:41:33 +02:00
Luca Deri b3f14bee1c Updated format 2015-04-19 08:40:11 +02:00
Luca Deri 2e5ceac844 Initial import from SVN 2015-04-19 07:25:59 +02:00
Luca Deri 7fa4694dad first commit 2015-04-19 07:21:14 +02:00
310 changed files with 53361 additions and 400 deletions
+37
View File
@@ -0,0 +1,37 @@
*.[oa]
*~
*o.cmd
*.lo
*.obj
*o.cmd
*.ko
*.swp
*.in
*.la
.libs
.dirstamp
stamp-h1
/configure
/config.guess
/config.h
/config.h.in
/config.sub
/config.log
/config.status
/depcomp
/install-sh
/ltmain.sh
/missing
/Makefile
/libndpi.pc
/libtool
/src/lib/Makefile
/src/include/Makefile
/example/ndpiReader
/example/Makefile
/aclocal.m4
/m4/libtool.m4
/m4/ltoptions.m4
/m4/ltsugar.m4
/m4/ltversion.m4
/m4/lt~obsolete.m4
+22
View File
@@ -0,0 +1,22 @@
language: c
compiler:
- clang
- gcc
install:
- sudo apt-get update || true
- sudo apt-get install build-essential
- sudo apt-get install libpcap-dev libtool autoconf automake autogen
before_script:
- ./autogen.sh
script:
- ./configure
- make
after_script:
- cd tests
- ./do.sh
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
+16
View File
@@ -0,0 +1,16 @@
2014-03-21:
- improved support for eDonkey/eMule/Kademlia
- improved support for PPLive
2014-03-20:
- code optimizations
- consistency improvements
- added support for new applications: Pando Media Booster
- improved support for Steam
- added support for new web services: Wikipedia, MSN, Amazon, eBay, CNN
2014-03-19:
- added new protocols: FTP, code improvements
2014-03-17:
- added new protocols: SOCKSv4, SOCKSv5, RTMP
+365
View File
@@ -0,0 +1,365 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
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 warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
+8
View File
@@ -0,0 +1,8 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src/lib example
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libndpi.pc
EXTRA_DIST = libndpi.sym autogen.sh
+46
View File
@@ -0,0 +1,46 @@
![ntop][ntopng_logo] ![ntop][ntop_logo]
# nDPI
[![Build Status](https://travis-ci.org/ntop/nDPI.png?branch=dev)](https://travis-ci.org/ntop/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
### How To Compile nDPI
In order to compile this library do
- ./autogen.sh
- ./configure
- make
Please note that the pre-requisites for compilation include:
- GNU tools (autogen, automake, autoconf, libtool)
- GNU C compiler (gcc)
### How To Add A New Protocol Dissector
The entire procedure of adding new protocols in detail:
1. Add new protocol together with its unique ID to: src/include/ndpi_protocols_osdpi.h
2. Create a new protocol in: src/lib/protocols/
3. Variables to be kept for the duration of the entire flow (as state variables) needs to be placed in: /include/ndpi_structs.h in ndpi_flow_tcp_struct (for TCP only), ndpi_flow_udp_struct (for UDP only), or ndpi_flow_struct (for both).
4. Add a new entry for the search function for the new protocol in: src/include/ndpi_protocols.h
5. Choose (do not change anything) a selection bitmask from: src/include/ndpi_define.h
6. Add a new entry in ndpi_set_protocol_detection_bitmask2 in: src/lib/ndpi_main.c
7. Set protocol default ports in ndpi_init_protocol_defaults in: src/lib/ndpi_main.c
8. Add the new protocol file to: src/lib/Makefile.am
9. ./autogen.sh
10. ./configure
11. make
### Creating A Source File Tar Ball
If you want to distribute a source tar file of nDPI do:
- make dist
[ntopng_logo]: https://camo.githubusercontent.com/0f789abcef232035c05e0d2e82afa3cc3be46485/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031312f30382f6e746f706e672d69636f6e2d313530783135302e706e67
[ntop_logo]: https://camo.githubusercontent.com/58e2a1ecfff62d8ecc9d74633bd1013f26e06cba/687474703a2f2f7777772e6e746f702e6f72672f77702d636f6e74656e742f75706c6f6164732f323031352f30352f6e746f702e706e67
+20
View File
@@ -0,0 +1,20 @@
rerequisites for Compilation
-----------------------------
Prerequisites
- GNU autotools/libtool
- libpcap or PF_RING (optional but recommended)
On Ubuntu/Debian
- apt-get install build-essential
- apt-get install git autoconf automake autogen libpcap-dev libtool
On Fedora/CentOS
- yum groupinstall "Development tools"
- yum install git autoconf automake autogen libpcap-devel libtool
On MacOSX (using http://brew.sh)
brew install autoconf automake libtool git
On FreeBSD
- pkg install autoconf automake libtool gmake git
+18
View File
@@ -0,0 +1,18 @@
Tor
---
Tor protocol can use SSL to hide itself. These are examples:
TCP 37.128.208.46:9001 <-> 172.16.253.130:2078 [VLAN: 0][proto: 91/SSL][132 pkts/93834 bytes][SSL client: www.jwrpsthzrih.com]
TCP 172.16.253.130:2021 <-> 75.147.140.249:443 [VLAN: 0][proto: 91/SSL][28 pkts/8053 bytes][SSL client: www.5akw23dx.com]
TCP 172.16.253.130:2077 <-> 77.247.181.163:443 [VLAN: 0][proto: 91/SSL][136 pkts/94329 bytes][SSL client: www.fk4pprq42hsvl2wey.com]
It can be detected by analyzing the SSL client certificate and checking the name that does not match to a real host in
addition of being a bit weird. As doing DNS resolution is not a task for nDPI we let applications do and then recognize
SSL-tunnelled connections.
See http://www.netresec.com/?page=Blog&month=2013-04&post=Detecting-TOR-Communication-in-Network-Traffic
For this reason nDPI uses a heuristic, non-DNS based, approach to detect tor communications. If possible, apps
should validate the certificate using the DNS. This is not something nDPI can afford to do for performance
reasons
Executable
+33
View File
@@ -0,0 +1,33 @@
#!/bin/sh
/bin/rm -f configure config.h config.h.in src/lib/Makefile.in
AUTOCONF=$(which autoconf)
AUTOMAKE=$(which automake)
LIBTOOL=$(which libtool)
LIBTOOLIZE=$(which libtoolize)
AUTORECONF=$(which autoreconf)
if test -z $AUTOCONF; then
echo "autoconf is missing: please install it and try again"
exit
fi
if test -z $AUTOMAKE; then
echo "automake is missing: please install it and try again"
exit
fi
if test -z $LIBTOOL && test -z $LIBTOOLIZE ; then
echo "libtool and libtoolize is missing: please install it and try again"
exit
fi
if test -z $AUTORECONF; then
echo "autoreconf is missing: please install it and try again"
exit
fi
autoreconf -ivf
./configure $*
+99
View File
@@ -0,0 +1,99 @@
AC_INIT([libndpi], [1.8.0])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign subdir-objects])
LT_INIT
AC_PROG_CC
AX_PTHREAD
if test -d ".git"; then :
GIT_TAG=`git log -1 --format=%h`
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_BRANCH=`git rev-parse --abbrev-ref HEAD`
GIT_RELEASE="${PACKAGE_VERSION}-${GIT_BRANCH}-${GIT_NUM}-${GIT_TAG}"
else
GIT_RELEASE="${PACKAGE_VERSION}"
GIT_DATE=`date`
fi
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])
PCAP_HOME=$HOME/PF_RING/userland
if test -d $PCAP_HOME; then :
echo -n ""
else
PCAP_HOME=`pwd`/../../PF_RING/userland
fi
SHORT_MACHINE=`uname -m | cut -b1-3`
if test $SHORT_MACHINE = "arm"; then
LIBNUMA=""
else
LIBNUMA="-lnuma"
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"])
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
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]))
],
[])
])
OLD_LIBS=$LIBS
LIBS="-L/opt/napatech3/lib $LIBS"
AC_CHECK_LIB([ntapi],
[NT_Init],
[PCAP_LIB="$PCAP_LIB -L/opt/napatech3/lib -lntapi"],
[], [] )
LIBS=$OLD_LIBS
AC_CHECK_LIB(pthread, pthread_setaffinity_np, AC_DEFINE_UNQUOTED(HAVE_PTHREAD_SETAFFINITY_NP, 1, [libc has pthread_setaffinity_np]))
AC_CONFIG_FILES([Makefile src/lib/Makefile example/Makefile libndpi.pc])
AC_CONFIG_HEADERS(config.h)
AC_SUBST(GIT_RELEASE)
AC_SUBST(SVN_DATE)
AC_SUBST(JSON_C_LIB)
AC_SUBST(PCAP_INC)
AC_SUBST(PCAP_LIB)
AC_SUBST(HAVE_PTHREAD_SETAFFINITY_NP)
AC_OUTPUT
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
bin_PROGRAMS = ndpiReader
AM_CPPFLAGS = -I$(top_srcdir)/src/include @PCAP_INC@
AM_CFLAGS = @PTHREAD_CFLAGS@
LDADD = $(top_builddir)/src/lib/libndpi.la @JSON_C_LIB@ @PTHREAD_LIBS@ @PCAP_LIB@
AM_LDFLAGS = -static
ndpiReader_SOURCES = ndpiReader.c ndpi_util.c
ndpiReader.o: ndpiReader.c
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pcapExample", "pcapExample\pcapExample.vcxproj", "{F6A2C0AE-2110-438A-87E4-7C1CFCE064C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F6A2C0AE-2110-438A-87E4-7C1CFCE064C6}.Debug|Win32.ActiveCfg = Debug|Win32
{F6A2C0AE-2110-438A-87E4-7C1CFCE064C6}.Debug|Win32.Build.0 = Debug|Win32
{F6A2C0AE-2110-438A-87E4-7C1CFCE064C6}.Release|Win32.ActiveCfg = Release|Win32
{F6A2C0AE-2110-438A-87E4-7C1CFCE064C6}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
// pcapExample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
@@ -0,0 +1,231 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F6A2C0AE-2110-438A-87E4-7C1CFCE064C6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pcapExample</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\ntop\nprobe\nprobe-win-32;C:\ntop\winpcap\Include;C:\ntop\dependencies\nDPI\src\lib\third_party\include;C:\ntop\dependencies\nDPI\src\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Wsock32.lib;Ws2_32.lib;C:\ntop\winpcap\Lib\Packet.lib;C:\ntop\winpcap\Lib\wpcap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\..\nprobe\nprobe-win-32\getopt.c" />
<ClCompile Include="..\..\..\..\..\nprobe\nprobe-win-32\getopt1.c" />
<ClCompile Include="..\..\..\src\lib\ndpi_main.c" />
<ClCompile Include="..\..\..\src\lib\protocols\afp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\aimini.c" />
<ClCompile Include="..\..\..\src\lib\protocols\applejuice.c" />
<ClCompile Include="..\..\..\src\lib\protocols\armagetron.c" />
<ClCompile Include="..\..\..\src\lib\protocols\battlefield.c" />
<ClCompile Include="..\..\..\src\lib\protocols\bgp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\bittorrent.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ciscovpn.c" />
<ClCompile Include="..\..\..\src\lib\protocols\citrix.c" />
<ClCompile Include="..\..\..\src\lib\protocols\corba.c" />
<ClCompile Include="..\..\..\src\lib\protocols\crossfire.c" />
<ClCompile Include="..\..\..\src\lib\protocols\dcerpc.c" />
<ClCompile Include="..\..\..\src\lib\protocols\dhcp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\dhcpv6.c" />
<ClCompile Include="..\..\..\src\lib\protocols\directconnect.c" />
<ClCompile Include="..\..\..\src\lib\protocols\directdownloadlink.c" />
<ClCompile Include="..\..\..\src\lib\protocols\dns.c" />
<ClCompile Include="..\..\..\src\lib\protocols\dofus.c" />
<ClCompile Include="..\..\..\src\lib\protocols\dropbox.c" />
<ClCompile Include="..\..\..\src\lib\protocols\edonkey.c" />
<ClCompile Include="..\..\..\src\lib\protocols\fasttrack.c" />
<ClCompile Include="..\..\..\src\lib\protocols\feidian.c" />
<ClCompile Include="..\..\..\src\lib\protocols\fiesta.c" />
<ClCompile Include="..\..\..\src\lib\protocols\filetopia.c" />
<ClCompile Include="..\..\..\src\lib\protocols\flash.c" />
<ClCompile Include="..\..\..\src\lib\protocols\florensia.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ftp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\gadu_gadu.c" />
<ClCompile Include="..\..\..\src\lib\protocols\gnutella.c" />
<ClCompile Include="..\..\..\src\lib\protocols\gtp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\guildwars.c" />
<ClCompile Include="..\..\..\src\lib\protocols\h323.c" />
<ClCompile Include="..\..\..\src\lib\protocols\halflife2_and_mods.c" />
<ClCompile Include="..\..\..\src\lib\protocols\http.c" />
<ClCompile Include="..\..\..\src\lib\protocols\http_activesync.c" />
<ClCompile Include="..\..\..\src\lib\protocols\i23v5.c" />
<ClCompile Include="..\..\..\src\lib\protocols\iax.c" />
<ClCompile Include="..\..\..\src\lib\protocols\icecast.c" />
<ClCompile Include="..\..\..\src\lib\protocols\imesh.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ipp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\irc.c" />
<ClCompile Include="..\..\..\src\lib\protocols\jabber.c" />
<ClCompile Include="..\..\..\src\lib\protocols\kerberos.c" />
<ClCompile Include="..\..\..\src\lib\protocols\kontiki.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ldap.c" />
<ClCompile Include="..\..\..\src\lib\protocols\lotus_notes.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mail_imap.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mail_pop.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mail_smtp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\maplestory.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mdns.c" />
<ClCompile Include="..\..\..\src\lib\protocols\meebo.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mgcp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mms.c" />
<ClCompile Include="..\..\..\src\lib\protocols\msn.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mssql.c" />
<ClCompile Include="..\..\..\src\lib\protocols\mysql.c" />
<ClCompile Include="..\..\..\src\lib\protocols\netbios.c" />
<ClCompile Include="..\..\..\src\lib\protocols\netflow.c" />
<ClCompile Include="..\..\..\src\lib\protocols\nfs.c" />
<ClCompile Include="..\..\..\src\lib\protocols\noe.c" />
<ClCompile Include="..\..\..\src\lib\protocols\non_tcp_udp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ntp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\openft.c" />
<ClCompile Include="..\..\..\src\lib\protocols\openvpn.c" />
<ClCompile Include="..\..\..\src\lib\protocols\oracle.c" />
<ClCompile Include="..\..\..\src\lib\protocols\oscar.c" />
<ClCompile Include="..\..\..\src\lib\protocols\pando.c" />
<ClCompile Include="..\..\..\src\lib\protocols\pcanywhere.c" />
<ClCompile Include="..\..\..\src\lib\protocols\popo.c" />
<ClCompile Include="..\..\..\src\lib\protocols\postgres.c" />
<ClCompile Include="..\..\..\src\lib\protocols\pplive.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ppstream.c" />
<ClCompile Include="..\..\..\src\lib\protocols\pptp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\qq.c" />
<ClCompile Include="..\..\..\src\lib\protocols\quake.c" />
<ClCompile Include="..\..\..\src\lib\protocols\quic.c" />
<ClCompile Include="..\..\..\src\lib\protocols\radius.c" />
<ClCompile Include="..\..\..\src\lib\protocols\rdp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\rsync.c" />
<ClCompile Include="..\..\..\src\lib\protocols\rtcp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\rtp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\rtsp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\sflow.c" />
<ClCompile Include="..\..\..\src\lib\protocols\shoutcast.c" />
<ClCompile Include="..\..\..\src\lib\protocols\sip.c" />
<ClCompile Include="..\..\..\src\lib\protocols\skinny.c" />
<ClCompile Include="..\..\..\src\lib\protocols\skype.c" />
<ClCompile Include="..\..\..\src\lib\protocols\smb.c" />
<ClCompile Include="..\..\..\src\lib\protocols\snmp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\socrates.c" />
<ClCompile Include="..\..\..\src\lib\protocols\sopcast.c" />
<ClCompile Include="..\..\..\src\lib\protocols\soulseek.c" />
<ClCompile Include="..\..\..\src\lib\protocols\spotify.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ssdp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ssh.c" />
<ClCompile Include="..\..\..\src\lib\protocols\ssl.c" />
<ClCompile Include="..\..\..\src\lib\protocols\stealthnet.c" />
<ClCompile Include="..\..\..\src\lib\protocols\steam.c" />
<ClCompile Include="..\..\..\src\lib\protocols\stun.c" />
<ClCompile Include="..\..\..\src\lib\protocols\syslog.c" />
<ClCompile Include="..\..\..\src\lib\protocols\tcp_udp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\tds.c" />
<ClCompile Include="..\..\..\src\lib\protocols\teamspeak.c" />
<ClCompile Include="..\..\..\src\lib\protocols\teamviewer.c" />
<ClCompile Include="..\..\..\src\lib\protocols\telnet.c" />
<ClCompile Include="..\..\..\src\lib\protocols\tftp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\thunder.c" />
<ClCompile Include="..\..\..\src\lib\protocols\tor.c" />
<ClCompile Include="..\..\..\src\lib\protocols\tvants.c" />
<ClCompile Include="..\..\..\src\lib\protocols\tvuplayer.c" />
<ClCompile Include="..\..\..\src\lib\protocols\usenet.c" />
<ClCompile Include="..\..\..\src\lib\protocols\veohtv.c" />
<ClCompile Include="..\..\..\src\lib\protocols\viber.c" />
<ClCompile Include="..\..\..\src\lib\protocols\vmware.c" />
<ClCompile Include="..\..\..\src\lib\protocols\vnc.c" />
<ClCompile Include="..\..\..\src\lib\protocols\warcraft3.c" />
<ClCompile Include="..\..\..\src\lib\protocols\winmx.c" />
<ClCompile Include="..\..\..\src\lib\protocols\world_of_kung_fu.c" />
<ClCompile Include="..\..\..\src\lib\protocols\world_of_warcraft.c" />
<ClCompile Include="..\..\..\src\lib\protocols\xbox.c" />
<ClCompile Include="..\..\..\src\lib\protocols\xdmcp.c" />
<ClCompile Include="..\..\..\src\lib\protocols\yahoo.c" />
<ClCompile Include="..\..\..\src\lib\protocols\zattoo.c" />
<ClCompile Include="..\..\..\src\lib\third_party\src\ahocorasick.c" />
<ClCompile Include="..\..\..\src\lib\third_party\src\node.c" />
<ClCompile Include="..\..\..\src\lib\third_party\src\sort.c" />
<ClCompile Include="..\..\pcapReader.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\..\nprobe\nprobe-win-32\getopt.h" />
<ClInclude Include="..\..\..\src\include\linux_compat.h" />
<ClInclude Include="..\..\..\src\include\ndpi_api.h" />
<ClInclude Include="..\..\..\src\include\ndpi_debug_functions.h" />
<ClInclude Include="..\..\..\src\include\ndpi_define.h" />
<ClInclude Include="..\..\..\src\include\ndpi_macros.h" />
<ClInclude Include="..\..\..\src\include\ndpi_main.h" />
<ClInclude Include="..\..\..\src\include\ndpi_protocols.h" />
<ClInclude Include="..\..\..\src\include\ndpi_protocols_osdpi.h" />
<ClInclude Include="..\..\..\src\include\ndpi_protocol_history.h" />
<ClInclude Include="..\..\..\src\include\ndpi_public_functions.h" />
<ClInclude Include="..\..\..\src\include\ndpi_structs.h" />
<ClInclude Include="..\..\..\src\include\ndpi_utils.h" />
<ClInclude Include="..\..\..\src\lib\third_party\include\actypes.h" />
<ClInclude Include="..\..\..\src\lib\third_party\include\ahocorasick.h" />
<ClInclude Include="..\..\..\src\lib\third_party\include\node.h" />
<ClInclude Include="..\..\..\src\lib\third_party\include\sort.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,465 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\pcapReader.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\ndpi_main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\zattoo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\afp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\aimini.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\applejuice.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\armagetron.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\battlefield.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\bgp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\bittorrent.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ciscovpn.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\citrix.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\corba.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\crossfire.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\dcerpc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\dhcp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\dhcpv6.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\directconnect.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\directdownloadlink.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\dns.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\dofus.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\dropbox.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\edonkey.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\fasttrack.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\feidian.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\fiesta.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\filetopia.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\flash.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\florensia.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ftp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\gadu_gadu.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\gnutella.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\gtp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\guildwars.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\h323.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\halflife2_and_mods.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\http.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\http_activesync.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\i23v5.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\iax.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\icecast.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\imesh.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ipp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\irc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\jabber.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\kerberos.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\kontiki.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ldap.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\lotus_notes.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mail_imap.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mail_pop.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mail_smtp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\maplestory.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mdns.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\meebo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mgcp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mms.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\msn.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mssql.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\mysql.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\netbios.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\netflow.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\nfs.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\noe.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\non_tcp_udp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ntp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\openft.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\openvpn.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\oracle.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\oscar.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\pando.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\pcanywhere.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\popo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\postgres.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\pplive.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ppstream.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\pptp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\qq.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\quake.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\quic.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\radius.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\rdp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\rsync.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\rtcp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\rtp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\rtsp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\sflow.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\shoutcast.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\sip.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\skinny.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\skype.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\smb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\snmp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\socrates.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\sopcast.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\soulseek.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\spotify.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ssdp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ssh.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\ssl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\stealthnet.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\steam.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\stun.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\syslog.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\tcp_udp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\tds.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\teamspeak.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\teamviewer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\telnet.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\tftp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\thunder.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\tor.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\tvants.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\tvuplayer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\usenet.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\veohtv.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\viber.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\vmware.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\vnc.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\warcraft3.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\winmx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\world_of_kung_fu.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\world_of_warcraft.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\xbox.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\xdmcp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\protocols\yahoo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\third_party\src\ahocorasick.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\third_party\src\node.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\lib\third_party\src\sort.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\..\nprobe\nprobe-win-32\getopt.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\..\nprobe\nprobe-win-32\getopt1.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\lib\third_party\include\actypes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\lib\third_party\include\ahocorasick.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\lib\third_party\include\node.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\lib\third_party\include\sort.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_api.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_debug_functions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_define.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_macros.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_main.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_protocol_history.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_protocols.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_protocols_osdpi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_public_functions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_structs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\ndpi_utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\include\linux_compat.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\..\nprobe\nprobe-win-32\getopt.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
+1381
View File
File diff suppressed because it is too large Load Diff
+847
View File
@@ -0,0 +1,847 @@
/*
* ndpi_util.c
*
* 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/>.
*
*/
#include <stdlib.h>
#ifdef WIN32
#include <winsock2.h> /* winsock.h is included automatically */
#include <process.h>
#include <io.h>
#else
#include <unistd.h>
#include <netinet/in.h>
#endif
#ifndef ETH_P_IP
#define ETH_P_IP 0x0800 /* IPv4 */
#endif
#ifndef ETH_P_IPv6
#define ETH_P_IPV6 0x86dd /* IPv6 */
#endif
#define SLARP 0x8035 /* Cisco Slarp */
#define CISCO_D_PROTO 0x2000 /* Cisco Discovery Protocol */
#define VLAN 0x8100
#define MPLS_UNI 0x8847
#define MPLS_MULTI 0x8848
#define PPPoE 0x8864
#define SNAP 0xaa
/* mask for FCF */
#define WIFI_DATA 0x2 /* 0000 0010 */
#define FCF_TYPE(fc) (((fc) >> 2) & 0x3) /* 0000 0011 = 0x3 */
#define FCF_SUBTYPE(fc) (((fc) >> 4) & 0xF) /* 0000 1111 = 0xF */
#define FCF_TO_DS(fc) ((fc) & 0x0100)
#define FCF_FROM_DS(fc) ((fc) & 0x0200)
/* mask for Bad FCF presence */
#define BAD_FCS 0x50 /* 0101 0000 */
#define GTP_U_V1_PORT 2152
#define TZSP_PORT 37008
#define SIZEOF_ID_STRUCT (sizeof(struct ndpi_id_struct))
#define SIZEOF_FLOW_STRUCT (sizeof(struct ndpi_flow_struct))
#include "ndpi_main.h"
#include "ndpi_util.h"
/* ***************************************************** */
void ndpi_free_flow_info_half(struct ndpi_flow_info *flow) {
if(flow->ndpi_flow) { ndpi_free_flow(flow->ndpi_flow); flow->ndpi_flow = NULL; }
if(flow->src_id) { ndpi_free(flow->src_id); flow->src_id = NULL; }
if(flow->dst_id) { ndpi_free(flow->dst_id); flow->dst_id = NULL; }
}
/* ***************************************************** */
static const u_int8_t nDPI_traceLevel = 0;
/* ***************************************************** */
extern u_int32_t current_ndpi_memory, max_ndpi_memory;
/**
* @brief malloc wrapper function
*/
static void *malloc_wrapper(size_t size) {
current_ndpi_memory += size;
if(current_ndpi_memory > max_ndpi_memory)
max_ndpi_memory = current_ndpi_memory;
return malloc(size);
}
/* ***************************************************** */
/**
* @brief free wrapper function
*/
static void free_wrapper(void *freeable) {
free(freeable);
}
/* ***************************************************** */
struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle) {
set_ndpi_malloc(malloc_wrapper), set_ndpi_free(free_wrapper);
/* TODO: just needed here to init ndpi malloc wrapper */
struct ndpi_detection_module_struct * module = ndpi_init_detection_module();
struct ndpi_workflow * workflow = ndpi_calloc(1, sizeof(struct ndpi_workflow));
workflow->pcap_handle = pcap_handle;
workflow->prefs = *prefs;
workflow->ndpi_struct = module;
if(workflow->ndpi_struct == NULL) {
NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
exit(-1);
}
workflow->ndpi_flows_root = ndpi_calloc(workflow->prefs.num_roots, sizeof(void *));
return workflow;
}
/* ***************************************************** */
static void ndpi_flow_info_freer(void *node) {
struct ndpi_flow_info *flow = (struct ndpi_flow_info*)node;
ndpi_free_flow_info_half(flow);
ndpi_free(flow);
}
/* ***************************************************** */
void ndpi_workflow_free(struct ndpi_workflow * workflow) {
int i;
for(i=0; i<workflow->prefs.num_roots; i++)
ndpi_tdestroy(workflow->ndpi_flows_root[i], ndpi_flow_info_freer);
ndpi_exit_detection_module(workflow->ndpi_struct);
free(workflow->ndpi_flows_root);
free(workflow);
}
/* ***************************************************** */
int ndpi_workflow_node_cmp(const void *a, const void *b) {
struct ndpi_flow_info *fa = (struct ndpi_flow_info*)a;
struct ndpi_flow_info *fb = (struct ndpi_flow_info*)b;
if(fa->vlan_id < fb->vlan_id ) return(-1); else { if(fa->vlan_id > fb->vlan_id ) return(1); }
if(fa->lower_ip < fb->lower_ip ) return(-1); else { if(fa->lower_ip > fb->lower_ip ) return(1); }
if(fa->lower_port < fb->lower_port) return(-1); else { if(fa->lower_port > fb->lower_port) return(1); }
if(fa->upper_ip < fb->upper_ip ) return(-1); else { if(fa->upper_ip > fb->upper_ip ) return(1); }
if(fa->upper_port < fb->upper_port) return(-1); else { if(fa->upper_port > fb->upper_port) return(1); }
if(fa->protocol < fb->protocol ) return(-1); else { if(fa->protocol > fb->protocol ) return(1); }
return(0);
}
/* ***************************************************** */
static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow,
const u_int8_t version,
u_int16_t vlan_id,
const struct ndpi_iphdr *iph,
const struct ndpi_ipv6hdr *iph6,
u_int16_t ip_offset,
u_int16_t ipsize,
u_int16_t l4_packet_len,
struct ndpi_tcphdr **tcph,
struct ndpi_udphdr **udph,
u_int16_t *sport, u_int16_t *dport,
struct ndpi_id_struct **src,
struct ndpi_id_struct **dst,
u_int8_t *proto,
u_int8_t **payload,
u_int16_t *payload_len,
u_int8_t *src_to_dst_direction) {
u_int32_t idx, l4_offset;
u_int32_t lower_ip;
u_int32_t upper_ip;
u_int16_t lower_port;
u_int16_t upper_port;
struct ndpi_flow_info flow;
void *ret;
u_int8_t *l3, *l4;
/*
Note: to keep things simple (ndpiReader is just a demo app)
we handle IPv6 a-la-IPv4.
*/
if(version == 4) {
if(ipsize < 20)
return NULL;
if((iph->ihl * 4) > ipsize || ipsize < ntohs(iph->tot_len)
|| (iph->frag_off & htons(0x1FFF)) != 0)
return NULL;
l4_offset = iph->ihl * 4;
l3 = (u_int8_t*)iph;
} else {
l4_offset = sizeof(struct ndpi_ipv6hdr);
l3 = (u_int8_t*)iph6;
}
if(l4_packet_len < 64)
workflow->stats.packet_len[0]++;
else if(l4_packet_len >= 64 && l4_packet_len < 128)
workflow->stats.packet_len[1]++;
else if(l4_packet_len >= 128 && l4_packet_len < 256)
workflow->stats.packet_len[2]++;
else if(l4_packet_len >= 256 && l4_packet_len < 1024)
workflow->stats.packet_len[3]++;
else if(l4_packet_len >= 1024 && l4_packet_len < 1500)
workflow->stats.packet_len[4]++;
else if(l4_packet_len >= 1500)
workflow->stats.packet_len[5]++;
if(l4_packet_len > workflow->stats.max_packet_len)
workflow->stats.max_packet_len = l4_packet_len;
if(iph->saddr < iph->daddr) {
lower_ip = iph->saddr;
upper_ip = iph->daddr;
} else {
lower_ip = iph->daddr;
upper_ip = iph->saddr;
}
*proto = iph->protocol;
l4 = ((u_int8_t *) l3 + l4_offset);
if(iph->protocol == 6 && l4_packet_len >= 20) {
u_int tcp_len;
workflow->stats.tcp_count++;
// tcp
*tcph = (struct ndpi_tcphdr *)l4;
*sport = ntohs((*tcph)->source), *dport = ntohs((*tcph)->dest);
if(iph->saddr < iph->daddr) {
lower_port = (*tcph)->source, upper_port = (*tcph)->dest;
*src_to_dst_direction = 1;
} else {
lower_port = (*tcph)->dest;
upper_port = (*tcph)->source;
*src_to_dst_direction = 0;
if(iph->saddr == iph->daddr) {
if(lower_port > upper_port) {
u_int16_t p = lower_port;
lower_port = upper_port;
upper_port = p;
}
}
}
tcp_len = ndpi_min(4*(*tcph)->doff, l4_packet_len);
*payload = &l4[tcp_len];
*payload_len = ndpi_max(0, l4_packet_len-4*(*tcph)->doff);
} else if(iph->protocol == 17 && l4_packet_len >= 8) {
// udp
workflow->stats.udp_count++;
*udph = (struct ndpi_udphdr *)l4;
*sport = ntohs((*udph)->source), *dport = ntohs((*udph)->dest);
*payload = &l4[sizeof(struct ndpi_udphdr)];
*payload_len = ndpi_max(0, l4_packet_len-sizeof(struct ndpi_udphdr));
if(iph->saddr < iph->daddr) {
lower_port = (*udph)->source, upper_port = (*udph)->dest;
*src_to_dst_direction = 1;
} else {
lower_port = (*udph)->dest, upper_port = (*udph)->source;
*src_to_dst_direction = 0;
if(iph->saddr == iph->daddr) {
if(lower_port > upper_port) {
u_int16_t p = lower_port;
lower_port = upper_port;
upper_port = p;
}
}
}
*sport = ntohs(lower_port), *dport = ntohs(upper_port);
} else {
// non tcp/udp protocols
lower_port = 0;
upper_port = 0;
}
flow.protocol = iph->protocol, flow.vlan_id = vlan_id;
flow.lower_ip = lower_ip, flow.upper_ip = upper_ip;
flow.lower_port = lower_port, flow.upper_port = upper_port;
if(0)
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "[NDPI] [%u][%u:%u <-> %u:%u]\n",
iph->protocol, lower_ip, ntohs(lower_port), upper_ip, ntohs(upper_port));
idx = (vlan_id + lower_ip + upper_ip + iph->protocol + lower_port + upper_port) % workflow->prefs.num_roots;
ret = ndpi_tfind(&flow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp);
if(ret == NULL) {
if(workflow->stats.ndpi_flow_count == workflow->prefs.max_ndpi_flows) {
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "maximum flow count (%u) has been exceeded\n", workflow->prefs.max_ndpi_flows);
exit(-1);
} else {
struct ndpi_flow_info *newflow = (struct ndpi_flow_info*)malloc(sizeof(struct ndpi_flow_info));
if(newflow == NULL) {
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(1): not enough memory\n", __FUNCTION__);
return(NULL);
}
memset(newflow, 0, sizeof(struct ndpi_flow_info));
newflow->protocol = iph->protocol, newflow->vlan_id = vlan_id;
newflow->lower_ip = lower_ip, newflow->upper_ip = upper_ip;
newflow->lower_port = lower_port, newflow->upper_port = upper_port;
newflow->ip_version = version;
if(version == 4) {
inet_ntop(AF_INET, &lower_ip, newflow->lower_name, sizeof(newflow->lower_name));
inet_ntop(AF_INET, &upper_ip, newflow->upper_name, sizeof(newflow->upper_name));
} else {
inet_ntop(AF_INET6, &iph6->ip6_src, newflow->lower_name, sizeof(newflow->lower_name));
inet_ntop(AF_INET6, &iph6->ip6_dst, newflow->upper_name, sizeof(newflow->upper_name));
}
if((newflow->ndpi_flow = ndpi_malloc(SIZEOF_FLOW_STRUCT)) == NULL) {
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(2): not enough memory\n", __FUNCTION__);
free(newflow);
return(NULL);
} else
memset(newflow->ndpi_flow, 0, SIZEOF_FLOW_STRUCT);
if((newflow->src_id = ndpi_malloc(SIZEOF_ID_STRUCT)) == NULL) {
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(3): not enough memory\n", __FUNCTION__);
free(newflow);
return(NULL);
} else
memset(newflow->src_id, 0, SIZEOF_ID_STRUCT);
if((newflow->dst_id = ndpi_malloc(SIZEOF_ID_STRUCT)) == NULL) {
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_ERROR, "[NDPI] %s(4): not enough memory\n", __FUNCTION__);
free(newflow);
return(NULL);
} else
memset(newflow->dst_id, 0, SIZEOF_ID_STRUCT);
ndpi_tsearch(newflow, &workflow->ndpi_flows_root[idx], ndpi_workflow_node_cmp); /* Add */
workflow->stats.ndpi_flow_count++;
*src = newflow->src_id, *dst = newflow->dst_id;
return newflow;
}
} else {
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)ret;
if(flow->lower_ip == lower_ip && flow->upper_ip == upper_ip
&& flow->lower_port == lower_port && flow->upper_port == upper_port)
*src = flow->src_id, *dst = flow->dst_id;
else
*src = flow->dst_id, *dst = flow->src_id;
return flow;
}
}
/* ****************************************************** */
static struct ndpi_flow_info *get_ndpi_flow_info6(struct ndpi_workflow * workflow,
u_int16_t vlan_id,
const struct ndpi_ipv6hdr *iph6,
u_int16_t ip_offset,
struct ndpi_tcphdr **tcph,
struct ndpi_udphdr **udph,
u_int16_t *sport, u_int16_t *dport,
struct ndpi_id_struct **src,
struct ndpi_id_struct **dst,
u_int8_t *proto,
u_int8_t **payload,
u_int16_t *payload_len,
u_int8_t *src_to_dst_direction) {
struct ndpi_iphdr iph;
memset(&iph, 0, sizeof(iph));
iph.version = 4;
iph.saddr = iph6->ip6_src.u6_addr.u6_addr32[2] + iph6->ip6_src.u6_addr.u6_addr32[3];
iph.daddr = iph6->ip6_dst.u6_addr.u6_addr32[2] + iph6->ip6_dst.u6_addr.u6_addr32[3];
iph.protocol = iph6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
if(iph.protocol == 0x3C /* IPv6 destination option */) {
u_int8_t *options = (u_int8_t*)iph6 + sizeof(const struct ndpi_ipv6hdr);
iph.protocol = options[0];
}
return(get_ndpi_flow_info(workflow, 6, vlan_id, &iph, iph6, ip_offset,
sizeof(struct ndpi_ipv6hdr),
ntohs(iph6->ip6_ctlun.ip6_un1.ip6_un1_plen),
tcph, udph, sport, dport,
src, dst, proto, payload, payload_len, src_to_dst_direction));
}
/* ****************************************************** */
// ipsize = header->len - ip_offset ; rawsize = header->len
static unsigned int packet_processing(struct ndpi_workflow * workflow,
const u_int64_t time,
u_int16_t vlan_id,
const struct ndpi_iphdr *iph,
struct ndpi_ipv6hdr *iph6,
u_int16_t ip_offset,
u_int16_t ipsize, u_int16_t rawsize) {
struct ndpi_id_struct *src, *dst;
struct ndpi_flow_info *flow;
struct ndpi_flow_struct *ndpi_flow = NULL;
u_int8_t proto;
struct ndpi_tcphdr *tcph = NULL;
struct ndpi_udphdr *udph = NULL;
u_int16_t sport, dport, payload_len;
u_int8_t *payload;
u_int8_t src_to_dst_direction= 1;
if(iph)
flow = get_ndpi_flow_info(workflow, 4, vlan_id, iph, NULL,
ip_offset, ipsize,
ntohs(iph->tot_len) - (iph->ihl * 4),
&tcph, &udph, &sport, &dport,
&src, &dst, &proto,
&payload, &payload_len, &src_to_dst_direction);
else
flow = get_ndpi_flow_info6(workflow, vlan_id, iph6, ip_offset,
&tcph, &udph, &sport, &dport,
&src, &dst, &proto,
&payload, &payload_len, &src_to_dst_direction);
if(flow != NULL) {
workflow->stats.ip_packet_count++;
workflow->stats.total_wire_bytes += rawsize + 24 /* CRC etc */, workflow->stats.total_ip_bytes += rawsize;
ndpi_flow = flow->ndpi_flow;
flow->packets++, flow->bytes += rawsize;
flow->last_seen = time;
} else {
return(0);
}
/* Protocol already detected */
if(flow->detection_completed) return(0);
flow->detected_protocol = ndpi_detection_process_packet(workflow->ndpi_struct, ndpi_flow,
iph ? (uint8_t *)iph : (uint8_t *)iph6,
ipsize, time, src, dst);
if((flow->detected_protocol.protocol != NDPI_PROTOCOL_UNKNOWN)
|| ((proto == IPPROTO_UDP) && (flow->packets > 8))
|| ((proto == IPPROTO_TCP) && (flow->packets > 10))) {
/* New protocol detected or give up */
flow->detection_completed = 1;
if((flow->detected_protocol.protocol == NDPI_PROTOCOL_UNKNOWN) && (ndpi_flow->num_stun_udp_pkts > 0))
ndpi_set_detected_protocol(workflow->ndpi_struct, ndpi_flow, NDPI_PROTOCOL_STUN, NDPI_PROTOCOL_UNKNOWN);
snprintf(flow->host_server_name, sizeof(flow->host_server_name), "%s", flow->ndpi_flow->host_server_name);
if(flow->detected_protocol.protocol == NDPI_PROTOCOL_BITTORRENT) {
int i, j, n = 0;
for(i=0, j = 0; i<20; i++) {
sprintf(&flow->bittorent_hash[j], "%02x", flow->ndpi_flow->bittorent_hash[i]);
j += 2, n += flow->ndpi_flow->bittorent_hash[i];
}
if(n == 0) flow->bittorent_hash[0] = '\0';
}
if((proto == IPPROTO_TCP) && (flow->detected_protocol.protocol != NDPI_PROTOCOL_DNS)) {
snprintf(flow->ssl.client_certificate, sizeof(flow->ssl.client_certificate), "%s", flow->ndpi_flow->protos.ssl.client_certificate);
snprintf(flow->ssl.server_certificate, sizeof(flow->ssl.server_certificate), "%s", flow->ndpi_flow->protos.ssl.server_certificate);
}
if(flow->detected_protocol.protocol == NDPI_PROTOCOL_UNKNOWN) {
flow->detected_protocol = ndpi_detection_giveup(workflow->ndpi_struct, flow->ndpi_flow);
if (workflow->__flow_giveup_callback != NULL)
workflow->__flow_giveup_callback(workflow, flow, workflow->__flow_giveup_udata);
} else {
if (workflow->__flow_detected_callback != NULL)
workflow->__flow_detected_callback(workflow, flow, workflow->__flow_detected_udata);
}
ndpi_free_flow_info_half(flow);
}
return 0;
}
/* ****************************************************** */
void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
const struct pcap_pkthdr *header,
const u_char *packet) {
/*
* Declare pointers to packet headers
*/
/* --- Ethernet header --- */
const struct ndpi_ethhdr *ethernet;
/* --- Ethernet II header --- */
const struct ndpi_ethhdr *ethernet_2;
/* --- LLC header --- */
const struct ndpi_llc_header *llc;
/* --- Cisco HDLC header --- */
const struct ndpi_chdlc *chdlc;
/* --- SLARP frame --- */
struct ndpi_slarp *slarp;
/* --- CDP --- */
struct ndpi_cdp *cdp;
/* --- Radio Tap header --- */
const struct ndpi_radiotap_header *radiotap;
/* --- Wifi header --- */
const struct ndpi_wifi_header *wifi;
/* --- MPLS header --- */
struct ndpi_mpls_header *mpls;
/** --- IP header --- **/
struct ndpi_iphdr *iph;
/** --- IPv6 header --- **/
struct ndpi_ipv6hdr *iph6;
/* lengths and offsets */
u_int16_t eth_offset = 0;
u_int16_t radio_len;
u_int16_t fc;
u_int16_t type;
int wifi_len = 0;
int llc_off;
int pyld_eth_len = 0;
int check;
u_int64_t time;
u_int16_t ip_offset, ip_len, ip6_offset;
u_int16_t frag_off = 0, vlan_id = 0;
u_int8_t proto = 0;
u_int32_t label;
/* counters */
u_int8_t vlan_packet = 0;
/* Increment raw packet counter */
workflow->stats.raw_packet_count++;
/* setting time */
time = ((uint64_t) header->ts.tv_sec) * TICK_RESOLUTION + header->ts.tv_usec / (1000000 / TICK_RESOLUTION);
/* safety check */
if(workflow->last_time > time) {
/* printf("\nWARNING: timestamp bug in the pcap file (ts delta: %llu, repairing)\n", ndpi_thread_info[thread_id].last_time - time); */
time = workflow->last_time;
}
/* update last time value */
workflow->last_time = time;
/*** check Data Link type ***/
const int datalink_type = pcap_datalink(workflow->pcap_handle);
datalink_check:
switch(datalink_type) {
case DLT_NULL :
if(ntohl(*((u_int32_t*)&packet[eth_offset])) == 2)
type = ETH_P_IP;
else
type = ETH_P_IPV6;
ip_offset = 4 + eth_offset;
break;
/* Cisco PPP in HDLC-like framing - 50 */
case DLT_PPP_SERIAL:
chdlc = (struct ndpi_chdlc *) &packet[eth_offset];
ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */
type = ntohs(chdlc->proto_code);
break;
/* Cisco PPP with HDLC framing - 104 */
case DLT_C_HDLC:
chdlc = (struct ndpi_chdlc *) &packet[eth_offset];
ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */
type = ntohs(chdlc->proto_code);
break;
/* IEEE 802.3 Ethernet - 1 */
case DLT_EN10MB :
ethernet = (struct ndpi_ethhdr *) &packet[eth_offset];
ip_offset = sizeof(struct ndpi_ethhdr) + eth_offset;
check = ntohs(ethernet->h_proto);
if(check <= 1500)
pyld_eth_len = check;
else if (check >= 1536)
type = check;
if(pyld_eth_len != 0) {
/* check for LLC layer with SNAP extension */
if(packet[ip_offset] == SNAP) {
llc = (struct ndpi_llc_header *)(&packet[ip_offset]);
type = llc->snap.proto_ID;
ip_offset += + 8;
}
}
break;
/* Linux Cooked Capture - 113 */
case DLT_LINUX_SLL :
type = (packet[eth_offset+14] << 8) + packet[eth_offset+15];
ip_offset = 16 + eth_offset;
break;
/* Radiotap link-layer - 127 */
case DLT_IEEE802_11_RADIO :
radiotap = (struct ndpi_radiotap_header *) &packet[eth_offset];
radio_len = radiotap->len;
/* Check Bad FCS presence */
if((radiotap->flags & BAD_FCS) == BAD_FCS) {
workflow->stats.total_discarded_bytes += header->len;
return;
}
/* Calculate 802.11 header length (variable) */
wifi = (struct ndpi_wifi_header*)( packet + eth_offset + radio_len);
fc = wifi->fc;
/* check wifi data presence */
if(FCF_TYPE(fc) == WIFI_DATA) {
if((FCF_TO_DS(fc) && FCF_FROM_DS(fc) == 0x0) ||
(FCF_TO_DS(fc) == 0x0 && FCF_FROM_DS(fc)))
wifi_len = 26; /* + 4 byte fcs */
} else /* no data frames */
break;
/* Check ether_type from LLC */
llc = (struct ndpi_llc_header*)(packet + eth_offset + wifi_len + radio_len);
if(llc->dsap == SNAP)
type = ntohs(llc->snap.proto_ID);
/* Set IP header offset */
ip_offset = wifi_len + radio_len + sizeof(struct ndpi_llc_header) + eth_offset;
break;
case DLT_RAW:
ip_offset = eth_offset = 0;
break;
default:
/* printf("Unknown datalink %d\n", datalink_type); */
return;
}
/* check ether type */
switch(type) {
case VLAN:
vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF;
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
ip_offset += 4;
vlan_packet = 1;
break;
case MPLS_UNI:
case MPLS_MULTI:
mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
label = ntohl(mpls->label);
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
workflow->stats.mpls_count++;
type = ETH_P_IP, ip_offset += 4;
while((label & 0x100) != 0x100) {
ip_offset += 4;
label = ntohl(mpls->label);
}
break;
case PPPoE:
workflow->stats.pppoe_count++;
type = ETH_P_IP;
ip_offset += 8;
break;
default:
break;
}
workflow->stats.vlan_count += vlan_packet;
iph_check:
/* Check and set IP header size and total packet length */
iph = (struct ndpi_iphdr *) &packet[ip_offset];
/* just work on Ethernet packets that contain IP */
if(type == ETH_P_IP && header->caplen >= ip_offset) {
frag_off = ntohs(iph->frag_off);
proto = iph->protocol;
if(header->caplen < header->len) {
static u_int8_t cap_warning_used = 0;
if(cap_warning_used == 0) {
if(!workflow->prefs.quiet_mode)
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: packet capture size is smaller than packet size, DETECTION MIGHT NOT WORK CORRECTLY\n\n");
cap_warning_used = 1;
}
}
}
if(iph->version == 4) {
ip_len = ((u_short)iph->ihl * 4);
iph6 = NULL;
if(iph->protocol == 41) {
ip_offset += ip_len;
goto iph_check;
}
if((frag_off & 0x1FFF) != 0) {
static u_int8_t ipv4_frags_warning_used = 0;
workflow->stats.fragmented_count++;
if(ipv4_frags_warning_used == 0) {
if(!workflow->prefs.quiet_mode)
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: IPv4 fragments are not handled by this demo (nDPI supports them)\n");
ipv4_frags_warning_used = 1;
}
workflow->stats.total_discarded_bytes += header->len;
return;
}
} else if(iph->version == 6) {
iph6 = (struct ndpi_ipv6hdr *)&packet[ip_offset];
proto = iph6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
ip_len = sizeof(struct ndpi_ipv6hdr);
if(proto == 0x3C /* IPv6 destination option */) {
u_int8_t *options = (u_int8_t*)&packet[ip_offset+ip_len];
proto = options[0];
ip_len += 8 * (options[1] + 1);
}
iph = NULL;
} else {
static u_int8_t ipv4_warning_used = 0;
v4_warning:
if(ipv4_warning_used == 0) {
if(!workflow->prefs.quiet_mode)
NDPI_LOG(0, workflow.ndpi_struct, NDPI_LOG_DEBUG, "\n\nWARNING: only IPv4/IPv6 packets are supported in this demo (nDPI supports both IPv4 and IPv6), all other packets will be discarded\n\n");
ipv4_warning_used = 1;
}
workflow->stats.total_discarded_bytes += header->len;
return;
}
if(workflow->prefs.decode_tunnels && (proto == IPPROTO_UDP)) {
struct ndpi_udphdr *udp = (struct ndpi_udphdr *)&packet[ip_offset+ip_len];
u_int16_t sport = ntohs(udp->source), dport = ntohs(udp->dest);
if((sport == GTP_U_V1_PORT) || (dport == GTP_U_V1_PORT)) {
/* Check if it's GTPv1 */
u_int offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr);
u_int8_t flags = packet[offset];
u_int8_t message_type = packet[offset+1];
if((((flags & 0xE0) >> 5) == 1 /* GTPv1 */) &&
(message_type == 0xFF /* T-PDU */)) {
ip_offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr)+8; /* GTPv1 header len */
if(flags & 0x04) ip_offset += 1; /* next_ext_header is present */
if(flags & 0x02) ip_offset += 4; /* sequence_number is present (it also includes next_ext_header and pdu_number) */
if(flags & 0x01) ip_offset += 1; /* pdu_number is present */
iph = (struct ndpi_iphdr *) &packet[ip_offset];
if(iph->version != 4) {
// printf("WARNING: not good (packet_id=%u)!\n", (unsigned int)workflow->stats.raw_packet_count);
goto v4_warning;
}
}
} else if((sport == TZSP_PORT) || (dport == TZSP_PORT)) {
/* https://en.wikipedia.org/wiki/TZSP */
u_int offset = ip_offset+ip_len+sizeof(struct ndpi_udphdr);
u_int8_t version = packet[offset];
u_int8_t type = packet[offset+1];
u_int16_t encapsulates = ntohs(*((u_int16_t*)&packet[offset+2]));
if((version == 1) && (type == 0) && (encapsulates == 1)) {
u_int8_t stop = 0;
offset += 4;
while((!stop) && (offset < header->caplen)) {
u_int8_t tag_type = packet[offset];
u_int8_t tag_len;
switch(tag_type) {
case 0: /* PADDING Tag */
tag_len = 1;
break;
case 1: /* END Tag */
tag_len = 1, stop = 1;
break;
default:
tag_len = packet[offset+1];
break;
}
offset += tag_len;
if(offset >= header->caplen)
return; /* Invalid packet */
else {
eth_offset = offset;
goto datalink_check;
}
}
}
}
}
/* process the packet */
packet_processing(workflow, time, vlan_id, iph, iph6,
ip_offset, header->len - ip_offset, header->len);
}
+151
View File
@@ -0,0 +1,151 @@
/*
* ndpi_util.h
*
* Copyright (C) 2011-16 - 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/>.
*
*/
/**
* This module contains routines to help setup a simple nDPI program.
*
* If you concern about performance or have to integrate nDPI in your
* application, you could need to reimplement them yourself.
*
* WARNING: this API is unstable! Use it at your own risk!
*/
#ifndef __NDPI_UTIL_H__
#define __NDPI_UTIL_H__
#include <pcap.h>
#define MAX_NUM_READER_THREADS 16
#define IDLE_SCAN_PERIOD 10 /* msec (use TICK_RESOLUTION = 1000) */
#define MAX_IDLE_TIME 30000
#define IDLE_SCAN_BUDGET 1024
#define NUM_ROOTS 512
#define MAX_NDPI_FLOWS 200000000
#define TICK_RESOLUTION 1000
// flow tracking
typedef struct ndpi_flow_info {
u_int32_t lower_ip;
u_int32_t upper_ip;
u_int16_t lower_port;
u_int16_t upper_port;
u_int8_t detection_completed, protocol;
u_int16_t vlan_id;
struct ndpi_flow_struct *ndpi_flow;
char lower_name[48], upper_name[48];
u_int8_t ip_version;
u_int64_t last_seen;
u_int64_t bytes;
u_int32_t packets;
// result only, not used for flow identification
ndpi_protocol detected_protocol;
char host_server_name[192];
char bittorent_hash[41];
struct {
char client_certificate[48], server_certificate[48];
} ssl;
void *src_id, *dst_id;
} ndpi_flow_info_t;
typedef struct ndpi_stats {
u_int32_t guessed_flow_protocols;
u_int64_t raw_packet_count;
u_int64_t ip_packet_count;
u_int64_t total_wire_bytes, total_ip_bytes, total_discarded_bytes;
u_int64_t protocol_counter[NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS + 1];
u_int64_t protocol_counter_bytes[NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS + 1];
u_int32_t protocol_flows[NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS + 1];
u_int32_t ndpi_flow_count;
u_int64_t tcp_count, udp_count;
u_int64_t mpls_count, pppoe_count, vlan_count, fragmented_count;
u_int64_t packet_len[6];
u_int16_t max_packet_len;
} ndpi_stats_t;
typedef struct ndpi_workflow_prefs {
u_int8_t decode_tunnels;
u_int8_t quiet_mode;
u_int32_t num_roots;
u_int32_t max_ndpi_flows;
} ndpi_workflow_prefs_t;
struct ndpi_workflow;
/** workflow, flow, user data */
typedef void (*ndpi_workflow_callback_ptr) (struct ndpi_workflow *, struct ndpi_flow_info *, void *);
typedef struct ndpi_workflow {
u_int64_t last_time;
struct ndpi_workflow_prefs prefs;
struct ndpi_stats stats;
ndpi_workflow_callback_ptr __flow_detected_callback;
void * __flow_detected_udata;
ndpi_workflow_callback_ptr __flow_giveup_callback;
void * __flow_giveup_udata;
/* outside referencies */
pcap_t *pcap_handle;
/* allocated by prefs */
void **ndpi_flows_root;
struct ndpi_detection_module_struct *ndpi_struct;
} ndpi_workflow_t;
/* TODO: remove wrappers parameters and use ndpi global, when their initialization will be fixed... */
struct ndpi_workflow * ndpi_workflow_init(const struct ndpi_workflow_prefs * prefs, pcap_t * pcap_handle);
void ndpi_workflow_free(struct ndpi_workflow * workflow);
/** Free flow_info ndpi support structures but not the flow_info itself
*
* TODO remove! Half freeing things is bad!
*/
void ndpi_free_flow_info_half(struct ndpi_flow_info *flow);
/** Process a @packet and update the @workflow. */
void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
const struct pcap_pkthdr *header,
const u_char *packet);
/* flow callbacks: ndpi_flow_info will be freed right after */
static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow,
ndpi_workflow_callback_ptr callback,
void * udata) {
workflow->__flow_detected_callback = callback;
workflow->__flow_detected_udata = udata;
}
static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow,
ndpi_workflow_callback_ptr callback,
void * udata) {
workflow->__flow_giveup_callback = callback;
workflow->__flow_giveup_udata = udata;
}
int ndpi_workflow_node_cmp(const void *a, const void *b);
#endif
+24
View File
@@ -0,0 +1,24 @@
# Format:
# <tcp|udp>:<port>,<tcp|udp>:<port>,.....@<proto>
tcp:81,tcp:8181@HTTP
udp:5061-5062@SIP
tcp:860,udp:860,tcp:3260,udp:3260@iSCSI
tcp:3000@ntop
# Subprotocols
# Format:
# host:"<value>",host:"<value>",.....@<subproto>
host:"googlesyndacation.com"@Google
host:"venere.com"@Venere
host:"kataweb.it",host:"repubblica.it"@Repubblica
host:"ntop"@ntop
# IP based Subprotocols
# Format:
# ip:<value>,ip:<value>,.....@<subproto>
ip:213.75.170.11@CustomProtocol
-58
View File
@@ -1,58 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>nDPI by ntop</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header>
<h1>nDPI</h1>
<p>Open Source Deep Packet Inspection Software Toolkit</p>
<p class="view"><a href="https://github.com/ntop/nDPI">View the Project on GitHub <small>ntop/nDPI</small></a></p>
<ul>
<li><a href="https://github.com/ntop/nDPI/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/ntop/nDPI/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/ntop/nDPI">View On <strong>GitHub</strong></a></li>
</ul>
</header>
<section>
<h3>
<a id="welcome-to-ndpi" class="anchor" href="#welcome-to-ndpi" aria-hidden="true"><span class="octicon octicon-link"></span></a>Welcome to nDPI</h3>
<p>Deep packet inspection (DPI) is a technique that allows you to identify application traffic protocol such as SSH, HTTP, WhatsApp or Facebook, simply dissecting the first few packets. In addition to that it can extract attributes such as the HTTP URL or DNS query.</p>
<p>There are many DPI toolkits available on the market, but they are closed, costly and usually not available in source format. For this reason we have developed nDPI. We wanted it free (LGPL v3), open and available in source format so you can see what we do with your packets and make sure that your privacy is respected.</p>
<p>Currently it supports almost 200 protocols. While we do our best to keep nDPI updated as new protocols are introduced, we need your help. Please contribute!</p>
</section>
<footer>
<p>This project is maintained by <a href="https://github.com/ntop">ntop</a></p>
<p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
</footer>
</div>
<script src="javascripts/scale.fix.js"></script>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-129330-01");
pageTracker._trackPageview();
} catch(err) {}
</script>
</body>
</html>
-17
View File
@@ -1,17 +0,0 @@
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
document.addEventListener("gesturestart", gestureStart, false);
}
function gestureStart() {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
}
}
}
Symlink
+1
View File
@@ -0,0 +1 @@
src/lib/.libs
+10
View File
@@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libndpi
Description: deep packet inspection library
Version: @VERSION@
Libs: -L${libdir} -lndpi
Cflags: -I${includedir}/libndpi-@VERSION@
+48
View File
@@ -0,0 +1,48 @@
ndpi_dump_protocols
ndpi_strnstr
ndpi_detection_giveup
ndpi_get_proto_name
ndpi_free
ndpi_guess_undetected_protocol
ndpi_tfind
ndpi_tsearch
ndpi_set_protocol_detection_bitmask2
ndpi_detection_get_sizeof_ndpi_id_struct
ndpi_detection_get_sizeof_ndpi_flow_struct
ndpi_load_protocols_file
ndpi_tdestroy
ndpi_exit_detection_module
ndpi_l4_detection_process_packet
ndpi_detection_process_packet
ndpi_twalk
ndpi_tdelete
ndpi_revision
ndpi_init_detection_module
ndpi_get_num_supported_protocols
ndpi_set_proto_defaults
ndpi_get_protocol_id
ndpi_find_port_based_protocol
ndpi_get_http_method
ndpi_get_http_url
ndpi_get_http_content_type
ndpi_free_flow
ndpi_get_proto_breed
ndpi_get_proto_breed_name
ndpi_get_proto_by_id
ndpi_get_protocol_id_master_proto
ndpi_guess_protocol_id
ndpi_protocol2name
ndpi_get_lower_proto
ndpi_is_proto
ndpi_malloc
ndpi_calloc
ndpi_set_detected_protocol
ndpi_match_string_subprotocol
ndpi_init_automa
ndpi_free_automa
ndpi_add_string_to_automa
ndpi_finalize_automa
ndpi_match_string
set_ndpi_malloc
set_ndpi_free
set_ndpi_debug_function
+332
View File
@@ -0,0 +1,332 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also link it with them as well. e.g. you should link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threads programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 21
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
# -pthreads: Solaris/gcc
# -mthreads: Mingw32/gcc, Lynx/gcc
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case ${host_os} in
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;;
esac
# Clang doesn't consider unrecognized options an error unless we specify
# -Werror. We throw in some extra Clang-specific options to ensure that
# this doesn't happen for GCC, which also accepts -Werror.
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
save_CFLAGS="$CFLAGS"
ax_pthread_extra_flags="-Werror"
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
[AC_MSG_RESULT([yes])],
[ax_pthread_extra_flags=
AC_MSG_RESULT([no])])
CFLAGS="$save_CFLAGS"
if test x"$ax_pthread_ok" = xno; then
for flag in $ax_pthread_flags; do
case $flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $flag])
PTHREAD_CFLAGS="$flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
if test x"$ax_pthread_config" = xno; then continue; fi
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$flag])
PTHREAD_LIBS="-l$flag"
;;
esac
save_LIBS="$LIBS"
save_CFLAGS="$CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = xyes; then
break;
fi
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_MSG_CHECKING([for joinable pthread attribute])
attr_name=unknown
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $attr; return attr /* ; */])],
[attr_name=$attr; break],
[])
done
AC_MSG_RESULT([$attr_name])
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
fi
AC_MSG_CHECKING([if more special flags are required for pthreads])
flag=no
case ${host_os} in
aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
osf* | hpux*) flag="-D_REENTRANT";;
solaris*)
if test "$GCC" = "yes"; then
flag="-D_REENTRANT"
else
# TODO: What about Clang on Solaris?
flag="-mt -D_REENTRANT"
fi
;;
esac
AC_MSG_RESULT([$flag])
if test "x$flag" != xno; then
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != xyes; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test x"$ax_pthread_ok" = xyes; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD
+11
View File
@@ -0,0 +1,11 @@
=== HOMEBREW PACKAGE ===
NB: Work in progress
- SUBMIT FORMULA
cp ndpi.rb /usr/local/Library/Formula/
- INSTALL FORMULA
#check the formula
brew audit ndpi
brew install -vd ndpi
+31
View File
@@ -0,0 +1,31 @@
class Ndpi < Formula
desc "Deep Packet Inspection (DPI) library"
homepage "http://www.ntop.org/products/ndpi/"
url "https://downloads.sourceforge.net/project/ntop/nDPI/nDPI-1.8.tgz"
sha256 "f490137a7387b69d0d55e990f2150b86d7b5eaae870e5326e8c2f18c17412443"
bottle do
cellar :any
sha256 "05053767fc3c70557745c348c7352e7c2716c040ca54c5cf8d5306167c878fcb" => :el_capitan
sha256 "34c0269039a0079820eeed862daa28158d9291f73f640a9415da60746d69a662" => :yosemite
sha256 "a2af4dc62c24313593b3a20e45ca9d2d49f8efc0ea5e52fd064001ea441b93e4" => :mavericks
sha256 "1bb200268a4d9df9bbe5d33bc773ee3bcf4b5d4fa00c76a040f16318438c284f" => :mountain_lion
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "pkg-config" => :build
depends_on "libtool" => :build
depends_on "json-c"
def install
system "./autogen.sh"
system "./configure", "--prefix=#{prefix}"
system "make"
system "make", "install"
end
test do
system "#{bin}/ndpiReader", "-i", test_fixtures("test.pcap")
end
end
+42
View File
@@ -0,0 +1,42 @@
#
# Change it according to your setup
#
NDPI_HOME=$(PWD)/../..
NDPI_BUILD=${NDPI_HOME}/packages/ubuntu
all: clean ndpi
ndpi:
\rm -rf ./usr ./debian/tmp ./debian/ndpi-dev
mkdir -p ./usr/local ./debian/ndpi-dev
mkdir -p ./usr/local/ndpi/lib ./usr/local/ndpi/bin ./ndpi-dev/usr/local/include/ndpi/
cd ${NDPI_HOME}; ./autogen.sh; ./configure; make
cp $(NDPI_HOME)/lib/libndpi.a $(NDPI_HOME)/lib/libndpi.so* ./usr/local/ndpi/lib/
cp $(NDPI_HOME)/example/ndpiReader ./usr/local/ndpi/bin/
cp $(NDPI_HOME)/src/include/*.h ndpi-dev/usr/local/include/ndpi/
-rm -fr ndpi-dev/usr/local/include/nprobe/ndpi/.svn ndpi-dev/usr/local/include/ndpi/Makefile* ndpi-dev/usr/local/include/ndpi/ndpi_win32.h* ndpi-dev/usr/local/include/ndpi/include
-find ./usr/local/lib -name "*.la" -exec /bin/rm {} ';'
@echo
@find . -name "*~" -exec /bin/rm {} ';'
dpkg-buildpackage -rfakeroot -d -us -uc
dpkg-sig --sign builder -k 7921DF34 ../ndpi*deb
@\rm -f ../ndpi*dsc ../ndpi*.gz ../ndpi*changes
@/bin/mv ../ndpi*deb .
@echo
@echo "Package built."
@/bin/ls ndpi*deb
@echo "-------------------------------"
-dpkg --contents ndpi*amd64.deb
@echo "-------------------------------"
@echo "-------------------------------"
-dpkg --contents ndpi*all.deb
@echo "-------------------------------"
distclean:
echo "dummy distclean"
install:
echo "dummy install"
clean:
-rm -rf *~ *deb debian/tmp ./usr
+42
View File
@@ -0,0 +1,42 @@
#
# Change it according to your setup
#
NDPI_HOME=$(PWD)/../..
NDPI_BUILD=${NDPI_HOME}/packages/ubuntu
all: clean ndpi
ndpi:
\rm -rf ./usr ./debian/tmp ./debian/ndpi-dev
mkdir -p ./usr/local ./debian/ndpi-dev
mkdir -p ./usr/local/ndpi/lib ./usr/local/ndpi/bin ./ndpi-dev/usr/local/include/ndpi/
cd ${NDPI_HOME}; ./autogen.sh; ./configure; make
cp $(NDPI_HOME)/lib/libndpi.a $(NDPI_HOME)/lib/libndpi.so* ./usr/local/ndpi/lib/
cp $(NDPI_HOME)/example/ndpiReader ./usr/local/ndpi/bin/
cp $(NDPI_HOME)/src/include/*.h ndpi-dev/usr/local/include/ndpi/
-rm -fr ndpi-dev/usr/local/include/nprobe/ndpi/.svn ndpi-dev/usr/local/include/ndpi/Makefile* ndpi-dev/usr/local/include/ndpi/ndpi_win32.h* ndpi-dev/usr/local/include/ndpi/include
-find ./usr/local/lib -name "*.la" -exec /bin/rm {} ';'
@echo
@find . -name "*~" -exec /bin/rm {} ';'
dpkg-buildpackage -rfakeroot -d -us -uc
dpkg-sig --sign builder -k 7921DF34 ../ndpi*deb
@\rm -f ../ndpi*dsc ../ndpi*.gz ../ndpi*changes
@/bin/mv ../ndpi*deb .
@echo
@echo "Package built."
@/bin/ls ndpi*deb
@echo "-------------------------------"
-dpkg --contents ndpi*amd64.deb
@echo "-------------------------------"
@echo "-------------------------------"
-dpkg --contents ndpi*all.deb
@echo "-------------------------------"
distclean:
echo "dummy distclean"
install:
echo "dummy install"
clean:
-rm -rf *~ *deb debian/tmp ./usr
Vendored Executable
+2863
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
AC_INIT([Makefile.in], 1.0)
NDPI_VERS=`cat ../../config.h | grep -w VERSION | cut -d \" -f 2`
PFRING_VERS=`cat $HOME/PF_RING/kernel/linux/pf_ring.h | grep RING_VERSION | head -1 | cut -d '"' -f 2`
SVN_RELEASE=`svn info ../.. | grep "^Revision"|cut -d " " -f 2`
PFRING_SVN_RELEASE=`svn info $HOME/PF_RING | grep "^Revision"|cut -d " " -f 2`
MACHINE=`uname -m`
if test $MACHINE = "x86_64"; then
EXTN="amd64"
else
EXTN="i386"
fi
DATE=`date -R`
KERNEL=`uname -r`
AC_SUBST(NDPI_VERS)
AC_SUBST(PFRING_VERS)
AC_SUBST(MACHINE)
AC_SUBST(EXTN)
AC_SUBST(DATE)
AC_SUBST(KERNEL)
AC_SUBST(SVN_RELEASE)
AC_SUBST(PFRING_SVN_RELEASE)
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(debian/changelog)
AC_CONFIG_FILES(debian/files)
AC_CONFIG_FILES(debian/control)
AC_OUTPUT
+340
View File
@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+2
View File
@@ -0,0 +1,2 @@
This directory contains the files needed to build the package
named 'nprobe' for the Debian GNU/Linux distribution.
+4
View File
@@ -0,0 +1,4 @@
ndpi (@NDPI_VERS@-@SVN_RELEASE@) stable; urgency=high
* Last packaged version
-- Luca Deri <deri@ntop.org> @DATE@
+1
View File
@@ -0,0 +1 @@
1
View File
+28
View File
@@ -0,0 +1,28 @@
Source: ndpi
Section: free
Priority: optional
Maintainer: Luca Deri <deri@ntop.org>
Standards-Version: @NDPI_VERSION@
Build-Depends:
Build-Conflicts:
Package: ndpi
Architecture: @EXTN@
Depends: pfring (=@PFRING_VERS@-@PFRING_SVN_RELEASE@), libnuma
Recommends:
Suggests:
Pre-Depends:
Conflicts:
Provides:
Replaces:
Description: A network probe.
Package: ndpi-dev
Section: libdevel
Architecture: all
Depends: ndpi (= ${binary:Version}), ${misc:Depends}
Conflicts:
Description: development library and header files for ndpi
Headers, static libraries, and documentation for the ndpi library
+1
View File
@@ -0,0 +1 @@
usr/local/ndpi
+1
View File
@@ -0,0 +1 @@
README
+1
View File
@@ -0,0 +1 @@
ndpi_@NDPI_VERS@_@EXTN@.deb free optional
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh -e
case "$1" in
configure)
# continue below
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
umask 022
# Update shared libs
echo "/usr/local/lib\n" > /etc/ld.so.conf.d/nprobe.conf
echo "Rebuilding ld cache..."
/sbin/ldconfig
echo "Adding the nprobe startup script"
update-rc.d nprobe defaults 93 >/dev/null
echo "Making the /etc/nprobe directory..."
mkdir -p /etc/nprobe/
echo "Making the /var/log/nprobe directory..."
mkdir -p /var/log/nprobe
exit 0
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh -e
set -e
#\/bin/rm /etc/ld.so.conf.d/nprobe.conf
/sbin/ldconfig
# Not needed: upstart does it
if [ "$1" = "purge" ] ; then
update-rc.d nprobe remove >/dev/null
fi
exit 0
+35
View File
@@ -0,0 +1,35 @@
#! /bin/sh
# preinst script for nbox
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <new-preinst> `install'
# * <new-preinst> `install' <old-version>
# * <new-preinst> `upgrade' <old-version>
# * <old-preinst> `abort-upgrade' <new-version>
case "$1" in
install|upgrade)
if test -f /usr/local/sbin/nprobe; then
rm /usr/local/sbin/nprobe
fi
;;
abort-upgrade)
;;
*)
echo "preinst called with unknown argument \`$1'" >&2
exit 0
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
exit 0
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh -e
# Only shut the daemon down if we're really removing the package. If this is
# an upgrade, we will instead do a restart in the postinst... this keeps nprobe
# from being left shut down for a long time, which could pose problems.
case "$1" in
upgrade)
;;
*)
/etc/init.d/nprobe stop
;;
esac
exit 0
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1
#
# debian/compat
# We should use at least comparibily version 5
# but this requires the whole building process
# to be remade and this is something we leave
# to when we will have more time
# http://www.tin.org/bin/man.cgi?section=7&topic=debhelper
#
package=ndpi
build: build-stamp
build-stamp:
dh_testdir
clean:
dh_testdir
dh_testroot
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
dh_installinit
dh_installman
# install the files into debian/tmp.
cp -r ./usr/ ./debian/tmp
cp -r ./ndpi-dev/* ./debian/ndpi-dev/
-find ./debian/tmp -name .svn -exec /bin/rm -rf {} ';'
-find ./debian/tmp -executable -type f |xargs strip
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
-1
View File
@@ -1 +0,0 @@
{"name":"nDPI","tagline":"Open Source Deep Packet Inspection Software Toolkit","body":"### Welcome to nDPI\r\nDeep packet inspection (DPI) is a technique that allows you to identify application traffic protocol such as SSH, HTTP, WhatsApp or Facebook, simply dissecting the first few packets. In addition to that it can extract attributes such as the HTTP URL or DNS query.\r\n\r\nThere are many DPI toolkits available on the market, but they are closed, costly and usually not available in source format. For this reason we have developed nDPI. We wanted it free (LGPL v3), open and available in source format so you can see what we do with your packets and make sure that your privacy is respected.\r\n\r\nCurrently it supports almost 200 protocols. While we do our best to keep nDPI updated as new protocols are introduced, we need your help. Please contribute!","google":"UA-129330-01","note":"Don't delete this file! It's used internally to help with page regeneration."}
+10
View File
@@ -0,0 +1,10 @@
library_includedir=$(includedir)/libndpi-1.4/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
+643
View File
@@ -0,0 +1,643 @@
/*
* ndpi_api.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_API_H__
#define __NDPI_API_H__
#include "ndpi_main.h"
#ifdef __cplusplus
extern "C" {
#endif
#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);
/**
* 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);
/**
* 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();
/**
* 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
* @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);
/**
* 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);
/**
* Processes one packet of L4 and returns the ID of the detected protocol.
* L3 and L4 packet headers are passed in the arguments while payload
* points to the L4 body.
* This function mimics ndpi_detection_process_packet behaviour.
*
* @par ndpi_struct = the detection module
* @par flow = pointer to the connection state machine
* @par iph = IP packet header for IPv4 or NULL
* @par iph6 = IP packet header for IPv6 or NULL
* @par tcp = TCP packet header for TCP or NULL
* @par udp = UDP packet header for UDP or NULL
* @par src_to_dst_direction = order of src/dst state machines in a flow.
* @par l4_proto = L4 protocol of the packet.
* @par src = pointer to the source subscriber state machine
* @par dst = pointer to the destination subscriber state machine
* @par sport = source port of L4 packet, used for protocol guessing.
* @par dport = destination port of L4 packet, used for protocol guessing.
* @par current_tick_l = the current timestamp for the packet
* @par payload = unsigned char pointer to the Layer 4 (TCP/UDP body)
* @par payload_len = the length of the payload
* @return the detected ID of the protocol
*
* NOTE: in a current implementation flow->src and flow->dst are swapped with
* the src_to_dst_direction flag while ndpi_detection_process_packet does not swap
* these values.
*
*/
ndpi_protocol ndpi_l4_detection_process_packet(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
const struct ndpi_iphdr *iph,
struct ndpi_ipv6hdr *iph6,
struct ndpi_tcphdr *tcp,
struct ndpi_udphdr *udp,
u_int8_t src_to_dst_direction,
u_int8_t l4_proto,
struct ndpi_id_struct *src,
u_int16_t sport,
struct ndpi_id_struct *dst,
u_int16_t dport,
const u_int64_t current_tick_l,
u_int8_t *payload, u_int16_t payload_len);
/**
* 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);
/**
* 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);
#if 0
/**
* returns true if the protocol history of the flow of the last packet given to the detection
* contains the given protocol.
*
* @param ndpi_struct the detection module
* @return 1 if protocol has been found, 0 otherwise
*
*/
u_int8_t ndpi_detection_flow_protocol_history_contains_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int16_t protocol_id);
#endif
/**
* 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 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,
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 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,
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 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,
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 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,
u_int16_t master_protocol_id);
/**
* Check if the string -bigram_to_match- match with a bigram of -automa-
*
* @par ndpi_struct = 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_struct,
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);
/**
* 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 ID of the protocol
* @return the string name of the breed ID
*
*/
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
/**
* 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);
#ifdef 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);
#endif
#ifdef 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);
#endif
/* Wrappers functions */
/**
* Init Aho-Corasick automata
*
* @return The requested automata, or NULL if an error occurred
*
*/
void* ndpi_init_automa();
/**
* 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
* @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);
/* 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_debug_function(ndpi_debug_function_ptr ndpi_debug_printf);
#ifdef __cplusplus
}
#endif
#endif /* __NDPI_API_H__ */
+296
View File
@@ -0,0 +1,296 @@
/*
*
* 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_DEFINE_INCLUDE_FILE__
#define __NDPI_DEFINE_INCLUDE_FILE__
/*
gcc -E -dM - < /dev/null |grep ENDIAN
*/
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <machine/endian.h>
#endif
#ifdef __OpenBSD__
#include <endian.h>
#define __BYTE_ORDER BYTE_ORDER
#if BYTE_ORDER == LITTLE_ENDIAN
#define __LITTLE_ENDIAN__
#else
#define __BIG_ENDIAN__
#endif/* BYTE_ORDER */
#endif/* __OPENBSD__ */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#ifndef __LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__
#endif
#else
#ifndef __BIG_ENDIAN__
#define __BIG_ENDIAN__
#endif
#endif
#ifdef WIN32
#ifndef __LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__ 1
#endif
#endif
#if !(defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__))
#if defined(__mips__)
#undef __LITTLE_ENDIAN__
#undef __LITTLE_ENDIAN
#define __BIG_ENDIAN__
#endif
/* Everything else */
#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__))
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__
#else
#define __BIG_ENDIAN__
#endif
#endif
#endif
#define NDPI_USE_ASYMMETRIC_DETECTION 0
#define NDPI_SELECTION_BITMASK_PROTOCOL_SIZE u_int32_t
#define NDPI_SELECTION_BITMASK_PROTOCOL_IP (1<<0)
#define NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP (1<<1)
#define NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP (1<<2)
#define NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP (1<<3)
#define NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD (1<<4)
#define NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION (1<<5)
#define NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 (1<<6)
#define NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6 (1<<7)
#define NDPI_SELECTION_BITMASK_PROTOCOL_COMPLETE_TRAFFIC (1<<8)
/* now combined detections */
/* v4 */
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP (NDPI_SELECTION_BITMASK_PROTOCOL_IP | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_UDP (NDPI_SELECTION_BITMASK_PROTOCOL_IP | NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP (NDPI_SELECTION_BITMASK_PROTOCOL_IP | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP)
/* v6 */
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP (NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP (NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP (NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP)
/* v4 or v6 */
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP (NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP (NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_INT_UDP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP (NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_INT_TCP_OR_UDP)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
/* does it make sense to talk about udp with payload ??? have you ever seen empty udp packets ? */
#define NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V6_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
#define NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION (NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP | NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION | NDPI_SELECTION_BITMASK_PROTOCOL_HAS_PAYLOAD)
/* safe src/dst protocol check macros... */
#define NDPI_SRC_HAS_PROTOCOL(src,protocol) ((src) != NULL && NDPI_COMPARE_PROTOCOL_TO_BITMASK((src)->detected_protocol_bitmask,(protocol)) != 0)
#define NDPI_DST_HAS_PROTOCOL(dst,protocol) ((dst) != NULL && NDPI_COMPARE_PROTOCOL_TO_BITMASK((dst)->detected_protocol_bitmask,(protocol)) != 0)
#define NDPI_SRC_OR_DST_HAS_PROTOCOL(src,dst,protocol) (NDPI_SRC_HAS_PROTOCOL(src,protocol) || NDPI_SRC_HAS_PROTOCOL(dst,protocol))
/**
* convenience macro to check for excluded protocol
* a protocol is excluded if the flow is known and either the protocol is not detected at all
* or the excluded bitmask contains the protocol
*/
#define NDPI_FLOW_PROTOCOL_EXCLUDED(ndpi_struct,flow,protocol) ((flow) != NULL && \
( NDPI_COMPARE_PROTOCOL_TO_BITMASK((ndpi_struct)->detection_bitmask, (protocol)) == 0 || \
NDPI_COMPARE_PROTOCOL_TO_BITMASK((flow)->excluded_protocol_bitmask, (protocol)) != 0 ) )
/* misc definitions */
#define NDPI_DEFAULT_MAX_TCP_RETRANSMISSION_WINDOW_SIZE 0x10000
/* TODO: rebuild all memory areas to have a more aligned memory block here */
/* DEFINITION OF MAX LINE NUMBERS FOR line parse algorithm */
#define NDPI_MAX_PARSE_LINES_PER_PACKET 64
#define MAX_PACKET_COUNTER 65000
#define MAX_DEFAULT_PORTS 5
#define NDPI_DIRECTCONNECT_CONNECTION_IP_TICK_TIMEOUT 600
#define NDPI_IRC_CONNECTION_TIMEOUT 120
#define NDPI_GNUTELLA_CONNECTION_TIMEOUT 60
#define NDPI_BATTLEFIELD_CONNECTION_TIMEOUT 60
#define NDPI_THUNDER_CONNECTION_TIMEOUT 30
#define NDPI_RTSP_CONNECTION_TIMEOUT 5
#define NDPI_TVANTS_CONNECTION_TIMEOUT 5
#define NDPI_YAHOO_DETECT_HTTP_CONNECTIONS 1
#define NDPI_YAHOO_LAN_VIDEO_TIMEOUT 30
#define NDPI_ZATTOO_CONNECTION_TIMEOUT 120
#define NDPI_ZATTOO_FLASH_TIMEOUT 5
#define NDPI_JABBER_STUN_TIMEOUT 30
#define NDPI_JABBER_FT_TIMEOUT 5
#define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
#define NDPI_LOG(proto, mod, log_level, args...) \
{ \
if(mod != NULL) { \
mod->ndpi_debug_print_file=__FILE__; \
mod->ndpi_debug_print_function=__FUNCTION__; \
mod->ndpi_debug_print_line=__LINE__; \
mod->ndpi_debug_printf(proto, mod, log_level, args); \
} \
}
#else /* NDPI_ENABLE_DEBUG_MESSAGES */
#ifdef WIN32
#define NDPI_LOG(...) {}
#else
#define NDPI_LOG(proto, mod, log_level, args...) {}
#endif
#endif /* NDPI_ENABLE_DEBUG_MESSAGES */
/**
* macro for getting the string len of a static string
*
* use it instead of strlen to avoid runtime calculations
*/
#define NDPI_STATICSTRING_LEN( s ) ( sizeof( s ) - 1 )
/** 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])) )
#define NDPI_NUM_BITS 256
#define NDPI_BITS /* 32 */ (sizeof(ndpi_ndpi_mask) * 8 /* number of bits in a byte */) /* bits per mask */
#define howmanybits(x, y) (((x)+((y)-1))/(y))
#define NDPI_SET(p, n) ((p)->fds_bits[(n)/NDPI_BITS] |= (1 << (((u_int32_t)n) % NDPI_BITS)))
#define NDPI_CLR(p, n) ((p)->fds_bits[(n)/NDPI_BITS] &= ~(1 << (((u_int32_t)n) % NDPI_BITS)))
#define NDPI_ISSET(p, n) ((p)->fds_bits[(n)/NDPI_BITS] & (1 << (((u_int32_t)n) % NDPI_BITS)))
#define NDPI_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
#define NDPI_ONE(p) memset((char *)(p), 0xFF, sizeof(*(p)))
#define NDPI_NUM_FDS_BITS howmanybits(NDPI_NUM_BITS, NDPI_BITS)
#define NDPI_PROTOCOL_BITMASK ndpi_protocol_bitmask_struct_t
#define NDPI_BITMASK_ADD(a,b) NDPI_SET(&a,b)
#define NDPI_BITMASK_DEL(a,b) NDPI_CLR(&a,b)
#define NDPI_BITMASK_RESET(a) NDPI_ZERO(&a)
#define NDPI_BITMASK_SET_ALL(a) NDPI_ONE(&a)
#define NDPI_BITMASK_SET(a, b) { memcpy(&a, &b, sizeof(NDPI_PROTOCOL_BITMASK)); }
/* this is a very very tricky macro *g*,
* the compiler will remove all shifts here if the protocol is static...
*/
#define NDPI_ADD_PROTOCOL_TO_BITMASK(bmask,value) NDPI_SET(&bmask,value)
#define NDPI_DEL_PROTOCOL_FROM_BITMASK(bmask,value) NDPI_CLR(&bmask,value)
#define NDPI_COMPARE_PROTOCOL_TO_BITMASK(bmask,value) NDPI_ISSET(&bmask,value)
#define NDPI_SAVE_AS_BITMASK(bmask,value) { NDPI_ZERO(&bmask) ; NDPI_ADD_PROTOCOL_TO_BITMASK(bmask, value); }
#define ndpi_min(a,b) ((a < b) ? a : b)
#define ndpi_max(a,b) ((a > b) ? a : b)
#define NDPI_PARSE_PACKET_LINE_INFO(ndpi_struct,flow,packet) \
if (packet->packet_lines_parsed_complete != 1) { \
ndpi_parse_packet_line_info(ndpi_struct,flow); \
} \
#define NDPI_IPSEC_PROTOCOL_ESP 50
#define NDPI_IPSEC_PROTOCOL_AH 51
#define NDPI_GRE_PROTOCOL_TYPE 0x2F
#define NDPI_ICMP_PROTOCOL_TYPE 0x01
#define NDPI_IGMP_PROTOCOL_TYPE 0x02
#define NDPI_EGP_PROTOCOL_TYPE 0x08
#define NDPI_OSPF_PROTOCOL_TYPE 0x59
#define NDPI_SCTP_PROTOCOL_TYPE 132
#define NDPI_IPIP_PROTOCOL_TYPE 0x04
#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))
/* new definitions to get little endian from network bytes */
#define get_ul8(X,O) get_u_int8_t(X,O)
#if defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
#define get_l16(X,O) get_u_int16_t(X,O)
#define get_l32(X,O) get_u_int32_t(X,O)
#elif defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN)
/* convert the bytes from big to little endian */
# define get_l16(X,O) bswap_16(get_u_int16_t(X,O))
# define get_l32(X,O) bswap_32(get_u_int32_t(X,O))
#else
#error "__BYTE_ORDER MUST BE DEFINED !"
#endif /* __BYTE_ORDER */
/* define memory callback function */
#define match_first_bytes(payload,st) (memcmp((payload),(st),(sizeof(st)-1))==0)
#if defined(WIN32) && !defined(snprintf)
#define snprintf _snprintf
#endif
#define NDPI_MAX_DNS_REQUESTS 16
#endif /* __NDPI_DEFINE_INCLUDE_FILE__ */
+69
View File
@@ -0,0 +1,69 @@
/*
* ndpi_includes.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_H__
#define __NDPI_INCLUDES_H__
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#ifdef WIN32
#include "ndpi_win32.h"
#else
#include <sys/types.h>
#include <sys/param.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__
#include <endian.h>
#include <byteswap.h>
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
#include <netinet/in.h>
#if defined __NetBSD__ || defined __OpenBSD__
#include <netinet/in_systm.h>
#ifdef __OpenBSD__
#include <pthread.h>
#endif
#endif
#endif
#endif
#endif /* Win32 */
#endif /* __NDPI_INCLUDES_H__ */
+127
View File
@@ -0,0 +1,127 @@
/*
* ndpi_main.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_MAIN_H__
#define __NDPI_MAIN_H__
#include "ndpi_includes.h"
#include "ndpi_define.h"
#include "ndpi_protocol_ids.h"
#include "ndpi_typedefs.h"
#include "ndpi_protocols.h"
#include "ndpi_api.h"
#ifdef __cplusplus
extern "C" {
#endif
void *ndpi_tdelete(const void * __restrict, void ** __restrict,
int (*)(const void *, const void *));
void *ndpi_tfind(const void *, void *, int (*)(const void *, const void *));
void *ndpi_tsearch(const void *, void**, int (*)(const void *, const void *));
void ndpi_twalk(const void *, void (*)(const void *, ndpi_VISIT, int, void*), void *user_data);
void ndpi_tdestroy(void *vrootp, void (*freefct)(void *));
int NDPI_BITMASK_COMPARE(NDPI_PROTOCOL_BITMASK a, NDPI_PROTOCOL_BITMASK b);
int NDPI_BITMASK_IS_EMPTY(NDPI_PROTOCOL_BITMASK a);
void NDPI_DUMP_BITMASK(NDPI_PROTOCOL_BITMASK a);
extern u_int8_t ndpi_net_match(u_int32_t ip_to_check,
u_int32_t net,
u_int32_t num_bits);
extern u_int8_t ndpi_ips_match(u_int32_t src, u_int32_t dst,
u_int32_t net, u_int32_t num_bits);
u_int16_t ntohs_ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
u_int32_t ndpi_bytestream_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
u_int64_t ndpi_bytestream_to_number64(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
u_int32_t ndpi_bytestream_dec_or_hex_to_number(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
u_int64_t ndpi_bytestream_dec_or_hex_to_number64(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
u_int32_t ndpi_bytestream_to_ipv4(const u_int8_t * str, u_int16_t max_chars_to_read, u_int16_t * bytes_read);
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int16_t upper_detected_protocol,
u_int16_t lower_detected_protocol);
extern void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
extern void ndpi_parse_packet_line_info_any(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
extern u_int16_t ndpi_check_for_email_address(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, u_int16_t counter);
extern void ndpi_int_change_packet_protocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
u_int16_t upper_detected_protocol,
u_int16_t lower_detected_protocol);
extern void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
u_int16_t upper_detected_protocol,
u_int16_t lower_detected_protocol);
extern void ndpi_set_proto_defaults(struct ndpi_detection_module_struct *ndpi_mod, ndpi_protocol_breed_t protoBreed, u_int16_t protoId,
u_int16_t tcp_alias_protoId[2], u_int16_t udp_alias_protoId[2], char *protoName,
ndpi_port_range *tcpDefPorts, ndpi_port_range *udpDefPorts);
extern void ndpi_int_reset_packet_protocol(struct ndpi_packet_struct *packet);
extern void ndpi_int_reset_protocol(struct ndpi_flow_struct *flow);
extern int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
extern int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t * ip);
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 char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id);
extern u_int16_t ndpi_guess_protocol_id(struct ndpi_detection_module_struct *ndpi_struct,
u_int8_t proto, u_int16_t sport, u_int16_t dport);
extern u_int8_t ndpi_is_proto(ndpi_protocol p, u_int16_t proto);
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, u_int16_t protocol_id,
u_int16_t** tcp_master_proto,
u_int16_t** udp_master_proto);
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
void ndpi_debug_get_last_log_function_line(struct ndpi_detection_module_struct *ndpi_struct,
const char **file, const char **func, u_int32_t * line);
#endif
/** Checks when the @p payload starts with the string literal @p str.
* When the string is larger than the payload, check fails.
* @return non-zero if check succeeded
*/
int ndpi_match_prefix(const u_int8_t *payload, size_t payload_len,
const char *str, size_t str_len);
/* version of ndpi_match_prefix with string literal */
#define ndpi_match_strprefix(payload, payload_len, str) \
ndpi_match_prefix((payload), (payload_len), (str), (sizeof(str)-1))
#ifdef __cplusplus
}
#endif
#endif /* __NDPI_MAIN_H__ */
+283
View File
@@ -0,0 +1,283 @@
/*
* ndpi_protocol_ids.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_API_H__
#endif
#ifndef __NDPI_PROTOCOLS_DEFAULT_H__
#define __NDPI_PROTOCOLS_DEFAULT_H__
#define NDPI_DETECTION_SUPPORT_IPV6
#define NDPI_PROTOCOL_HISTORY_SIZE 2
#define NDPI_PROTOCOL_UNKNOWN 0
#define NDPI_PROTOCOL_NO_MASTER_PROTO NDPI_PROTOCOL_UNKNOWN
#define NDPI_PROTOCOL_IP_VRRP 73
#define NDPI_PROTOCOL_IP_IPSEC 79
#define NDPI_PROTOCOL_IP_GRE 80
#define NDPI_PROTOCOL_IP_ICMP 81
#define NDPI_PROTOCOL_IP_IGMP 82
#define NDPI_PROTOCOL_IP_EGP 83
#define NDPI_PROTOCOL_IP_SCTP 84
#define NDPI_PROTOCOL_IP_OSPF 85
#define NDPI_PROTOCOL_IP_IP_IN_IP 86
#define NDPI_PROTOCOL_IP_ICMPV6 102
#define NDPI_PROTOCOL_HTTP 7
#define NDPI_PROTOCOL_HTTP_DOWNLOAD 60
#define NDPI_PROTOCOL_SSL_NO_CERT 64 /* SSL without certificate (Skype, Ultrasurf?) - ntop.org */
#define NDPI_PROTOCOL_SSL 91
#define NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC 110
#define NDPI_PROTOCOL_HTTP_CONNECT 130
#define NDPI_PROTOCOL_HTTP_PROXY 131
#define NDPI_PROTOCOL_SOCKS 172 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_FTP_CONTROL 1 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_MAIL_POP 2
#define NDPI_PROTOCOL_MAIL_SMTP 3
#define NDPI_PROTOCOL_MAIL_IMAP 4
#define NDPI_PROTOCOL_DNS 5
#define NDPI_PROTOCOL_IPP 6
#define NDPI_PROTOCOL_MDNS 8
#define NDPI_PROTOCOL_NTP 9
#define NDPI_PROTOCOL_NETBIOS 10
#define NDPI_PROTOCOL_NFS 11
#define NDPI_PROTOCOL_SSDP 12
#define NDPI_PROTOCOL_BGP 13
#define NDPI_PROTOCOL_SNMP 14
#define NDPI_PROTOCOL_XDMCP 15
#define NDPI_PROTOCOL_SMB 16
#define NDPI_PROTOCOL_SYSLOG 17
#define NDPI_PROTOCOL_DHCP 18
#define NDPI_PROTOCOL_POSTGRES 19
#define NDPI_PROTOCOL_MYSQL 20
#define NDPI_PROTOCOL_TDS 21
#define NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK 22
#define NDPI_PROTOCOL_MAIL_POPS 23
#define NDPI_PROTOCOL_APPLEJUICE 24
#define NDPI_PROTOCOL_DIRECTCONNECT 25
#define NDPI_PROTOCOL_SOCRATES 26
#define NDPI_PROTOCOL_COAP 27
#define NDPI_PROTOCOL_VMWARE 28
#define NDPI_PROTOCOL_MAIL_SMTPS 29
#define NDPI_PROTOCOL_FILETOPIA 30
#define NDPI_PROTOCOL_IMESH 31
#define NDPI_PROTOCOL_KONTIKI 32
#define NDPI_PROTOCOL_OPENFT 33
#define NDPI_PROTOCOL_FASTTRACK 34
#define NDPI_PROTOCOL_GNUTELLA 35
#define NDPI_PROTOCOL_EDONKEY 36 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_BITTORRENT 37
#define NDPI_PROTOCOL_EPP 38
#define NDPI_PROTOCOL_XBOX 47
#define NDPI_PROTOCOL_QQ 48
#define NDPI_PROTOCOL_MOVE 49
#define NDPI_PROTOCOL_RTSP 50
#define NDPI_PROTOCOL_MAIL_IMAPS 51
#define NDPI_PROTOCOL_ICECAST 52
#define NDPI_PROTOCOL_PPLIVE 53 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_PPSTREAM 54
#define NDPI_PROTOCOL_ZATTOO 55
#define NDPI_PROTOCOL_SHOUTCAST 56
#define NDPI_PROTOCOL_SOPCAST 57
#define NDPI_PROTOCOL_TVANTS 58
#define NDPI_PROTOCOL_TVUPLAYER 59
#define NDPI_PROTOCOL_QQLIVE 61
#define NDPI_PROTOCOL_THUNDER 62
#define NDPI_PROTOCOL_SOULSEEK 63
#define NDPI_PROTOCOL_IRC 65
#define NDPI_PROTOCOL_AYIYA 66
#define NDPI_PROTOCOL_UNENCRYPED_JABBER 67
#define NDPI_PROTOCOL_MSN 68
#define NDPI_PROTOCOL_OSCAR 69
#define NDPI_PROTOCOL_YAHOO 70
#define NDPI_PROTOCOL_BATTLEFIELD 71
#define NDPI_PROTOCOL_QUAKE 72
#define NDPI_PROTOCOL_STEAM 74 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_HALFLIFE2 75
#define NDPI_PROTOCOL_WORLDOFWARCRAFT 76
#define NDPI_PROTOCOL_TELNET 77
#define NDPI_PROTOCOL_STUN 78
#define NDPI_PROTOCOL_RTP 87
#define NDPI_PROTOCOL_RDP 88
#define NDPI_PROTOCOL_VNC 89
#define NDPI_PROTOCOL_PCANYWHERE 90
#define NDPI_PROTOCOL_SSH 92
#define NDPI_PROTOCOL_USENET 93
#define NDPI_PROTOCOL_MGCP 94
#define NDPI_PROTOCOL_IAX 95
#define NDPI_PROTOCOL_TFTP 96
#define NDPI_PROTOCOL_AFP 97
#define NDPI_PROTOCOL_STEALTHNET 98
#define NDPI_PROTOCOL_AIMINI 99
#define NDPI_PROTOCOL_SIP 100
#define NDPI_PROTOCOL_TRUPHONE 101
#define NDPI_PROTOCOL_DHCPV6 103
#define NDPI_PROTOCOL_ARMAGETRON 104
#define NDPI_PROTOCOL_CROSSFIRE 105
#define NDPI_PROTOCOL_DOFUS 106
#define NDPI_PROTOCOL_FIESTA 107
#define NDPI_PROTOCOL_FLORENSIA 108
#define NDPI_PROTOCOL_GUILDWARS 109
#define NDPI_PROTOCOL_KERBEROS 111
#define NDPI_PROTOCOL_LDAP 112
#define NDPI_PROTOCOL_MAPLESTORY 113
#define NDPI_PROTOCOL_MSSQL 114
#define NDPI_PROTOCOL_PPTP 115
#define NDPI_PROTOCOL_WARCRAFT3 116
#define NDPI_PROTOCOL_WORLD_OF_KUNG_FU 117
#define NDPI_PROTOCOL_MEEBO 118
#define NDPI_PROTOCOL_DROPBOX 121
#define NDPI_PROTOCOL_SKYPE 125
#define NDPI_PROTOCOL_DCERPC 127
#define NDPI_PROTOCOL_NETFLOW 128
#define NDPI_PROTOCOL_SFLOW 129
#define NDPI_PROTOCOL_CITRIX 132
#define NDPI_PROTOCOL_SKYFILE_PREPAID 136
#define NDPI_PROTOCOL_SKYFILE_RUDICS 137
#define NDPI_PROTOCOL_SKYFILE_POSTPAID 138
#define NDPI_PROTOCOL_CITRIX_ONLINE 139
#define NDPI_PROTOCOL_WEBEX 141
#define NDPI_PROTOCOL_VIBER 144
#define NDPI_PROTOCOL_RADIUS 146
#define NDPI_SERVICE_WINDOWS_UPDATE 147
#define NDPI_PROTOCOL_TEAMVIEWER 148 /* xplico.org */
#define NDPI_PROTOCOL_LOTUS_NOTES 150
#define NDPI_PROTOCOL_SAP 151
#define NDPI_PROTOCOL_GTP 152
#define NDPI_PROTOCOL_UPNP 153
#define NDPI_PROTOCOL_LLMNR 154
#define NDPI_PROTOCOL_REMOTE_SCAN 155
#define NDPI_PROTOCOL_SPOTIFY 156
#define NDPI_PROTOCOL_H323 158 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_OPENVPN 159 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_NOE 160 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_CISCOVPN 161 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_TEAMSPEAK 162 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_TOR 163 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_SKINNY 164 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_RTCP 165 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_RSYNC 166 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_ORACLE 167 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_CORBA 168 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_UBUNTUONE 169 /* Remy Mudingay <mudingay@ill.fr> */
#define NDPI_PROTOCOL_WHOIS_DAS 170
#define NDPI_PROTOCOL_COLLECTD 171
#define NDPI_PROTOCOL_RTMP 174 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_FTP_DATA 175 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_ZMQ 177
#define NDPI_PROTOCOL_MEGACO 181 /* Gianluca Costa <g.costa@xplico.org> */
#define NDPI_PROTOCOL_REDIS 182
#define NDPI_PROTOCOL_PANDO 183 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_PROTOCOL_VHUA 184
#define NDPI_PROTOCOL_TELEGRAM 185 /* Gianluca Costa <g.costa@xplico.org> */
#define NDPI_PROTOCOL_QUIC 188 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> - Michele Campus <michelecampus5@gmail.com> */
#define NDPI_PROTOCOL_WHATSAPP_VOICE 189
#define NDPI_PROTOCOL_STARCRAFT 213 /* Matteo Bracci <matteobracci1@gmail.com> */
#define NDPI_PROTOCOL_TEREDO 214
#define NDPI_PROTOCOL_HEP 216 /* Sipcapture.org QXIP BV */
#define NDPI_PROTOCOL_UBNTAC2 217 /* Ubiquity UBNT AirControl 2 - Thomas Fjellstrom <thomas+ndpi@fjellstrom.ca> */
#define NDPI_PROTOCOL_MS_LYNC 173
#define NDPI_CONTENT_AVI 39
#define NDPI_CONTENT_FLASH 40
#define NDPI_CONTENT_OGG 41
#define NDPI_CONTENT_MPEG 42
#define NDPI_CONTENT_QUICKTIME 43
#define NDPI_CONTENT_REALMEDIA 44
#define NDPI_CONTENT_WINDOWSMEDIA 45
#define NDPI_CONTENT_MMS 46
#define NDPI_CONTENT_WEBM 157
#define NDPI_SERVICE_FACEBOOK 119
#define NDPI_SERVICE_TWITTER 120
#define NDPI_SERVICE_GMAIL 122
#define NDPI_SERVICE_GOOGLE_MAPS 123
#define NDPI_SERVICE_YOUTUBE 124
#define NDPI_SERVICE_VEVO 186
#define NDPI_SERVICE_GOOGLE 126
#define NDPI_SERVICE_NETFLIX 133
#define NDPI_SERVICE_LASTFM 134
#define NDPI_SERVICE_WAZE 135
#define NDPI_SERVICE_APPLE 140
#define NDPI_SERVICE_WHATSAPP 142
#define NDPI_SERVICE_APPLE_ICLOUD 143
#define NDPI_SERVICE_APPLE_ITUNES 145
#define NDPI_SERVICE_TUENTI 149
#define NDPI_SERVICE_WIKIPEDIA 176 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_MSN NDPI_PROTOCOL_MSN /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_AMAZON 178 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_EBAY 179 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_CNN 180 /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_DROPBOX NDPI_PROTOCOL_DROPBOX /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_SKYPE NDPI_PROTOCOL_SKYPE /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_VIBER NDPI_PROTOCOL_VIBER
#define NDPI_SERVICE_YAHOO NDPI_PROTOCOL_YAHOO /* Tomasz Bujlow <tomasz@skatnet.dk> */
#define NDPI_SERVICE_PANDORA 187
#define NDPI_PROTOCOL_EAQ 190
#define NDPI_SERVICE_TIMMEU 191
#define NDPI_SERVICE_TORCEDOR 192
#define NDPI_SERVICE_KAKAOTALK 193 /* KakaoTalk Chat (no voice call) */
#define NDPI_SERVICE_KAKAOTALK_VOICE 194 /* KakaoTalk Voice */
#define NDPI_SERVICE_TWITCH 195 /* Edoardo Dominici <edoaramis@gmail.com> */
#define NDPI_SERVICE_QUICKPLAY 196 /* Streaming service used by various services such as hooq.tv */
#define NDPI_SERVICE_TIM 197 /* Traffic for tim.com.br and tim.it */
#define NDPI_PROTOCOL_MPEGTS 198
#define NDPI_SERVICE_SNAPCHAT 199
#define NDPI_SERVICE_SIMET 200
#define NDPI_SERVICE_OPENSIGNAL 201
#define NDPI_SERVICE_99TAXI 202
#define NDPI_SERVICE_EASYTAXI 203
#define NDPI_SERVICE_GLOBOTV 204
#define NDPI_SERVICE_TIMSOMDECHAMADA 205
#define NDPI_SERVICE_TIMMENU 206
#define NDPI_SERVICE_TIMPORTASABERTAS 207
#define NDPI_SERVICE_TIMRECARGA 208
#define NDPI_SERVICE_TIMBETA 209
#define NDPI_SERVICE_DEEZER 210
#define NDPI_SERVICE_INSTAGRAM 211 /* Andrea Buscarinu <andrea.buscarinu@gmail.com> */
#define NDPI_SERVICE_MICROSOFT 212
#define NDPI_SERVICE_HOTSPOT_SHIELD 215
#define NDPI_SERVICE_OCS 218
#define NDPI_SERVICE_OFFICE_365 219
#define NDPI_SERVICE_CLOUDFLARE 220
#define NDPI_SERVICE_MS_ONE_DRIVE 221
#define NDPI_PROTOCOL_MQTT 222
#define NDPI_PROTOCOL_RX 223
#define NDPI_SERVICE_WEIBO 224
#define NDPI_SERVICE_OPENDNS 225
#define NDPI_PROTOCOL_GIT 226
#define NDPI_PROTOCOL_DRDA 227
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE */
#define NDPI_LAST_IMPLEMENTED_PROTOCOL NDPI_PROTOCOL_DRDA
#define NDPI_MAX_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1)
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
#endif
+341
View File
@@ -0,0 +1,341 @@
/*
* ndpi_protocols.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_PROTOCOLS_H__
#define __NDPI_PROTOCOLS_H__
#include "ndpi_main.h"
ndpi_port_range* ndpi_build_default_ports_range(ndpi_port_range *ports,
u_int16_t portA_low, u_int16_t portA_high,
u_int16_t portB_low, u_int16_t portB_high,
u_int16_t portC_low, u_int16_t portC_high,
u_int16_t portD_low, u_int16_t portD_high,
u_int16_t portE_low, u_int16_t portE_high);
ndpi_port_range* ndpi_build_default_ports(ndpi_port_range *ports,
u_int16_t portA,
u_int16_t portB,
u_int16_t portC,
u_int16_t portD,
u_int16_t portE);
/* TCP/UDP protocols */
u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct,
u_int8_t protocol,
u_int32_t saddr, u_int32_t daddr,
u_int16_t sport, u_int16_t dport);
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_bittorrent(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_imesh_tcp_udp(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_tds_tcp(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(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_meebo(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_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_twitter(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_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);
/* --- INIT FUNCTIONS --- */
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);
void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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_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_teredo_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ciscovpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_citrix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_corba_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_crossfire_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_dcerpc_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);
void init_dhcpv6_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_directconnect_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);
void init_dofus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_directdownloadlink_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_dropbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_eaq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_edonkey_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_fasttrack_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_fiesta_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_filetopia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_florensia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ftp_control_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ftp_data_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_gnutella_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_gtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_guildwars_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_h323_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_halflife2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_http_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_http_activesync_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_iax_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_icecast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_imesh_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ipp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_irc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_jabber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_kakaotalk_voice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_kerberos_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_kontiki_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ldap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_lotus_notes_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mail_imap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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_meebo_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_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_mpegts_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mssql_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);
void init_netbios_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_netflow_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_nfs_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_noe_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_non_tcp_udp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ntp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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);
void init_quake_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_quic_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_radius_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_redis_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rsync_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rtcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rtmp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rtp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rtsp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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_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);
void init_snmp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_socrates_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_sopcast_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_soulseek_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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_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);
void init_stun_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_syslog_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_ssdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_tds_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_teamspeak_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_teamviewer_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_telegram_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_telnet_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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_twitter_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_veohtv_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_vhua_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_viber_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_vmware_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_vnc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_warcraft3_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_whois_das_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_world_of_warcraft_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
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);
void init_ubntac2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_coap_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_mqtt_dissector (struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_rx_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_git_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask);
void init_drda_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
+43
View File
@@ -0,0 +1,43 @@
/*
* ndpi_unix.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_UNIX_INCLUDE_FILE__
#define __NDPI_UNIX_INCLUDE_FILE__
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <netinet/in.h>
#if defined(__NetBSD__) || defined(__OpenBSD__)
#include <netinet/in_systm.h>
#if defined(__OpenBSD__)
#include <pthread.h>
#endif
#endif
#endif
#ifndef WIN32
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#endif
#endif /* __NDPI_UNIX_INCLUDE_FILE__ */
+68
View File
@@ -0,0 +1,68 @@
/*
* ndpi_win32.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_WIN32_H__
#define __NDPI_WIN32_H__
#include <winsock2.h>
#include <ws2tcpip.h>
#include <process.h>
#include <io.h>
#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */
#include <process.h> /* for getpid() and the exec..() family */
#include <stdint.h>
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#define _WS2TCPIP_H_ /* Avoid compilation problems */
extern char* strsep(char **sp, const char *sep);
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int uint;
typedef unsigned long u_long;
typedef u_char u_int8_t;
typedef u_short u_int16_t;
typedef uint u_int32_t;
typedef uint u_int;
typedef unsigned __int64 u_int64_t;
#define pthread_t HANDLE
#define pthread_mutex_t HANDLE
#define pthread_rwlock_t pthread_mutex_t
#define pthread_rwlock_init pthread_mutex_init
#define pthread_rwlock_wrlock pthread_mutex_lock
#define pthread_rwlock_rdlock pthread_mutex_lock
#define pthread_rwlock_unlock pthread_mutex_unlock
#define pthread_rwlock_destroy pthread_mutex_destroy
#define gmtime_r(a, b) memcpy(b, gmtime(a), sizeof(struct tm))
extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */);
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
#endif /* __NDPI_WIN32_H__ */
+166
View File
@@ -0,0 +1,166 @@
lib_LTLIBRARIES = libndpi.la
CFLAGS += -fPIC -DPIC
libndpi_la_CPPFLAGS = -I$(top_srcdir)/src/include/ -I$(top_srcdir)/src/lib/third_party/include/
libndpi_la_LDFLAGS = -version-info 1:0:0 -export-symbols $(top_srcdir)/libndpi.sym
libndpi_la_includedir = $(includedir)/libndpi-@VERSION@/libndpi
libndpi_la_include_HEADERS = ../include/ndpi_api.h \
../include/ndpi_define.h \
../include/ndpi_main.h \
../include/ndpi_includes.h \
../include/ndpi_protocol_ids.h \
../include/ndpi_protocols.h \
../include/ndpi_typedefs.h
libndpi_la_SOURCES = ndpi_content_match.c.inc \
ndpi_main.c \
protocols/afp.c \
protocols/aimini.c \
protocols/applejuice.c \
protocols/armagetron.c \
protocols/ayiya.c \
protocols/battlefield.c \
protocols/bgp.c \
protocols/bittorrent.c \
protocols/ciscovpn.c \
protocols/citrix.c \
protocols/coap.c \
protocols/collectd.c \
protocols/corba.c \
protocols/crossfire.c \
protocols/dcerpc.c \
protocols/dhcp.c \
protocols/dhcpv6.c \
protocols/directconnect.c \
protocols/directdownloadlink.c \
protocols/dns.c \
protocols/dofus.c \
protocols/drda.c \
protocols/dropbox.c \
protocols/eaq.c \
protocols/edonkey.c \
protocols/fasttrack.c \
protocols/fiesta.c \
protocols/filetopia.c \
protocols/florensia.c \
protocols/ftp_control.c \
protocols/ftp_data.c \
protocols/git.c \
protocols/gnutella.c \
protocols/gtp.c \
protocols/guildwars.c \
protocols/h323.c \
protocols/halflife2_and_mods.c \
protocols/hep.c \
protocols/http_activesync.c \
protocols/http.c \
protocols/iax.c \
protocols/icecast.c \
protocols/imesh.c \
protocols/ipp.c \
protocols/irc.c \
protocols/jabber.c \
protocols/kakaotalk_voice.c \
protocols/kerberos.c \
protocols/kontiki.c \
protocols/ldap.c \
protocols/lotus_notes.c \
protocols/mail_imap.c \
protocols/mail_pop.c \
protocols/mail_smtp.c \
protocols/maplestory.c \
protocols/mdns.c \
protocols/meebo.c \
protocols/megaco.c \
protocols/mgcp.c \
protocols/mms.c \
protocols/mpegts.c \
protocols/mqtt.c \
protocols/msn.c \
protocols/mssql.c \
protocols/mysql.c \
protocols/netbios.c \
protocols/netflow.c \
protocols/nfs.c \
protocols/noe.c \
protocols/non_tcp_udp.c \
protocols/ntp.c \
protocols/openft.c \
protocols/openvpn.c \
protocols/oracle.c \
protocols/oscar.c \
protocols/pando.c \
protocols/pcanywhere.c \
protocols/postgres.c \
protocols/pplive.c \
protocols/ppstream.c \
protocols/pptp.c \
protocols/qq.c \
protocols/quake.c \
protocols/quic.c \
protocols/radius.c \
protocols/rdp.c \
protocols/redis_net.c \
protocols/rsync.c \
protocols/rtcp.c \
protocols/rtmp.c \
protocols/rtp.c \
protocols/rtsp.c \
protocols/rx.c \
protocols/sflow.c \
protocols/shoutcast.c \
protocols/sip.c \
protocols/skinny.c \
protocols/skype.c \
protocols/smb.c \
protocols/snmp.c \
protocols/socks45.c \
protocols/socrates.c \
protocols/sopcast.c \
protocols/soulseek.c \
protocols/spotify.c \
protocols/ssdp.c \
protocols/ssh.c \
protocols/ssl.c \
protocols/starcraft.c \
protocols/stealthnet.c \
protocols/steam.c \
protocols/stun.c \
protocols/syslog.c \
protocols/tcp_udp.c \
protocols/tds.c \
protocols/teamspeak.c \
protocols/teamviewer.c \
protocols/telegram.c \
protocols/telnet.c \
protocols/tftp.c \
protocols/thunder.c \
protocols/tor.c \
protocols/teredo.c \
protocols/tvants.c \
protocols/tvuplayer.c \
protocols/twitter.c \
protocols/ubntac2.c \
protocols/usenet.c \
protocols/viber.c \
protocols/vhua.c \
protocols/vmware.c \
protocols/vnc.c \
protocols/warcraft3.c \
protocols/whoisdas.c \
protocols/world_of_kung_fu.c \
protocols/world_of_warcraft.c \
protocols/xbox.c \
protocols/xdmcp.c \
protocols/yahoo.c \
protocols/zattoo.c \
protocols/zeromq.c \
third_party/include/actypes.h \
third_party/include/ahocorasick.h \
third_party/include/node.h \
third_party/include/sort.h \
third_party/src/ahocorasick.c \
third_party/src/node.c \
third_party/src/sort.c
File diff suppressed because it is too large Load Diff
+4635
View File
File diff suppressed because it is too large Load Diff
+87
View File
@@ -0,0 +1,87 @@
/*
* afp.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_AFP
static void ndpi_int_afp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_afp(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;
/*
* this will detect the OpenSession command of the Data Stream Interface (DSI) protocol
* which is exclusively used by the Apple Filing Protocol (AFP) on TCP/IP networks
*/
if (packet->payload_packet_len >= 22 && get_u_int16_t(packet->payload, 0) == htons(0x0004) &&
get_u_int16_t(packet->payload, 2) == htons(0x0001) && get_u_int32_t(packet->payload, 4) == 0 &&
get_u_int32_t(packet->payload, 8) == htonl(packet->payload_packet_len - 16) &&
get_u_int32_t(packet->payload, 12) == 0 && get_u_int16_t(packet->payload, 16) == htons(0x0104)) {
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI OpenSession detected.\n");
ndpi_int_afp_add_connection(ndpi_struct, flow);
return;
}
/*
* detection of GetStatus command of DSI protocl
*/
if (packet->payload_packet_len >= 18 && get_u_int16_t(packet->payload, 0) == htons(0x0003) &&
get_u_int16_t(packet->payload, 2) == htons(0x0001) && get_u_int32_t(packet->payload, 4) == 0 &&
get_u_int32_t(packet->payload, 8) == htonl(packet->payload_packet_len - 16) &&
get_u_int32_t(packet->payload, 12) == 0 && get_u_int16_t(packet->payload, 16) == htons(0x0f00)) {
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP: DSI GetStatus detected.\n");
ndpi_int_afp_add_connection(ndpi_struct, flow);
return;
}
NDPI_LOG(NDPI_PROTOCOL_AFP, ndpi_struct, NDPI_LOG_DEBUG, "AFP excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AFP);
}
void init_afp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("AFP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_AFP,
ndpi_search_afp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+297
View File
@@ -0,0 +1,297 @@
/*
* aimini.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_AIMINI
static void ndpi_int_aimini_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow/* , */
/* ndpi_protocol_type_t protocol_type */)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AIMINI, NDPI_PROTOCOL_UNKNOWN);
}
static u_int8_t is_special_aimini_host(struct ndpi_int_one_line_struct host_line)
{
if (host_line.ptr != NULL && host_line.len >= NDPI_STATICSTRING_LEN("X.X.X.X.aimini.net")) {
if ((get_u_int32_t(host_line.ptr, 0) & htonl(0x00ff00ff)) == htonl(0x002e002e) &&
(get_u_int32_t(host_line.ptr, 4) & htonl(0x00ff00ff)) == htonl(0x002e002e) &&
memcmp(&host_line.ptr[8], "aimini.net", NDPI_STATICSTRING_LEN("aimini.net")) == 0) {
return 1;
}
}
return 0;
}
void ndpi_search_aimini(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "search aimini.\n");
if (packet->udp != NULL) {
if (flow->l4.udp.aimini_stage == 0) {
if (packet->payload_packet_len == 64 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010b) {
flow->l4.udp.aimini_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 1.\n");
return;
}
if (packet->payload_packet_len == 136
&& (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)) {
flow->l4.udp.aimini_stage = 4;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 4.\n");
return;
}
if (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101) {
flow->l4.udp.aimini_stage = 7;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 7.\n");
return;
}
if (packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) {
flow->l4.udp.aimini_stage = 10;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 10.\n");
return;
}
if (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) {
flow->l4.udp.aimini_stage = 13;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 13.\n");
return;
}
if (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) {
flow->l4.udp.aimini_stage = 16;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 16.\n");
return;
}
}
/* first packet chronology: (len, value): (64, 0x010b), (>100, 0x0115), (16, 0x010c || 64, 0x010b || 88, 0x0115),
* (16, 0x010c || 64, 0x010b || >100, 0x0115)
*/
if (flow->l4.udp.aimini_stage == 1 && packet->payload_packet_len > 100
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x0115) {
flow->l4.udp.aimini_stage = 2;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 2.\n");
return;
}
if (flow->l4.udp.aimini_stage == 2 &&
((packet->payload_packet_len == 16 && get_u_int16_t(packet->payload, 0) == htons(0x010c)) ||
(packet->payload_packet_len == 64 && get_u_int16_t(packet->payload, 0) == htons(0x010b)) ||
(packet->payload_packet_len == 88 && get_u_int16_t(packet->payload, 0) == ntohs(0x0115)))) {
flow->l4.udp.aimini_stage = 3;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 3.\n");
return;
}
if (flow->l4.udp.aimini_stage == 3
&& ((packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)
|| (packet->payload_packet_len == 64 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010b)
|| (packet->payload_packet_len > 100 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0115))) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "found aimini (64, 0x010b), (>300, 0x0115), "
"(16, 0x010c || 64, 0x010b), (16, 0x010c || 64, 0x010b || >100, 0x0115).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
/* second packet chronology: (len, value): (136, 0x01c9), (136, 0x01c9),(136, 0x01c9),(136, 0x01c9 || 32, 0x01ca) */
if (flow->l4.udp.aimini_stage == 4 && packet->payload_packet_len == 136
&& (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9 || ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)) {
flow->l4.udp.aimini_stage = 5;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 5.\n");
return;
}
if (flow->l4.udp.aimini_stage == 5 && (packet->payload_packet_len == 136
&& (ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9
|| ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165))) {
flow->l4.udp.aimini_stage = 6;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 6.\n");
return;
}
if (flow->l4.udp.aimini_stage == 6 && ((packet->payload_packet_len == 136
&& ((ntohs(get_u_int16_t(packet->payload, 0)) == 0x0165)
|| ntohs(get_u_int16_t(packet->payload, 0)) == 0x01c9))
|| (packet->payload_packet_len == 32
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (136, 0x01c9), (136, 0x01c9)," "(136, 0x01c9),(136, 0x01c9 || 32, 0x01ca).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
/* third packet chronology: (len, value): (88, 0x0101), (88, 0x0101),(88, 0x0101),(88, 0x0101) */
if (flow->l4.udp.aimini_stage == 7 && packet->payload_packet_len == 88
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101) {
flow->l4.udp.aimini_stage = 8;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 8.\n");
return;
}
if (flow->l4.udp.aimini_stage == 8
&& (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) {
flow->l4.udp.aimini_stage = 9;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 9.\n");
return;
}
if (flow->l4.udp.aimini_stage == 9
&& (packet->payload_packet_len == 88 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0101)) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (88, 0x0101), (88, 0x0101)," "(88, 0x0101),(88, 0x0101).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
/* fourth packet chronology: (len, value): (104, 0x0102), (104, 0x0102), (104, 0x0102), (104, 0x0102) */
if (flow->l4.udp.aimini_stage == 10 && packet->payload_packet_len == 104
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102) {
flow->l4.udp.aimini_stage = 11;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 11.\n");
return;
}
if (flow->l4.udp.aimini_stage == 11
&& (packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102)) {
flow->l4.udp.aimini_stage = 12;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 12.\n");
return;
}
if (flow->l4.udp.aimini_stage == 12
&& ((packet->payload_packet_len == 104 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0102)
|| (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (104, 0x0102), (104, 0x0102), " "(104, 0x0102), (104, 0x0102).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
/* fifth packet chronology (len, value): (32,0x01ca), (32,0x01ca), (32,0x01ca), ((136, 0x0166) || (32,0x01ca)) */
if (flow->l4.udp.aimini_stage == 13 && packet->payload_packet_len == 32
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca) {
flow->l4.udp.aimini_stage = 14;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 14.\n");
return;
}
if (flow->l4.udp.aimini_stage == 14
&& ((packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca)
|| (packet->payload_packet_len == 136 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0166))) {
flow->l4.udp.aimini_stage = 15;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 15.\n");
return;
}
if (flow->l4.udp.aimini_stage == 15
&& ((packet->payload_packet_len == 136 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0166)
|| (packet->payload_packet_len == 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x01ca))) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (32,0x01ca), (32,0x01ca), (32,0x01ca), ((136, 0x0166)||(32,0x01ca)).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
/* sixth packet chronology (len, value): (16, 0x010c), (16, 0x010c), (16, 0x010c), (16, 0x010c) */
if (flow->l4.udp.aimini_stage == 16 && packet->payload_packet_len == 16
&& ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c) {
flow->l4.udp.aimini_stage = 17;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 17.\n");
return;
}
if (flow->l4.udp.aimini_stage == 17
&& (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) {
flow->l4.udp.aimini_stage = 18;
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "stage = 18.\n");
return;
}
if (flow->l4.udp.aimini_stage == 18
&& (packet->payload_packet_len == 16 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x010c)) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"found aimini (16, 0x010c), (16, 0x010c), (16, 0x010c), (16, 0x010c).\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
} else if (packet->tcp != NULL) {
if ((packet->payload_packet_len > NDPI_STATICSTRING_LEN("GET /player/") &&
(memcmp(packet->payload, "GET /player/", NDPI_STATICSTRING_LEN("GET /player/")) == 0)) ||
(packet->payload_packet_len > NDPI_STATICSTRING_LEN("GET /play/?fid=") &&
(memcmp(packet->payload, "GET /play/?fid=", NDPI_STATICSTRING_LEN("GET /play/?fid=")) == 0))) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "HTTP packet detected.\n");
ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->host_line.ptr != NULL && packet->host_line.len > 11
&& (memcmp(&packet->host_line.ptr[packet->host_line.len - 11], ".aimini.net", 11) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "AIMINI HTTP traffic detected.\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
}
if (packet->payload_packet_len > 100) {
if (memcmp(packet->payload, "GET /", NDPI_STATICSTRING_LEN("GET /")) == 0) {
if (memcmp(&packet->payload[NDPI_STATICSTRING_LEN("GET /")], "play/",
NDPI_STATICSTRING_LEN("play/")) == 0 ||
memcmp(&packet->payload[NDPI_STATICSTRING_LEN("GET /")], "download/",
NDPI_STATICSTRING_LEN("download/")) == 0) {
ndpi_parse_packet_line_info(ndpi_struct, flow);
if (is_special_aimini_host(packet->host_line) == 1) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"AIMINI HTTP traffic detected.\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
}
} else if (memcmp(packet->payload, "POST /", NDPI_STATICSTRING_LEN("POST /")) == 0) {
if (memcmp(&packet->payload[NDPI_STATICSTRING_LEN("POST /")], "upload/",
NDPI_STATICSTRING_LEN("upload/")) == 0) {
ndpi_parse_packet_line_info(ndpi_struct, flow);
if (is_special_aimini_host(packet->host_line) == 1) {
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG,
"AIMINI HTTP traffic detected.\n");
ndpi_int_aimini_add_connection(ndpi_struct, flow);
return;
}
}
}
}
}
NDPI_LOG(NDPI_PROTOCOL_AIMINI, ndpi_struct, NDPI_LOG_DEBUG, "exclude aimini.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AIMINI);
}
void init_aimini_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Aimini", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_AIMINI,
ndpi_search_aimini,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+70
View File
@@ -0,0 +1,70 @@
/*
* applejuice.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_APPLEJUICE
static void ndpi_int_applejuice_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_APPLEJUICE, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_applejuice_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=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_APPLEJUICE, ndpi_struct, NDPI_LOG_DEBUG, "search applejuice.\n");
if ((packet->payload_packet_len > 7) && (packet->payload[6] == 0x0d)
&& (packet->payload[7] == 0x0a)
&& (memcmp(packet->payload, "ajprot", 6) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_APPLEJUICE, ndpi_struct, NDPI_LOG_DEBUG, "detected applejuice.\n");
ndpi_int_applejuice_add_connection(ndpi_struct, flow);
return;
}
NDPI_LOG(NDPI_PROTOCOL_APPLEJUICE, ndpi_struct, NDPI_LOG_DEBUG, "exclude applejuice.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_APPLEJUICE);
}
void init_applejuice_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("AppleJuice", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_APPLEJUICE,
ndpi_search_applejuice_tcp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+116
View File
@@ -0,0 +1,116 @@
/*
* armagetron.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_ARMAGETRON
static void ndpi_int_armagetron_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ARMAGETRON, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_armagetron_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "search armagetron.\n");
if (packet->payload_packet_len > 10) {
/* login request */
if (get_u_int32_t(packet->payload, 0) == htonl(0x000b0000)) {
const u_int16_t dataLength = ntohs(get_u_int16_t(packet->payload, 4));
if (dataLength == 0 || dataLength * 2 + 8 != packet->payload_packet_len)
goto exclude;
if (get_u_int16_t(packet->payload, 6) == htons(0x0008)
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) {
NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "detected armagetron.\n");
ndpi_int_armagetron_add_connection(ndpi_struct, flow);
return;
}
}
/* sync_msg */
if (packet->payload_packet_len == 16 && get_u_int16_t(packet->payload, 0) == htons(0x001c)
&& get_u_int16_t(packet->payload, 2) != 0) {
const u_int16_t dataLength = ntohs(get_u_int16_t(packet->payload, 4));
if (dataLength != 4)
goto exclude;
if (get_u_int32_t(packet->payload, 6) == htonl(0x00000500) && get_u_int32_t(packet->payload, 6 + 4) == htonl(0x00010000)
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) {
NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "detected armagetron.\n");
ndpi_int_armagetron_add_connection(ndpi_struct, flow);
return;
}
}
/* net_sync combination */
if (packet->payload_packet_len > 50 && get_u_int16_t(packet->payload, 0) == htons(0x0018)
&& get_u_int16_t(packet->payload, 2) != 0) {
u_int16_t val;
const u_int16_t dataLength = ntohs(get_u_int16_t(packet->payload, 4));
if (dataLength == 0 || dataLength * 2 + 8 > packet->payload_packet_len)
goto exclude;
val = get_u_int16_t(packet->payload, 6 + 2);
if (val == get_u_int16_t(packet->payload, 6 + 6)) {
val = ntohs(get_u_int16_t(packet->payload, 6 + 8));
if ((6 + 10 + val + 4) < packet->payload_packet_len
&& (get_u_int32_t(packet->payload, 6 + 10 + val) == htonl(0x00010000)
|| get_u_int32_t(packet->payload, 6 + 10 + val) == htonl(0x00000001))
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == 0) {
NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "detected armagetron.\n");
ndpi_int_armagetron_add_connection(ndpi_struct, flow);
return;
}
}
}
}
exclude:
NDPI_LOG(NDPI_PROTOCOL_ARMAGETRON, ndpi_struct, NDPI_LOG_DEBUG, "exclude armagetron.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_ARMAGETRON);
}
void init_armagetron_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Armagetron", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_ARMAGETRON,
ndpi_search_armagetron_udp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+93
View File
@@ -0,0 +1,93 @@
/*
* flash.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_FLASH
static void ndpi_int_flash_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FLASH);
}
void ndpi_search_flash(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (flow->l4.tcp.flash_stage == 0 && packet->payload_packet_len > 0
&& (packet->payload[0] == 0x03 || packet->payload[0] == 0x06)) {
flow->l4.tcp.flash_bytes = packet->payload_packet_len;
if (packet->tcp->psh == 0) {
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG, "FLASH pass 1: \n");
flow->l4.tcp.flash_stage = packet->packet_direction + 1;
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG,
"FLASH pass 1: flash_stage: %u, flash_bytes: %u\n", flow->l4.tcp.flash_stage,
flow->l4.tcp.flash_bytes);
return;
} else if (packet->tcp->psh != 0 && flow->l4.tcp.flash_bytes == 1537) {
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG,
"FLASH hit: flash_stage: %u, flash_bytes: %u\n", flow->l4.tcp.flash_stage,
flow->l4.tcp.flash_bytes);
flow->l4.tcp.flash_stage = 3;
ndpi_int_flash_add_connection(ndpi_struct, flow);
return;
}
} else if (flow->l4.tcp.flash_stage == 1 + packet->packet_direction) {
flow->l4.tcp.flash_bytes += packet->payload_packet_len;
if (packet->tcp->psh != 0 && flow->l4.tcp.flash_bytes == 1537) {
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG,
"FLASH hit: flash_stage: %u, flash_bytes: %u\n", flow->l4.tcp.flash_stage,
flow->l4.tcp.flash_bytes);
flow->l4.tcp.flash_stage = 3;
ndpi_int_flash_add_connection(ndpi_struct, flow);
return;
} else if (packet->tcp->psh == 0 && flow->l4.tcp.flash_bytes < 1537) {
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG,
"FLASH pass 2: flash_stage: %u, flash_bytes: %u\n", flow->l4.tcp.flash_stage,
flow->l4.tcp.flash_bytes);
return;
}
}
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG,
"FLASH might be excluded: flash_stage: %u, flash_bytes: %u, packet_direction: %u\n",
flow->l4.tcp.flash_stage, flow->l4.tcp.flash_bytes, packet->packet_direction);
#ifdef NDPI_PROTOCOL_HTTP
if (NDPI_COMPARE_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP) != 0) {
#endif /* NDPI_PROTOCOL_HTTP */
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG, "FLASH: exclude\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FLASH);
#ifdef NDPI_PROTOCOL_HTTP
} else {
NDPI_LOG(NDPI_PROTOCOL_FLASH, ndpi_struct, NDPI_LOG_DEBUG, "FLASH avoid early exclude from http\n");
}
#endif /* NDPI_PROTOCOL_HTTP */
}
#endif
+469
View File
@@ -0,0 +1,469 @@
/*
* ftp.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#include "ndpi_utils.h"
#ifdef NDPI_PROTOCOL_FTP
static void ndpi_int_ftp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FTP);
}
/**
* checks for possible FTP command
* not all valid commands are tested, it just need to be 3 or 4 characters followed by a space if the
* packet is longer
*
* this functions is not used to accept, just to not reject
*/
#if !defined(WIN32)
static inline
#else
__forceinline static
#endif
u_int8_t ndpi_int_check_possible_ftp_command(const struct ndpi_packet_struct *packet)
{
if (packet->payload_packet_len < 3)
return 0;
if ((packet->payload[0] < 'a' || packet->payload[0] > 'z') &&
(packet->payload[0] < 'A' || packet->payload[0] > 'Z'))
return 0;
if ((packet->payload[1] < 'a' || packet->payload[1] > 'z') &&
(packet->payload[1] < 'A' || packet->payload[1] > 'Z'))
return 0;
if ((packet->payload[2] < 'a' || packet->payload[2] > 'z') &&
(packet->payload[2] < 'A' || packet->payload[2] > 'Z'))
return 0;
if (packet->payload_packet_len > 3) {
if ((packet->payload[3] < 'a' || packet->payload[3] > 'z') &&
(packet->payload[3] < 'A' || packet->payload[3] > 'Z') && packet->payload[3] != ' ')
return 0;
if (packet->payload_packet_len > 4) {
if (packet->payload[3] != ' ' && packet->payload[4] != ' ')
return 0;
}
}
return 1;
}
/**
* ftp replies are are 3-digit number followed by space or hyphen
*/
#if !defined(WIN32)
static inline
#else
__forceinline static
#endif
u_int8_t ndpi_int_check_possible_ftp_reply(const struct ndpi_packet_struct *packet)
{
if (packet->payload_packet_len < 5)
return 0;
if (packet->payload[3] != ' ' && packet->payload[3] != '-')
return 0;
if (packet->payload[0] < '0' || packet->payload[0] > '9')
return 0;
if (packet->payload[1] < '0' || packet->payload[1] > '9')
return 0;
if (packet->payload[2] < '0' || packet->payload[2] > '9')
return 0;
return 1;
}
/**
* check for continuation replies
* there is no real indication whether it is a continuation message, we just
* require that there are at least 5 ascii characters
*/
#if !defined(WIN32)
static inline
#else
__forceinline static
#endif
u_int8_t ndpi_int_check_possible_ftp_continuation_reply(const struct ndpi_packet_struct *packet)
{
u_int16_t i;
if (packet->payload_packet_len < 5)
return 0;
for (i = 0; i < 5; i++) {
if (packet->payload[i] < ' ' || packet->payload[i] > 127)
return 0;
}
return 1;
}
/*
* these are the commands we tracking and expecting to see
*/
enum {
FTP_USER_CMD = 1 << 0,
FTP_FEAT_CMD = 1 << 1,
FTP_COMMANDS = ((1 << 2) - 1),
FTP_220_CODE = 1 << 2,
FTP_331_CODE = 1 << 3,
FTP_211_CODE = 1 << 4,
FTP_CODES = ((1 << 5) - 1 - FTP_COMMANDS)
};
/*
return 0 if nothing has been detected
return 1 if a pop packet
*/
static u_int8_t search_ftp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int8_t current_ftp_code = 0;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
/* initiate client direction flag */
if (flow->packet_counter == 1) {
if (flow->l4.tcp.seen_syn) {
flow->l4.tcp.ftp_client_direction = flow->setup_packet_direction;
} else {
/* no syn flag seen so guess */
if (packet->payload_packet_len > 0) {
if (packet->payload[0] >= '0' && packet->payload[0] <= '9') {
/* maybe server side */
flow->l4.tcp.ftp_client_direction = 1 - packet->packet_direction;
} else {
flow->l4.tcp.ftp_client_direction = packet->packet_direction;
}
}
}
}
if (packet->packet_direction == flow->l4.tcp.ftp_client_direction) {
if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("USER ") &&
(memcmp(packet->payload, "USER ", NDPI_STATICSTRING_LEN("USER ")) == 0 ||
memcmp(packet->payload, "user ", NDPI_STATICSTRING_LEN("user ")) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP: found USER command\n");
flow->l4.tcp.ftp_codes_seen |= FTP_USER_CMD;
current_ftp_code = FTP_USER_CMD;
} else if (packet->payload_packet_len >= NDPI_STATICSTRING_LEN("FEAT") &&
(memcmp(packet->payload, "FEAT", NDPI_STATICSTRING_LEN("FEAT")) == 0 ||
memcmp(packet->payload, "feat", NDPI_STATICSTRING_LEN("feat")) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP: found FEAT command\n");
flow->l4.tcp.ftp_codes_seen |= FTP_FEAT_CMD;
current_ftp_code = FTP_FEAT_CMD;
} else if (!ndpi_int_check_possible_ftp_command(packet)) {
return 0;
}
} else {
if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("220 ") &&
(memcmp(packet->payload, "220 ", NDPI_STATICSTRING_LEN("220 ")) == 0 ||
memcmp(packet->payload, "220-", NDPI_STATICSTRING_LEN("220-")) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP: found 220 reply code\n");
flow->l4.tcp.ftp_codes_seen |= FTP_220_CODE;
current_ftp_code = FTP_220_CODE;
} else if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("331 ") &&
(memcmp(packet->payload, "331 ", NDPI_STATICSTRING_LEN("331 ")) == 0 ||
memcmp(packet->payload, "331-", NDPI_STATICSTRING_LEN("331-")) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP: found 331 reply code\n");
flow->l4.tcp.ftp_codes_seen |= FTP_331_CODE;
current_ftp_code = FTP_331_CODE;
} else if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("211 ") &&
(memcmp(packet->payload, "211 ", NDPI_STATICSTRING_LEN("211 ")) == 0 ||
memcmp(packet->payload, "211-", NDPI_STATICSTRING_LEN("211-")) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP: found 211reply code\n");
flow->l4.tcp.ftp_codes_seen |= FTP_211_CODE;
current_ftp_code = FTP_211_CODE;
} else if (!ndpi_int_check_possible_ftp_reply(packet)) {
if ((flow->l4.tcp.ftp_codes_seen & FTP_CODES) == 0 ||
(!ndpi_int_check_possible_ftp_continuation_reply(packet))) {
return 0;
}
}
}
if ((flow->l4.tcp.ftp_codes_seen & FTP_COMMANDS) != 0 && (flow->l4.tcp.ftp_codes_seen & FTP_CODES) != 0) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP detected\n");
ndpi_int_ftp_add_connection(ndpi_struct, flow);
return 1;
}
/* if no valid code has been seen for the first packets reject */
if (flow->l4.tcp.ftp_codes_seen == 0 && flow->packet_counter > 3)
return 0;
/* otherwise wait more packets, wait more for traffic on known ftp port */
if ((packet->packet_direction == flow->setup_packet_direction && packet->tcp && packet->tcp->dest == htons(21)) ||
(packet->packet_direction != flow->setup_packet_direction && packet->tcp && packet->tcp->source == htons(21))) {
/* flow to known ftp port */
/* wait much longer if this was a 220 code, initial messages might be long */
if (current_ftp_code == FTP_220_CODE) {
if (flow->packet_counter > 40)
return 0;
} else {
if (flow->packet_counter > 20)
return 0;
}
} else {
/* wait much longer if this was a 220 code, initial messages might be long */
if (current_ftp_code == FTP_220_CODE) {
if (flow->packet_counter > 20)
return 0;
} else {
if (flow->packet_counter > 10)
return 0;
}
}
return 2;
}
static void search_passive_ftp_mode(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
struct ndpi_id_struct *dst = flow->dst;
struct ndpi_id_struct *src = flow->src;
u_int16_t plen;
u_int8_t i;
u_int32_t ftp_ip;
// TODO check if normal passive mode also needs adaption for ipv6
if (packet->payload_packet_len > 3 && ndpi_mem_cmp(packet->payload, "227 ", 4) == 0) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP passive mode initial string\n");
plen = 4; //=4 for "227 "
while (1) {
if (plen >= packet->payload_packet_len) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"plen >= packet->payload_packet_len, return\n");
return;
}
if (packet->payload[plen] == '(') {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "found (. break.\n");
break;
}
/* if (!isalnum(packet->payload[plen])) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "no alpha numeric symbol --> break.\n");
return;
}*/
plen++;
}
plen++;
if (plen >= packet->payload_packet_len)
return;
ftp_ip = 0;
for (i = 0; i < 4; i++) {
u_int16_t oldplen = plen;
ftp_ip =
(ftp_ip << 8) +
ndpi_bytestream_to_number(&packet->payload[plen], packet->payload_packet_len - plen, &plen);
if (oldplen == plen || plen >= packet->payload_packet_len) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP passive mode %u value parse failed\n",
i);
return;
}
if (packet->payload[plen] != ',') {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"FTP passive mode %u value parse failed, char ',' is missing\n", i);
return;
}
plen++;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"FTP passive mode %u value parsed, ip is now: %u\n", i, ftp_ip);
}
if (dst != NULL) {
dst->ftp_ip.ipv4 = htonl(ftp_ip);
dst->ftp_timer = packet->tick_timestamp;
dst->ftp_timer_set = 1;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "saved ftp_ip, ftp_timer, ftp_timer_set to dst");
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP PASSIVE MODE FOUND: use Server %s\n",
ndpi_get_ip_string(ndpi_struct, &dst->ftp_ip));
}
if (src != NULL) {
src->ftp_ip.ipv4 = packet->iph->daddr;
src->ftp_timer = packet->tick_timestamp;
src->ftp_timer_set = 1;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "saved ftp_ip, ftp_timer, ftp_timer_set to src");
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP PASSIVE MODE FOUND: use Server %s\n",
ndpi_get_ip_string(ndpi_struct, &src->ftp_ip));
}
return;
}
if (packet->payload_packet_len > 34 && ndpi_mem_cmp(packet->payload, "229 Entering Extended Passive Mode", 34) == 0) {
if (dst != NULL) {
ndpi_packet_src_ip_get(packet, &dst->ftp_ip);
dst->ftp_timer = packet->tick_timestamp;
dst->ftp_timer_set = 1;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "saved ftp_ip, ftp_timer, ftp_timer_set to dst");
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"FTP Extended PASSIVE MODE FOUND: use Server %s\n", ndpi_get_ip_string(ndpi_struct, &dst->ftp_ip));
}
if (src != NULL) {
ndpi_packet_dst_ip_get(packet, &src->ftp_ip);
src->ftp_timer = packet->tick_timestamp;
src->ftp_timer_set = 1;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "saved ftp_ip, ftp_timer, ftp_timer_set to src");
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"FTP Extended PASSIVE MODE FOUND: use Server %s\n", ndpi_get_ip_string(ndpi_struct, &src->ftp_ip));
}
return;
}
}
static void search_active_ftp_mode(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->payload_packet_len > 5
&& (ndpi_mem_cmp(packet->payload, "PORT ", 5) == 0 || ndpi_mem_cmp(packet->payload, "EPRT ", 5) == 0)) {
//src->local_ftp_data_port = htons(data_port_number);
if (src != NULL) {
ndpi_packet_dst_ip_get(packet, &src->ftp_ip);
src->ftp_timer = packet->tick_timestamp;
src->ftp_timer_set = 1;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP ACTIVE MODE FOUND, command is %.*s\n", 4,
packet->payload);
}
if (dst != NULL) {
ndpi_packet_src_ip_get(packet, &dst->ftp_ip);
dst->ftp_timer = packet->tick_timestamp;
dst->ftp_timer_set = 1;
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "FTP ACTIVE MODE FOUND, command is %.*s\n", 4,
packet->payload);
}
}
return;
}
void ndpi_search_ftp_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 (src != NULL && ndpi_packet_dst_ip_eql(packet, &src->ftp_ip)
&& packet->tcp->syn != 0 && packet->tcp->ack == 0
&& packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(src->detected_protocol_bitmask,
NDPI_PROTOCOL_FTP) != 0 && src->ftp_timer_set != 0) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "possible ftp data, src!= 0.\n");
if (((u_int32_t)
(packet->tick_timestamp - src->ftp_timer)) >= ndpi_struct->ftp_connection_timeout) {
src->ftp_timer_set = 0;
} else if (ntohs(packet->tcp->dest) > 1024
&& (ntohs(packet->tcp->source) > 1024 || ntohs(packet->tcp->source) == 20)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "detected FTP data stream.\n");
ndpi_int_ftp_add_connection(ndpi_struct, flow);
return;
}
}
if (dst != NULL && ndpi_packet_src_ip_eql(packet, &dst->ftp_ip)
&& packet->tcp->syn != 0 && packet->tcp->ack == 0
&& packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask,
NDPI_PROTOCOL_FTP) != 0 && dst->ftp_timer_set != 0) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "possible ftp data; dst!= 0.\n");
if (((u_int32_t)
(packet->tick_timestamp - dst->ftp_timer)) >= ndpi_struct->ftp_connection_timeout) {
dst->ftp_timer_set = 0;
} else if (ntohs(packet->tcp->dest) > 1024
&& (ntohs(packet->tcp->source) > 1024 || ntohs(packet->tcp->source) == 20)) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "detected FTP data stream.\n");
ndpi_int_ftp_add_connection(ndpi_struct, flow);
return;
}
}
// ftp data asymmetrically
/* skip packets without payload */
if (packet->payload_packet_len == 0) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"FTP test skip because of data connection or zero byte packet_payload.\n");
return;
}
/* skip excluded connections */
// we test for FTP connection and search for passive mode
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_FTP) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG,
"detected ftp command mode. going to test data mode.\n");
search_passive_ftp_mode(ndpi_struct, flow);
search_active_ftp_mode(ndpi_struct, flow);
return;
}
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN && search_ftp(ndpi_struct, flow) != 0) {
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "unknown. need next packet.\n");
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP);
NDPI_LOG(NDPI_PROTOCOL_FTP, ndpi_struct, NDPI_LOG_DEBUG, "exclude ftp.\n");
}
#endif
+180
View File
@@ -0,0 +1,180 @@
/*
* manolito.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_MANOLITO
static void ndpi_int_manolito_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_MANOLITO);
if (src != NULL) {
if (packet->udp != NULL) {
src->manolito_last_pkt_arrival_time = packet->tick_timestamp;
}
}
if (dst != NULL) {
if (packet->udp != NULL) {
dst->manolito_last_pkt_arrival_time = packet->tick_timestamp;
}
}
}
/*
return 0 if nothing has been detected
return 1 if it is a megaupload packet
*/
u_int8_t search_manolito_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
u_int8_t search_manolito_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;
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO TCP DETECTION\n");
if (flow->l4.tcp.manolito_stage == 0 && packet->payload_packet_len > 6) {
if (memcmp(packet->payload, "SIZ ", 4) != 0)
goto end_manolito_nothing_found;
flow->l4.tcp.manolito_stage = 1 + packet->packet_direction;
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO Stage 1.\n");
goto end_manolito_maybe_hit;
} else if ((flow->l4.tcp.manolito_stage == 2 - packet->packet_direction)
&& packet->payload_packet_len > 4) {
if (memcmp(packet->payload, "STR ", 4) != 0)
goto end_manolito_nothing_found;
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO Stage 2.\n");
flow->l4.tcp.manolito_stage = 3 + packet->packet_direction;
goto end_manolito_maybe_hit;
} else if ((flow->l4.tcp.manolito_stage == 4 - packet->packet_direction) && packet->payload_packet_len > 5) {
if (memcmp(packet->payload, "MD5 ", 4) != 0)
goto end_manolito_nothing_found;
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO Stage 3.\n");
flow->l4.tcp.manolito_stage = 5 + packet->packet_direction;
goto end_manolito_maybe_hit;
} else if ((flow->l4.tcp.manolito_stage == 6 - packet->packet_direction) && packet->payload_packet_len == 4) {
if (memcmp(packet->payload, "GO!!", 4) != 0)
goto end_manolito_nothing_found;
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO Stage 4.\n");
goto end_manolito_found;
}
//NDPI_LOG(NDPI_PROTOCOL_MANOLITO,ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO FLOW STAGE %d\n", flow->l4.tcp.manolito_stage);
goto end_manolito_nothing_found;
end_manolito_found:
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO FOUND\n");
ndpi_int_manolito_add_connection(ndpi_struct, flow);
return 1;
end_manolito_maybe_hit:
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO maybe hit.\n");
return 2;
end_manolito_nothing_found:
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO NOTHING FOUND\n");
return 0;
}
void ndpi_search_manolito_tcp_udp(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->tcp != NULL) {
if (search_manolito_tcp(ndpi_struct, flow) != 0)
return;
} else if (packet->udp != NULL) {
if (flow->detected_protocol_stack[0] == NDPI_PROTOCOL_MANOLITO) {
if (src != NULL) {
src->manolito_last_pkt_arrival_time = packet->tick_timestamp;
}
if (dst != NULL) {
dst->manolito_last_pkt_arrival_time = packet->tick_timestamp;
}
return;
} else if (packet->udp->source == htons(41170)
|| packet->udp->dest == htons(41170)) {
if (src != NULL && src->manolito_last_pkt_arrival_time != 0
&& (packet->tick_timestamp - src->manolito_last_pkt_arrival_time <
ndpi_struct->manolito_subscriber_timeout)) {
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO: UDP detected \n");
ndpi_int_manolito_add_connection(ndpi_struct, flow);
return;
} else if (src != NULL
&& (packet->tick_timestamp - src->manolito_last_pkt_arrival_time) >=
ndpi_struct->manolito_subscriber_timeout) {
src->manolito_last_pkt_arrival_time = 0;
}
if (dst != NULL && dst->manolito_last_pkt_arrival_time != 0
&& (packet->tick_timestamp - dst->manolito_last_pkt_arrival_time <
ndpi_struct->manolito_subscriber_timeout)) {
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO: UDP detected \n");
ndpi_int_manolito_add_connection(ndpi_struct, flow);
return;
} else if (dst != NULL
&& (packet->tick_timestamp - dst->manolito_last_pkt_arrival_time) >=
ndpi_struct->manolito_subscriber_timeout) {
dst->manolito_last_pkt_arrival_time = 0;
}
if ((packet->payload_packet_len == 20 && htons(0x3d4b) == get_u_int16_t(packet->payload, 0)
&& packet->payload[2] == 0xd9 && htons(0xedbb) == get_u_int16_t(packet->payload, 16))
|| (packet->payload_packet_len == 25 && htons(0x3e4a) == get_u_int16_t(packet->payload, 0)
&& htons(0x092f) == get_u_int16_t(packet->payload, 20) && packet->payload[22] == 0x20)
|| (packet->payload_packet_len == 20 && !get_u_int16_t(packet->payload, 2) && !get_u_int32_t(packet->payload, 8)
&& !get_u_int16_t(packet->payload, 18) && get_u_int16_t(packet->payload, 0))
) { //20B pkt is For PING
NDPI_LOG(NDPI_PROTOCOL_MANOLITO, ndpi_struct, NDPI_LOG_DEBUG, "MANOLITO: UDP detected \n");
ndpi_int_manolito_add_connection(ndpi_struct, flow);
return;
} else if (flow->packet_counter < 7) {
return;
}
}
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MANOLITO);
}
#endif
+86
View File
@@ -0,0 +1,86 @@
/*
* popo.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_POPO
static void ndpi_int_popo_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_POPO);
}
void ndpi_search_popo_tcp_udp(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->tcp != NULL) {
if ((packet->payload_packet_len == 20)
&& get_u_int32_t(packet->payload, 0) == htonl(0x0c000000)
&& get_u_int32_t(packet->payload, 4) == htonl(0x01010000)
&& get_u_int32_t(packet->payload, 8) == htonl(0x06000000)
&& get_u_int32_t(packet->payload, 12) == 0 && get_u_int32_t(packet->payload, 16) == 0) {
NDPI_LOG(NDPI_PROTOCOL_POPO, ndpi_struct, NDPI_LOG_DEBUG, "POPO detected\n");
ndpi_int_popo_add_connection(ndpi_struct, flow);
return;
}
if (NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_POPO) != 0) {
#define NDPI_POPO_IP_SUBNET_START ( (220 << 24) + (181 << 16) + (28 << 8) + 220)
#define NDPI_POPO_IP_SUBNET_END ( (220 << 24) + (181 << 16) + (28 << 8) + 238)
/* may match the first payload ip packet only ... */
if (ntohl(packet->iph->daddr) >= NDPI_POPO_IP_SUBNET_START
&& ntohl(packet->iph->daddr) <= NDPI_POPO_IP_SUBNET_END) {
NDPI_LOG(NDPI_PROTOCOL_POPO, ndpi_struct, NDPI_LOG_DEBUG, "POPO ip subnet detected\n");
ndpi_int_popo_add_connection(ndpi_struct, flow);
return;
}
}
}
if (packet->payload_packet_len > 13 && packet->payload_packet_len == get_l32(packet->payload, 0)
&& !get_l16(packet->payload, 12)) {
register u_int16_t ii;
for (ii = 14; ii < 50 && ii < packet->payload_packet_len - 8; ++ii) {
if (packet->payload[ii] == '@')
if (!memcmp(&packet->payload[ii + 1], "163.com", 7)
|| (ii <= packet->payload_packet_len - 13 && !memcmp(&packet->payload[ii + 1], "popo.163.com", 12))) {
NDPI_LOG(NDPI_PROTOCOL_POPO, ndpi_struct, NDPI_LOG_DEBUG, "POPO detected.\n");
ndpi_int_popo_add_connection(ndpi_struct, flow);
return;
}
}
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_POPO);
}
#endif
+123
View File
@@ -0,0 +1,123 @@
/*
* secondlife.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_utils.h"
#ifdef NDPI_PROTOCOL_SECONDLIFE
static void ndpi_int_secondlife_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow/* , */
/* ndpi_protocol_type_t protocol_type */)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SECONDLIFE, protocol_type);
}
void ndpi_search_secondlife(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
// if ((ntohs(packet->udp->dest) == 12035 || ntohs(packet->udp->dest) == 12036 || (ntohs(packet->udp->dest) >= 13000 && ntohs(packet->udp->dest) <= 13050)) //port
// && packet->payload_packet_len > 6 // min length with no extra header, high frequency and 1 byte message body
// && get_u_int8_t(packet->payload, 0) == 0x40 // reliable packet
// && ntohl(get_u_int32_t(packet->payload, 1)) == 0x00000001 // sequence number equals 1
// //ntohl (get_u_int32_t (packet->payload, 5)) == 0x00FFFF00 // no extra header, low frequency message - can't use, message may have higher frequency
// ) {
// NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life detected.\n");
// ndpi_int_secondlife_add_connection(ndpi_struct, flow);
// return;
// }
if (packet->tcp != NULL) {
if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("GET /")
&& memcmp(packet->payload, "GET /", NDPI_STATICSTRING_LEN("GET /")) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life HTTP 'GET /'' found.\n");
ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->user_agent_line.ptr != NULL
&& packet->user_agent_line.len >
NDPI_STATICSTRING_LEN
("Mozilla/5.0 (Windows; U; Windows NT 6.1; de-DE) AppleWebKit/532.4 (KHTML, like Gecko) SecondLife/")
&& memcmp(&packet->user_agent_line.ptr[NDPI_STATICSTRING_LEN
("Mozilla/5.0 (Windows; U; Windows NT 6.1; de-DE) AppleWebKit/532.4 (KHTML, like Gecko) ")],
"SecondLife/", NDPI_STATICSTRING_LEN("SecondLife/")) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG,
"Second Life TCP HTTP User Agent detected.\n");
ndpi_int_secondlife_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
return;
}
if (packet->host_line.ptr != NULL && packet->host_line.len > NDPI_STATICSTRING_LEN(".agni.lindenlab.com:")) {
u_int8_t x;
for (x = 2; x < 6; x++) {
if (packet->host_line.ptr[packet->host_line.len - (1 + x)] == ':') {
if ((1 + x + NDPI_STATICSTRING_LEN(".agni.lindenlab.com")) < packet->host_line.len
&& memcmp(&packet->host_line.ptr[packet->host_line.len -
(1 + x + NDPI_STATICSTRING_LEN(".agni.lindenlab.com"))],
".agni.lindenlab.com", NDPI_STATICSTRING_LEN(".agni.lindenlab.com")) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG,
"Second Life TCP HTTP Host detected.\n");
ndpi_int_secondlife_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
return;
}
break;
}
}
}
}
}
if (packet->udp != NULL) {
if (packet->payload_packet_len == 46
&& memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\xff\xff\x00\x03", 10) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0xffff0003 detected.\n");
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len == 54
&& memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\xff\xff\x00\x52", 10) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0xffff0052 detected.\n");
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len == 58
&& memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\xff\xff\x00\xa9", 10) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0xffff00a9 detected.\n");
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len > 54 && memcmp(packet->payload, "\x40\x00\x00\x00\x01\x00\x08", 7) == 0 &&
get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == 0) {
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life 0x08 detected.\n");
ndpi_int_secondlife_add_connection(ndpi_struct, flow);
return;
}
}
NDPI_LOG(NDPI_PROTOCOL_SECONDLIFE, ndpi_struct, NDPI_LOG_DEBUG, "Second Life excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_SECONDLIFE);
}
#endif
+81
View File
@@ -0,0 +1,81 @@
/*
* ayiya.c
*
* Copyright (C) 2011-15 - 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/>.
*
*/
/*
http://en.wikipedia.org/wiki/Anything_In_Anything
http://tools.ietf.org/html/rfc4891
*/
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_AYIYA
struct ayiya {
u_int8_t flags[3];
u_int8_t next_header;
u_int32_t epoch;
u_int8_t identity[16];
u_int8_t signature[20];
};
void ndpi_search_ayiya(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)) {
/* Ayiya is udp based, port 5072 */
if ((packet->udp->source == htons(5072) || packet->udp->dest == htons(5072))
/* check for ayiya new packet */
&& (packet->payload_packet_len > 44)
) {
/* FINISH */
struct ayiya *a = (struct ayiya*)packet->payload;
u_int32_t epoch = ntohl(a->epoch), now;
u_int32_t fireyears = 86400 * 365 * 5;
now = flow->packet.tick_timestamp;
if((epoch >= (now - fireyears)) && (epoch <= (now+86400 /* 1 day */)))
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AYIYA, NDPI_PROTOCOL_UNKNOWN);
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AYIYA);
}
}
void init_ayiya_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Ayiya", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_AYIYA,
ndpi_search_ayiya,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+130
View File
@@ -0,0 +1,130 @@
/*
* battlefield.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_BATTLEFIELD
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(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG,
"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(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG,
"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(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct,
NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG,
"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(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_BATTLEFIELD, ndpi_struct, NDPI_LOG_DEBUG, "Battlefield safe pattern detected.\n");
ndpi_int_battlefield_add_connection(ndpi_struct, flow);
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BATTLEFIELD);
return;
}
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;
}
#endif
+70
View File
@@ -0,0 +1,70 @@
/*
* bgp.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_BGP
static void ndpi_int_bgp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BGP, NDPI_PROTOCOL_UNKNOWN);
}
/* this detection also works asymmetrically */
void ndpi_search_bgp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t bgp_port = htons(179);
if(packet->tcp
&& (packet->payload[18] < 5)
&& ((packet->tcp->dest == bgp_port) || (packet->tcp->source == bgp_port))
&& (packet->payload_packet_len > 18)
&& (get_u_int64_t(packet->payload, 0) == 0xffffffffffffffffULL)
&& (get_u_int64_t(packet->payload, 8) == 0xffffffffffffffffULL)
&& (ntohs(get_u_int16_t(packet->payload, 16)) <= packet->payload_packet_len)
) {
NDPI_LOG(NDPI_PROTOCOL_BGP, ndpi_struct, NDPI_LOG_DEBUG, "BGP detected.\n");
ndpi_int_bgp_add_connection(ndpi_struct, flow);
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BGP);
}
void init_bgp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("BGP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_BGP,
ndpi_search_bgp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+513
View File
@@ -0,0 +1,513 @@
/*
* bittorrent.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_BITTORRENT
#define NDPI_PROTOCOL_UNSAFE_DETECTION 0
#define NDPI_PROTOCOL_SAFE_DETECTION 1
#define NDPI_PROTOCOL_PLAIN_DETECTION 0
#define NDPI_PROTOCOL_WEBSEED_DETECTION 2
struct ndpi_utp_hdr {
u_int8_t h_version:4, h_type:4, next_extension;
u_int16_t connection_id;
u_int32_t ts_usec, tdiff_usec, window_size;
u_int16_t sequence_nr, ack_nr;
};
static u_int8_t is_utp_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);
if(h->h_version != 1) return(0);
if(h->h_type > 4) return(0);
if(h->next_extension > 2) return(0);
if(ntohl(h->window_size) > 65565) return(0);
return(1);
}
static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
int bt_offset, int check_hash,
const u_int8_t save_detection, const u_int8_t encrypted_connection)
{
if(check_hash) {
const char *bt_hash = NULL; /* 20 bytes long */
const char *peer_id = 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);
if(bt_magic)
bt_hash = &bt_magic[19], peer_id = &bt_magic[39];
} else
bt_hash = (const char*)&flow->packet.payload[28], peer_id = (const char*)&flow->packet.payload[48];
if(bt_hash) memcpy(flow->bittorent_hash, bt_hash, 20);
}
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, NDPI_PROTOCOL_UNKNOWN);
}
static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t a = 0;
if(packet->payload_packet_len == 1 && packet->payload[0] == 0x13) {
/* reset stage back to 0 so we will see the next packet here too */
flow->bittorrent_stage = 0;
return 0;
}
if(flow->packet_counter == 2 && packet->payload_packet_len > 20) {
if(memcmp(&packet->payload[0], "BitTorrent protocol", 19) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 19, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
}
if(packet->payload_packet_len > 20) {
/* test for match 0x13+"BitTorrent protocol" */
if(packet->payload[0] == 0x13) {
if(memcmp(&packet->payload[1], "BitTorrent protocol", 19) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, 20, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
}
}
if(packet->payload_packet_len > 23 && memcmp(packet->payload, "GET /webseed?info_hash=", 23) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "BT: plain webseed BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1;
}
/* seen Azureus as server for webseed, possibly other servers existing, to implement */
/* is Server: hypertracker Bittorrent? */
/* no asymmetric detection possible for answer of pattern "GET /data?fid=". */
if(packet->payload_packet_len > 60
&& memcmp(packet->payload, "GET /data?fid=", 14) == 0 && memcmp(&packet->payload[54], "&size=", 6) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "BT: plain Bitcomet persistent seed protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1;
}
if(packet->payload_packet_len > 90 && (memcmp(packet->payload, "GET ", 4) == 0
|| memcmp(packet->payload, "POST ", 5) == 0)) {
const u_int8_t *ptr = &packet->payload[4];
u_int16_t len = packet->payload_packet_len - 4;
/* parse complete get packet here into line structure elements */
ndpi_parse_packet_line_info(ndpi_struct, flow);
/* answer to this pattern is HTTP....Server: hypertracker */
if(packet->user_agent_line.ptr != NULL
&& ((packet->user_agent_line.len > 8 && memcmp(packet->user_agent_line.ptr, "Azureus ", 8) == 0)
|| (packet->user_agent_line.len >= 10 && memcmp(packet->user_agent_line.ptr, "BitTorrent", 10) == 0)
|| (packet->user_agent_line.len >= 11 && memcmp(packet->user_agent_line.ptr, "BTWebClient", 11) == 0))) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "Azureus /Bittorrent user agent line detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1;
}
if(packet->user_agent_line.ptr != NULL
&& (packet->user_agent_line.len >= 9 && memcmp(packet->user_agent_line.ptr, "Shareaza ", 9) == 0)
&& (packet->parsed_lines > 8 && packet->line[8].ptr != 0
&& packet->line[8].len >= 9 && memcmp(packet->line[8].ptr, "X-Queue: ", 9) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "Bittorrent Shareaza detected.\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1;
}
/* this is a self built client, not possible to catch asymmetrically */
if((packet->parsed_lines == 10 || (packet->parsed_lines == 11 && packet->line[11].len == 0))
&& packet->user_agent_line.ptr != NULL
&& packet->user_agent_line.len > 12
&& memcmp(packet->user_agent_line.ptr, "Mozilla/4.0 ",
12) == 0
&& packet->host_line.ptr != NULL
&& packet->host_line.len >= 7
&& packet->line[2].ptr != NULL
&& packet->line[2].len > 14
&& memcmp(packet->line[2].ptr, "Keep-Alive: 300", 15) == 0
&& packet->line[3].ptr != NULL
&& packet->line[3].len > 21
&& memcmp(packet->line[3].ptr, "Connection: Keep-alive", 22) == 0
&& packet->line[4].ptr != NULL
&& packet->line[4].len > 10
&& (memcmp(packet->line[4].ptr, "Accpet: */*", 11) == 0
|| memcmp(packet->line[4].ptr, "Accept: */*", 11) == 0)
&& packet->line[5].ptr != NULL
&& packet->line[5].len > 12
&& memcmp(packet->line[5].ptr, "Range: bytes=", 13) == 0
&& packet->line[7].ptr != NULL
&& packet->line[7].len > 15
&& memcmp(packet->line[7].ptr, "Pragma: no-cache", 16) == 0
&& packet->line[8].ptr != NULL
&& packet->line[8].len > 22 && memcmp(packet->line[8].ptr, "Cache-Control: no-cache", 23) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "Bitcomet LTS detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
/* FlashGet pattern */
if(packet->parsed_lines == 8
&& packet->user_agent_line.ptr != NULL
&& packet->user_agent_line.len > (sizeof("Mozilla/4.0 (compatible; MSIE 6.0;") - 1)
&& memcmp(packet->user_agent_line.ptr, "Mozilla/4.0 (compatible; MSIE 6.0;",
sizeof("Mozilla/4.0 (compatible; MSIE 6.0;") - 1) == 0
&& packet->host_line.ptr != NULL
&& packet->host_line.len >= 7
&& packet->line[2].ptr != NULL
&& packet->line[2].len == 11
&& memcmp(packet->line[2].ptr, "Accept: */*", 11) == 0
&& packet->line[3].ptr != NULL && packet->line[3].len >= (sizeof("Referer: ") - 1)
&& memcmp(packet->line[3].ptr, "Referer: ", sizeof("Referer: ") - 1) == 0
&& packet->line[5].ptr != NULL
&& packet->line[5].len > 13
&& memcmp(packet->line[5].ptr, "Range: bytes=", 13) == 0
&& packet->line[6].ptr != NULL
&& packet->line[6].len > 21 && memcmp(packet->line[6].ptr, "Connection: Keep-Alive", 22) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "FlashGet detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
if(packet->parsed_lines == 7
&& packet->user_agent_line.ptr != NULL
&& packet->user_agent_line.len > (sizeof("Mozilla/4.0 (compatible; MSIE 6.0;") - 1)
&& memcmp(packet->user_agent_line.ptr, "Mozilla/4.0 (compatible; MSIE 6.0;",
sizeof("Mozilla/4.0 (compatible; MSIE 6.0;") - 1) == 0
&& packet->host_line.ptr != NULL
&& packet->host_line.len >= 7
&& packet->line[2].ptr != NULL
&& packet->line[2].len == 11
&& memcmp(packet->line[2].ptr, "Accept: */*", 11) == 0
&& packet->line[3].ptr != NULL && packet->line[3].len >= (sizeof("Referer: ") - 1)
&& memcmp(packet->line[3].ptr, "Referer: ", sizeof("Referer: ") - 1) == 0
&& packet->line[5].ptr != NULL
&& packet->line[5].len > 21 && memcmp(packet->line[5].ptr, "Connection: Keep-Alive", 22) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_TRACE, "FlashGet detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
/* answer to this pattern is not possible to implement asymmetrically */
while (1) {
if(len < 50 || ptr[0] == 0x0d) {
goto ndpi_end_bt_tracker_check;
}
if(memcmp(ptr, "info_hash=", 10) == 0) {
break;
}
len--;
ptr++;
}
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, " BT stat: tracker info hash found\n");
/* len is > 50, so save operation here */
len -= 10;
ptr += 10;
/* parse bt hash */
for (a = 0; a < 20; a++) {
if(len < 3) {
goto ndpi_end_bt_tracker_check;
}
if(*ptr == '%') {
u_int8_t x1 = 0xFF;
u_int8_t x2 = 0xFF;
if(ptr[1] >= '0' && ptr[1] <= '9') {
x1 = ptr[1] - '0';
}
if(ptr[1] >= 'a' && ptr[1] <= 'f') {
x1 = 10 + ptr[1] - 'a';
}
if(ptr[1] >= 'A' && ptr[1] <= 'F') {
x1 = 10 + ptr[1] - 'A';
}
if(ptr[2] >= '0' && ptr[2] <= '9') {
x2 = ptr[2] - '0';
}
if(ptr[2] >= 'a' && ptr[2] <= 'f') {
x2 = 10 + ptr[2] - 'a';
}
if(ptr[2] >= 'A' && ptr[2] <= 'F') {
x2 = 10 + ptr[2] - 'A';
}
if(x1 == 0xFF || x2 == 0xFF) {
goto ndpi_end_bt_tracker_check;
}
ptr += 3;
len -= 3;
} else if(*ptr >= 32 && *ptr < 127) {
ptr++;
len--;
} else {
goto ndpi_end_bt_tracker_check;
}
}
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, " BT stat: tracker info hash parsed\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
ndpi_end_bt_tracker_check:
if(packet->payload_packet_len == 80) {
/* Warez 80 Bytes Packet
* +----------------+---------------+-----------------+-----------------+
* |20 BytesPattern | 32 Bytes Value| 12 BytesPattern | 16 Bytes Data |
* +----------------+---------------+-----------------+-----------------+
* 20 BytesPattern : 4c 00 00 00 ff ff ff ff 57 00 00 00 00 00 00 00 20 00 00 00
* 12 BytesPattern : 28 23 00 00 01 00 00 00 10 00 00 00
* */
static const char pattern_20_bytes[20] = { 0x4c, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0x57, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00
};
static const char pattern_12_bytes[12] = { 0x28, 0x23, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00
};
/* did not see this pattern anywhere */
if((memcmp(&packet->payload[0], pattern_20_bytes, 20) == 0)
&& (memcmp(&packet->payload[52], pattern_12_bytes, 12) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct,
NDPI_LOG_TRACE, "BT: Warez - Plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return 1;
}
}
else if(packet->payload_packet_len > 50) {
if(memcmp(packet->payload, "GET", 3) == 0) {
ndpi_parse_packet_line_info(ndpi_struct, flow);
/* haven't fount this pattern anywhere */
if(packet->host_line.ptr != NULL
&& packet->host_line.len >= 9 && memcmp(packet->host_line.ptr, "ip2p.com:", 9) == 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
ndpi_struct, NDPI_LOG_TRACE,
"BT: Warez - Plain BitTorrent protocol detected due to Host: ip2p.com: pattern\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION);
return 1;
}
}
}
return 0;
}
/*Search for BitTorrent commands*/
static void ndpi_int_search_bittorrent_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
if(packet->payload_packet_len == 0) {
return;
}
if(flow->bittorrent_stage == 0 && packet->payload_packet_len != 0) {
/* exclude stage 0 detection from next run */
flow->bittorrent_stage = 1;
if(ndpi_int_search_bittorrent_tcp_zero(ndpi_struct, flow) != 0) {
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_DEBUG,
"stage 0 has detected something, returning\n");
return;
}
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT, ndpi_struct, NDPI_LOG_DEBUG,
"stage 0 has no direct detection, fall through\n");
}
return;
}
void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
int no_bittorrent = 0;
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_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
return;
}
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_BITTORRENT) {
/* check for tcp retransmission here */
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) {
char *bt_search = "BT-SEARCH * HTTP/1.1\r\n";
if((ntohs(packet->udp->source) < 1024)
|| (ntohs(packet->udp->dest) < 1024) /* High ports only */)
return;
/*
Check for uTP http://www.bittorrent.org/beps/bep_0029.html
wireshark/epan/dissectors/packet-bt-utp.c
*/
if(packet->payload_packet_len >= 23 /* min header size */) {
if(strncmp((const char*)packet->payload, bt_search, strlen(bt_search)) == 0) {
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 1,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return;
} else {
/* Check if this is protocol v0 */
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))
goto bittorrent_found;
else if((packet->payload[0]== 0x60)
&& (packet->payload[1]== 0x0)
&& (packet->payload[2]== 0x0)
&& (packet->payload[3]== 0x0)
&& (packet->payload[4]== 0x0)) {
/* Heuristic */
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
goto bittorrent_found;
} else if(((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;
} 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;
now = (u_int32_t)time(NULL);
if((ts < (now+86400)) && (ts > (now-86400))) {
bt_proto = ndpi_strnstr((const char *)&packet->payload[20], "BitTorrent protocol", packet->payload_packet_len-20);
goto bittorrent_found;
}
}
}
}
flow->bittorrent_stage++;
if(flow->bittorrent_stage < 10) {
/* We have detected bittorrent but we need to wait until we get a hash */
if(packet->payload_packet_len > 19 /* min size */) {
if(ndpi_strnstr((const char *)packet->payload, ":target20:", packet->payload_packet_len)
|| ndpi_strnstr((const char *)packet->payload, ":find_node1:", packet->payload_packet_len)
|| ndpi_strnstr((const char *)packet->payload, "d1:ad2:id20:", packet->payload_packet_len)
|| ndpi_strnstr((const char *)packet->payload, ":info_hash20:", packet->payload_packet_len)
|| ndpi_strnstr((const char *)packet->payload, ":filter64", packet->payload_packet_len)
|| ndpi_strnstr((const char *)packet->payload, "d1:rd2:id20:", packet->payload_packet_len)
|| (bt_proto = ndpi_strnstr((const char *)packet->payload, "BitTorrent protocol", packet->payload_packet_len))
) {
bittorrent_found:
if(bt_proto && (packet->payload_packet_len > 47))
memcpy(flow->bittorent_hash, &bt_proto[27], 20);
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 0,
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION);
return;
}
}
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
}
}
}
void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("BitTorrent", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_BITTORRENT,
ndpi_search_bittorrent,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+504
View File
@@ -0,0 +1,504 @@
/*
* btlib.c
*
* Copyright (C) 2011-15 - ntop.org
* Contributed by Vitaly Lavrov <vel21ripn@gmail.com>
*
* 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_NO_STD_INC
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
typedef unsigned char u_int8_t;
typedef unsigned short int u_int16_t;
typedef unsigned long long int u_int64_t;
#include <stdint.h>
#include <stdlib.h>
#include <arpa/inet.h>
#endif
typedef signed long long int i_int64_t;
#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);
}
void dump_bt_proto_struct(struct bt_parse_protocol *p) {
char b20h[128];
int i;
if(p->y_e && p->e_msg) {
printf("Error %s/%u\n", p->e_msg, p->e_len);
}
if(p->y_q) {
printf("Query ");
if(p->q_ping) printf("ping\n");
if(p->q_g_peers) printf("get_peers\n");
if(p->q_f_node) printf("find_node\n");
if(p->q_a_peer) printf("announce_peer\n");
}
if(p->y_r)
printf("Reply\n");
if(p->t) printf("\tt\t%llx\n",p->t);
if(p->v) printf("\tv\t%llx\n",p->v);
if(p->ip) printf("\tIP\t%s\n",print_ip_p(b20h,p->ip,0));
if(p->a.port) printf("\tport\t%d\n",htons(p->a.port));
if(p->a.id) printf("\tID\t%s\n",print20b(b20h,p->a.id));
if(p->a.target) printf("\ttarget\t%s\n",print20b(b20h,p->a.target));
if(p->a.token) printf("\ttoken\t%s\n",printXb(b20h,p->a.token,p->a.t_len));
if(p->a.info_hash) printf("\ti_hash\t%s\n",print20b(b20h,p->a.info_hash));
if(p->a.name && p->a.name_len) printf("\tname\t%.*s\n",p->a.name_len,p->a.name);
if(p->r.ip) printf("\tip\t%s\n",print_ip_p(b20h,p->r.ip,1));
if(p->r.port) printf("\tport\t%d\n",htons(p->r.port));
if(p->r.id) printf("\tID\t%s\n",print20b(b20h,p->r.id));
if(p->r.token) printf("\ttoken\t%s\n",printXb(b20h,p->r.token,p->r.t_len));
if(p->r.name && p->r.name_len) printf("\tname\t%.*s\n",p->r.name_len,p->r.name);
if(p->r.values && p->r.nv) {
struct bt_ipv4p2 *n = (struct bt_ipv4p2 *)p->r.values;
for(i=0;i < p->r.nv; i++,n++) {
printf("\tvalues\t%s\n", print_ip_p(b20h,&n->d,0));
}
}
if(p->r.values6 && p->r.nv6) {
struct bt_ipv6p2 *n = (struct bt_ipv6p2 *)p->r.values6;
for(i=0;i < p->r.nv6; i++,n++) {
printf("\tvalues6\t%s\n", print_ip6_p(b20h,&n->d,0));
}
}
if(p->r.nodes && p->r.nn) {
for(i=0;i < p->r.nn; i++) {
printf("\tnodes\t%s\n",print_id_ip_p(b20h,p->r.nodes+i));
}
}
if(p->r.nodes6 && p->r.nn6) {
for(i=0;i < p->r.nn6; i++) {
printf("\tnodes6\t%s\n",print_id_ip6_p(b20h,p->r.nodes6+i));
}
}
if(p->peers && p->n_peers) {
for(i=0;i < p->n_peers; i++) {
printf("\tpeers\t%s\n",print_ip_p(b20h,p->peers+i,0));
}
}
if(p->interval) printf("\tinterval\t%d\n",p->interval);
if(p->min_interval) printf("\tmin interval\t%d\n",p->min_interval);
}
static void _print_safe_str(char *msg,char *k,const u_int8_t *s,size_t l) {
static const char *th="0123456789abcdef?";
char *buf = (char*)ndpi_malloc((size_t)(l*3+2));
int sl = l;
if(buf) {
char *b = buf;
for(;l > 0; s++,l--) {
if(*s < ' ' || *s >= 127) {
*b++ = '%';
*b++ = th[(*s >> 4)&0xf];
*b++ = th[(*s)&0xf];
} else *b++ = *s;
}
*b = 0;
printf("%s %s %s len %d\n",msg,k,buf ? buf:"",sl);
ndpi_free(buf);
}
}
static void print_safe_str(char *msg,bt_parse_data_cb_t *cbd) {
_print_safe_str(msg,cbd->buf,cbd->v.s.s,cbd->v.s.l);
}
#define DEBUG_TRACE(cmd) { if(bt_parse_debug) cmd; }
#define STREQ(a,b) !strcmp(a,b)
void cb_data(bt_parse_data_cb_t *cbd,int *ret) {
struct bt_parse_protocol *p = &(cbd->p);
const u_int8_t *s;
const char *ss;
if(cbd->t == 0) return;
if(cbd->t == 1) {
DEBUG_TRACE(printf("%s %lld\n",cbd->buf,cbd->v.i));
if(STREQ(cbd->buf,"a.port")) {
p->a.port = (u_int16_t)(cbd->v.i & 0xffff);
return;
}
if(
STREQ(cbd->buf,"a.implied_port") ||
STREQ(cbd->buf,"a.noseed") ||
STREQ(cbd->buf,"a.scrape") ||
STREQ(cbd->buf,"a.seed") ||
STREQ(cbd->buf,"a.vote")
) {
return;
}
if(STREQ(cbd->buf,"r.port") || STREQ(cbd->buf,"r.p")) {
p->r.port = (u_int16_t)(cbd->v.i & 0xffff);
return;
}
if(STREQ(cbd->buf,"interval")) {
p->interval = (u_int16_t)(cbd->v.i & 0x7fffffff);
p->h_int = 1;
return;
}
if(STREQ(cbd->buf,"min interval")) {
p->min_interval = (u_int16_t)(cbd->v.i & 0x7fffffff);
p->h_mint = 1;
return;
}
DEBUG_TRACE(printf("UNKNOWN %s %lld\n",cbd->buf,cbd->v.i));
return;
}
if(cbd->t != 2) {
DEBUG_TRACE(printf("BUG! t=%d %s\n",cbd->t,cbd->buf));
return;
}
DEBUG_TRACE(print_safe_str("",cbd));
s = cbd->v.s.s;
ss = (char *)s;
if(STREQ(cbd->buf,"a.id")) {
p->a.id = s;
return;
}
if(STREQ(cbd->buf,"a.info_hash")) {
p->a.info_hash = s;
return;
}
if(STREQ(cbd->buf,"a.target")) {
p->a.target = s;
return;
}
if(STREQ(cbd->buf,"a.token")) {
p->a.token = s;
p->a.t_len = cbd->v.s.l;
return;
}
if(STREQ(cbd->buf,"a.name")) {
p->a.name = s;
p->a.name_len = cbd->v.s.l;
return;
}
if(STREQ(cbd->buf,"a.want")) {
return;
}
if(STREQ(cbd->buf,"r.id")) {
p->r.id = s;
return;
}
if(STREQ(cbd->buf,"r.ip")) {
if(cbd->v.s.l != 4) {
DEBUG_TRACE(printf("BUG! r.ip with port\n"));
return;
}
p->r.ip = (struct bt_ipv4p *)s;
return;
}
if(STREQ(cbd->buf,"r.token")) {
p->r.token = s;
p->r.t_len = cbd->v.s.l;
return;
}
if(STREQ(cbd->buf,"r.values")) {
if(cbd->v.s.l == 18) {
if(!p->r.values6) {
p->r.values6 = s;
p->r.nv6 = 1;
} else {
if(s != p->r.values6+(p->r.nv6*21)) {
// DEBUG_TRACE(printf("BUG! r.values6 not in list! %08x %08x \n", p->r.values+(p->r.nv6*21),s));
return;
}
p->r.nv6++;
}
return;
}
if(cbd->v.s.l == 6) {
if(!p->r.values) {
p->r.values = s;
p->r.nv = 1;
} else {
if(s != p->r.values+(p->r.nv*8)) {
// DEBUG_TRACE(printf("BUG! r.values not in list! %u \n",s-p->r.values+(p->r.nv*8)));
return;
}
p->r.nv++;
}
return;
}
return;
}
if(STREQ(cbd->buf,"r.name") || STREQ(cbd->buf,"r.n")) {
p->r.name = s;
p->r.name_len = cbd->v.s.l;
return;
}
if(STREQ(cbd->buf,"r.nodes")) {
if(cbd->v.s.l % 26) {
// DEBUG_TRACE(printf("BUG! r.nodes length %d not %% 26\n",cbd->v.s.l));
return;
}
p->r.nodes = (struct bt_nodes_data *)s;
p->r.nn = cbd->v.s.l / 26;
return;
}
if(STREQ(cbd->buf,"r.nodes6")) {
if(cbd->v.s.l % 38) {
// DEBUG_TRACE(printf("BUG! r.nodes length %d not %% 38\n",cbd->v.s.l));
return;
}
p->r.nodes6 = (struct bt_nodes6_data *)s;
p->r.nn6 = cbd->v.s.l / 38;
return;
}
if(cbd->buf[0] == 'y' && !cbd->buf[1]) {
if(cbd->v.s.l != 1) return;
if(*ss == 'q') { p->y_q = 1; return; }
if(*ss == 'r') { p->y_r = 1; return; }
if(*ss == 'e') { p->y_e = 1; return; }
return;
}
if(cbd->buf[0] == 'q' && !cbd->buf[1]) {
if(!strncmp(ss,"announce_peer",13)) {
p->q_a_peer = 1;
return;
}
if(!strncmp(ss,"find_node",9)) {
p->q_f_node = 1;
return;
}
if(!strncmp(ss,"get_peers",9)) {
p->q_g_peers = 1;
return;
}
if(!strncmp(ss,"ping",4)) {
p->q_ping = 1;
return;
}
if(!strncmp(ss,"vote",4)) {
return;
}
}
if(STREQ(cbd->buf,"ip")) {
if(cbd->v.s.l != 6) {
// DEBUG_TRACE(printf("BUG! r.ip w/o port\n"));
}
p->ip = (struct bt_ipv4p *)s;
p->h_ip = 1;
return;
}
if(STREQ(cbd->buf,"peers")) {
if(cbd->v.s.l % 6) return;
p->peers = (struct bt_ipv4p *)s;
p->n_peers = cbd->v.s.l / 6;
return;
}
if((*cbd->buf == 't' || *cbd->buf == 'v') && !cbd->buf[1]) {
u_int64_t d = *(u_int64_t*)s;
switch(cbd->v.s.l) {
case 2:
d &= 0xffffllu; d = htons(d); break;
case 4:
d &= 0xffffffffllu; d = htonl(d); break;
case 6:
d &= 0xffffffffffffllu; d = (htonl(d & 0xffffffff) << 16) |
(htons(d >> 32) & 0xffff);
break;
case 8: d = ((u_int64_t)htonl(d & 0xffffffff) << 32) |
htonl(d >> 32);
break;
default: d = 0;
}
if(*cbd->buf == 'v') cbd->p.v = d;
else cbd->p.t = d;
return;
}
if(cbd->buf[0] == 'e' && !cbd->buf[0]) {
p->e_msg = s;
p->e_len = cbd->v.s.l;
return;
}
// DEBUG_TRACE(print_safe_str("UKNOWN",cbd));
}
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd) {
unsigned int n=0,neg=0;
i_int64_t d = 0;
register u_int8_t c;
if(*l == 0) return NULL;
if(cbd->level > BDEC_MAXDEPT) goto bad_data;
c = *b++; (*l)--;
if(c == 'i') { // integer
while(*l) {
c = *b++; (*l)--;
n++;
if(c == '-') {
if(n != 1) goto bad_data;
n--;
neg=1;
continue;
}
if(c >= '0' && c <= '9') {
if(c == '0' && n > 1 && !d && *b != 'e') goto bad_data;
d *= 10;
d += c-'0';
continue;
}
if(c != 'e') goto bad_data;
break;
}
if(neg) d=-d;
cbd->t = 1;
cbd->v.i = neg ? -d:d;
return b;
}
if(c >= '1' && c <= '9') { //string
d=c-'0';
while(*l) {
c = *b++; (*l)--;
n++;
if(c >= '0' && c <= '9') {
if(c == '0' && n > 1 && d == 0) goto bad_data;
d *= 10;
d += c-'0';
continue;
}
if(c != ':') goto bad_data;
break;
}
if(d > *l) goto bad_data;
cbd->t = 2;
cbd->v.s.s = b;
cbd->v.s.l = d;
b += d;
*l -= d;
return b;
}
if(c == 'l') {
cbd->level++;
do {
b = bt_decode(b,l,ret,cbd);
if(*ret < 0 || *l == 0) goto bad_data;
cb_data(cbd,ret);
if(*ret < 0) goto bad_data;
cbd->t = 0;
} while (*b != 'e' && *l != 0);
b++; (*l)--;
cbd->level--;
return b;
}
if(c == 'd') {
cbd->level++;
do {
char *ls = cbd->buf + strlen(cbd->buf);
int l1 = ls != cbd->buf ? 1:0;
if(!(*b >= '1' && *b <= '9')) goto bad_data;
b = bt_decode(b,l,ret,cbd);
if(*ret < 0 || *l == 0) goto bad_data;
if(ls+cbd->v.s.l+l1 < &cbd->buf[sizeof(cbd->buf)-1]) {
if(l1) ls[0]='.';
strncpy(ls+l1,(char *)cbd->v.s.s,cbd->v.s.l);
ls[cbd->v.s.l+l1]=0;
}
b = bt_decode(b,l,ret,cbd);
if(*ret < 0 || *l == 0) goto bad_data;
cb_data(cbd,ret);
if(*ret < 0) goto bad_data;
cbd->t = 0;
*ls = 0;
} while (*b != 'e' && l != 0);
b++; (*l)--;
cbd->level--;
return b;
}
bad_data:
*ret=-1;
return b;
}
+145
View File
@@ -0,0 +1,145 @@
/*
* btlib.h
*
* Copyright (C) 2011-15 - ntop.org
* Contributed by Vitaly Lavrov <vel21ripn@gmail.com>
*
* 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/>.
*
*/
#define BDEC_MAXDEPT 8
typedef struct b_elem_s {
const u_int8_t *s;
size_t l;
} b_elem_s_t;
struct __attribute__ ((__packed__)) bt_nodes_data {
u_int8_t id[20] ;
u_int32_t ip;
u_int16_t port;
};
struct __attribute__ ((__packed__)) bt_ipv4p {
u_int32_t ip;
u_int16_t port;
};
struct __attribute__ ((__packed__)) bt_ipv4p2 {
struct bt_ipv4p d;
u_int8_t pad[2];
};
struct __attribute__ ((__packed__)) bt_nodes6_data {
u_int8_t id[20] ;
u_int32_t ip[4];
u_int16_t port;
};
struct __attribute__ ((__packed__)) bt_ipv6p {
u_int32_t ip[4];
u_int16_t port;
};
struct __attribute__ ((__packed__)) bt_ipv6p2 {
struct bt_ipv6p d;
u_int8_t pad[3];
};
/*
a.id S r.id S
a.info_hash S r.ip ipv4
a.name S r.nodes x(id,ipv4,port)
-a.noseed 0|1 r.n S name of file
a.port N r.p port
-a.scrape 0|1 r.token S
-a.seed 0|1 r.values x(ipv4,port)
a.target S
a.token S -a.vote N
-a.want n4|n6
q announce_peer q find_node
q get_peers q ping
-q vote
ip ipv4+port interval N
min interval N peers x(ipv4,port)
t 2/4/8b v 4/6b
e S y e y r y q
*/
struct bt_parse_protocol {
u_int16_t y_e:1, y_r:1, y_q:1,
q_a_peer:1,q_f_node:1,
q_g_peers:1,q_ping:1,
h_int:1,h_mint:1,h_ip:1;
struct {
const u_int8_t *id, // 20
*info_hash, // 20
*target, // 20
*token, // 20|8
*name; // varlen
u_int16_t name_len;
u_int16_t port;
u_int16_t t_len;
} a;
struct {
const u_int8_t *id, // 20
*token, // 20|8
*values, // (6+2)*x
*values6, // (18_3)*x
*name; // varlen
struct bt_ipv4p *ip;
struct bt_nodes_data *nodes;
struct bt_nodes6_data *nodes6;
u_int16_t name_len;
u_int16_t nn; // nodes num
u_int16_t nv; // valuse num
u_int16_t nn6; // nodes6 num
u_int16_t nv6; // valuse6 num
u_int16_t port;
u_int16_t t_len;
} r;
int interval,min_interval;
struct bt_ipv4p *peers;
int n_peers;
struct bt_ipv4p *ip;
const u_int8_t *e_msg;
u_int16_t e_len;
u_int64_t t,v;
};
typedef struct bt_parse_data_cb {
struct bt_parse_protocol p;
char buf[64];
int level;
int t;
union {
i_int64_t i;
b_elem_s_t s;
} v;
} bt_parse_data_cb_t;
extern int bt_parse_debug;
void dump_bt_proto_struct(struct bt_parse_protocol *p);
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd);
+83
View File
@@ -0,0 +1,83 @@
/*
* ciscovpn.c
* Copyright (C) 2013 by Remy Mudingay <mudingay@ill.fr>
*
*/
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_CISCOVPN
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;
u_int16_t udport = 0, usport = 0;
u_int16_t tdport = 0, tsport = 0;
NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "search CISCOVPN.\n");
if(packet->tcp != NULL) {
tsport = ntohs(packet->tcp->source), tdport = ntohs(packet->tcp->dest);
NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "calculated CISCOVPN over tcp ports.\n");
}
if(packet->udp != NULL) {
usport = ntohs(packet->udp->source), udport = ntohs(packet->udp->dest);
NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "calculated CISCOVPN over udp ports.\n");
}
if((tdport == 10000 && tsport == 10000) ||
((tsport == 443 || tdport == 443) &&
(packet->payload[0] == 0x17 &&
packet->payload[1] == 0x01 &&
packet->payload[2] == 0x00 &&
packet->payload[3] == 0x00)
)
)
{
/* This is a good query 17010000*/
NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "found CISCOVPN.\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
}
else if(
(
(usport == 10000 && udport == 10000)
&&
(packet->payload[0] == 0xfe &&
packet->payload[1] == 0x57 &&
packet->payload[2] == 0x7e &&
packet->payload[3] == 0x2b)
)
)
{
/* This is a good query fe577e2b */
NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "found CISCOVPN.\n");
ndpi_int_ciscovpn_add_connection(ndpi_struct, flow);
} else {
NDPI_LOG(NDPI_PROTOCOL_CISCOVPN, ndpi_struct, NDPI_LOG_DEBUG, "exclude CISCOVPN.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CISCOVPN);
}
}
void init_ciscovpn_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("CiscoVPN", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CISCOVPN,
ndpi_search_ciscovpn,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_OR_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+96
View File
@@ -0,0 +1,96 @@
/*
* citrix.c
*
* Copyright (C) 2012-15 - 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_api.h"
#ifdef NDPI_PROTOCOL_CITRIX
/* ************************************ */
static void ndpi_check_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t payload_len = packet->payload_packet_len;
if(packet->tcp != NULL) {
flow->l4.tcp.citrix_packet_id++;
if((flow->l4.tcp.citrix_packet_id == 3)
/* We have seen the 3-way handshake */
&& flow->l4.tcp.seen_syn
&& flow->l4.tcp.seen_syn_ack
&& flow->l4.tcp.seen_ack) {
if(payload_len == 6) {
char citrix_header[] = { 0x07, 0x07, 0x49, 0x43, 0x41, 0x00 };
if(memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0) {
NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "Found citrix.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
}
return;
} else if(payload_len > 4) {
char citrix_header[] = { 0x1a, 0x43, 0x47, 0x50, 0x2f, 0x30, 0x31 };
if((memcmp(packet->payload, citrix_header, sizeof(citrix_header)) == 0)
|| (ndpi_strnstr((const char *)packet->payload, "Citrix.TcpProxyService", payload_len) != NULL)) {
NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "Found citrix.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_PROTOCOL_UNKNOWN);
}
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
} else if(flow->l4.tcp.citrix_packet_id > 3)
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CITRIX);
return;
}
}
void ndpi_search_citrix(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG(NDPI_PROTOCOL_CITRIX, ndpi_struct, NDPI_LOG_DEBUG, "citrix detection...\n");
/* skip marked packets */
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_CITRIX)
ndpi_check_citrix(ndpi_struct, flow);
}
void init_citrix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Citrix", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CITRIX,
ndpi_search_citrix,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+165
View File
@@ -0,0 +1,165 @@
/*
* coap.c
*
* Copyright (C) 2016 Sorin Zamfir <sorin.zamfir@yahoo.com>
*
* 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_protocols.h"
#ifdef NDPI_PROTOCOL_COAP
#define CON 0
#define NO_CON 1
#define ACK 2
#define RST 3
struct ndpi_coap_hdr
{
#if defined(__BIG_ENDIAN__)
u_int8_t version:2, type:2, tkl:4;
#elif defined(__LITTLE_ENDIAN__)
u_int8_t tkl:4, type:2, version:2;
#endif
u_int8_t code;
u_int16_t message_id; //if needed, remember to convert in host number
};
/**
VALUE OF -CODE- FIELD
[0] = "Empty",
[1] = "GET",
[2] = "POST",
[3] = "PUT",
[4] = "DELETE",
[65] = "2.01 Created",
[66] = "2.02 Deleted",
[67] = "2.03 Valid",
[68] = "2.04 Changed",
[69] = "2.05 Content",
[128] = "4.00 Bad Request",
[129] = "4.01 Unauthorized",
[130] = "4.02 Bad Option",
[131] = "4.03 Forbidden",
[132] = "4.04 Not Found",
[133] = "4.05 Method Not Allowed",
[134] = "4.06 Not Acceptable",
[140] = "4.12 Precondition Failed",
[141] = "4.13 Request Entity Too Large",
[143] = "4.15 Unsupported Content-Format",
[160] = "5.00 Internal Server Error",
[161] = "5.01 Not Implemented",
[162] = "5.02 Bad Gateway",
[163] = "5.03 Service Unavailable",
[164] = "5.04 Gateway Timeout",
[165] = "5.05 Proxying Not Supported"
**/
/**
* Entry point when protocol is identified.
*/
static void ndpi_int_coap_add_connection (struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct,flow,NDPI_PROTOCOL_COAP,NDPI_PROTOCOL_UNKNOWN);
}
/**
* Check if the default port is acceptable
*
* UDP Port 5683 (mandatory)
* UDP Ports 61616-61631 compressed 6lowPAN
*/
static int isCoAPport(u_int16_t port) {
if((port == 5683)
|| ((port >= 61616) && (port <= 61631)))
return(1);
else
return(0);
}
/**
* Dissector function that searches CoAP headers
*/
void ndpi_search_coap (struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
struct ndpi_coap_hdr * h = (struct ndpi_coap_hdr*) packet->payload;
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) {
return;
}
// search for udp packet
if(packet->udp != NULL) {
u_int16_t s_port = ntohs(flow->packet.udp->source);
u_int16_t d_port = ntohs(flow->packet.udp->dest);
if((!isCoAPport(s_port) && !isCoAPport(s_port))
|| (packet->payload_packet_len < 4) // header too short
) {
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "excluding Coap\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_COAP);
return;
}
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "calculating coap over udp.\n");
// 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) ||
(h->code >= 128 && h->code <= 134) || (h->code >= 140 && h->code <= 143) ||
(h->code >= 160 && h->code <= 165)) {
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "Coap found...\n");
ndpi_int_coap_add_connection(ndpi_struct,flow);
return;
}
}
}
}
}
NDPI_LOG(NDPI_PROTOCOL_COAP, ndpi_struct, NDPI_LOG_DEBUG, "Excluding Coap ...\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_COAP);
return;
}
/**
* Entry point for the ndpi library
*/
void init_coap_dissector (struct ndpi_detection_module_struct *ndpi_struct,
u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection ("COAP", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_COAP,
ndpi_search_coap,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN, ADD_TO_DETECTION_BITMASK);
*id +=1;
}
#endif // NDPI_PROTOCOL_COAP
+54
View File
@@ -0,0 +1,54 @@
/*
* collectd.c
*
* Copyright (C) 2014 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_COLLECTD
void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
u_int len = 0;
NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "search collectd.\n");
if (packet->udp == NULL) return;
while(len < packet->payload_packet_len) {
// u_int16_t elem_type = ntohs(*((u_int16_t*)&packet->payload[len]));
u_int16_t elem_len = ntohs(*((u_int16_t*)&packet->payload[len+2]));
if (elem_len == 0) break;
len += elem_len;
}
if(len == packet->payload_packet_len) {
NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "found COLLECTD.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_COLLECTD, NDPI_PROTOCOL_UNKNOWN);
} else {
NDPI_LOG(NDPI_PROTOCOL_COLLECTD, ndpi_struct, NDPI_LOG_DEBUG, "exclude COLLECTD.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_COLLECTD);
}
}
#endif
+60
View File
@@ -0,0 +1,60 @@
/*
* corba.c
*
* Copyright (C) 2013 Remy Mudingay <mudingay@ill.fr>
*
* This module 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.
*
* This module 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.
* If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_CORBA
static void ndpi_int_corba_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CORBA, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_corba(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "search for CORBA.\n");
if(packet->tcp != NULL) {
NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "calculating CORBA over tcp.\n");
/* Corba General Inter-ORB Protocol -> GIOP */
if ((packet->payload_packet_len >= 24 && packet->payload_packet_len <= 144) &&
memcmp(packet->payload, "GIOP", 4) == 0) {
NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "found corba.\n");
ndpi_int_corba_add_connection(ndpi_struct, flow);
}
} else {
NDPI_LOG(NDPI_PROTOCOL_CORBA, ndpi_struct, NDPI_LOG_DEBUG, "exclude CORBA.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CORBA);
}
}
void init_corba_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Corba", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CORBA,
ndpi_search_corba,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+94
View File
@@ -0,0 +1,94 @@
/*
* crossfire.c
*
* Copyright (C) 2012-15 - 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 files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_CROSSFIRE
static void ndpi_int_crossfire_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow/* , ndpi_protocol_type_t protocol_type */)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CROSSFIRE, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_crossfire_tcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "search crossfire.\n");
if (packet->udp != 0) {
if (packet->payload_packet_len == 25 && get_u_int32_t(packet->payload, 0) == ntohl(0xc7d91999)
&& get_u_int16_t(packet->payload, 4) == ntohs(0x0200)
&& get_u_int16_t(packet->payload, 22) == ntohs(0x7d00)
) {
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "Crossfire: found udp packet.\n");
ndpi_int_crossfire_add_connection(ndpi_struct, flow);
return;
}
} else if (packet->tcp != 0) {
if (packet->payload_packet_len > 4 && memcmp(packet->payload, "GET /", 5) == 0) {
ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->parsed_lines == 8
&& (packet->line[0].ptr != NULL && packet->line[0].len >= 30
&& (memcmp(&packet->payload[5], "notice/login_big", 16) == 0
|| memcmp(&packet->payload[5], "notice/login_small", 18) == 0))
&& memcmp(&packet->payload[packet->line[0].len - 19], "/index.asp HTTP/1.", 18) == 0
&& (packet->host_line.ptr != NULL && packet->host_line.len >= 13
&& (memcmp(packet->host_line.ptr, "crossfire", 9) == 0
|| memcmp(packet->host_line.ptr, "www.crossfire", 13) == 0))
) {
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "Crossfire: found HTTP request.\n");
ndpi_int_crossfire_add_connection(ndpi_struct, flow);
return;
}
}
}
NDPI_LOG(NDPI_PROTOCOL_CROSSFIRE, ndpi_struct, NDPI_LOG_DEBUG, "exclude crossfire.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_CROSSFIRE);
}
void init_crossfire_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Crossfire", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_CROSSFIRE,
ndpi_search_crossfire_tcp_udp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+67
View File
@@ -0,0 +1,67 @@
/*
* dcerpc.c
*
* Copyright (C) 2011-13 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_api.h"
#ifdef NDPI_PROTOCOL_DCERPC
static void ndpi_int_dcerpc_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DCERPC, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_dcerpc(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
if((packet->tcp != NULL)
&& (packet->payload_packet_len >= 64)
&& (packet->payload[0] == 0x05) /* version 5 */
&& (packet->payload[2] < 16) /* Packet type */
&& (((packet->payload[9]<<8) | packet->payload[8]) == packet->payload_packet_len) /* Packet Length */
) {
NDPI_LOG(NDPI_PROTOCOL_DCERPC, ndpi_struct, NDPI_LOG_DEBUG, "DCERPC match\n");
ndpi_int_dcerpc_add_connection(ndpi_struct, flow);
return;
}
if(packet->payload_packet_len>1){
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DCERPC);
}
}
void init_dcerpc_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("DCE_RPC", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DCERPC,
ndpi_search_dcerpc,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+73
View File
@@ -0,0 +1,73 @@
/*
* dhcp.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_DHCP
static void ndpi_int_dhcp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DHCP, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
/* this detection also works for asymmetric dhcp traffic */
/*check standard DHCP 0.0.0.0:68 -> 255.255.255.255:67 */
if (packet->payload_packet_len >= 244 && (packet->udp->source == htons(67)
|| packet->udp->source == htons(68))
&& (packet->udp->dest == htons(67) || packet->udp->dest == htons(68))
&& get_u_int32_t(packet->payload, 236) == htonl(0x63825363)
&& get_u_int16_t(packet->payload, 240) == htons(0x3501)) {
NDPI_LOG(NDPI_PROTOCOL_DHCP, ndpi_struct, NDPI_LOG_DEBUG, "DHCP request\n");
ndpi_int_dhcp_add_connection(ndpi_struct, flow);
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCP);
}
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,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+72
View File
@@ -0,0 +1,72 @@
/*
* dhcpv6.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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 files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DHCPV6
static void ndpi_int_dhcpv6_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DHCPV6, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_dhcpv6_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (packet->payload_packet_len >= 4 &&
(packet->udp->source == htons(546) || packet->udp->source == htons(547)) &&
(packet->udp->dest == htons(546) || packet->udp->dest == htons(547)) &&
packet->payload[0] >= 1 && packet->payload[0] <= 13) {
NDPI_LOG(NDPI_PROTOCOL_DHCPV6, ndpi_struct, NDPI_LOG_DEBUG, "DHCPv6 detected.\n");
ndpi_int_dhcpv6_add_connection(ndpi_struct, flow);
return;
}
NDPI_LOG(NDPI_PROTOCOL_DHCPV6, ndpi_struct, NDPI_LOG_DEBUG, "DHCPv6 excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DHCPV6);
}
void init_dhcpv6_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("DHCPV6", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DHCPV6,
ndpi_search_dhcpv6_udp,
NDPI_SELECTION_BITMASK_PROTOCOL_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+487
View File
@@ -0,0 +1,487 @@
/*
* directconnect.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_DIRECTCONNECT
//#define NDPI_DEBUG_DIRECTCONNECT
//#define NDPI_DIRECTCONNECT_PORT_DEBUG
//#define NDPI_DEBUG_DIRECTCONNECT_CONN
#define DIRECT_CONNECT_TYPE_HUB 0
#define DIRECT_CONNECT_TYPE_PEER 1
#define DIRECT_CONNECT_ADC_PEER 2
static u_int32_t skip_unknown_headers(const u_int8_t * payload, u_int32_t payload_len, u_int32_t pos)
{
u_int32_t i = pos;
while (i < payload_len && payload[i] != 0x0a)
i++;
i++;
return i;
}
static u_int16_t parse_binf_message(struct ndpi_detection_module_struct
*ndpi_struct, const u_int8_t * payload, int payload_len)
{
u_int32_t i = 4;
u_int16_t bytes_read = 0;
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) {
ssl_port = ntohs_ndpi_bytestream_to_number(&payload[i + 25], 5, &bytes_read);
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect ssl port parsed %d", ssl_port);
}
}
} else {
break;
}
}
return ssl_port;
}
static void ndpi_int_directconnect_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
const u_int8_t connection_type)
{
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_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
&& flow->setup_packet_direction != packet->packet_direction && src->detected_directconnect_port == 0) {
src->detected_directconnect_port = packet->tcp->source;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect tcp PORT %u for src\n", ntohs(src->detected_directconnect_port));
}
if (packet->udp != NULL && src->detected_directconnect_udp_port == 0) {
src->detected_directconnect_udp_port = packet->udp->source;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect udp PORT %u for src\n", ntohs(src->detected_directconnect_port));
}
}
}
if (dst != NULL) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
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
* to the server
*/
/*
dst->detected_directconnect_port = packet->tcp->dest;
NDPI_LOG (NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect tcp PORT %u for dst\n",
ntohs (dst->detected_directconnect_port));
*/
}
}
}
}
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) {
dst->detected_directconnect_ssl_port = 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)
&& memcmp(&packet->payload[0], "DCTM", 4) == 0 && memcmp(&packet->payload[15], "ADCS", 4) == 0) {
u_int16_t bytes_read = 0;
if (dst != NULL) {
dst->detected_directconnect_ssl_port =
ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read);
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect ssl port parsed %d", ntohs(dst->detected_directconnect_ssl_port));
}
if (src != NULL) {
src->detected_directconnect_ssl_port =
ntohs_ndpi_bytestream_to_number(&packet->payload[25], 5, &bytes_read);
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect ssl port parsed %d", ntohs(src->detected_directconnect_ssl_port));
}
}
return;
}
if (src != NULL) {
if (src->detected_directconnect_port == packet->tcp->source) {
if ((u_int32_t)
(packet->tick_timestamp -
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
src->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(src->detected_directconnect_port));
return;
} else {
src->detected_directconnect_port = 0;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting src port due to timeout");
return;
}
}
if (src->detected_directconnect_ssl_port == packet->tcp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
src->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
src->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(src->detected_directconnect_ssl_port));
return;
} else {
src->detected_directconnect_ssl_port = 0;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting src port due to timeout");
return;
}
}
}
if (dst != NULL) {
if (dst->detected_directconnect_port == packet->tcp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(dst->detected_directconnect_port));
return;
} else {
dst->detected_directconnect_port = 0;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting dst port due to timeout");
return;
}
}
if (dst->detected_directconnect_ssl_port == packet->tcp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc port\n %d", ntohs(dst->detected_directconnect_ssl_port));
return;
} else {
dst->detected_directconnect_ssl_port = 0;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting dst port due to timeout");
return;
}
}
}
if (flow->directconnect_stage == 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(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "maybe first dc connect to hub detected\n");
flow->directconnect_stage = 1;
return;
}
if (packet->payload_packet_len > 7
&& packet->payload[0] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|'
&& (memcmp(&packet->payload[1], "MyNick ", 7) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "maybe first dc connect between peers detected\n");
flow->directconnect_stage = 2;
return;
}
}
if (packet->payload_packet_len >= 11) {
/* did not see this pattern in any trace */
if (memcmp(&packet->payload[0], "HSUP ADBAS0", 11) == 0
|| memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect 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 ||
memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect CSUP ADBAS0 E\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER);
return;
}
}
} 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
|| memcmp(&packet->payload[0], "HSUP ADBASE", 11) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect 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 ||
memcmp(&packet->payload[0], "CSUP ADBASE", 11) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "found directconnect HSUP ADBAS0 E in second packet\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_ADC_PEER);
return;
}
}
/* get client hello answer or server message */
if (packet->payload_packet_len > 6) {
if ((packet->payload[0] == '$' || packet->payload[0] == '<')
&& packet->payload[packet->payload_packet_len - 1] == '|') {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "second dc detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_HUB);
return;
} else {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "second dc not detected\n");
}
}
} 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] == '|') {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "second dc between peers detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return;
} else {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "second dc between peers not detected\n");
}
}
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT);
}
static void ndpi_search_directconnect_udp(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;
int pos, count = 0;
if (dst != NULL && dst->detected_directconnect_udp_port == packet->udp->dest) {
if ((u_int32_t)
(packet->tick_timestamp -
dst->directconnect_last_safe_access_time) < ndpi_struct->directconnect_connection_ip_tick_timeout) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_PROTOCOL_UNKNOWN);
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "marking using dc udp port\n %d", ntohs(dst->detected_directconnect_udp_port));
return;
} else {
dst->detected_directconnect_udp_port = 0;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "resetting dst udp port due to timeout");
return;
}
}
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] == '$'
&& packet->payload[packet->payload_packet_len - 1] == '|'
&& memcmp(&packet->payload[1], "SR ", 3) == 0) {
pos = packet->payload_packet_len - 2;
if (packet->payload[pos] == ')') {
while (pos > 0 && packet->payload[pos] != '(' && count < 21) {
pos--;
count++;
}
if (packet->payload[pos] == '(') {
pos = pos - 44;
if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "dc udp detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return;
}
}
}
flow->directconnect_stage++;
if (flow->directconnect_stage < 3) {
return;
}
}
}
if (dst != NULL
&& NDPI_COMPARE_PROTOCOL_TO_BITMASK(dst->detected_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT)) {
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] == ')') {
while (pos > 0 && packet->payload[pos] != '(' && count < 21) {
pos--;
count++;
}
if (packet->payload[pos] == '(') {
pos = pos - 44;
if (pos > 2 && memcmp(&packet->payload[pos], "TTH:", 4) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG, "dc udp detected\n");
ndpi_int_directconnect_add_connection(ndpi_struct, flow, DIRECT_CONNECT_TYPE_PEER);
return;
}
}
}
flow->directconnect_stage++;
if (flow->directconnect_stage < 3)
return;
}
}
}
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct, NDPI_LOG_DEBUG,
"excluded at stage %d \n", flow->directconnect_stage);
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECTCONNECT);
}
void ndpi_search_directconnect(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_DIRECTCONNECT) {
if (src != NULL && ((u_int32_t)
(packet->tick_timestamp -
src->directconnect_last_safe_access_time) <
ndpi_struct->directconnect_connection_ip_tick_timeout)) {
src->directconnect_last_safe_access_time = packet->tick_timestamp;
} else if (dst != NULL && ((u_int32_t)
(packet->tick_timestamp -
dst->directconnect_last_safe_access_time) <
ndpi_struct->directconnect_connection_ip_tick_timeout)) {
dst->directconnect_last_safe_access_time = packet->tick_timestamp;
} else {
packet->detected_protocol_stack[0] = NDPI_PROTOCOL_UNKNOWN;
NDPI_LOG(NDPI_PROTOCOL_DIRECTCONNECT, ndpi_struct,
NDPI_LOG_DEBUG, "directconnect: skipping as unknown due to timeout\n");
}
return;
}
if (packet->tcp != NULL) {
ndpi_search_directconnect_tcp(ndpi_struct, flow);
} else if (packet->udp != NULL) {
ndpi_search_directconnect_udp(ndpi_struct, flow);
}
}
void init_directconnect_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("DirectConnect", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DIRECTCONNECT,
ndpi_search_directconnect,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+736
View File
@@ -0,0 +1,736 @@
/*
* directdownloadlink.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-14svn - 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_protocols.h"
#ifdef NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK
#ifdef NDPI_DEBUG_DIRECT_DOWNLOAD_LINK
//#define NDPI_DEBUG_DIRECT_DOWNLOAD_LINK_NOTHING_FOUND
//#define NDPI_DEBUG_DIRECT_DOWNLOAD_LINK_PACKET_TOO_SMALL
#define NDPI_DEBUG_DIRECT_DOWNLOAD_LINK_IP
#endif
static void ndpi_int_direct_download_link_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, NDPI_PROTOCOL_UNKNOWN);
flow->l4.tcp.ddlink_server_direction = packet->packet_direction;
}
/*
return 0 if nothing has been detected
return 1 if it is a megaupload packet
*/
u_int8_t search_ddl_domains(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
u_int16_t filename_start = 0;
u_int8_t i = 1;
u_int16_t host_line_len_without_port;
if (packet->payload_packet_len < 100) {
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: Packet too small.\n");
goto end_ddl_nothing_found;
}
if (memcmp(packet->payload, "POST ", 5) == 0) {
filename_start = 5; // POST
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: POST FOUND\n");
} else if (memcmp(packet->payload, "GET ", 4) == 0) {
filename_start = 4; // GET
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: GET FOUND\n");
} else {
goto end_ddl_nothing_found;
}
// parse packet
ndpi_parse_packet_line_info(ndpi_struct, flow);
if (packet->host_line.ptr == NULL) {
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: NO HOST FOUND\n");
goto end_ddl_nothing_found;
}
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: Host: found\n");
if (packet->line[0].len < 9 + filename_start
|| memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) != 0) {
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct,
NDPI_LOG_DEBUG, "DDL: PACKET NOT HTTP CONFORM.\nXXX%.*sXXX\n",
8, &packet->line[0].ptr[packet->line[0].len - 9]);
goto end_ddl_nothing_found;
}
// BEGIN OF AUTOMATED CODE GENERATION
// first see if we have ':port' at the end of the line
host_line_len_without_port = packet->host_line.len;
if (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] >= '0'
&& packet->host_line.ptr[packet->host_line.len - i] <= '9') {
i = 2;
while (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] >= '0'
&& packet->host_line.ptr[host_line_len_without_port - i] <= '9') {
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: number found\n");
i++;
}
if (host_line_len_without_port >= i && packet->host_line.ptr[host_line_len_without_port - i] == ':') {
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: ':' found\n");
host_line_len_without_port = host_line_len_without_port - i;
}
}
// then start automated code generation
if (host_line_len_without_port >= 0 + 4
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 0 - 4], ".com", 4) == 0) {
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'd') {
if (host_line_len_without_port >= 5 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 6], "4share", 6) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 6 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 8], "fileclou", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 5
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 5], "uploa", 5) == 0) {
if (host_line_len_without_port >= 10 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 6], "files-", 6) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 6 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 4], "mega", 4) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 5], "rapid", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 5], "turbo", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'o') {
if (host_line_len_without_port >= 5 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 6], "badong", 6) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 6 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 5], "fileh", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'g') {
if (host_line_len_without_port >= 5 + 2
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 2], "in", 2) == 0) {
if (host_line_len_without_port >= 7 + 4
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 7 - 4], "shar", 4) == 0) {
if (host_line_len_without_port >= 11 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 11 - 4], "best", 4) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 11 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 11 - 4 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 11 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 11 - 5], "quick", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 11 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 11 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 7 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 7 - 6], "upload", 6) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 7 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 7 - 6 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 5 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 7], "sharebi", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 8], "bigfilez", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'e') {
if (host_line_len_without_port >= 5 + 3
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 3], "fil", 3) == 0) {
if (host_line_len_without_port >= 8 + 2
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 2], "mo", 2) == 0) {
if (host_line_len_without_port >= 10 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 5], "china", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 8 + 2 + 1
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 2 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 2 - 1] == '.')) {
goto end_ddl_found;
}
}
if (host_line_len_without_port >= 8 + 3 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 3], "hot", 3) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 3 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 3 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 8 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 6], "keepmy", 6) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 6 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 8 + 1
&& packet->host_line.ptr[host_line_len_without_port - 8 - 1] == 'e') {
if (host_line_len_without_port >= 9 + 3 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 9 - 3], "sav", 3) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 9 - 3 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 9 - 3 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 9 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 9 - 5], "sendm", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 9 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 9 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 8 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 8], "sharebig", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 8 + 3 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 3], "up-", 3) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 3 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 3 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 5 + 1 && packet->host_line.ptr[host_line_len_without_port - 5 - 1] == 'r') {
if (host_line_len_without_port >= 6 + 3
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 6 - 3], "sha", 3) == 0) {
if (host_line_len_without_port >= 9 + 1
&& packet->host_line.ptr[host_line_len_without_port - 9 - 1] == '-') {
if (host_line_len_without_port >= 10 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 4], "easy",
4) == 0 && (packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] ==
'.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 4], "fast",
4) == 0 && (packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] ==
'.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 4], "live",
4) == 0 && (packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 4 - 1] ==
'.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 9 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 9 - 4], "ftp2", 4) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 9 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 9 - 4 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 9 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 9 - 4], "gige", 4) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 9 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 9 - 4 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 9 + 4 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 9 - 4], "mega", 4) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 9 - 4 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 9 - 4 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 9 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 9 - 5], "rapid", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 9 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 9 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 6 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 6 - 7], "mediafi", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 6 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 6 - 7 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 5 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 7], "gigasiz", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 8], "sendspac", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 7], "sharebe", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 11 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 11], "sharebigfli", 11) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 11 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 11 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 8], "fileserv", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 's') {
if (host_line_len_without_port >= 5 + 1 && packet->host_line.ptr[host_line_len_without_port - 5 - 1] == 'e') {
if (host_line_len_without_port >= 6 + 10 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 6 - 10], "depositfil",
10) == 0 && (packet->host_line.ptr[host_line_len_without_port - 6 - 10 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 6 - 10 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 6 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 6 - 8], "megashar", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 6 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 6 - 8 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 5 + 10 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 10], "fileupyour", 10) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 10 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 10 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 11 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 11], "filefactory", 11) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 11 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 11 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 't') {
if (host_line_len_without_port >= 5 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 8], "filefron", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 10 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 10], "uploadingi", 10) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 10 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 10 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 11 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 11], "yourfilehos", 11) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 11 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 11 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'r') {
if (host_line_len_without_port >= 5 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 8], "mytempdi", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 10 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 10], "uploadpowe", 10) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 10 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 10 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 9 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 9], "mega.1280", 9) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 9 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 9 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 9 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 9], "filesonic", 9) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 9 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 9 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 4
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 0 - 4], ".net", 4) == 0) {
if (host_line_len_without_port >= 4 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 7], "badongo", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 7 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'd') {
if (host_line_len_without_port >= 5 + 3
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 3], "loa", 3) == 0) {
if (host_line_len_without_port >= 8 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 5], "fast-", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 8 + 2
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 2], "up", 2) == 0) {
if (host_line_len_without_port >= 10 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 5], "file-", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 6], "simple",
6) == 0 && (packet->host_line.ptr[host_line_len_without_port - 10 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 6 - 1] ==
'.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 10 + 3 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 10 - 3], "wii", 3) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 10 - 3 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 10 - 3 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 5 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 7], "filesen", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 7 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 4 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 5], "filer", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 9 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 9], "livedepot", 9) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 9 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 9 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 1 && packet->host_line.ptr[host_line_len_without_port - 4 - 1] == 'e') {
if (host_line_len_without_port >= 5 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 5], "mofil", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 17 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 17], "odsiebie.najlepsz",
17) == 0 && (packet->host_line.ptr[host_line_len_without_port - 5 - 17 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 17 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 5 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 5 - 5], "zshar", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 5 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 5 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 1 && packet->host_line.ptr[host_line_len_without_port - 0 - 1] == 'u') {
if (host_line_len_without_port >= 1 + 6 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 1 - 6], "data.h", 6) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 1 - 6 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 1 - 6 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 1 + 2
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 1 - 2], ".r", 2) == 0) {
if (host_line_len_without_port >= 3 + 10 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 10], "filearchiv", 10) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 10 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 10 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 3 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 8], "filepost", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 8 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 3 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 7], "ifolder", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 7 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 11 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 0 - 11], "filehost.tv", 11) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 0 - 11 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 0 - 11 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 0 + 3
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 0 - 3], ".to", 3) == 0) {
if (host_line_len_without_port >= 3 + 1 && packet->host_line.ptr[host_line_len_without_port - 3 - 1] == 'e') {
if (host_line_len_without_port >= 4 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 7], "filesaf", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 7 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 8 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 8], "sharebas", 8) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 8 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 8 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 3 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 5], "files", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 3 + 1 && packet->host_line.ptr[host_line_len_without_port - 3 - 1] == 'd') {
if (host_line_len_without_port >= 4 + 3
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 3], "loa", 3) == 0) {
if (host_line_len_without_port >= 7 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 7 - 7], "file-up", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 7 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 7 - 7 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 4 + 3 + 1
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 3 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 3 - 1] == '.')) {
goto end_ddl_found;
}
}
if (host_line_len_without_port >= 4 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 4 - 7], "uploade", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 4 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 4 - 7 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 1 && packet->host_line.ptr[host_line_len_without_port - 0 - 1] == 'z') {
if (host_line_len_without_port >= 1 + 14 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 1 - 14], "leteckaposta.c", 14) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 1 - 14 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 1 - 14 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 1 + 12 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 1 - 12], "yourfiles.bi", 12) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 1 - 12 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 1 - 12 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 1 && packet->host_line.ptr[host_line_len_without_port - 0 - 1] == 'n') {
if (host_line_len_without_port >= 1 + 9 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 1 - 9], "netload.i", 9) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 1 - 9 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 1 - 9 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 1 + 2
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 1 - 2], ".v", 2) == 0) {
if (host_line_len_without_port >= 3 + 7 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 7], "4shared", 7) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 7 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 7 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 3 + 9 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 9], "megashare", 9) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 9 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 9 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 3
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 0 - 3], ".de", 3) == 0) {
if (host_line_len_without_port >= 3 + 5
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 5], "share", 5) == 0) {
if (host_line_len_without_port >= 8 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 5], "rapid", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 5 - 1] == '.')) {
goto end_ddl_found;
}
if (host_line_len_without_port >= 8 + 5 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 8 - 5], "ultra", 5) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 8 - 5 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 8 - 5 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 3 + 15 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 3 - 15], "uploadyourfiles", 15) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 3 - 15 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 3 - 15 - 1] == '.')) {
goto end_ddl_found;
}
goto end_ddl_nothing_found;
}
if (host_line_len_without_port >= 0 + 14 + 1
&& memcmp((void *) &packet->host_line.ptr[host_line_len_without_port - 0 - 14], "speedshare.org", 14) == 0
&& (packet->host_line.ptr[host_line_len_without_port - 0 - 14 - 1] == ' '
|| packet->host_line.ptr[host_line_len_without_port - 0 - 14 - 1] == '.')) {
goto end_ddl_found;
}
// END OF AUTOMATED CODE GENERATION
/* This is the hard way. We do this in order to find the download of services when other
domains are involved. This is not significant if ddl is blocked. --> then the link can not be started because
the ads are not viewed. But when ddl is only limited then the download is the important part.
*/
end_ddl_nothing_found:
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG,
"Nothing Found\n");
return 0;
end_ddl_found:
NDPI_LOG(NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, ndpi_struct, NDPI_LOG_DEBUG, "DDL: DIRECT DOWNLOAD LINK FOUND\n");
ndpi_int_direct_download_link_add_connection(ndpi_struct, flow);
return 1;
}
void ndpi_search_direct_download_link_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=ndpi_struct->src; */
/* struct ndpi_id_struct *dst=ndpi_struct->dst; */
/* do not detect again if it is already ddl */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
if (search_ddl_domains(ndpi_struct, flow) != 0) {
return;
}
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK);
}
}
void init_directdownloadlink_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Direct_Download_Link", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK,
ndpi_search_direct_download_link_tcp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+249
View File
@@ -0,0 +1,249 @@
/*
* dns.c
*
* Copyright (C) 2012-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/>.
*
*/
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_DNS
#define FLAGS_MASK 0x8000
/* #define DNS_DEBUG 1 */
/* *********************************************** */
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)
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));
}
}
/* *********************************************** */
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
int x;
u_int8_t is_query;
u_int16_t s_port = 0, d_port = 0;
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "search DNS.\n");
if(flow->packet.udp != NULL) {
s_port = ntohs(flow->packet.udp->source);
d_port = ntohs(flow->packet.udp->dest);
x = 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;
} else {
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "exclude DNS.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
}
if((s_port == 53 || d_port == 53 || d_port == 5355)
&& (flow->packet.payload_packet_len > sizeof(struct ndpi_dns_packet_header))) {
struct ndpi_dns_packet_header dns_header;
int invalid = 0;
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
invalid = 1;
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 */
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
printf("[%s:%d] query_type=%2d\n", __FILE__, __LINE__, flow->protos.dns.query_type);
#endif
break;
} else
x++;
}
}
} else
invalid = 1;
} 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 */
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_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "exclude DNS.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
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(flow->packet.payload[off] != '\0' && off < flow->packet.payload_packet_len) {
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++;
}
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_match_host_subprotocol(ndpi_struct, flow,
(char *)flow->host_server_name,
strlen((const char*)flow->host_server_name),
NDPI_PROTOCOL_DNS);
#ifdef DNS_DEBUG
printf("[%s:%d] [num_queries=%d][num_answers=%d][reply_code=%u][rsp_type=%u][host_server_name=%s]\n",
__FILE__, __LINE__,
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) {
if(is_query && ndpi_struct->dns_dissect_response)
return; /* The response will set the verdict */
/**
Do not set the protocol with DNS if ndpi_match_host_subprotocol() has
matched a subprotocol
**/
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "found DNS.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_PROTOCOL_UNKNOWN);
} else {
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "exclude DNS.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DNS);
}
}
}
}
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,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+160
View File
@@ -0,0 +1,160 @@
/*
* dofus.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_api.h"
#ifdef NDPI_PROTOCOL_DOFUS
static void ndpi_dofus_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DOFUS, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_dofus(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
/* Dofus v 1.x.x */
if (packet->payload_packet_len == 13 && get_u_int16_t(packet->payload, 1) == ntohs(0x0508)
&& get_u_int16_t(packet->payload, 5) == ntohs(0x04a0)
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) == ntohs(0x0194)) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow);
return;
}
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 3 && memcmp(packet->payload, "HG", 2) == 0
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 35 && memcmp(packet->payload, "HC", 2) == 0
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len > 2 && packet->payload[0] == 'A'
&& (packet->payload[1] == 'x' || packet->payload[1] == 'X')
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len == 12 && memcmp(packet->payload, "Af", 2) == 0
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (flow->l4.tcp.dofus_stage == 0 && packet->payload_packet_len > 2 && memcmp(packet->payload, "Ad", 2)
&& packet->payload[packet->payload_packet_len - 1] == 0) {
flow->l4.tcp.dofus_stage = 1;
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "maybe dofus.\n");
return;
}
if (packet->payload_packet_len == 11 && memcmp(packet->payload, "AT", 2) == 0 && packet->payload[10] == 0x00) {
if (flow->l4.tcp.dofus_stage == 1) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow);
return;
}
}
if (flow->l4.tcp.dofus_stage == 1 && packet->payload_packet_len == 5
&& packet->payload[0] == 'A' && packet->payload[4] == 0x00 && (packet->payload[1] == 'T'
|| packet->payload[1] == 'k')) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus asym.\n");
ndpi_dofus_add_connection(ndpi_struct, flow);
return;
}
/* end Dofus 1.x.x */
/* Dofus 2.0 */
if ((packet->payload_packet_len == 11 || packet->payload_packet_len == 13 || packet->payload_packet_len == 49)
&& get_u_int32_t(packet->payload, 0) == ntohl(0x00050800)
&& get_u_int16_t(packet->payload, 4) == ntohs(0x0005)
&& get_u_int16_t(packet->payload, 8) == ntohs(0x0005)
&& packet->payload[10] == 0x18) {
if (packet->payload_packet_len == 13
&& get_u_int16_t(packet->payload, packet->payload_packet_len - 2) != ntohs(0x0194)) {
goto exclude;
}
if (packet->payload_packet_len == 49 && ntohs(get_u_int16_t(packet->payload, 15)) + 17 != packet->payload_packet_len) {
goto exclude;
}
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len >= 41 && get_u_int16_t(packet->payload, 0) == ntohs(0x01b9) && packet->payload[2] == 0x26) {
u_int16_t len, len2;
len = ntohs(get_u_int16_t(packet->payload, 3));
if ((len + 5 + 2) > packet->payload_packet_len)
goto exclude;
len2 = ntohs(get_u_int16_t(packet->payload, 5 + len));
if (5 + len + 2 + len2 == packet->payload_packet_len) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow);
return;
}
}
if (packet->payload_packet_len == 56
&& memcmp(packet->payload, "\x00\x11\x35\x02\x03\x00\x93\x96\x01\x00", 10) == 0) {
u_int16_t len, len2;
len = ntohs(get_u_int16_t(packet->payload, 10));
if ((len + 12 + 2) > packet->payload_packet_len)
goto exclude;
len2 = ntohs(get_u_int16_t(packet->payload, 12 + len));
if ((12 + len + 2 + len2 + 1) > packet->payload_packet_len)
goto exclude;
if (12 + len + 2 + len2 + 1 == packet->payload_packet_len && packet->payload[12 + len + 2 + len2] == 0x01) {
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "found dofus.\n");
ndpi_dofus_add_connection(ndpi_struct, flow);
return;
}
}
exclude:
NDPI_LOG(NDPI_PROTOCOL_DOFUS, ndpi_struct, NDPI_LOG_DEBUG, "exclude dofus.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DOFUS);
}
void init_dofus_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Dofus", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DOFUS,
ndpi_search_dofus,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+106
View File
@@ -0,0 +1,106 @@
/*
* drda.c
*
* Copyright (C) 2012-16 - ntop.org
*
* This module 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.
*
* This module 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.
* If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ndpi_api.h"
#ifdef NDPI_PROTOCOL_DRDA
#define DRDA_PORT 50000
struct ndpi_drda_hdr {
u_int16_t length;
u_int8_t magic;
u_int8_t format;
u_int16_t correlID;
u_int16_t length2;
u_int16_t code_pnt;
};
void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct * packet = &flow->packet;
u_int16_t payload_len = packet->payload_packet_len;
u_int16_t count = 0;
if(packet->tcp != NULL) {
/* check port */
if((ntohs(packet->tcp->source) == DRDA_PORT ||
ntohs(packet->tcp->dest) == DRDA_PORT)) {
struct ndpi_drda_hdr * drda = (struct ndpi_drda_hdr *) packet->payload;
u_int16_t len = ntohs(drda->length);
/* check first header */
if(len - 6 != ntohs(drda->length2) &&
drda->magic != 0xd0)
goto no_drda;
/* check if there are more drda headers */
if(payload_len > len) {
count = len;
const u_int8_t * pp = packet->payload + len;
while(count < payload_len)
{
/* update info */
drda = (struct ndpi_drda_hdr *) pp;
len = ntohs(drda->length);
if(len - 6 != ntohs(drda->length2) &&
drda->magic != 0xd0)
goto no_drda;
count += len;
}
if(count != payload_len) goto no_drda;
}
NDPI_LOG(NDPI_PROTOCOL_DRDA, ndpi_struct, NDPI_LOG_DEBUG, "found DRDA.\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DRDA, NDPI_PROTOCOL_UNKNOWN);
return;
}
}
no_drda:
NDPI_LOG(NDPI_PROTOCOL_DRDA, ndpi_struct, NDPI_LOG_DEBUG, "exclude DRDA.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DRDA);
}
/* ***************************************************************** */
void init_drda_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("DRDA", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DRDA,
ndpi_search_drda,
NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif /* NDPI_PROTOCOL_DRDA */
+94
View File
@@ -0,0 +1,94 @@
/*
* dropbox.c
*
* Copyright (C) 2012-16 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_api.h"
#ifdef NDPI_PROTOCOL_DROPBOX
#define DB_LSP_PORT 17500
static void ndpi_int_dropbox_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow,
u_int8_t due_to_correlation)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DROPBOX, NDPI_PROTOCOL_UNKNOWN);
}
static void ndpi_check_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// const u_int8_t *packet_payload = packet->payload;
u_int32_t payload_len = packet->payload_packet_len;
if(packet->udp != NULL) {
u_int16_t dropbox_port = htons(DB_LSP_PORT);
if((packet->udp->source == dropbox_port)
&& (packet->udp->dest == dropbox_port)) {
if(payload_len > 2) {
if(strncmp((const char *)packet->payload, "{\"host_int\"", 11) == 0) {
NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "Found dropbox.\n");
ndpi_int_dropbox_add_connection(ndpi_struct, flow, 0);
return;
}
}
}
}
NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "exclude dropbox.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DROPBOX);
}
void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG(NDPI_PROTOCOL_DROPBOX, ndpi_struct, NDPI_LOG_DEBUG, "dropbox detection...\n");
/* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_DROPBOX) {
if (packet->tcp_retransmission == 0) {
ndpi_check_dropbox(ndpi_struct, flow);
}
}
}
void init_dropbox_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("DROPBOX", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_DROPBOX,
ndpi_search_dropbox,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+85
View File
@@ -0,0 +1,85 @@
/*
* eaq.c
*
* Copyright (C) 2015 - ntop.org
*
* This module 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.
*
* This module 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.
* If not, see <http://www.gnu.org/licenses/>.
*
*/
/*
EAQ: Entitade Aferidora da Qualidade de Banda Larga
http://www.brasilbandalarga.com.br
*/
#include "ndpi_api.h"
#define EAQ_DEFAULT_PORT 6000
#define EAQ_DEFAULT_SIZE 16
#ifdef NDPI_PROTOCOL_EAQ
static void ndpi_int_eaq_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EAQ, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
if((packet->payload_packet_len != EAQ_DEFAULT_SIZE)
|| ((sport != EAQ_DEFAULT_PORT) && (dport != EAQ_DEFAULT_PORT))) {
exclude_eaq:
NDPI_LOG(NDPI_PROTOCOL_EAQ, ndpi_struct, NDPI_LOG_DEBUG, "Exclude eaq.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_EAQ);
return;
}
if(packet->udp != NULL) {
u_int32_t seq = (packet->payload[0] * 1000) + (packet->payload[1] * 100) + (packet->payload[2] * 10) + packet->payload[3];
if(flow->l4.udp.eaq_pkt_id == 0)
flow->l4.udp.eaq_sequence = seq;
else {
if((flow->l4.udp.eaq_sequence == seq) || ((flow->l4.udp.eaq_sequence+1) == seq)) {
; /* Looks good */
} else
goto exclude_eaq;
}
if(++flow->l4.udp.eaq_pkt_id == 4) {
/* We have collected enough packets so we assume it's EAQ */
NDPI_LOG(NDPI_PROTOCOL_EAQ, ndpi_struct, NDPI_LOG_DEBUG, "found eaq.\n");
ndpi_int_eaq_add_connection(ndpi_struct, flow);
}
} else
goto exclude_eaq;
}
void init_eaq_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("EAQ", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_EAQ,
ndpi_search_eaq,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+224
View File
@@ -0,0 +1,224 @@
/*
* edonkey.c
*
* Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
*
* The signature is based on the Libprotoident library.
*
* 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_api.h"
#ifdef NDPI_PROTOCOL_EDONKEY
static void ndpi_int_edonkey_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EDONKEY, NDPI_PROTOCOL_UNKNOWN);
}
static int ndpi_edonkey_payload_check(const u_int8_t *data, u_int32_t len) {
if ((len >= 4) && (data[0] == 0xe3) && (data[2] == 0x00) && (data[3] == 0x00))
return 1;
if ((len >= 4) && (data[0] == 0xc5) && (data[2] == 0x00) && (data[3] == 0x00))
return 1;
if ((len >= 2) && (data[0] == 0xe5) && (data[1] == 0x43))
return 1;
if ((len >= 4) && (data[0] == 0xe5) && (data[1] == 0x08) && (data[2] == 0x78) && (data[3] == 0xda))
return 1;
if ((len >= 4) && (data[0] == 0xe5) && (data[1] == 0x28) && (data[2] == 0x78) && (data[3] == 0xda))
return 1;
if ((len >= 2) && (data[0] == 0xc5) && (data[1] == 0x90))
return 1;
if ((len >= 2) && (data[0] == 0xc5) && (data[1] == 0x91))
return 1;
if ((len == 2) && (data[0] == 0xc5) && (data[1] == 0x92))
return 1;
if ((len == 2) && (data[0] == 0xc5) && (data[1] == 0x93))
return 1;
if ((len >= 38 && len <= 70) && (data[0] == 0xc5) && (data[1] == 0x94))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0x9a))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0x9b))
return 1;
if ((len == 6) && (data[0] == 0xe3) && (data[1] == 0x96))
return 1;
if ((len <= 34 && ((len - 2) % 4 == 0)) && (data[0] == 0xe3) && (data[1] == 0x97))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0x92))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0x94))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0x98))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0x99))
return 1;
if ((len == 6) && (data[0] == 0xe3) && (data[1] == 0xa2))
return 1;
if ((len >= 2) && (data[0] == 0xe3) && (data[1] == 0xa3))
return 1;
if ((len == 27) && (data[0] == 0xe4) && (data[1] == 0x00))
return 1;
if ((len == 529) && (data[0] == 0xe4) && (data[1] == 0x08))
return 1;
if ((len == 18) && (data[0] == 0xe4) && (data[1] == 0x01) && (data[2] == 0x00) && (data[3] == 0x00))
return 1;
if ((len == 523) && (data[0] == 0xe4) && (data[1] == 0x09))
return 1;
if ((len == 35) && (data[0] == 0xe4) && (data[1] == 0x21))
return 1;
if ((len == 19) && (data[0] == 0xe4) && (data[1] == 0x4b))
return 1;
if ((len >= 2) && (data[0] == 0xe4) && (data[1] == 0x11))
return 1;
if ((len == 22 || len == 38 || len == 28) && (data[0] == 0xe4) && (data[1] == 0x19))
return 1;
if ((len == 35) && (data[0] == 0xe4) && (data[1] == 0x20))
return 1;
if ((len == 27) && (data[0] == 0xe4) && (data[1] == 0x18))
return 1;
if ((len == 27) && (data[0] == 0xe4) && (data[1] == 0x10))
return 1;
if ((len == 6) && (data[0] == 0xe4) && (data[1] == 0x58))
return 1;
if ((len == 4) && (data[0] == 0xe4) && (data[1] == 0x50))
return 1;
if ((len == 36) && (data[0] == 0xe4) && (data[1] == 0x52))
return 1;
if ((len == 48) && (data[0] == 0xe4) && (data[1] == 0x40))
return 1;
if ((len == 225) && (data[0] == 0xe4) && (data[1] == 0x43))
return 1;
if ((len == 19) && (data[0] == 0xe4) && (data[1] == 0x48))
return 1;
if ((len == 119 || len == 69 || len == 294) && (data[0] == 0xe4) && (data[1] == 0x29))
return 1;
if ((len == 119 || len == 69 || len == 294 || len == 44 || len == 269) && (data[0] == 0xe4) && (data[1] == 0x28))
return 1;
return 0;
}
static void ndpi_check_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
u_int32_t payload_len = packet->payload_packet_len;
/* Break after 20 packets. */
if (flow->packet_counter > 20) {
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "Exclude EDONKEY.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_EDONKEY);
return;
}
/* Check if we so far detected the protocol in the request or not. */
if (flow->edonkey_stage == 0) {
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "EDONKEY stage 0: \n");
if (ndpi_edonkey_payload_check(packet->payload, payload_len)) {
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "Possible EDONKEY request detected, we will look further for the response...\n");
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
flow->edonkey_stage = packet->packet_direction + 1;
}
} else {
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "EDONKEY stage %u: \n", flow->edonkey_stage);
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
if ((flow->edonkey_stage - packet->packet_direction) == 1) {
return;
}
/* This is a packet in another direction. Check if we find the proper response. */
if ((payload_len == 0) || (ndpi_edonkey_payload_check(packet->payload, payload_len))) {
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "Found EDONKEY.\n");
ndpi_int_edonkey_add_connection(ndpi_struct, flow);
} else {
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "The reply did not seem to belong to EDONKEY, resetting the stage to 0...\n");
flow->edonkey_stage = 0;
}
}
}
void ndpi_search_edonkey(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &flow->packet;
NDPI_LOG(NDPI_PROTOCOL_EDONKEY, ndpi_struct, NDPI_LOG_DEBUG, "EDONKEY detection...\n");
/* skip marked packets */
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_EDONKEY) {
if (packet->tcp_retransmission == 0) {
ndpi_check_edonkey(ndpi_struct, flow);
}
}
}
void init_edonkey_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("eDonkey", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_EDONKEY,
ndpi_search_edonkey,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+96
View File
@@ -0,0 +1,96 @@
/*
* fasttrack.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_FASTTRACK
static void ndpi_int_fasttrack_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FASTTRACK, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_fasttrack_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=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (packet->payload_packet_len > 6 && ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a) {
NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "detected 0d0a at the end of the packet.\n");
if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) {
u_int16_t i;
for (i = 5; i < (packet->payload_packet_len - 2); i++) {
// make shure that the argument to GIVE is numeric
if (!(packet->payload[i] >= '0' && packet->payload[i] <= '9')) {
goto exclude_fasttrack;
}
}
NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "FASTTRACK GIVE DETECTED\n");
ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) {
u_int8_t a = 0;
NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "detected GET /. \n");
ndpi_parse_packet_line_info(ndpi_struct, flow);
for (a = 0; a < packet->parsed_lines; a++) {
if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0)
|| (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) {
NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE,
"detected X-Kazaa-Username: || User-Agent: PeerEnabler/\n");
ndpi_int_fasttrack_add_connection(ndpi_struct, flow);
return;
}
}
}
}
exclude_fasttrack:
NDPI_LOG(NDPI_PROTOCOL_FASTTRACK, ndpi_struct, NDPI_LOG_TRACE, "fasttrack/kazaa excluded.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FASTTRACK);
}
void init_fasttrack_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("FastTrack", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_FASTTRACK,
ndpi_search_fasttrack_tcp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+108
View File
@@ -0,0 +1,108 @@
/*
* fiesta.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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 files */
#include "ndpi_protocols.h"
#ifdef NDPI_PROTOCOL_FIESTA
static void ndpi_int_fiesta_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FIESTA, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_fiesta(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
// struct ndpi_id_struct *src=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "search fiesta.\n");
if (flow->l4.tcp.fiesta_stage == 0 && packet->payload_packet_len == 5
&& get_u_int16_t(packet->payload, 0) == ntohs(0x0407)
&& (packet->payload[2] == 0x08)
&& (packet->payload[4] == 0x00 || packet->payload[4] == 0x01)) {
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "maybe fiesta symmetric, first packet.\n");
flow->l4.tcp.fiesta_stage = 1 + packet->packet_direction;
goto maybe_fiesta;
}
if (flow->l4.tcp.fiesta_stage == (2 - packet->packet_direction)
&& ((packet->payload_packet_len > 1 && packet->payload_packet_len - 1 == packet->payload[0])
|| (packet->payload_packet_len > 3 && packet->payload[0] == 0
&& get_l16(packet->payload, 1) == packet->payload_packet_len - 3))) {
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "Maybe fiesta.\n");
goto maybe_fiesta;
}
if (flow->l4.tcp.fiesta_stage == (1 + packet->packet_direction)) {
if (packet->payload_packet_len == 4 && get_u_int32_t(packet->payload, 0) == htonl(0x03050c01)) {
goto add_fiesta;
}
if (packet->payload_packet_len == 5 && get_u_int32_t(packet->payload, 0) == htonl(0x04030c01)
&& packet->payload[4] == 0) {
goto add_fiesta;
}
if (packet->payload_packet_len == 6 && get_u_int32_t(packet->payload, 0) == htonl(0x050e080b)) {
goto add_fiesta;
}
if (packet->payload_packet_len == 100 && packet->payload[0] == 0x63 && packet->payload[61] == 0x52
&& packet->payload[81] == 0x5a && get_u_int16_t(packet->payload, 1) == htons(0x3810)
&& get_u_int16_t(packet->payload, 62) == htons(0x6f75)) {
goto add_fiesta;
}
if (packet->payload_packet_len > 3 && packet->payload_packet_len - 1 == packet->payload[0]
&& get_u_int16_t(packet->payload, 1) == htons(0x140c)) {
goto add_fiesta;
}
}
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "exclude fiesta.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FIESTA);
return;
maybe_fiesta:
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "Stage is set to %d.\n", flow->l4.tcp.fiesta_stage);
return;
add_fiesta:
NDPI_LOG(NDPI_PROTOCOL_FIESTA, ndpi_struct, NDPI_LOG_DEBUG, "detected fiesta.\n");
ndpi_int_fiesta_add_connection(ndpi_struct, flow);
return;
}
void init_fiesta_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Fiesta", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_FIESTA,
ndpi_search_fiesta,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif
+95
View File
@@ -0,0 +1,95 @@
/*
* filetopia.c
*
* Copyright (C) 2009-2011 by ipoque GmbH
* Copyright (C) 2011-15 - 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_protocols.h"
#ifdef NDPI_PROTOCOL_FILETOPIA
static void ndpi_int_filetopia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_FILETOPIA, NDPI_PROTOCOL_UNKNOWN);
}
void ndpi_search_filetopia_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=ndpi_struct->src;
// struct ndpi_id_struct *dst=ndpi_struct->dst;
if (flow->l4.tcp.filetopia_stage == 0) {
if (packet->payload_packet_len >= 50 && packet->payload_packet_len <= 70
&& packet->payload[0] == 0x03 && packet->payload[1] == 0x9a
&& packet->payload[3] == 0x22 && packet->payload[packet->payload_packet_len - 1] == 0x2b) {
NDPI_LOG(NDPI_PROTOCOL_FILETOPIA, ndpi_struct, NDPI_LOG_DEBUG, "Filetopia stage 1 detected\n");
flow->l4.tcp.filetopia_stage = 1;
return;
}
} else if (flow->l4.tcp.filetopia_stage == 1) {
if (packet->payload_packet_len >= 100 && packet->payload[0] == 0x03
&& packet->payload[1] == 0x9a && (packet->payload[3] == 0x22 || packet->payload[3] == 0x23)) {
int i;
for (i = 0; i < 10; i++) { // check 10 bytes for valid ASCII printable characters
if (!(packet->payload[5 + i] >= 0x20 && packet->payload[5 + i] <= 0x7e)) {
goto end_filetopia_nothing_found;
}
}
NDPI_LOG(NDPI_PROTOCOL_FILETOPIA, ndpi_struct, NDPI_LOG_DEBUG, "Filetopia stage 2 detected\n");
flow->l4.tcp.filetopia_stage = 2;
return;
}
} else if (flow->l4.tcp.filetopia_stage == 2) {
if (packet->payload_packet_len >= 4 && packet->payload_packet_len <= 100
&& packet->payload[0] == 0x03 && packet->payload[1] == 0x9a
&& (packet->payload[3] == 0x22 || packet->payload[3] == 0x23)) {
NDPI_LOG(NDPI_PROTOCOL_FILETOPIA, ndpi_struct, NDPI_LOG_DEBUG, "Filetopia detected\n");
ndpi_int_filetopia_add_connection(ndpi_struct, flow);
return;
}
}
end_filetopia_nothing_found:
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FILETOPIA);
}
void init_filetopia_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id, NDPI_PROTOCOL_BITMASK *detection_bitmask)
{
ndpi_set_bitmask_protocol_detection("Filetopia", ndpi_struct, detection_bitmask, *id,
NDPI_PROTOCOL_FILETOPIA,
ndpi_search_filetopia_tcp,
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}
#endif

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