Initial import from SVN
This commit is contained in:
@@ -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.
|
||||||
@@ -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
|
||||||
@@ -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.
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -1 +1,58 @@
|
|||||||
# ndpi
|
This directory contains a modified version of OpenDPI which
|
||||||
|
includes ntop extensions. I have tried to push them into the
|
||||||
|
OpenDPI source tree but nobody in answering emails so I have
|
||||||
|
decided to create my own source tree
|
||||||
|
|
||||||
|
==========
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
==========
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
==========
|
||||||
|
|
||||||
|
If you want to distribute a source tar file of nDPI do:
|
||||||
|
|
||||||
|
# make dist
|
||||||
|
|
||||||
|
--------------------------
|
||||||
|
April 2015 - ntop
|
||||||
@@ -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 begin 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
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.5.1 r8171 06/09/2014
|
||||||
|
#
|
||||||
|
autoreconf -ivf
|
||||||
|
./configure
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
AC_INIT([libndpi], [1.5.2])
|
||||||
|
|
||||||
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
|
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||||
|
|
||||||
|
LT_INIT
|
||||||
|
|
||||||
|
AC_PROG_CC
|
||||||
|
AX_PTHREAD
|
||||||
|
|
||||||
|
if test -d ".svn"; then :
|
||||||
|
SVN_RELEASE=`svn info . | grep "^Revision"|cut -d " " -f 2`
|
||||||
|
SVN_DATE=`svn info . | grep "^Last Changed Date"|cut -d " " -f 4-`
|
||||||
|
else
|
||||||
|
SVN_RELEASE="${PACKAGE_VERSION}"
|
||||||
|
SVN_DATE=`date`
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(NDPI_SVN_RELEASE, "r${SVN_RELEASE}", [SVN Release])
|
||||||
|
AC_DEFINE_UNQUOTED(NDPI_SVN_DATE, "${SVN_DATE}", [Last SVN 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"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if test -d /usr/local/include/json-c/; then :
|
||||||
|
CFLAGS="$CFLAGS -I/usr/local/include/json-c/"
|
||||||
|
LDFLAGS="$LDFLAGS -L/usr/local/lib -ljson-c"
|
||||||
|
else
|
||||||
|
CFLAGS="$CFLAGS $(pkg-config --cflags json-c)"
|
||||||
|
LDFLAGS="$LDFLAGS $(pkg-config --libs json-c)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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(json-c, json_object_new_object, AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [The JSON-C library is present]))
|
||||||
|
|
||||||
|
AC_CONFIG_FILES([Makefile src/lib/Makefile example/Makefile libndpi.pc])
|
||||||
|
AC_CONFIG_HEADERS(config.h)
|
||||||
|
AC_SUBST(SVN_RELEASE)
|
||||||
|
AC_SUBST(SVN_DATE)
|
||||||
|
AC_SUBST(JSON_C_LIB)
|
||||||
|
AC_SUBST(PCAP_INC)
|
||||||
|
AC_SUBST(PCAP_LIB)
|
||||||
|
|
||||||
|
AC_OUTPUT
|
||||||
Binary file not shown.
Binary file not shown.
@@ -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
|
||||||
|
|
||||||
|
ndpiReader.o: ndpiReader.c
|
||||||
|
|
||||||
@@ -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.
@@ -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,230 @@
|
|||||||
|
<?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\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,462 @@
|
|||||||
|
<?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\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>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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@
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
ndpi_dump_protocols
|
||||||
|
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_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
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
This package is a GPL implementation of an iptables and netfilter module for
|
||||||
|
nDPI integration into the Linux kernel.
|
||||||
|
|
||||||
|
https://github.com/ewildgoose/ndpi-netfilter
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
require "formula"
|
||||||
|
|
||||||
|
class Ndpi < Formula
|
||||||
|
homepage "http://www.ntop.org/products/ndpi/"
|
||||||
|
url "https://downloads.sourceforge.net/project/ntop/nDPI/libndpi-1.5.1.tar.gz"
|
||||||
|
sha1 "0a6ed585545ab6611f3f0ac9efd9eb36bb5481dd"
|
||||||
|
|
||||||
|
depends_on "autoconf" => :build
|
||||||
|
depends_on "automake" => :build
|
||||||
|
depends_on "pkg-config" => :build
|
||||||
|
depends_on "libtool" => :build
|
||||||
|
depends_on "json-c"
|
||||||
|
|
||||||
|
def install
|
||||||
|
system "./configure","--prefix=#{prefix}"
|
||||||
|
system "make"
|
||||||
|
system "make", "install"
|
||||||
|
end
|
||||||
|
|
||||||
|
test do
|
||||||
|
system "#{bin}/ndpiReader","-h"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
+2863
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||||
@@ -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.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
This directory contains the files needed to build the package
|
||||||
|
named 'nprobe' for the Debian GNU/Linux distribution.
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ndpi (@NDPI_VERS@-@SVN_RELEASE@) stable; urgency=high
|
||||||
|
* Last packaged version
|
||||||
|
|
||||||
|
-- Luca Deri <deri@ntop.org> @DATE@
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
usr/local/ndpi
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
README
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ndpi_@NDPI_VERS@_@EXTN@.deb free optional
|
||||||
Executable
+34
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
Executable
+14
@@ -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
|
||||||
Executable
+59
@@ -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
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
library_includedir=$(includedir)/libndpi-1.4/libndpi
|
||||||
|
|
||||||
|
library_include_HEADERS = ndpi_api.h \
|
||||||
|
ndpi_debug_functions.h \
|
||||||
|
ndpi_define.h \
|
||||||
|
ndpi_macros.h \
|
||||||
|
ndpi_protocols_osdpi.h \
|
||||||
|
ndpi_public_functions.h
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
* linux_compat.h
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __NDPI_LINUX_COMPAT_H__
|
||||||
|
#define __NDPI_LINUX_COMPAT_H__
|
||||||
|
|
||||||
|
#include "ndpi_define.h"
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
#include <machine/endian.h>
|
||||||
|
|
||||||
|
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||||
|
#ifndef __LITTLE_ENDIAN__
|
||||||
|
#define __LITTLE_ENDIAN__ 1
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef __BIG_ENDIAN__
|
||||||
|
#define __BIG_ENDIAN__ 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma pack(push, 1) /* push current alignment to stack */
|
||||||
|
#pragma pack(1) /* set alignment to 1 byte boundary */
|
||||||
|
|
||||||
|
#pragma pack(pop) /* restore original alignment from stack */
|
||||||
|
|
||||||
|
struct ndpi_ethhdr {
|
||||||
|
u_char h_dest[6]; /* destination eth addr */
|
||||||
|
u_char h_source[6]; /* source ether addr */
|
||||||
|
u_int16_t h_proto; /* packet type ID field */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ndpi_80211q {
|
||||||
|
u_int16_t vlanId;
|
||||||
|
u_int16_t protoType;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ndpi_iphdr {
|
||||||
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
|
u_int8_t ihl:4, version:4;
|
||||||
|
#elif defined(__BIG_ENDIAN__)
|
||||||
|
u_int8_t version:4, ihl:4;
|
||||||
|
#else
|
||||||
|
# error "Byte order must be defined"
|
||||||
|
#endif
|
||||||
|
u_int8_t tos;
|
||||||
|
u_int16_t tot_len;
|
||||||
|
u_int16_t id;
|
||||||
|
u_int16_t frag_off;
|
||||||
|
u_int8_t ttl;
|
||||||
|
u_int8_t protocol;
|
||||||
|
u_int16_t check;
|
||||||
|
u_int32_t saddr;
|
||||||
|
u_int32_t daddr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
#define _WS2TCPIP_H_ /* Avoid compilation problems */
|
||||||
|
#define HAVE_SIN6_LEN
|
||||||
|
|
||||||
|
|
||||||
|
/* IPv6 address */
|
||||||
|
/* Already defined in WS2tcpip.h */
|
||||||
|
struct ndpi_win_in6_addr
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
u_int8_t u6_addr8[16];
|
||||||
|
u_int16_t u6_addr16[8];
|
||||||
|
u_int32_t u6_addr32[4];
|
||||||
|
} in6_u;
|
||||||
|
#ifdef s6_addr
|
||||||
|
#undef s6_addr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef s6_addr16
|
||||||
|
#undef s6_addr16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef s6_addr32
|
||||||
|
#undef s6_addr32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define s6_addr in6_u.u6_addr8
|
||||||
|
// #define s6_addr16 in6_u.u6_addr16
|
||||||
|
// #define s6_addr32 in6_u.u6_addr32
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#define in6_addr win_in6_addr
|
||||||
|
|
||||||
|
/* Generic extension header. */
|
||||||
|
struct ndpi_ip6_ext
|
||||||
|
{
|
||||||
|
u_int8_t ip6e_nxt; /* next header. */
|
||||||
|
u_int8_t ip6e_len; /* length in units of 8 octets. */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define s6_addr16 __u6_addr.__u6_addr16
|
||||||
|
#define s6_addr32 __u6_addr.__u6_addr32
|
||||||
|
#else
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct ndpi_in6_addr {
|
||||||
|
union {
|
||||||
|
u_int8_t __u6_addr8[16];
|
||||||
|
u_int16_t __u6_addr16[8];
|
||||||
|
u_int32_t __u6_addr32[4];
|
||||||
|
} __u6_addr; /* 128-bit IP6 address */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ndpi_ip6_hdr {
|
||||||
|
union {
|
||||||
|
struct ndpi_ip6_hdrctl {
|
||||||
|
u_int32_t ip6_un1_flow;
|
||||||
|
u_int16_t ip6_un1_plen;
|
||||||
|
u_int8_t ip6_un1_nxt;
|
||||||
|
u_int8_t ip6_un1_hlim;
|
||||||
|
} ip6_un1;
|
||||||
|
u_int8_t ip6_un2_vfc;
|
||||||
|
} ip6_ctlun;
|
||||||
|
struct ndpi_in6_addr ip6_src;
|
||||||
|
struct ndpi_in6_addr ip6_dst;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ndpi_tcphdr {
|
||||||
|
u_int16_t source;
|
||||||
|
u_int16_t dest;
|
||||||
|
u_int32_t seq;
|
||||||
|
u_int32_t ack_seq;
|
||||||
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
|
u_int16_t res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
|
||||||
|
#elif defined(__BIG_ENDIAN__)
|
||||||
|
u_int16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;
|
||||||
|
#else
|
||||||
|
# error "Byte order must be defined"
|
||||||
|
#endif
|
||||||
|
u_int16_t window;
|
||||||
|
u_int16_t check;
|
||||||
|
u_int16_t urg_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ndpi_udphdr {
|
||||||
|
u_int16_t source;
|
||||||
|
u_int16_t dest;
|
||||||
|
u_int16_t len;
|
||||||
|
u_int16_t check;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_api.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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_PUBLIC_FUNCTIONS_H__
|
||||||
|
#define __NDPI_PUBLIC_FUNCTIONS_H__
|
||||||
|
|
||||||
|
#include "ndpi_main.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns the size of the flow struct
|
||||||
|
* @return the size of the flow struct
|
||||||
|
*/
|
||||||
|
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns the size of the id struct
|
||||||
|
* @return the size of the id struct
|
||||||
|
*/
|
||||||
|
u_int32_t ndpi_detection_get_sizeof_ndpi_id_struct(void);
|
||||||
|
|
||||||
|
|
||||||
|
/* Public malloc/free */
|
||||||
|
void* ndpi_malloc(unsigned long size);
|
||||||
|
void* ndpi_calloc(unsigned long count, unsigned long size);
|
||||||
|
void ndpi_free(void *ptr);
|
||||||
|
void *ndpi_realloc(void *ptr, size_t old_size, size_t new_size);
|
||||||
|
char *ndpi_strdup(const char *s);
|
||||||
|
/*
|
||||||
|
* Find the first occurrence of find in s, where the search is limited to the
|
||||||
|
* first slen characters of s.
|
||||||
|
*/
|
||||||
|
char* ndpi_strnstr(const char *s, const char *find, size_t slen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns the nDPI protocol id for IP-based protocol detection
|
||||||
|
*/
|
||||||
|
u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, struct in_addr *pin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as ndpi_network_ptree_match
|
||||||
|
*/
|
||||||
|
u_int16_t ndpi_host_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t host);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns a new initialized detection module.
|
||||||
|
* @param ticks_per_second the timestamp resolution per second (like 1000 for millisecond resolution)
|
||||||
|
* @param ndpi_malloc function pointer to a memory allocator
|
||||||
|
* @param ndpi_debug_printf a function pointer to a debug output function, use NULL in productive envionments
|
||||||
|
* @return the initialized detection module
|
||||||
|
*/
|
||||||
|
struct ndpi_detection_module_struct *ndpi_init_detection_module(u_int32_t ticks_per_second,
|
||||||
|
void* (*__ndpi_malloc)(unsigned long size),
|
||||||
|
void (*__ndpi_free)(void *ptr),
|
||||||
|
ndpi_debug_function_ptr ndpi_debug_printf);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function frees the memory allocated in the specified flow
|
||||||
|
* @param flow to free
|
||||||
|
*/
|
||||||
|
void ndpi_free_flow(struct ndpi_flow_struct *flow);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function enables cache support in nDPI used for some protocol such as Skype
|
||||||
|
* @param cache host name
|
||||||
|
* @param cache port
|
||||||
|
*/
|
||||||
|
void ndpi_enable_cache(struct ndpi_detection_module_struct *ndpi_mod, char* host, u_int port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function destroys the detection module
|
||||||
|
* @param ndpi_struct the to clearing detection module
|
||||||
|
* @param ndpi_free function pointer to a memory free function
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ndpi_exit_detection_module(struct ndpi_detection_module_struct
|
||||||
|
*ndpi_struct, void (*ndpi_free) (void *ptr));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function sets the protocol bitmask2
|
||||||
|
* @param ndpi_struct the detection module
|
||||||
|
* @param detection_bitmask the protocol bitmask
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
const NDPI_PROTOCOL_BITMASK * detection_bitmask);
|
||||||
|
/**
|
||||||
|
* This function will processes one packet and returns the ID of the detected protocol.
|
||||||
|
* This is the main packet processing function.
|
||||||
|
*
|
||||||
|
* @param ndpi_struct the detection module
|
||||||
|
* @param flow void pointer to the connection state machine
|
||||||
|
* @param packet the packet as unsigned char pointer with the length of packetlen. the pointer must point to the Layer 3 (IP header)
|
||||||
|
* @param packetlen the length of the packet
|
||||||
|
* @param current_tick the current timestamp for the packet
|
||||||
|
* @param src void pointer to the source subscriber state machine
|
||||||
|
* @param dst void pointer to the destination subscriber state machine
|
||||||
|
* @return returns the detected ID of the protocol
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
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);
|
||||||
|
|
||||||
|
#define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 )
|
||||||
|
#define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* query the pointer to the layer 4 packet
|
||||||
|
*
|
||||||
|
* @param l3 pointer to the layer 3 data
|
||||||
|
* @param l3_len length of the layer 3 data
|
||||||
|
* @param l4_return filled with the pointer the layer 4 data if return value == 0, undefined otherwise
|
||||||
|
* @param l4_len_return filled with the length of the layer 4 data if return value == 0, undefined otherwise
|
||||||
|
* @param l4_protocol_return filled with the protocol of the layer 4 data if return value == 0, undefined otherwise
|
||||||
|
* @param flags limit operation on ipv4 or ipv6 packets, possible values are NDPI_DETECTION_ONLY_IPV4 or NDPI_DETECTION_ONLY_IPV6; 0 means any
|
||||||
|
* @return 0 if correct layer 4 data could be found, != 0 otherwise
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
/**
|
||||||
|
* returns the real protocol for the flow of the last packet given to the detection.
|
||||||
|
* if no real protocol could be found, the unknown protocol will be returned.
|
||||||
|
*
|
||||||
|
* @param ndpi_struct the detection module
|
||||||
|
* @return the protocol id of the last real protocol found in the protocol history of the flow
|
||||||
|
*/
|
||||||
|
u_int16_t ndpi_detection_get_real_protocol_of_flow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
unsigned int 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);
|
||||||
|
unsigned int 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);
|
||||||
|
int ndpi_match_string_subprotocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow, char *string_to_match, u_int string_to_match_len);
|
||||||
|
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);
|
||||||
|
int ndpi_match_bigram(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
ndpi_automa *automa, char *bigram_to_match);
|
||||||
|
char* ndpi_get_proto_name(struct ndpi_detection_module_struct *mod, u_int16_t proto_id);
|
||||||
|
ndpi_protocol_breed_t ndpi_get_proto_breed(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t proto);
|
||||||
|
char* ndpi_get_proto_breed_name(struct ndpi_detection_module_struct *ndpi_struct, ndpi_protocol_breed_t breed_id);
|
||||||
|
int ndpi_get_protocol_id(struct ndpi_detection_module_struct *ndpi_mod, char *proto);
|
||||||
|
void ndpi_dump_protocols(struct ndpi_detection_module_struct *mod);
|
||||||
|
int matchStringProtocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
|
||||||
|
char *string_to_match, u_int string_to_match_len);
|
||||||
|
|
||||||
|
int ndpi_load_protocols_file(struct ndpi_detection_module_struct *ndpi_mod, char* path);
|
||||||
|
u_int ndpi_get_num_supported_protocols(struct ndpi_detection_module_struct *ndpi_mod);
|
||||||
|
char* ndpi_revision(void);
|
||||||
|
void ndpi_set_automa(struct ndpi_detection_module_struct *ndpi_struct, void* automa);
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function sets a single protocol bitmask
|
||||||
|
* @param label Protocol name
|
||||||
|
* @param ndpi_struct the detection module
|
||||||
|
* @param detection_bitmask the protocol bitmask
|
||||||
|
* @param idx the index of the callback_buffer
|
||||||
|
* @param func void function point of the protocol search
|
||||||
|
* @param ndpi_selection_bitmask the protocol selected bitmask
|
||||||
|
* @param b_save_bitmask_unknow set true if you want save the detection bitmask as unknow
|
||||||
|
* @param b_add_detection_bitmask set true if you want add the protocol bitmask to the detection bitmask
|
||||||
|
* NB: this function does not increment the index of the callback_buffer
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_HTTP
|
||||||
|
/*
|
||||||
|
API used to retrieve information for HTTP flows
|
||||||
|
*/
|
||||||
|
ndpi_http_method ndpi_get_http_method(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
|
struct ndpi_flow_struct *flow);
|
||||||
|
|
||||||
|
char* ndpi_get_http_url(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
|
struct ndpi_flow_struct *flow);
|
||||||
|
|
||||||
|
char* ndpi_get_http_content_type(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
|
struct ndpi_flow_struct *flow);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_TOR
|
||||||
|
int ndpi_is_ssl_tor(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow, char *certificate);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,309 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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 0
|
||||||
|
#ifndef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
|
#define NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define __LITTLE_ENDIAN__ 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !(defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__))
|
||||||
|
#if defined(__mips__)
|
||||||
|
#undef __LITTLE_ENDIAN__
|
||||||
|
#undef __LITTLE_ENDIAN
|
||||||
|
#define __BIG_ENDIAN__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Kernel modules */
|
||||||
|
#if defined(__LITTLE_ENDIAN)
|
||||||
|
#define __LITTLE_ENDIAN__
|
||||||
|
#endif
|
||||||
|
#if defined(__BIG_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
|
||||||
|
|
||||||
|
/**********************
|
||||||
|
* detection features *
|
||||||
|
**********************/
|
||||||
|
#define NDPI_SELECT_DETECTION_WITH_REAL_PROTOCOL ( 1 << 0 )
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
|
||||||
|
#if defined(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])) )
|
||||||
|
|
||||||
|
#if !defined(__KERNEL__) && !defined(NDPI_IPTABLES_EXT)
|
||||||
|
#define NDPI_NUM_BITS 256
|
||||||
|
#else
|
||||||
|
/* custom protocols not supported */
|
||||||
|
#define NDPI_NUM_BITS 192
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
# 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
|
||||||
|
# define get_l16(X,O) __cpu_to_le16(get_u_int16_t(X,O))
|
||||||
|
# define get_l32(X,O) __cpu_to_le32(get_u_int32_t(X,O))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
#endif /* __NDPI_DEFINE_INCLUDE_FILE__ */
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_main.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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_INCLUDE_FILE__
|
||||||
|
#define __NDPI_MAIN_INCLUDE_FILE__
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifndef WIN32
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined __APPLE__ && !defined __FreeBSD__ && !defined __NetBSD__ && !defined __OpenBSD__
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <endian.h>
|
||||||
|
#include <byteswap.h>
|
||||||
|
#else
|
||||||
|
#include <asm/byteorder.h>
|
||||||
|
#include <linux/ctype.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* default includes */
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ndpi_win32.h"
|
||||||
|
#include "ndpi_unix.h"
|
||||||
|
#include "ndpi_define.h"
|
||||||
|
#include "ndpi_protocol_ids.h"
|
||||||
|
#include "ndpi_typedefs.h"
|
||||||
|
#include "ndpi_protocols.h"
|
||||||
|
|
||||||
|
|
||||||
|
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_int_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow,
|
||||||
|
u_int16_t detected_protocol, ndpi_protocol_type_t protocol_type);
|
||||||
|
|
||||||
|
|
||||||
|
/* function to parse a packet which has line based information into a line based structure
|
||||||
|
* this function will also set some well known line pointers like:
|
||||||
|
* - host, user agent, empty line,....
|
||||||
|
*/
|
||||||
|
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 detected_protocol, ndpi_protocol_type_t protocol_type);
|
||||||
|
extern void ndpi_int_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow,
|
||||||
|
u_int16_t detected_protocol,
|
||||||
|
ndpi_protocol_type_t protocol_type);
|
||||||
|
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 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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
#include "ndpi_api.h"
|
||||||
|
|
||||||
|
#endif /* __NDPI_MAIN_INCLUDE_FILE__ */
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_protocol_ids.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-11 - ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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_INCLUDE_FILE__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __NDPI_PROTOCOLS_DEFAULT_H__
|
||||||
|
#define __NDPI_PROTOCOLS_DEFAULT_H__
|
||||||
|
|
||||||
|
#define NDPI_DETECTION_SUPPORT_IPV6
|
||||||
|
#define NDPI_PROTOCOL_HISTORY_SIZE 3
|
||||||
|
|
||||||
|
#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_APPLICATION_VEOHTV 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_SOCKS5 172 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||||
|
#define NDPI_PROTOCOL_SOCKS4 173 /* 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_WINMX 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_PROTOCOL_WINDOWS_UPDATE 147 /* Thierry Laurion */
|
||||||
|
#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_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 188
|
||||||
|
#define NDPI_SERVICE_GOOGLE 126
|
||||||
|
#define NDPI_SERVICE_NETFLIX 133
|
||||||
|
#define NDPI_SERVICE_LASTFM 134
|
||||||
|
#define NDPI_SERVICE_GROOVESHARK 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 /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||||
|
#define NDPI_SERVICE_YAHOO NDPI_PROTOCOL_YAHOO /* Tomasz Bujlow <tomasz@skatnet.dk> */
|
||||||
|
#define NDPI_SERVICE_FACEBOOK_CHAT 186
|
||||||
|
#define NDPI_SERVICE_PANDORA 187
|
||||||
|
|
||||||
|
/* UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE UPDATE (NDPI_SERVICE_VEVO) */
|
||||||
|
#define NDPI_LAST_IMPLEMENTED_PROTOCOL 188
|
||||||
|
|
||||||
|
#define NDPI_MAX_SUPPORTED_PROTOCOLS (NDPI_LAST_IMPLEMENTED_PROTOCOL + 1)
|
||||||
|
#define NDPI_MAX_NUM_CUSTOM_PROTOCOLS (NDPI_NUM_BITS-NDPI_LAST_IMPLEMENTED_PROTOCOL)
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_protocols.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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_INCLUDE_FILE__
|
||||||
|
#define __NDPI_PROTOCOLS_INCLUDE_FILE__
|
||||||
|
|
||||||
|
#include "ndpi_main.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* 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_bittorrent_init(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t size,u_int32_t timeout);
|
||||||
|
void ndpi_bittorrent_done(struct ndpi_detection_module_struct *ndpi_struct);
|
||||||
|
int ndpi_bittorrent_gc(struct hash_ip4p_table *ht,int key,time_t now);
|
||||||
|
|
||||||
|
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_winmx_tcp(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_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_skype(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);
|
||||||
|
|
||||||
|
#endif /* __NDPI_PROTOCOLS_INCLUDE_FILE__ */
|
||||||
@@ -0,0 +1,852 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_typedefs.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-11 - ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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_TYPEDEFS_FILE__
|
||||||
|
#define __NDPI_TYPEDEFS_FILE__
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NDPI_LOG_ERROR,
|
||||||
|
NDPI_LOG_TRACE,
|
||||||
|
NDPI_LOG_DEBUG
|
||||||
|
} ndpi_log_level_t;
|
||||||
|
|
||||||
|
typedef void (*ndpi_debug_function_ptr) (u_int32_t protocol,
|
||||||
|
void *module_struct, ndpi_log_level_t log_level,
|
||||||
|
const char *format, ...);
|
||||||
|
#define BT_ANNOUNCE
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ndpi_preorder,
|
||||||
|
ndpi_postorder,
|
||||||
|
ndpi_endorder,
|
||||||
|
ndpi_leaf
|
||||||
|
} ndpi_VISIT;
|
||||||
|
|
||||||
|
typedef struct node_t {
|
||||||
|
char *key;
|
||||||
|
struct node_t *left, *right;
|
||||||
|
} ndpi_node;
|
||||||
|
|
||||||
|
typedef u_int32_t ndpi_ndpi_mask;
|
||||||
|
|
||||||
|
typedef struct ndpi_protocol_bitmask_struct {
|
||||||
|
ndpi_ndpi_mask fds_bits[NDPI_NUM_FDS_BITS];
|
||||||
|
} ndpi_protocol_bitmask_struct_t;
|
||||||
|
|
||||||
|
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||||
|
struct ndpi_ip6_addr {
|
||||||
|
union {
|
||||||
|
u_int8_t u6_addr8[16];
|
||||||
|
u_int16_t u6_addr16[8];
|
||||||
|
u_int32_t u6_addr32[4];
|
||||||
|
u_int64_t u6_addr64[2];
|
||||||
|
} ndpi_v6_u;
|
||||||
|
|
||||||
|
#define ndpi_v6_addr ndpi_v6_u.u6_addr8
|
||||||
|
#define ndpi_v6_addr16 ndpi_v6_u.u6_addr16
|
||||||
|
#define ndpi_v6_addr32 ndpi_v6_u.u6_addr32
|
||||||
|
#define ndpi_v6_addr64 ndpi_v6_u.u6_addr64
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ndpi_ipv6hdr {
|
||||||
|
/* use userspace and kernelspace compatible compile parameters */
|
||||||
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
|
u_int8_t priority:4, version:4;
|
||||||
|
#elif defined(__BIG_ENDIAN__)
|
||||||
|
u_int8_t version:4, priority:4;
|
||||||
|
#else
|
||||||
|
# error "Byte order must be defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
u_int8_t flow_lbl[3];
|
||||||
|
|
||||||
|
u_int16_t payload_len;
|
||||||
|
u_int8_t nexthdr;
|
||||||
|
u_int8_t hop_limit;
|
||||||
|
|
||||||
|
struct ndpi_ip6_addr saddr;
|
||||||
|
struct ndpi_ip6_addr daddr;
|
||||||
|
};
|
||||||
|
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
u_int32_t ipv4;
|
||||||
|
u_int8_t ipv4_u_int8_t[4];
|
||||||
|
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||||
|
struct ndpi_ip6_addr ipv6;
|
||||||
|
#endif
|
||||||
|
} ndpi_ip_addr_t;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_BITTORRENT
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
typedef struct spinlock {
|
||||||
|
volatile int val;
|
||||||
|
} spinlock_t;
|
||||||
|
typedef struct atomic {
|
||||||
|
volatile int counter;
|
||||||
|
} atomic_t;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct hash_ip4p_node {
|
||||||
|
struct hash_ip4p_node *next,*prev;
|
||||||
|
time_t lchg;
|
||||||
|
u_int16_t port,count:12,flag:4;
|
||||||
|
u_int32_t ip;
|
||||||
|
// + 12 bytes for ipv6
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hash_ip4p {
|
||||||
|
struct hash_ip4p_node *top;
|
||||||
|
spinlock_t lock;
|
||||||
|
size_t len;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hash_ip4p_table {
|
||||||
|
size_t size;
|
||||||
|
int ipv6;
|
||||||
|
spinlock_t lock;
|
||||||
|
atomic_t count;
|
||||||
|
struct hash_ip4p tbl[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct bt_announce { // 192 bytes
|
||||||
|
u_int32_t hash[5];
|
||||||
|
u_int32_t ip[4];
|
||||||
|
u_int32_t time;
|
||||||
|
u_int16_t port;
|
||||||
|
u_int8_t name_len,
|
||||||
|
name[192 - 4*10 - 2 - 1]; // 149 bytes
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
HTTP_METHOD_UNKNOWN = 0,
|
||||||
|
HTTP_METHOD_OPTIONS,
|
||||||
|
HTTP_METHOD_GET,
|
||||||
|
HTTP_METHOD_HEAD,
|
||||||
|
HTTP_METHOD_POST,
|
||||||
|
HTTP_METHOD_PUT,
|
||||||
|
HTTP_METHOD_DELETE,
|
||||||
|
HTTP_METHOD_TRACE,
|
||||||
|
HTTP_METHOD_CONNECT
|
||||||
|
} ndpi_http_method;
|
||||||
|
|
||||||
|
typedef struct ndpi_id_struct {
|
||||||
|
/* detected_protocol_bitmask:
|
||||||
|
* access this bitmask to find out whether an id has used skype or not
|
||||||
|
* if a flag is set here, it will not be resetted
|
||||||
|
* to compare this, use:
|
||||||
|
* if (NDPI_BITMASK_COMPARE(id->detected_protocol_bitmask,
|
||||||
|
* NDPI_PROTOCOL_BITMASK_XXX) != 0)
|
||||||
|
* {
|
||||||
|
* // protocol XXX detected on this id
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
NDPI_PROTOCOL_BITMASK detected_protocol_bitmask;
|
||||||
|
#ifdef NDPI_PROTOCOL_RTSP
|
||||||
|
ndpi_ip_addr_t rtsp_ip_address;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SIP
|
||||||
|
#ifdef NDPI_PROTOCOL_YAHOO
|
||||||
|
u_int32_t yahoo_video_lan_timer;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/* NDPI_PROTOCOL_IRC_MAXPORT % 2 must be 0 */
|
||||||
|
#ifdef NDPI_PROTOCOL_IRC
|
||||||
|
#define NDPI_PROTOCOL_IRC_MAXPORT 8
|
||||||
|
u_int16_t irc_port[NDPI_PROTOCOL_IRC_MAXPORT];
|
||||||
|
u_int32_t last_time_port_used[NDPI_PROTOCOL_IRC_MAXPORT];
|
||||||
|
u_int32_t irc_ts;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_GNUTELLA
|
||||||
|
u_int32_t gnutella_ts;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_BATTLEFIELD
|
||||||
|
u_int32_t battlefield_ts;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_THUNDER
|
||||||
|
u_int32_t thunder_ts;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_RTSP
|
||||||
|
u_int32_t rtsp_timer;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_OSCAR
|
||||||
|
u_int32_t oscar_last_safe_access_time;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_ZATTOO
|
||||||
|
u_int32_t zattoo_ts;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
|
||||||
|
u_int32_t jabber_stun_or_ft_ts;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_DIRECTCONNECT
|
||||||
|
u_int32_t directconnect_last_safe_access_time;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SOULSEEK
|
||||||
|
u_int32_t soulseek_last_safe_access_time;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_DIRECTCONNECT
|
||||||
|
u_int16_t detected_directconnect_port;
|
||||||
|
u_int16_t detected_directconnect_udp_port;
|
||||||
|
u_int16_t detected_directconnect_ssl_port;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_BITTORRENT
|
||||||
|
#define NDPI_BT_PORTS 8
|
||||||
|
u_int16_t bt_port_t[NDPI_BT_PORTS];
|
||||||
|
u_int16_t bt_port_u[NDPI_BT_PORTS];
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
|
||||||
|
#define JABBER_MAX_STUN_PORTS 6
|
||||||
|
u_int16_t jabber_voice_stun_port[JABBER_MAX_STUN_PORTS];
|
||||||
|
u_int16_t jabber_file_transfer_port[2];
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_GNUTELLA
|
||||||
|
u_int16_t detected_gnutella_port;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_GNUTELLA
|
||||||
|
u_int16_t detected_gnutella_udp_port1;
|
||||||
|
u_int16_t detected_gnutella_udp_port2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SOULSEEK
|
||||||
|
u_int16_t soulseek_listen_port;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_IRC
|
||||||
|
u_int8_t irc_number_of_port;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_OSCAR
|
||||||
|
u_int8_t oscar_ssl_session_id[33];
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_UNENCRYPED_JABBER
|
||||||
|
u_int8_t jabber_voice_stun_used_ports;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SIP
|
||||||
|
#ifdef NDPI_PROTOCOL_YAHOO
|
||||||
|
u_int32_t yahoo_video_lan_dir:1;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_YAHOO
|
||||||
|
u_int32_t yahoo_conf_logged_in:1;
|
||||||
|
u_int32_t yahoo_voice_conf_logged_in:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_RTSP
|
||||||
|
u_int32_t rtsp_ts_set:1;
|
||||||
|
#endif
|
||||||
|
} ndpi_id_struct;
|
||||||
|
|
||||||
|
/* ************************************************** */
|
||||||
|
|
||||||
|
struct ndpi_flow_tcp_struct {
|
||||||
|
#ifdef NDPI_PROTOCOL_MAIL_SMTP
|
||||||
|
u_int16_t smtp_command_bitmask;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_MAIL_POP
|
||||||
|
u_int16_t pop_command_bitmask;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_QQ
|
||||||
|
u_int16_t qq_nxt_len;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_TDS
|
||||||
|
u_int8_t tds_login_version;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_IRC
|
||||||
|
u_int8_t irc_stage;
|
||||||
|
u_int8_t irc_port;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_H323
|
||||||
|
u_int8_t h323_valid_packets;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_GNUTELLA
|
||||||
|
u_int8_t gnutella_msg_id[3];
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_IRC
|
||||||
|
u_int32_t irc_3a_counter:3;
|
||||||
|
u_int32_t irc_stage2:5;
|
||||||
|
u_int32_t irc_direction:2;
|
||||||
|
u_int32_t irc_0x1000_full:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_WINMX
|
||||||
|
u_int32_t winmx_stage:1; // 0-1
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SOULSEEK
|
||||||
|
u_int32_t soulseek_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_FILETOPIA
|
||||||
|
u_int32_t filetopia_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_TDS
|
||||||
|
u_int32_t tds_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_USENET
|
||||||
|
u_int32_t usenet_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_IMESH
|
||||||
|
u_int32_t imesh_stage:4;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_HTTP
|
||||||
|
u_int32_t http_setup_dir:2;
|
||||||
|
u_int32_t http_stage:2;
|
||||||
|
u_int32_t http_empty_line_seen:1;
|
||||||
|
u_int32_t http_wait_for_retransmission:1;
|
||||||
|
#endif // NDPI_PROTOCOL_HTTP
|
||||||
|
#ifdef NDPI_PROTOCOL_GNUTELLA
|
||||||
|
u_int32_t gnutella_stage:2; //0-2
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_MMS
|
||||||
|
u_int32_t mms_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_YAHOO
|
||||||
|
u_int32_t yahoo_sip_comm:1;
|
||||||
|
u_int32_t yahoo_http_proxy_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_MSN
|
||||||
|
u_int32_t msn_stage:3;
|
||||||
|
u_int32_t msn_ssl_ft:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SSH
|
||||||
|
u_int32_t ssh_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_VNC
|
||||||
|
u_int32_t vnc_stage:2; // 0 - 3
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_TELNET
|
||||||
|
u_int32_t telnet_stage:2; // 0 - 2
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SSL
|
||||||
|
u_int8_t ssl_stage:2, ssl_seen_client_cert:1, ssl_seen_server_cert:1; // 0 - 5
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_POSTGRES
|
||||||
|
u_int32_t postgres_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK
|
||||||
|
u_int32_t ddlink_server_direction:1;
|
||||||
|
#endif
|
||||||
|
u_int32_t seen_syn:1;
|
||||||
|
u_int32_t seen_syn_ack:1;
|
||||||
|
u_int32_t seen_ack:1;
|
||||||
|
#ifdef NDPI_PROTOCOL_ICECAST
|
||||||
|
u_int32_t icecast_stage:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_DOFUS
|
||||||
|
u_int32_t dofus_stage:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_FIESTA
|
||||||
|
u_int32_t fiesta_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_WORLDOFWARCRAFT
|
||||||
|
u_int32_t wow_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_HTTP_APPLICATION_VEOHTV
|
||||||
|
u_int32_t veoh_tv_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SHOUTCAST
|
||||||
|
u_int32_t shoutcast_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_RTP
|
||||||
|
u_int32_t rtp_special_packets_seen:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_MAIL_POP
|
||||||
|
u_int32_t mail_pop_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_MAIL_IMAP
|
||||||
|
u_int32_t mail_imap_stage:3;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_SKYPE
|
||||||
|
u_int8_t skype_packet_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_CITRIX
|
||||||
|
u_int8_t citrix_packet_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_LOTUS_NOTES
|
||||||
|
u_int8_t lotus_notes_packet_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_TEAMVIEWER
|
||||||
|
u_int8_t teamviewer_stage;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_ZMQ
|
||||||
|
u_int8_t prev_zmq_pkt_len;
|
||||||
|
u_char prev_zmq_pkt[10];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if !defined(WIN32)
|
||||||
|
__attribute__ ((__packed__))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
/* ************************************************** */
|
||||||
|
|
||||||
|
struct ndpi_flow_udp_struct {
|
||||||
|
#ifdef NDPI_PROTOCOL_BATTLEFIELD
|
||||||
|
u_int32_t battlefield_msg_id;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SNMP
|
||||||
|
u_int32_t snmp_msg_id;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_BATTLEFIELD
|
||||||
|
u_int32_t battlefield_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SNMP
|
||||||
|
u_int32_t snmp_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_PPSTREAM
|
||||||
|
u_int32_t ppstream_stage:3; // 0-7
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_HALFLIFE2
|
||||||
|
u_int32_t halflife2_stage:2; // 0 - 2
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_TFTP
|
||||||
|
u_int32_t tftp_stage:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_AIMINI
|
||||||
|
u_int32_t aimini_stage:5;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_XBOX
|
||||||
|
u_int32_t xbox_stage:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_WINDOWS_UPDATE
|
||||||
|
u_int32_t wsus_stage:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SKYPE
|
||||||
|
u_int8_t skype_packet_id;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_TEAMVIEWER
|
||||||
|
u_int8_t teamviewer_stage;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#if !defined(WIN32)
|
||||||
|
__attribute__ ((__packed__))
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
/* ************************************************** */
|
||||||
|
|
||||||
|
typedef struct ndpi_int_one_line_struct {
|
||||||
|
const u_int8_t *ptr;
|
||||||
|
u_int16_t len;
|
||||||
|
} ndpi_int_one_line_struct_t;
|
||||||
|
|
||||||
|
typedef struct ndpi_packet_struct {
|
||||||
|
const struct ndpi_iphdr *iph;
|
||||||
|
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||||
|
const struct ndpi_ipv6hdr *iphv6;
|
||||||
|
#endif
|
||||||
|
const struct ndpi_tcphdr *tcp;
|
||||||
|
const struct ndpi_udphdr *udp;
|
||||||
|
const u_int8_t *generic_l4_ptr; /* is set only for non tcp-udp traffic */
|
||||||
|
const u_int8_t *payload;
|
||||||
|
|
||||||
|
u_int32_t tick_timestamp;
|
||||||
|
u_int64_t tick_timestamp_l;
|
||||||
|
|
||||||
|
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
|
||||||
|
u_int8_t detected_subprotocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
|
||||||
|
|
||||||
|
/* this is for simple read-only access to the real protocol
|
||||||
|
* used for the main loop */
|
||||||
|
u_int16_t real_protocol_read_only;
|
||||||
|
|
||||||
|
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
|
||||||
|
# if NDPI_PROTOCOL_HISTORY_SIZE > 5
|
||||||
|
# error protocol stack size not supported
|
||||||
|
# endif
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u_int8_t entry_is_real_protocol:5;
|
||||||
|
u_int8_t current_stack_size_minus_one:3;
|
||||||
|
}
|
||||||
|
#if !defined(WIN32)
|
||||||
|
__attribute__ ((__packed__))
|
||||||
|
#endif
|
||||||
|
protocol_stack_info;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET];
|
||||||
|
struct ndpi_int_one_line_struct host_line;
|
||||||
|
struct ndpi_int_one_line_struct forwarded_line;
|
||||||
|
struct ndpi_int_one_line_struct referer_line;
|
||||||
|
struct ndpi_int_one_line_struct content_line;
|
||||||
|
struct ndpi_int_one_line_struct accept_line;
|
||||||
|
struct ndpi_int_one_line_struct user_agent_line;
|
||||||
|
struct ndpi_int_one_line_struct http_url_name;
|
||||||
|
struct ndpi_int_one_line_struct http_encoding;
|
||||||
|
struct ndpi_int_one_line_struct http_transfer_encoding;
|
||||||
|
struct ndpi_int_one_line_struct http_contentlen;
|
||||||
|
struct ndpi_int_one_line_struct http_cookie;
|
||||||
|
struct ndpi_int_one_line_struct http_origin;
|
||||||
|
struct ndpi_int_one_line_struct http_x_session_type;
|
||||||
|
struct ndpi_int_one_line_struct server_line;
|
||||||
|
struct ndpi_int_one_line_struct http_method;
|
||||||
|
struct ndpi_int_one_line_struct http_response;
|
||||||
|
|
||||||
|
u_int16_t l3_packet_len;
|
||||||
|
u_int16_t l4_packet_len;
|
||||||
|
u_int16_t payload_packet_len;
|
||||||
|
u_int16_t actual_payload_len;
|
||||||
|
u_int16_t num_retried_bytes;
|
||||||
|
u_int16_t parsed_lines;
|
||||||
|
u_int16_t parsed_unix_lines;
|
||||||
|
u_int16_t empty_line_position;
|
||||||
|
u_int8_t tcp_retransmission;
|
||||||
|
u_int8_t l4_protocol;
|
||||||
|
|
||||||
|
u_int8_t ssl_certificate_detected:4, ssl_certificate_num_checks:4;
|
||||||
|
u_int8_t packet_lines_parsed_complete:1,
|
||||||
|
packet_direction:1,
|
||||||
|
empty_line_position_set:1;
|
||||||
|
} ndpi_packet_struct_t;
|
||||||
|
|
||||||
|
struct ndpi_detection_module_struct;
|
||||||
|
struct ndpi_flow_struct;
|
||||||
|
|
||||||
|
typedef struct ndpi_call_function_struct {
|
||||||
|
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||||
|
NDPI_PROTOCOL_BITMASK excluded_protocol_bitmask;
|
||||||
|
NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask;
|
||||||
|
void (*func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow);
|
||||||
|
u_int8_t detection_feature;
|
||||||
|
} ndpi_call_function_struct_t;
|
||||||
|
|
||||||
|
typedef struct ndpi_subprotocol_conf_struct {
|
||||||
|
void (*func) (struct ndpi_detection_module_struct *, char *attr, char *value, int protocol_id);
|
||||||
|
} ndpi_subprotocol_conf_struct_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u_int16_t port_low, port_high;
|
||||||
|
} ndpi_port_range;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NDPI_PROTOCOL_SAFE = 0, /* Safe protocol with encryption */
|
||||||
|
NDPI_PROTOCOL_ACCEPTABLE, /* Ok but not encrypted */
|
||||||
|
NDPI_PROTOCOL_FUN, /* Pure fun protocol */
|
||||||
|
NDPI_PROTOCOL_UNSAFE, /* Protocol with a safe version existing what should be used instead */
|
||||||
|
NDPI_PROTOCOL_POTENTIALLY_DANGEROUS, /* Be prepared to troubles */
|
||||||
|
NDPI_PROTOCOL_UNRATED /* No idea */
|
||||||
|
} ndpi_protocol_breed_t;
|
||||||
|
|
||||||
|
#define NUM_BREEDS (NDPI_PROTOCOL_UNRATED+1)
|
||||||
|
|
||||||
|
/* ntop extensions */
|
||||||
|
typedef struct ndpi_proto_defaults {
|
||||||
|
char *protoName;
|
||||||
|
u_int16_t protoId, protoIdx;
|
||||||
|
u_int16_t master_tcp_protoId[2], master_udp_protoId[2]; /* The main protocols on which this sub-protocol sits on */
|
||||||
|
ndpi_protocol_breed_t protoBreed;
|
||||||
|
void (*func) (struct ndpi_detection_module_struct *, struct ndpi_flow_struct *flow);
|
||||||
|
} ndpi_proto_defaults_t;
|
||||||
|
|
||||||
|
typedef struct ndpi_default_ports_tree_node {
|
||||||
|
ndpi_proto_defaults_t *proto;
|
||||||
|
u_int16_t default_port;
|
||||||
|
} ndpi_default_ports_tree_node_t;
|
||||||
|
|
||||||
|
typedef struct _ndpi_automa {
|
||||||
|
void *ac_automa; /* Real type is AC_AUTOMATA_t */
|
||||||
|
u_int8_t ac_automa_finalized;
|
||||||
|
} ndpi_automa;
|
||||||
|
|
||||||
|
typedef struct ndpi_detection_module_struct {
|
||||||
|
NDPI_PROTOCOL_BITMASK detection_bitmask;
|
||||||
|
NDPI_PROTOCOL_BITMASK generic_http_packet_bitmask;
|
||||||
|
|
||||||
|
u_int32_t current_ts;
|
||||||
|
u_int32_t ticks_per_second;
|
||||||
|
|
||||||
|
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
|
void *user_data;
|
||||||
|
#endif
|
||||||
|
/* callback function buffer */
|
||||||
|
struct ndpi_call_function_struct callback_buffer[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
|
||||||
|
u_int32_t callback_buffer_size;
|
||||||
|
|
||||||
|
struct ndpi_call_function_struct callback_buffer_tcp_no_payload[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
|
||||||
|
u_int32_t callback_buffer_size_tcp_no_payload;
|
||||||
|
|
||||||
|
struct ndpi_call_function_struct callback_buffer_tcp_payload[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
|
||||||
|
u_int32_t callback_buffer_size_tcp_payload;
|
||||||
|
|
||||||
|
struct ndpi_call_function_struct callback_buffer_udp[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
|
||||||
|
u_int32_t callback_buffer_size_udp;
|
||||||
|
|
||||||
|
struct ndpi_call_function_struct callback_buffer_non_tcp_udp[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
|
||||||
|
u_int32_t callback_buffer_size_non_tcp_udp;
|
||||||
|
|
||||||
|
ndpi_default_ports_tree_node_t *tcpRoot, *udpRoot;
|
||||||
|
|
||||||
|
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
|
/* debug callback, only set when debug is used */
|
||||||
|
ndpi_debug_function_ptr ndpi_debug_printf;
|
||||||
|
const char *ndpi_debug_print_file;
|
||||||
|
const char *ndpi_debug_print_function;
|
||||||
|
u_int32_t ndpi_debug_print_line;
|
||||||
|
#endif
|
||||||
|
/* misc parameters */
|
||||||
|
u_int32_t tcp_max_retransmission_window_size;
|
||||||
|
|
||||||
|
u_int32_t directconnect_connection_ip_tick_timeout;
|
||||||
|
|
||||||
|
/* subprotocol registration handler */
|
||||||
|
struct ndpi_subprotocol_conf_struct subprotocol_conf[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
|
||||||
|
|
||||||
|
u_int ndpi_num_supported_protocols;
|
||||||
|
u_int ndpi_num_custom_protocols;
|
||||||
|
|
||||||
|
/* HTTP/DNS/HTTPS host matching */
|
||||||
|
ndpi_automa host_automa, content_automa, bigrams_automa, impossible_bigrams_automa;
|
||||||
|
|
||||||
|
/* IP-based protocol detection */
|
||||||
|
void *protocols_ptree;
|
||||||
|
|
||||||
|
/* irc parameters */
|
||||||
|
u_int32_t irc_timeout;
|
||||||
|
/* gnutella parameters */
|
||||||
|
u_int32_t gnutella_timeout;
|
||||||
|
/* battlefield parameters */
|
||||||
|
u_int32_t battlefield_timeout;
|
||||||
|
/* thunder parameters */
|
||||||
|
u_int32_t thunder_timeout;
|
||||||
|
/* SoulSeek parameters */
|
||||||
|
u_int32_t soulseek_connection_ip_tick_timeout;
|
||||||
|
/* rtsp parameters */
|
||||||
|
u_int32_t rtsp_connection_timeout;
|
||||||
|
/* tvants parameters */
|
||||||
|
u_int32_t tvants_connection_timeout;
|
||||||
|
u_int32_t orb_rstp_ts_timeout;
|
||||||
|
/* yahoo */
|
||||||
|
// u_int32_t yahoo_http_filetransfer_timeout;
|
||||||
|
u_int8_t yahoo_detect_http_connections;
|
||||||
|
u_int32_t yahoo_lan_video_timeout;
|
||||||
|
u_int32_t zattoo_connection_timeout;
|
||||||
|
u_int32_t jabber_stun_timeout;
|
||||||
|
u_int32_t jabber_file_transfer_timeout;
|
||||||
|
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||||
|
#define NDPI_IP_STRING_SIZE 40
|
||||||
|
char ip_string[NDPI_IP_STRING_SIZE];
|
||||||
|
#endif
|
||||||
|
u_int8_t ip_version_limit;
|
||||||
|
/* ********************* */
|
||||||
|
#ifdef NDPI_PROTOCOL_BITTORRENT
|
||||||
|
struct hash_ip4p_table *bt_ht;
|
||||||
|
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
||||||
|
struct hash_ip4p_table *bt6_ht;
|
||||||
|
#endif
|
||||||
|
#ifdef BT_ANNOUNCE
|
||||||
|
struct bt_announce *bt_ann;
|
||||||
|
int bt_ann_len;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
|
||||||
|
|
||||||
|
u_int8_t match_dns_host_names:1, http_dissect_response:1;
|
||||||
|
u_int8_t direction_detect_disable:1; /* disable internal detection of packet direction */
|
||||||
|
} ndpi_detection_module_struct_t;
|
||||||
|
|
||||||
|
typedef struct ndpi_flow_struct {
|
||||||
|
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
|
||||||
|
#if NDPI_PROTOCOL_HISTORY_SIZE > 1
|
||||||
|
# if NDPI_PROTOCOL_HISTORY_SIZE > 5
|
||||||
|
# error protocol stack size not supported
|
||||||
|
# endif
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u_int8_t entry_is_real_protocol:5;
|
||||||
|
u_int8_t current_stack_size_minus_one:3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(WIN32)
|
||||||
|
__attribute__ ((__packed__))
|
||||||
|
#endif
|
||||||
|
protocol_stack_info;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* init parameter, internal used to set up timestamp,... */
|
||||||
|
u_int16_t guessed_protocol_id;
|
||||||
|
|
||||||
|
u_int8_t protocol_id_already_guessed:1;
|
||||||
|
u_int8_t no_cache_protocol:1;
|
||||||
|
u_int8_t init_finished:1;
|
||||||
|
u_int8_t setup_packet_direction:1;
|
||||||
|
u_int8_t packet_direction:1; /* if ndpi_struct->direction_detect_disable == 1 */
|
||||||
|
/* tcp sequence number connection tracking */
|
||||||
|
u_int32_t next_tcp_seq_nr[2];
|
||||||
|
|
||||||
|
/* the tcp / udp / other l4 value union
|
||||||
|
* this is used to reduce the number of bytes for tcp or udp protocol states
|
||||||
|
* */
|
||||||
|
union {
|
||||||
|
struct ndpi_flow_tcp_struct tcp;
|
||||||
|
struct ndpi_flow_udp_struct udp;
|
||||||
|
} l4;
|
||||||
|
|
||||||
|
struct ndpi_id_struct *server_id; /*
|
||||||
|
Pointer to src or dst
|
||||||
|
that identifies the
|
||||||
|
server of this connection
|
||||||
|
*/
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
u_char host_server_name[256]; /* HTTP host or DNS query */
|
||||||
|
#else
|
||||||
|
u_char host_server_name[160];
|
||||||
|
#endif
|
||||||
|
u_char detected_os[32]; /* Via HTTP User-Agent */
|
||||||
|
u_char nat_ip[24]; /* Via HTTP X-Forwarded-For */
|
||||||
|
|
||||||
|
/*
|
||||||
|
This structure below will not not stay inside the protos
|
||||||
|
structure below as HTTP is used by many subprotocols
|
||||||
|
such as FaceBook, Google... so it is hard to know
|
||||||
|
when to use it or not. Thus we leave it outside for the
|
||||||
|
time being.
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
ndpi_http_method method;
|
||||||
|
char *url, *content_type;
|
||||||
|
} http;
|
||||||
|
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
u_int8_t num_queries, num_answers, ret_code;
|
||||||
|
u_int8_t bad_packet /* the received packet looks bad */;
|
||||||
|
u_int16_t query_type, query_class, rsp_type;
|
||||||
|
} dns;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char client_certificate[48], server_certificate[48];
|
||||||
|
} ssl;
|
||||||
|
} protos;
|
||||||
|
/* ALL protocol specific 64 bit variables here */
|
||||||
|
|
||||||
|
/* protocols which have marked a connection as this connection cannot be protocol XXX, multiple u_int64_t */
|
||||||
|
NDPI_PROTOCOL_BITMASK excluded_protocol_bitmask;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#ifdef NDPI_PROTOCOL_RTP
|
||||||
|
u_int32_t rtp_ssid[2];
|
||||||
|
u_int16_t rtp_seqnum[2]; /* current highest sequence number (only goes forwards, is not decreased by retransmissions) */
|
||||||
|
/* tcp and udp */
|
||||||
|
u_int8_t rtp_payload_type[2];
|
||||||
|
u_int32_t rtp_stage1:2; //0-3
|
||||||
|
u_int32_t rtp_stage2:2;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_REDIS
|
||||||
|
u_int8_t redis_s2d_first_char, redis_d2s_first_char;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
u_int16_t packet_counter; // can be 0-65000
|
||||||
|
u_int16_t packet_direction_counter[2];
|
||||||
|
u_int16_t byte_counter[2];
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_BITTORRENT
|
||||||
|
u_int8_t bittorrent_stage; // can be 0-255
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_DIRECTCONNECT
|
||||||
|
u_int32_t directconnect_stage:2; // 0-1
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SIP
|
||||||
|
#ifdef NDPI_PROTOCOL_YAHOO
|
||||||
|
u_int32_t sip_yahoo_voice:1;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_HTTP
|
||||||
|
u_int32_t http_detected:1;
|
||||||
|
#endif // NDPI_PROTOCOL_HTTP
|
||||||
|
#ifdef NDPI_PROTOCOL_RTSP
|
||||||
|
u_int32_t rtsprdt_stage:2;
|
||||||
|
u_int32_t rtsp_control_flow:1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_YAHOO
|
||||||
|
u_int32_t yahoo_detection_finished:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_ZATTOO
|
||||||
|
u_int32_t zattoo_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_QQ
|
||||||
|
u_int32_t qq_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_THUNDER
|
||||||
|
u_int32_t thunder_stage:2; // 0-3
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_OSCAR
|
||||||
|
u_int32_t oscar_ssl_voice_stage:3;
|
||||||
|
u_int32_t oscar_video_voice:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_FLORENSIA
|
||||||
|
u_int32_t florensia_stage:1;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SOCKS5
|
||||||
|
u_int32_t socks5_stage:2; // 0-3
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_SOCKS4
|
||||||
|
u_int32_t socks4_stage:2; // 0-3
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_EDONKEY
|
||||||
|
u_int32_t edonkey_stage:2; // 0-3
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_FTP_CONTROL
|
||||||
|
u_int32_t ftp_control_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_FTP_DATA
|
||||||
|
u_int32_t ftp_data_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_RTMP
|
||||||
|
u_int32_t rtmp_stage:2;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_PANDO
|
||||||
|
u_int32_t pando_stage:3;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_STEAM
|
||||||
|
u_int32_t steam_stage:3;
|
||||||
|
u_int32_t steam_stage1:3; // 0 - 4
|
||||||
|
u_int32_t steam_stage2:2; // 0 - 2
|
||||||
|
u_int32_t steam_stage3:2; // 0 - 2
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_PPLIVE
|
||||||
|
u_int32_t pplive_stage1:3; // 0-6
|
||||||
|
u_int32_t pplive_stage2:2; // 0-2
|
||||||
|
u_int32_t pplive_stage3:2; // 0-2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* internal structures to save functions calls */
|
||||||
|
struct ndpi_packet_struct packet;
|
||||||
|
struct ndpi_flow_struct *flow;
|
||||||
|
struct ndpi_id_struct *src;
|
||||||
|
struct ndpi_id_struct *dst;
|
||||||
|
} ndpi_flow_struct_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NDPI_REAL_PROTOCOL = 0,
|
||||||
|
NDPI_CORRELATED_PROTOCOL = 1
|
||||||
|
} ndpi_protocol_type_t;
|
||||||
|
|
||||||
|
#endif/* __NDPI_TYPEDEFS_FILE__ */
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_unix.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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__
|
||||||
|
|
||||||
|
#include "linux_compat.h"
|
||||||
|
|
||||||
|
#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
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
#include <netinet/udp.h>
|
||||||
|
#else
|
||||||
|
#include <linux/ip.h>
|
||||||
|
#include <linux/tcp.h>
|
||||||
|
#include <linux/udp.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __NDPI_UNIX_INCLUDE_FILE__ */
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* ndpi_win32.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - ntop.org
|
||||||
|
* Copyright (C) 2009-2011 by ipoque GmbH
|
||||||
|
*
|
||||||
|
* 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_INCLUDE_FILE__
|
||||||
|
#define __NDPI_WIN32_INCLUDE_FILE__
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <Winsock2.h> /* winsock.h is included automatically */
|
||||||
|
#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 */
|
||||||
|
|
||||||
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
#define snprintf _snprintf
|
||||||
|
|
||||||
|
extern char* strsep(char **stringp, const char *delim);
|
||||||
|
|
||||||
|
#define __attribute__(x)
|
||||||
|
#include <stdint.h>
|
||||||
|
#ifndef __GNUC__
|
||||||
|
typedef unsigned char u_char;
|
||||||
|
typedef unsigned short u_short;
|
||||||
|
typedef unsigned int uint;
|
||||||
|
typedef unsigned long u_long;
|
||||||
|
#endif
|
||||||
|
typedef u_char u_int8_t;
|
||||||
|
typedef u_short u_int16_t;
|
||||||
|
typedef unsigned int u_int32_t;
|
||||||
|
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) gmtime(a) /* Already thread safe on windows */
|
||||||
|
|
||||||
|
extern unsigned long waitForNextEvent(unsigned long ulDelay /* ms */);
|
||||||
|
|
||||||
|
#define sleep(a /* sec */) waitForNextEvent(1000*a /* ms */)
|
||||||
|
|
||||||
|
#endif /* Win32 */
|
||||||
|
|
||||||
|
#endif /* __NDPI_WIN32_INCLUDE_FILE__ */
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
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/linux_compat.h \
|
||||||
|
../include/ndpi_define.h \
|
||||||
|
../include/ndpi_main.h \
|
||||||
|
../include/ndpi_protocol_ids.h \
|
||||||
|
../include/ndpi_protocols.h \
|
||||||
|
../include/ndpi_typedefs.h \
|
||||||
|
../include/ndpi_unix.h \
|
||||||
|
../include/ndpi_win32.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/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/dropbox.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/gnutella.c \
|
||||||
|
protocols/gtp.c \
|
||||||
|
protocols/guildwars.c \
|
||||||
|
protocols/h323.c \
|
||||||
|
protocols/halflife2_and_mods.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/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/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/radius.c \
|
||||||
|
protocols/rdp.c \
|
||||||
|
protocols/redis.c \
|
||||||
|
protocols/rsync.c \
|
||||||
|
protocols/rtcp.c \
|
||||||
|
protocols/rtmp.c \
|
||||||
|
protocols/rtp.c \
|
||||||
|
protocols/rtsp.c \
|
||||||
|
protocols/sflow.c \
|
||||||
|
protocols/shoutcast.c \
|
||||||
|
protocols/sip.c \
|
||||||
|
protocols/skinny.c \
|
||||||
|
protocols/skype.c \
|
||||||
|
protocols/smb.c \
|
||||||
|
protocols/snmp.c \
|
||||||
|
protocols/socks4.c \
|
||||||
|
protocols/socks5.c \
|
||||||
|
protocols/socrates.c \
|
||||||
|
protocols/sopcast.c \
|
||||||
|
protocols/soulseek.c \
|
||||||
|
protocols/spotify.c \
|
||||||
|
protocols/ssdp.c \
|
||||||
|
protocols/ssh.c \
|
||||||
|
protocols/ssl.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/tvants.c \
|
||||||
|
protocols/tvuplayer.c \
|
||||||
|
protocols/twitter.c \
|
||||||
|
protocols/usenet.c \
|
||||||
|
protocols/veohtv.c \
|
||||||
|
protocols/viber.c \
|
||||||
|
protocols/vhua.c \
|
||||||
|
protocols/vmware.c \
|
||||||
|
protocols/vnc.c \
|
||||||
|
protocols/warcraft3.c \
|
||||||
|
protocols/whoisdas.c \
|
||||||
|
protocols/winmx.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/zmq.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
+5706
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_AFP, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,283 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_AIMINI, protocol_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_APPLEJUICE, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* 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 files */
|
||||||
|
#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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_ARMAGETRON, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FLASH, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
@@ -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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FTP, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
@@ -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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_MANOLITO, NDPI_REAL_PROTOCOL);
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
@@ -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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_POPO, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
@@ -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_int_add_connection(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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_AYIYA, NDPI_REAL_PROTOCOL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_AYIYA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_BATTLEFIELD, NDPI_REAL_PROTOCOL);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_BGP, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||||
|
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||||
|
|
||||||
|
if (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 &&
|
||||||
|
(packet->tcp->dest == htons(179) || packet->tcp->source == htons(179))
|
||||||
|
&& packet->payload[18] < 5) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,469 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow,
|
||||||
|
const u_int8_t save_detection, const u_int8_t encrypted_connection,
|
||||||
|
ndpi_protocol_type_t protocol_type)
|
||||||
|
{
|
||||||
|
ndpi_int_change_protocol(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, protocol_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// struct ndpi_id_struct *src = flow->src;
|
||||||
|
// struct ndpi_id_struct *dst = flow->dst;
|
||||||
|
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_REAL_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_REAL_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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;
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* 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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_UNSAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_REAL_PROTOCOL);
|
||||||
|
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,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_WEBSEED_DETECTION,
|
||||||
|
NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* This is broadcast */
|
||||||
|
if(packet->iph
|
||||||
|
&& ((packet->iph->saddr == 0xFFFFFFFF) || (packet->iph->daddr == 0xFFFFFFFF)))
|
||||||
|
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) {
|
||||||
|
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 */) {
|
||||||
|
/* 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((packet->payload[0]== 0x60)
|
||||||
|
&& (packet->payload[1]== 0x0)
|
||||||
|
&& (packet->payload[2]== 0x0)
|
||||||
|
&& (packet->payload[3]== 0x0)
|
||||||
|
&& (packet->payload[4]== 0x0)) {
|
||||||
|
/* Heuristic */
|
||||||
|
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 */)
|
||||||
|
) {
|
||||||
|
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;
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
now = (u_int32_t)time(NULL);
|
||||||
|
#else
|
||||||
|
struct timespec t;
|
||||||
|
|
||||||
|
getnstimeofday(&t);
|
||||||
|
now = t.tv_sec;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if((ts < (now+86400)) && (ts > (now-86400))) {
|
||||||
|
goto bittorrent_found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flow->bittorrent_stage++;
|
||||||
|
|
||||||
|
if(flow->bittorrent_stage < 10) {
|
||||||
|
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)
|
||||||
|
|| ndpi_strnstr((const char *)packet->payload, "BitTorrent protocol", packet->payload_packet_len)
|
||||||
|
) {
|
||||||
|
bittorrent_found:
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_BITTORRENT,
|
||||||
|
ndpi_struct, NDPI_LOG_TRACE, "BT: plain BitTorrent protocol detected\n");
|
||||||
|
ndpi_add_connection_as_bittorrent(ndpi_struct, flow,
|
||||||
|
NDPI_PROTOCOL_SAFE_DETECTION, NDPI_PROTOCOL_PLAIN_DETECTION,
|
||||||
|
NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_BITTORRENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,509 @@
|
|||||||
|
/*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
|
||||||
|
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; }
|
||||||
|
#else
|
||||||
|
#define DEBUG_TRACE(cmd,args...)
|
||||||
|
#endif /* __KERNEL */
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
extern int bt_parse_debug;
|
||||||
|
void dump_bt_proto_struct(struct bt_parse_protocol *p);
|
||||||
|
#endif
|
||||||
|
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd);
|
||||||
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CISCOVPN, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* 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 0
|
||||||
|
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||||
|
packet->payload[0] & 0xFF,
|
||||||
|
packet->payload[1] & 0xFF,
|
||||||
|
packet->payload[2] & 0xFF,
|
||||||
|
packet->payload[3] & 0xFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CITRIX, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_COLLECTD, NDPI_REAL_PROTOCOL);
|
||||||
|
} 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
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CORBA, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_CROSSFIRE, protocol_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
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, NDPI_REAL_PROTOCOL);
|
||||||
|
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, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DCERPC, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
&& ((ntohs(packet->tcp->source) == 135) || (ntohs(packet->tcp->dest) == 135))
|
||||||
|
&& (packet->payload[0] == 0x05) /* version 5 */
|
||||||
|
&& (packet->payload[2] < 16) /* Packet type */
|
||||||
|
) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_DCERPC, ndpi_struct, NDPI_LOG_DEBUG, "DCERPC match\n");
|
||||||
|
ndpi_int_dcerpc_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_DCERPC);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DHCP, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DHCPV6, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,474 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||||
|
|
||||||
|
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_REAL_PROTOCOL);
|
||||||
|
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_REAL_PROTOCOL);
|
||||||
|
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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||||
|
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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||||
|
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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECTCONNECT, NDPI_REAL_PROTOCOL);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,737 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
|
||||||
|
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;
|
||||||
|
#if 0
|
||||||
|
if (ndpi_struct->direct_download_link_counter_callback != NULL) {
|
||||||
|
if (packet->detected_protocol == NDPI_PROTOCOL_DIRECT_DOWNLOAD_LINK) {
|
||||||
|
/* skip packets not requests from the client to the server */
|
||||||
|
if (packet->packet_direction == flow->l4.tcp.ddlink_server_direction) {
|
||||||
|
search_ddl_domains(ndpi_struct, flow); // do the detection again in order to get the URL in keep alive streams
|
||||||
|
} else {
|
||||||
|
// just count the packet
|
||||||
|
ndpi_struct->direct_download_link_counter_callback(flow->hash_id_number, packet->l3_packet_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
/*
|
||||||
|
* dns.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_protocols.h"
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_DNS
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *********************************************** */
|
||||||
|
|
||||||
|
static char* ndpi_intoa_v4(unsigned int addr, char* buf, u_short bufLen) {
|
||||||
|
char *cp, *retStr;
|
||||||
|
uint byte;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
cp = &buf[bufLen];
|
||||||
|
*--cp = '\0';
|
||||||
|
|
||||||
|
n = 4;
|
||||||
|
do {
|
||||||
|
byte = addr & 0xff;
|
||||||
|
*--cp = byte % 10 + '0';
|
||||||
|
byte /= 10;
|
||||||
|
if(byte > 0) {
|
||||||
|
*--cp = byte % 10 + '0';
|
||||||
|
byte /= 10;
|
||||||
|
if(byte > 0)
|
||||||
|
*--cp = byte + '0';
|
||||||
|
}
|
||||||
|
*--cp = '.';
|
||||||
|
addr >>= 8;
|
||||||
|
} while (--n > 0);
|
||||||
|
|
||||||
|
/* Convert the string to lowercase */
|
||||||
|
retStr = (char*)(cp+1);
|
||||||
|
|
||||||
|
return(retStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *********************************************** */
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* *********************************************** */
|
||||||
|
|
||||||
|
struct dns_packet_header {
|
||||||
|
u_int16_t transaction_id, flags, num_queries, answer_rrs, authority_rrs, additional_rrs;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
u_int16_t dport = 0, sport = 0;
|
||||||
|
|
||||||
|
#define NDPI_MAX_DNS_REQUESTS 16
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "search DNS.\n");
|
||||||
|
|
||||||
|
if (packet->udp != NULL) {
|
||||||
|
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over UDP.\n");
|
||||||
|
} else if(packet->tcp != NULL) {
|
||||||
|
sport = ntohs(packet->tcp->source), dport = ntohs(packet->tcp->dest);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over tcp.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((dport == 53) || (sport == 53) || (dport == 5355))
|
||||||
|
&& (packet->payload_packet_len > sizeof(struct dns_packet_header))) {
|
||||||
|
int i = packet->tcp ? 2 : 0;
|
||||||
|
struct dns_packet_header header, *dns = (struct dns_packet_header*)&packet->payload[i];
|
||||||
|
u_int8_t is_query, ret_code, is_dns = 0;
|
||||||
|
u_int32_t a_record[NDPI_MAX_DNS_REQUESTS] = { 0 }, query_offset, num_a_records = 0;
|
||||||
|
|
||||||
|
header.flags = ntohs(dns->flags);
|
||||||
|
header.transaction_id = ntohs(dns->transaction_id);
|
||||||
|
header.num_queries = ntohs(dns->num_queries);
|
||||||
|
header.answer_rrs = ntohs(dns->answer_rrs);
|
||||||
|
header.authority_rrs = ntohs(dns->authority_rrs);
|
||||||
|
header.additional_rrs = ntohs(dns->additional_rrs);
|
||||||
|
is_query = (header.flags & 0x8000) ? 0 : 1;
|
||||||
|
ret_code = is_query ? 0 : (header.flags & 0x0F);
|
||||||
|
i += sizeof(struct dns_packet_header);
|
||||||
|
query_offset = i;
|
||||||
|
|
||||||
|
if(is_query) {
|
||||||
|
/* DNS Request */
|
||||||
|
if((header.num_queries > 0) && (header.num_queries <= NDPI_MAX_DNS_REQUESTS)
|
||||||
|
&& (((header.flags & 0x2800) == 0x2800 /* Dynamic DNS Update */)
|
||||||
|
|| ((header.answer_rrs == 0) && (header.authority_rrs == 0)))) {
|
||||||
|
/* This is a good query */
|
||||||
|
is_dns = 1;
|
||||||
|
|
||||||
|
if(header.num_queries > 0) {
|
||||||
|
while(i < packet->payload_packet_len) {
|
||||||
|
if(packet->payload[i] == '\0') {
|
||||||
|
i++;
|
||||||
|
flow->protos.dns.query_type = get16(&i, packet->payload);
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* DNS Reply */
|
||||||
|
|
||||||
|
flow->server_id = flow->dst;
|
||||||
|
|
||||||
|
if((header.num_queries <= NDPI_MAX_DNS_REQUESTS) /* Don't assume that num_queries must be zero */
|
||||||
|
&& (((header.answer_rrs > 0) && (header.answer_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||||
|
|| ((header.authority_rrs > 0) && (header.authority_rrs <= NDPI_MAX_DNS_REQUESTS))
|
||||||
|
|| ((header.additional_rrs > 0) && (header.additional_rrs <= NDPI_MAX_DNS_REQUESTS)))
|
||||||
|
) {
|
||||||
|
/* This is a good reply */
|
||||||
|
is_dns = 1;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if(packet->payload[i] != '\0') {
|
||||||
|
while((i < packet->payload_packet_len)
|
||||||
|
&& (packet->payload[i] != '\0')) {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += 4;
|
||||||
|
|
||||||
|
if(header.answer_rrs > 0) {
|
||||||
|
u_int16_t rsp_type /*, rsp_class */;
|
||||||
|
u_int16_t num;
|
||||||
|
|
||||||
|
for(num = 0; num < header.answer_rrs; num++) {
|
||||||
|
u_int16_t data_len;
|
||||||
|
|
||||||
|
if((i+6) >= packet->payload_packet_len) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((data_len = getNameLength(i, packet->payload, packet->payload_packet_len)) == 0) {
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
i += data_len;
|
||||||
|
|
||||||
|
rsp_type = get16(&i, packet->payload);
|
||||||
|
// rsp_class = get16(&i, packet->payload);
|
||||||
|
|
||||||
|
i += 4;
|
||||||
|
data_len = get16(&i, packet->payload);
|
||||||
|
|
||||||
|
if((data_len <= 1) || (data_len > (packet->payload_packet_len-i))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
flow->protos.dns.rsp_type = rsp_type;
|
||||||
|
|
||||||
|
if(rsp_type == 1 /* A */) {
|
||||||
|
if(data_len == 4) {
|
||||||
|
u_int32_t v = ntohl(*((u_int32_t*)&packet->payload[i]));
|
||||||
|
|
||||||
|
if(num_a_records < (NDPI_MAX_DNS_REQUESTS-1))
|
||||||
|
a_record[num_a_records++] = v;
|
||||||
|
else
|
||||||
|
break; /* One record is enough */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data_len == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += data_len;
|
||||||
|
} /* for */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((header.num_queries <= NDPI_MAX_DNS_REQUESTS)
|
||||||
|
&& ((header.answer_rrs == 0)
|
||||||
|
|| (header.authority_rrs == 0)
|
||||||
|
|| (header.additional_rrs == 0))
|
||||||
|
&& (ret_code != 0 /* 0 == OK */)
|
||||||
|
) {
|
||||||
|
/* This is a good reply */
|
||||||
|
is_dns = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_dns) {
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
flow->protos.dns.num_queries = (u_int8_t)header.num_queries,
|
||||||
|
flow->protos.dns.num_answers = (u_int8_t)(header.answer_rrs+header.authority_rrs+header.additional_rrs),
|
||||||
|
flow->protos.dns.ret_code = ret_code;
|
||||||
|
|
||||||
|
i = query_offset+1;
|
||||||
|
|
||||||
|
while((i < packet->payload_packet_len)
|
||||||
|
&& (j < (sizeof(flow->host_server_name)-1))
|
||||||
|
&& (packet->payload[i] != '\0')) {
|
||||||
|
flow->host_server_name[j] = tolower(packet->payload[i]);
|
||||||
|
if(flow->host_server_name[j] < ' ')
|
||||||
|
flow->host_server_name[j] = '.';
|
||||||
|
j++, i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(a_record != 0) {
|
||||||
|
char a_buf[32];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0; i<num_a_records; i++) {
|
||||||
|
j += snprintf((char*)&flow->host_server_name[j], sizeof(flow->host_server_name)-1-j, "%s%s",
|
||||||
|
(i == 0) ? "@" : ";",
|
||||||
|
ndpi_intoa_v4(a_record[i], a_buf, sizeof(a_buf)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flow->host_server_name[j] = '\0';
|
||||||
|
|
||||||
|
if(j > 0) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("==> %s\n", flow->host_server_name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(ndpi_struct->match_dns_host_names)
|
||||||
|
ndpi_match_string_subprotocol(ndpi_struct, flow,
|
||||||
|
(char *)flow->host_server_name,
|
||||||
|
strlen((const char*)flow->host_server_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
memcpy(&flow->protos.dns.query_type, &packet->payload[i], 2);
|
||||||
|
flow->protos.dns.query_type = ntohs(flow->protos.dns.query_type), i += 2;
|
||||||
|
|
||||||
|
memcpy(&flow->protos.dns.query_class, &packet->payload[i], 2);
|
||||||
|
flow->protos.dns.query_class = ntohs(flow->protos.dns.query_class), i += 2;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
printf("%s [type=%04X][class=%04X]\n", flow->host_server_name, flow->protos.dns.query_type, flow->protos.dns.query_class);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
/*
|
||||||
|
Do not set the protocol with DNS if ndpi_match_string_subprotocol() has
|
||||||
|
matched a subprotocol
|
||||||
|
*/
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_DNS, ndpi_struct, NDPI_LOG_DEBUG, "found DNS.\n");
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, (dport == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flow->protos.dns.bad_packet = 1;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_DOFUS, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* dropbox.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_DROPBOX
|
||||||
|
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_int_add_connection(ndpi_struct, flow,
|
||||||
|
NDPI_PROTOCOL_DROPBOX,
|
||||||
|
due_to_correlation ? NDPI_CORRELATED_PROTOCOL : NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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(17500);
|
||||||
|
|
||||||
|
if((packet->udp->source == dropbox_port)
|
||||||
|
&& (packet->udp->dest == dropbox_port)) {
|
||||||
|
if(payload_len > 2) {
|
||||||
|
if(strncmp((const char *)packet->payload, "{\"", 2) == 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_EDONKEY, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FASTTRACK, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FIESTA, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FILETOPIA, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* florensia.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_FLORENSIA
|
||||||
|
|
||||||
|
|
||||||
|
static void ndpi_florensia_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FLORENSIA, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_florensia(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_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "search florensia.\n");
|
||||||
|
|
||||||
|
if (packet->tcp != NULL) {
|
||||||
|
if (packet->payload_packet_len == 5 && get_l16(packet->payload, 0) == packet->payload_packet_len
|
||||||
|
&& packet->payload[2] == 0x65 && packet->payload[4] == 0xff) {
|
||||||
|
if (flow->florensia_stage == 1) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
|
||||||
|
ndpi_florensia_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
|
||||||
|
flow->florensia_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len > 8 && get_l16(packet->payload, 0) == packet->payload_packet_len
|
||||||
|
&& get_u_int16_t(packet->payload, 2) == htons(0x0201) && get_u_int32_t(packet->payload, 4) == htonl(0xFFFFFFFF)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
|
||||||
|
flow->florensia_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 406 && get_l16(packet->payload, 0) == packet->payload_packet_len
|
||||||
|
&& packet->payload[2] == 0x63) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
|
||||||
|
flow->florensia_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 12 && get_l16(packet->payload, 0) == packet->payload_packet_len
|
||||||
|
&& get_u_int16_t(packet->payload, 2) == htons(0x0301)) {
|
||||||
|
if (flow->florensia_stage == 1) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
|
||||||
|
ndpi_florensia_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
|
||||||
|
flow->florensia_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flow->florensia_stage == 1) {
|
||||||
|
if (packet->payload_packet_len == 8 && get_l16(packet->payload, 0) == packet->payload_packet_len
|
||||||
|
&& get_u_int16_t(packet->payload, 2) == htons(0x0302) && get_u_int32_t(packet->payload, 4) == htonl(0xFFFFFFFF)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia asymmetrically.\n");
|
||||||
|
ndpi_florensia_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 24 && get_l16(packet->payload, 0) == packet->payload_packet_len
|
||||||
|
&& get_u_int16_t(packet->payload, 2) == htons(0x0202)
|
||||||
|
&& get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0xFFFFFFFF)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
|
||||||
|
ndpi_florensia_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (flow->packet_counter < 10 && get_l16(packet->payload, 0) == packet->payload_packet_len) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packet->udp != NULL) {
|
||||||
|
if (flow->florensia_stage == 0 && packet->payload_packet_len == 6
|
||||||
|
&& get_u_int16_t(packet->payload, 0) == ntohs(0x0503) && get_u_int32_t(packet->payload, 2) == htonl(0xFFFF0000)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "maybe florensia -> stage is set to 1.\n");
|
||||||
|
flow->florensia_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (flow->florensia_stage == 1 && packet->payload_packet_len == 8
|
||||||
|
&& get_u_int16_t(packet->payload, 0) == ntohs(0x0500) && get_u_int16_t(packet->payload, 4) == htons(0x4191)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "found florensia.\n");
|
||||||
|
ndpi_florensia_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FLORENSIA, ndpi_struct, NDPI_LOG_DEBUG, "exclude florensia.\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FLORENSIA);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,999 @@
|
|||||||
|
/*
|
||||||
|
* ftp_control.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
|
||||||
|
*
|
||||||
|
* 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_FTP_CONTROL
|
||||||
|
|
||||||
|
static void ndpi_int_ftp_control_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FTP_CONTROL, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ndpi_ftp_control_check_request(const u_int8_t *payload) {
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "ABOR")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "ACCT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "ADAT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "ALLO")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "APPE")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "AUTH")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (match_first_bytes(payload, "CCC")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "CDUP")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "CONF")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "CWD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "DELE")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "ENC")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "EPRT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "EPSV")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "FEAT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "HELP")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "LANG")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "LIST")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "LPRT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "LPSV")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "MDTM")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "MIC")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "MKD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "MLSD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "MLST")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "MODE")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "NLST")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "NOOP")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "OPTS")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "PASS")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "PASV")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "PBSZ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "PORT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "PROT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "PWD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "QUIT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "REIN")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "REST")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "RETR")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "RMD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "RNFR")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "RNTO")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "SITE")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "SIZE")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "SMNT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "STAT")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "STOR")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "STOU")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "STRU")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "SYST")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "TYPE")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "USER")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XCUP")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XMKD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XPWD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XRCP")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XRMD")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XRSQ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XSEM")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "XSEN")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "HOST")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "abor")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "acct")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "adat")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "allo")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "appe")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "auth")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "ccc")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "cdup")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "conf")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "cwd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "dele")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "enc")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "eprt")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "epsv")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "feat")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "help")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "lang")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "list")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "lprt")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "lpsv")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "mdtm")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "mic")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "mkd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "mlsd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "mlst")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "mode")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "nlst")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "noop")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "opts")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "pass")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "pasv")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "pbsz")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "port")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "prot")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "pwd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "quit")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "rein")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "rest")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "retr")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "rmd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "rnfr")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "rnto")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "site")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "size")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "smnt")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "stat")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "stor")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "stou")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "stru")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "syst")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "type")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "user")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xcup")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xmkd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xpwd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xrcp")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xrmd")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xrsq")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xsem")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "xsen")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "host")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ndpi_ftp_control_check_response(const u_int8_t *payload) {
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "110-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "120-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "125-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "150-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "202-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "211-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "212-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "213-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "214-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "215-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "220-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "221-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "225-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "226-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "227-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "228-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "229-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "230-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "231-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "232-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "250-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "257-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "331-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "332-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "350-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "421-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "425-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "426-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "430-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "434-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "450-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "451-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "452-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "501-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "502-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "503-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "504-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "530-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "532-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "550-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "551-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "552-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "553-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "631-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "632-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "633-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10054-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10060-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10061-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10066-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10068-")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "110 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "120 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "125 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "150 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "202 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "211 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "212 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "213 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "214 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "215 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "220 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "221 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "225 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "226 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "227 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "228 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "229 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "230 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "231 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "232 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "250 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "257 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "331 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "332 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "350 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "421 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "425 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "426 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "430 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "434 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "450 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "451 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "452 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "501 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "502 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "503 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "504 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "530 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "532 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (match_first_bytes(payload, "550 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "551 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "552 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "553 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "631 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "632 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "633 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10054 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10060 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10061 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10066 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match_first_bytes(payload, "10068 ")) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ndpi_check_ftp_control(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;
|
||||||
|
|
||||||
|
/* Exclude SMTP, which uses similar commands. */
|
||||||
|
if (packet->tcp->dest == htons(25) || packet->tcp->source == htons(25)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Exclude FTP_CONTROL.\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_CONTROL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Break after 20 packets. */
|
||||||
|
if (flow->packet_counter > 20) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Exclude FTP_CONTROL.\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_CONTROL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we so far detected the protocol in the request or not. */
|
||||||
|
if (flow->ftp_control_stage == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "FTP_CONTROL stage 0: \n");
|
||||||
|
|
||||||
|
if ((payload_len > 0) && ndpi_ftp_control_check_request(packet->payload)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Possible FTP_CONTROL 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->ftp_control_stage = packet->packet_direction + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "FTP_CONTROL stage %u: \n", flow->ftp_control_stage);
|
||||||
|
|
||||||
|
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||||
|
if ((flow->ftp_control_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_ftp_control_check_response(packet->payload)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "Found FTP_CONTROL.\n");
|
||||||
|
ndpi_int_ftp_control_add_connection(ndpi_struct, flow);
|
||||||
|
} else {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "The reply did not seem to belong to FTP_CONTROL, resetting the stage to 0...\n");
|
||||||
|
flow->ftp_control_stage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_ftp_control(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_CONTROL, ndpi_struct, NDPI_LOG_DEBUG, "FTP_CONTROL detection...\n");
|
||||||
|
|
||||||
|
/* skip marked packets */
|
||||||
|
if (packet->detected_protocol_stack[0] != NDPI_PROTOCOL_FTP_CONTROL) {
|
||||||
|
if (packet->tcp_retransmission == 0) {
|
||||||
|
ndpi_check_ftp_control(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
/*
|
||||||
|
* ftp_data.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Tomasz Bujlow <tomasz@skatnet.dk>
|
||||||
|
* Copyright (C) 2014 - ntop.org
|
||||||
|
*
|
||||||
|
* 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_FTP_DATA
|
||||||
|
static void ndpi_int_ftp_data_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_FTP_DATA, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ndpi_match_ftp_data_port(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
if(packet->tcp->dest == htons(20) || packet->tcp->source == htons(20)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ndpi_match_ftp_data_directory(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((payload_len >= 4)
|
||||||
|
&& ((packet->payload[0] == '-') || (packet->payload[0] == 'd'))
|
||||||
|
&& ((packet->payload[1] == '-') || (packet->payload[1] == 'r'))
|
||||||
|
&& ((packet->payload[2] == '-') || (packet->payload[2] == 'w'))
|
||||||
|
&& ((packet->payload[3] == '-') || (packet->payload[3] == 'x'))) {
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ndpi_match_file_header(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
/* A FTP packet is pretty long so 256 is a bit consrvative but it should be OK */
|
||||||
|
if(packet->payload_packet_len < 256)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* RIFF is a meta-format for storing AVI and WAV files */
|
||||||
|
if(match_first_bytes(packet->payload, "RIFF"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* MZ is a .exe file */
|
||||||
|
if((packet->payload[0] == 'M') && (packet->payload[1] == 'Z') && (packet->payload[3] == 0x00))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Ogg files */
|
||||||
|
if(match_first_bytes(packet->payload, "OggS"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ZIP files */
|
||||||
|
if((packet->payload[0] == 'P') && (packet->payload[1] == 'K') && (packet->payload[2] == 0x03) && (packet->payload[3] == 0x04))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* MPEG files */
|
||||||
|
if((packet->payload[0] == 0x00) && (packet->payload[1] == 0x00) && (packet->payload[2] == 0x01) && (packet->payload[3] == 0xba))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* RAR files */
|
||||||
|
if(match_first_bytes(packet->payload, "Rar!"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* EBML */
|
||||||
|
if((packet->payload[0] == 0x1a) && (packet->payload[1] == 0x45) && (packet->payload[2] == 0xdf) && (packet->payload[3] == 0xa3))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* JPG */
|
||||||
|
if((packet->payload[0] == 0xff) && (packet->payload[1] ==0xd8))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* GIF */
|
||||||
|
if(match_first_bytes(packet->payload, "GIF8"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* PHP scripts */
|
||||||
|
if((packet->payload[0] == 0x3c) && (packet->payload[1] == 0x3f) && (packet->payload[2] == 0x70) && (packet->payload[3] == 0x68))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Unix scripts */
|
||||||
|
if((packet->payload[0] == 0x23) && (packet->payload[1] == 0x21) && (packet->payload[2] == 0x2f) && (packet->payload[3] == 0x62))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* PDFs */
|
||||||
|
if(match_first_bytes(packet->payload, "%PDF"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* PNG */
|
||||||
|
if((packet->payload[0] == 0x89) && (packet->payload[1] == 'P') && (packet->payload[2] == 'N') && (packet->payload[3] == 'G'))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* HTML */
|
||||||
|
if(match_first_bytes(packet->payload, "<htm"))
|
||||||
|
return 1;
|
||||||
|
if((packet->payload[0] == 0x0a) && (packet->payload[1] == '<') && (packet->payload[2] == '!') && (packet->payload[3] == 'D'))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* 7zip */
|
||||||
|
if((packet->payload[0] == 0x37) && (packet->payload[1] == 0x7a) && (packet->payload[2] == 0xbc) && (packet->payload[3] == 0xaf))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* gzip */
|
||||||
|
if((packet->payload[0] == 0x1f) && (packet->payload[1] == 0x8b) && (packet->payload[2] == 0x08))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* XML */
|
||||||
|
if(match_first_bytes(packet->payload, "<!DO"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* FLAC */
|
||||||
|
if(match_first_bytes(packet->payload, "fLaC"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* MP3 */
|
||||||
|
if((packet->payload[0] == 'I') && (packet->payload[1] == 'D') && (packet->payload[2] == '3') && (packet->payload[3] == 0x03))
|
||||||
|
return 1;
|
||||||
|
if(match_first_bytes(packet->payload, "\xff\xfb\x90\xc0"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* RPM */
|
||||||
|
if((packet->payload[0] == 0xed) && (packet->payload[1] == 0xab) && (packet->payload[2] == 0xee) && (packet->payload[3] == 0xdb))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Wz Patch */
|
||||||
|
if(match_first_bytes(packet->payload, "WzPa"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Flash Video */
|
||||||
|
if((packet->payload[0] == 'F') && (packet->payload[1] == 'L') && (packet->payload[2] == 'V') && (packet->payload[3] == 0x01))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* .BKF (Microsoft Tape Format) */
|
||||||
|
if(match_first_bytes(packet->payload, "TAPE"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* MS Office Doc file - this is unpleasantly geeky */
|
||||||
|
if((packet->payload[0] == 0xd0) && (packet->payload[1] == 0xcf) && (packet->payload[2] == 0x11) && (packet->payload[3] == 0xe0))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ASP */
|
||||||
|
if((packet->payload[0] == 0x3c) && (packet->payload[1] == 0x25) && (packet->payload[2] == 0x40) && (packet->payload[3] == 0x20))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* WMS file */
|
||||||
|
if((packet->payload[0] == 0x3c) && (packet->payload[1] == 0x21) && (packet->payload[2] == 0x2d) && (packet->payload[3] == 0x2d))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ar archive, typically .deb files */
|
||||||
|
if(match_first_bytes(packet->payload, "!<ar"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Raw XML (skip jabber-like traffic as this is not FTP but unencrypted jabber) */
|
||||||
|
if((match_first_bytes(packet->payload, "<?xm"))
|
||||||
|
&& (ndpi_strnstr((const char *)packet->payload, "jabber", packet->payload_packet_len) == NULL))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(match_first_bytes(packet->payload, "<iq "))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* SPF */
|
||||||
|
if(match_first_bytes(packet->payload, "SPFI"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* ABIF - Applied Biosystems */
|
||||||
|
if(match_first_bytes(packet->payload, "ABIF"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* bzip2 - other digits are also possible instead of 9 */
|
||||||
|
if((packet->payload[0] == 'B') && (packet->payload[1] == 'Z') && (packet->payload[2] == 'h') && (packet->payload[3] == '9'))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Some other types of files */
|
||||||
|
|
||||||
|
if((packet->payload[0] == '<') && (packet->payload[1] == 'c') && (packet->payload[2] == 'f'))
|
||||||
|
return 1;
|
||||||
|
if((packet->payload[0] == '<') && (packet->payload[1] == 'C') && (packet->payload[2] == 'F'))
|
||||||
|
return 1;
|
||||||
|
if(match_first_bytes(packet->payload, ".tem"))
|
||||||
|
return 1;
|
||||||
|
if(match_first_bytes(packet->payload, ".ite"))
|
||||||
|
return 1;
|
||||||
|
if(match_first_bytes(packet->payload, ".lef"))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ndpi_check_ftp_data(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;
|
||||||
|
|
||||||
|
/* Check if we so far detected the protocol in the request or not. */
|
||||||
|
if(flow->ftp_data_stage == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA stage 0: \n");
|
||||||
|
|
||||||
|
if((payload_len > 0) && (ndpi_match_file_header(ndpi_struct, flow) || ndpi_match_ftp_data_directory(ndpi_struct, flow) || ndpi_match_ftp_data_port(ndpi_struct, flow))) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Possible FTP_DATA 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->ftp_data_stage = packet->packet_direction + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA stage %u: \n", flow->ftp_data_stage);
|
||||||
|
|
||||||
|
/* At first check, if this is for sure a response packet (in another direction. If not, do nothing now and return. */
|
||||||
|
if((flow->ftp_data_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_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Found FTP_DATA.\n");
|
||||||
|
ndpi_int_ftp_data_add_connection(ndpi_struct, flow);
|
||||||
|
} else {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "The reply did not seem to belong to FTP_DATA, resetting the stage to 0...\n");
|
||||||
|
flow->ftp_data_stage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_ftp_data(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
/* Break after 20 packets. */
|
||||||
|
if(flow->packet_counter > 20) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "Exclude FTP_DATA.\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_FTP_DATA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* skip marked or retransmitted packets */
|
||||||
|
if(packet->tcp_retransmission != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packet->detected_protocol_stack[0] == NDPI_PROTOCOL_FTP_DATA) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_FTP_DATA, ndpi_struct, NDPI_LOG_DEBUG, "FTP_DATA detection...\n");
|
||||||
|
ndpi_check_ftp_data(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,375 @@
|
|||||||
|
/*
|
||||||
|
* gnutella.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_GNUTELLA
|
||||||
|
|
||||||
|
static void ndpi_int_gnutella_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow,
|
||||||
|
ndpi_protocol_type_t protocol_type)
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
struct ndpi_id_struct *src = flow->src;
|
||||||
|
struct ndpi_id_struct *dst = flow->dst;
|
||||||
|
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_GNUTELLA, protocol_type);
|
||||||
|
|
||||||
|
if (src != NULL) {
|
||||||
|
src->gnutella_ts = packet->tick_timestamp;
|
||||||
|
if (packet->udp != NULL) {
|
||||||
|
if (!src->detected_gnutella_udp_port1) {
|
||||||
|
src->detected_gnutella_udp_port1 = (packet->udp->source);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
|
||||||
|
NDPI_LOG_DEBUG, "GNUTELLA UDP PORT1 DETECTED as %u\n",
|
||||||
|
src->detected_gnutella_udp_port1);
|
||||||
|
|
||||||
|
} else if ((ntohs(packet->udp->source) != src->detected_gnutella_udp_port1)
|
||||||
|
&& !src->detected_gnutella_udp_port2) {
|
||||||
|
src->detected_gnutella_udp_port2 = (packet->udp->source);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
|
||||||
|
NDPI_LOG_DEBUG, "GNUTELLA UDP PORT2 DETECTED as %u\n",
|
||||||
|
src->detected_gnutella_udp_port2);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dst != NULL) {
|
||||||
|
dst->gnutella_ts = packet->tick_timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_gnutella(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;
|
||||||
|
|
||||||
|
u_int16_t c;
|
||||||
|
if (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_GNUTELLA) {
|
||||||
|
if (src != NULL && ((u_int32_t)
|
||||||
|
(packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
|
||||||
|
NDPI_LOG_DEBUG, "gnutella : save src connection packet detected\n");
|
||||||
|
src->gnutella_ts = packet->tick_timestamp;
|
||||||
|
} else if (dst != NULL && ((u_int32_t)
|
||||||
|
(packet->tick_timestamp - dst->gnutella_ts) < ndpi_struct->gnutella_timeout)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
|
||||||
|
NDPI_LOG_DEBUG, "gnutella : save dst connection packet detected\n");
|
||||||
|
dst->gnutella_ts = packet->tick_timestamp;
|
||||||
|
}
|
||||||
|
if (src != NULL && (packet->tick_timestamp - src->gnutella_ts) > ndpi_struct->gnutella_timeout) {
|
||||||
|
src->detected_gnutella_udp_port1 = 0;
|
||||||
|
src->detected_gnutella_udp_port2 = 0;
|
||||||
|
}
|
||||||
|
if (dst != NULL && (packet->tick_timestamp - dst->gnutella_ts) > ndpi_struct->gnutella_timeout) {
|
||||||
|
dst->detected_gnutella_udp_port1 = 0;
|
||||||
|
dst->detected_gnutella_udp_port2 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* skip packets without payload */
|
||||||
|
if (packet->payload_packet_len < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->tcp != NULL) {
|
||||||
|
/* this case works asymmetrically */
|
||||||
|
if (packet->payload_packet_len > 10 && memcmp(packet->payload, "GNUTELLA/", 9) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "GNUTELLA DETECTED\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* this case works asymmetrically */
|
||||||
|
if (packet->payload_packet_len > 17 && memcmp(packet->payload, "GNUTELLA CONNECT/", 17) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "GNUTELLA DETECTED\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packet->payload_packet_len > 50 && ((memcmp(packet->payload, "GET /get/", 9) == 0)
|
||||||
|
|| (memcmp(packet->payload, "GET /uri-res/", 13) == 0)
|
||||||
|
)) {
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
for (c = 0; c < packet->parsed_lines; c++) {
|
||||||
|
if ((packet->line[c].len > 19 && memcmp(packet->line[c].ptr, "User-Agent: Gnutella", 20) == 0)
|
||||||
|
|| (packet->line[c].len > 10 && memcmp(packet->line[c].ptr, "X-Gnutella-", 11) == 0)
|
||||||
|
|| (packet->line[c].len > 7 && memcmp(packet->line[c].ptr, "X-Queue:", 8) == 0)
|
||||||
|
|| (packet->line[c].len > 36 && memcmp(packet->line[c].ptr,
|
||||||
|
"Content-Type: application/x-gnutella-", 37) == 0)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "DETECTED GNUTELLA GET.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len > 50 && ((memcmp(packet->payload, "GET / HTTP", 9) == 0))) {
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
if ((packet->user_agent_line.ptr != NULL && packet->user_agent_line.len > 15
|
||||||
|
&& memcmp(packet->user_agent_line.ptr, "BearShare Lite ", 15) == 0)
|
||||||
|
|| (packet->accept_line.ptr != NULL && packet->accept_line.len > 24
|
||||||
|
&& memcmp(packet->accept_line.ptr, "application n/x-gnutella", 24) == 0)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "DETECTED GNUTELLA GET.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* haven't found this pattern in any trace. */
|
||||||
|
if (packet->payload_packet_len > 50 && ((memcmp(packet->payload, "GET /get/", 9) == 0)
|
||||||
|
|| (memcmp(packet->payload, "GET /uri-res/", 13) == 0))) {
|
||||||
|
c = 8;
|
||||||
|
while (c < (packet->payload_packet_len - 9)) {
|
||||||
|
if (packet->payload[c] == '?')
|
||||||
|
break;
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c < (packet->payload_packet_len - 9) && memcmp(&packet->payload[c], "urn:sha1:", 9) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
|
||||||
|
"detected GET /get/ or GET /uri-res/.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* answer to this packet is HTTP/1.1 ..... Content-Type: application/x-gnutella-packets,
|
||||||
|
* it is searched in the upper paragraph. */
|
||||||
|
if (packet->payload_packet_len > 30 && memcmp(packet->payload, "HEAD /gnutella/push-proxy?", 26) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected HEAD /gnutella/push-proxy?\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* haven't found any trace with this pattern */
|
||||||
|
if (packet->payload_packet_len == 46
|
||||||
|
&& memcmp(packet->payload, "\x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a", 10) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
|
||||||
|
"detected \x50\x55\x53\x48\x20\x67\x75\x69\x64\x3a\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* haven't found any trace with this pattern */
|
||||||
|
if (packet->payload_packet_len > 250 && memcmp(packet->payload, "GET /gnutella/", 14) == 0)
|
||||||
|
//PATTERN IS :: GET /gnutella/tigertree/v3?urn:tree:tiger/:
|
||||||
|
{
|
||||||
|
const u_int16_t end = packet->payload_packet_len - 3;
|
||||||
|
|
||||||
|
c = 13;
|
||||||
|
while (c < end) {
|
||||||
|
if ((memcmp(&packet->payload[14], "tigertree/", 10) == 0)
|
||||||
|
|| (end - c > 18 && memcmp(&packet->payload[c], "\r\nUser-Agent: Foxy", 18) == 0)
|
||||||
|
|| (end - c > 44
|
||||||
|
&& memcmp(&packet->payload[c],
|
||||||
|
"\r\nAccept: application/tigertree-breadthfirst",
|
||||||
|
44) == 0) || (end - c > 10 && memcmp(&packet->payload[c], "\r\nX-Queue:", 10) == 0)
|
||||||
|
|| (end - c > 13 && memcmp(&packet->payload[c], "\r\nX-Features:", 13) == 0)) {
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA,
|
||||||
|
ndpi_struct, NDPI_LOG_TRACE, "FOXY :: GNUTELLA GET 2 DETECTED\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* haven't found any trace with this pattern */
|
||||||
|
if (packet->payload_packet_len > 1 && packet->payload[packet->payload_packet_len - 1] == 0x0a
|
||||||
|
&& packet->payload[packet->payload_packet_len - 2] == 0x0a) {
|
||||||
|
if (packet->payload_packet_len > 3 && memcmp(packet->payload, "GIV", 3) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "MORPHEUS GIV DETECTED\n");
|
||||||
|
/* Not Excludeing the flow now.. We shall Check the next Packet too for Gnutella Patterns */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* might be super tricky new ssl gnutella transmission, but the certificate is strange... */
|
||||||
|
if (packet->payload_packet_len == 46 && get_u_int32_t(packet->payload, 0) == htonl(0x802c0103) &&
|
||||||
|
get_u_int32_t(packet->payload, 4) == htonl(0x01000300) && get_u_int32_t(packet->payload, 8) == htonl(0x00002000) &&
|
||||||
|
get_u_int16_t(packet->payload, 12) == htons(0x0034)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected gnutella len == 46.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 49 &&
|
||||||
|
memcmp(packet->payload, "\x80\x2f\x01\x03\x01\x00\x06\x00\x00\x00\x20\x00\x00\x34\x00\x00\xff\x4d\x6c",
|
||||||
|
19) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected gnutella len == 49.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 89 && memcmp(&packet->payload[43], "\x20\x4d\x6c", 3) == 0 &&
|
||||||
|
memcmp(packet->payload, "\x16\x03\x01\x00\x54\x01\x00\x00\x50\x03\x01\x4d\x6c", 13) == 0 &&
|
||||||
|
memcmp(&packet->payload[76], "\x00\x02\x00\x34\x01\x00\x00\x05", 8) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE,
|
||||||
|
"detected gnutella asymmetrically len == 388.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
} else if (packet->payload_packet_len == 82) {
|
||||||
|
if (get_u_int32_t(packet->payload, 0) == htonl(0x16030100)
|
||||||
|
&& get_u_int32_t(packet->payload, 4) == htonl(0x4d010000)
|
||||||
|
&& get_u_int16_t(packet->payload, 8) == htons(0x4903)
|
||||||
|
&& get_u_int16_t(packet->payload, 76) == htons(0x0002)
|
||||||
|
&& get_u_int32_t(packet->payload, 78) == htonl(0x00340100)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_TRACE, "detected len == 82.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (packet->udp != NULL) {
|
||||||
|
if (src != NULL && (packet->udp->source == src->detected_gnutella_udp_port1 ||
|
||||||
|
packet->udp->source == src->detected_gnutella_udp_port2) &&
|
||||||
|
(packet->tick_timestamp - src->gnutella_ts) < ndpi_struct->gnutella_timeout) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG, "port based detection\n\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
}
|
||||||
|
/* observations:
|
||||||
|
* all the following patterns send out many packets which are the only ones of their flows,
|
||||||
|
* often on the very beginning of the traces, or flows with many packets in one direction only.
|
||||||
|
* but then suddenly, one gets an answer as you can see in netpeker-gnutella-rpc.pcap packet 11483.
|
||||||
|
* Maybe gnutella tries to send out keys?
|
||||||
|
*/
|
||||||
|
if (packet->payload_packet_len == 23 && packet->payload[15] == 0x00
|
||||||
|
&& packet->payload[16] == 0x41 && packet->payload[17] == 0x01
|
||||||
|
&& packet->payload[18] == 0x00 && packet->payload[19] == 0x00
|
||||||
|
&& packet->payload[20] == 0x00 && packet->payload[21] == 0x00 && packet->payload[22] == 0x00) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 23.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 35 && packet->payload[25] == 0x49
|
||||||
|
&& packet->payload[26] == 0x50 && packet->payload[27] == 0x40
|
||||||
|
&& packet->payload[28] == 0x83 && packet->payload[29] == 0x53
|
||||||
|
&& packet->payload[30] == 0x43 && packet->payload[31] == 0x50 && packet->payload[32] == 0x41) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 35.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 32
|
||||||
|
&& (memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00\x4c\x49\x4d\x45", 11) == 0)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 32.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 34 && (memcmp(&packet->payload[25], "SCP@", 4) == 0)
|
||||||
|
&& (memcmp(&packet->payload[30], "DNA@", 4) == 0)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 34.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((packet->payload_packet_len == 73 || packet->payload_packet_len == 96)
|
||||||
|
&& memcmp(&packet->payload[32], "urn:sha1:", 9) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 73,96.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memcmp(packet->payload, "GND", 3) == 0) {
|
||||||
|
if ((packet->payload_packet_len == 8 && (memcmp(&packet->payload[6], "\x01\x00", 2) == 0))
|
||||||
|
|| (packet->payload_packet_len == 11 && (memcmp(&packet->payload[6], "\x01\x01\x08\x50\x49", 5)
|
||||||
|
== 0)) || (packet->payload_packet_len == 17
|
||||||
|
&&
|
||||||
|
(memcmp
|
||||||
|
(&packet->payload[6], "\x01\x01\x4c\x05\x50",
|
||||||
|
5) == 0))
|
||||||
|
|| (packet->payload_packet_len == 28
|
||||||
|
&& (memcmp(&packet->payload[6], "\x01\x01\x54\x0f\x51\x4b\x52\x50\x06\x52", 10) == 0))
|
||||||
|
|| (packet->payload_packet_len == 41
|
||||||
|
&& (memcmp(&packet->payload[6], "\x01\x01\x5c\x1b\x50\x55\x53\x48\x48\x10", 10) == 0))
|
||||||
|
|| (packet->payload_packet_len > 200 && packet->payload_packet_len < 300 && packet->payload[3] == 0x03)
|
||||||
|
|| (packet->payload_packet_len > 300 && (packet->payload[3] == 0x01 || packet->payload[3] == 0x03))) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, GND.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((packet->payload_packet_len == 32)
|
||||||
|
&& memcmp(&packet->payload[16], "\x31\x01\x00\x09\x00\x00\x00", 7) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 32 ii.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((packet->payload_packet_len == 23)
|
||||||
|
&& memcmp(&packet->payload[16], "\x00\x01\x00\x00\x00\x00\x00", 7) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"detected gnutella udp, len = 23 ii.\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//neonet detection follows
|
||||||
|
|
||||||
|
/* haven't found any trace with this pattern */
|
||||||
|
if (packet->tcp != NULL && ntohs(packet->tcp->source) >= 1024 && ntohs(packet->tcp->dest) >= 1024) {
|
||||||
|
if (flow->l4.tcp.gnutella_stage == 0) {
|
||||||
|
if (flow->packet_counter == 1
|
||||||
|
&& (packet->payload_packet_len == 11
|
||||||
|
|| packet->payload_packet_len == 33 || packet->payload_packet_len == 37)) {
|
||||||
|
flow->l4.tcp.gnutella_msg_id[0] = packet->payload[4];
|
||||||
|
flow->l4.tcp.gnutella_msg_id[1] = packet->payload[6];
|
||||||
|
flow->l4.tcp.gnutella_msg_id[2] = packet->payload[8];
|
||||||
|
flow->l4.tcp.gnutella_stage = 1 + packet->packet_direction;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (flow->l4.tcp.gnutella_stage == 1 + packet->packet_direction) {
|
||||||
|
if (flow->packet_counter == 2 && (packet->payload_packet_len == 33 || packet->payload_packet_len == 22)
|
||||||
|
&& flow->l4.tcp.gnutella_msg_id[0] == packet->payload[0]
|
||||||
|
&& flow->l4.tcp.gnutella_msg_id[1] == packet->payload[2]
|
||||||
|
&& flow->l4.tcp.gnutella_msg_id[2] == packet->payload[4]
|
||||||
|
&& NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
|
||||||
|
NDPI_LOG_TRACE, "GNUTELLA DETECTED due to message ID match (NEONet protocol)\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (flow->l4.tcp.gnutella_stage == 2 - packet->packet_direction) {
|
||||||
|
if (flow->packet_counter == 2 && (packet->payload_packet_len == 10 || packet->payload_packet_len == 75)
|
||||||
|
&& flow->l4.tcp.gnutella_msg_id[0] == packet->payload[0]
|
||||||
|
&& flow->l4.tcp.gnutella_msg_id[1] == packet->payload[2]
|
||||||
|
&& flow->l4.tcp.gnutella_msg_id[2] == packet->payload[4]
|
||||||
|
&& NDPI_SRC_OR_DST_HAS_PROTOCOL(src, dst, NDPI_PROTOCOL_GNUTELLA)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GNUTELLA, ndpi_struct,
|
||||||
|
NDPI_LOG_TRACE, "GNUTELLA DETECTED due to message ID match (NEONet protocol)\n");
|
||||||
|
ndpi_int_gnutella_add_connection(ndpi_struct, flow, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GNUTELLA);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* gtp.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011-15 - 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_api.h"
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_GTP
|
||||||
|
|
||||||
|
struct gtp_header_generic {
|
||||||
|
u_int8_t flags, message_type;
|
||||||
|
u_int16_t message_len;
|
||||||
|
u_int32_t teid;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ndpi_check_gtp(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 0
|
||||||
|
printf("[len=%u][%02X %02X %02X %02X]\n", payload_len,
|
||||||
|
packet->payload[0] & 0xFF,
|
||||||
|
packet->payload[1] & 0xFF,
|
||||||
|
packet->payload[2] & 0xFF,
|
||||||
|
packet->payload[3] & 0xFF);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if((packet->udp != NULL) && (payload_len > sizeof(struct gtp_header_generic))) {
|
||||||
|
u_int32_t gtp_u = ntohs(2152);
|
||||||
|
u_int32_t gtp_c = ntohs(2123);
|
||||||
|
u_int32_t gtp_v0 = ntohs(3386);
|
||||||
|
|
||||||
|
if((packet->udp->source == gtp_u) || (packet->udp->dest == gtp_u)
|
||||||
|
|| (packet->udp->source == gtp_c) || (packet->udp->dest == gtp_c)
|
||||||
|
|| (packet->udp->source == gtp_v0) || (packet->udp->dest == gtp_v0)
|
||||||
|
) {
|
||||||
|
struct gtp_header_generic *gtp = (struct gtp_header_generic*)packet->payload;
|
||||||
|
u_int8_t gtp_version = (gtp->flags & 0xE0) >> 5;
|
||||||
|
|
||||||
|
if((gtp_version == 0) || (gtp_version == 1) || (gtp_version == 2)) {
|
||||||
|
u_int16_t message_len = ntohs(gtp->message_len);
|
||||||
|
|
||||||
|
if(message_len <= (payload_len-sizeof(struct gtp_header_generic))) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GTP, ndpi_struct, NDPI_LOG_DEBUG, "Found gtp.\n");
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_GTP, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GTP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_gtp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GTP, ndpi_struct, NDPI_LOG_DEBUG, "gtp detection...\n");
|
||||||
|
|
||||||
|
/* skip marked packets */
|
||||||
|
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_GTP)
|
||||||
|
ndpi_check_gtp(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* guildwars.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_GUILDWARS
|
||||||
|
|
||||||
|
|
||||||
|
static void ndpi_int_guildwars_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_GUILDWARS, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_guildwars_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_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "search guildwars.\n");
|
||||||
|
|
||||||
|
if (packet->payload_packet_len == 64 && get_u_int16_t(packet->payload, 1) == ntohs(0x050c)
|
||||||
|
&& memcmp(&packet->payload[50], "@2&P", 4) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "GuildWars version 29.350: found.\n");
|
||||||
|
ndpi_int_guildwars_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 16 && get_u_int16_t(packet->payload, 1) == ntohs(0x040c)
|
||||||
|
&& get_u_int16_t(packet->payload, 4) == ntohs(0xa672)
|
||||||
|
&& packet->payload[8] == 0x01 && packet->payload[12] == 0x04) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "GuildWars version 29.350: found.\n");
|
||||||
|
ndpi_int_guildwars_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet->payload_packet_len == 21 && get_u_int16_t(packet->payload, 0) == ntohs(0x0100)
|
||||||
|
&& get_u_int32_t(packet->payload, 5) == ntohl(0xf1001000)
|
||||||
|
&& packet->payload[9] == 0x01) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "GuildWars version 216.107.245.50: found.\n");
|
||||||
|
ndpi_int_guildwars_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_GUILDWARS, ndpi_struct, NDPI_LOG_DEBUG, "exclude guildwars.\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_GUILDWARS);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* h323.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 ntop.org
|
||||||
|
* Copyright (C) 2013 Remy Mudingay <mudingay@ill.fr>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ndpi_protocols.h"
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_H323
|
||||||
|
|
||||||
|
struct tpkt {
|
||||||
|
u_int8_t version, reserved;
|
||||||
|
u_int16_t len;
|
||||||
|
};
|
||||||
|
|
||||||
|
void ndpi_search_h323(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
u_int16_t dport = 0, sport = 0;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "search H323.\n");
|
||||||
|
|
||||||
|
if(packet->tcp != NULL) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over tcp.\n");
|
||||||
|
|
||||||
|
/* H323 */
|
||||||
|
if((packet->payload[0] == 0x03)
|
||||||
|
&& (packet->payload[1] == 0x00)
|
||||||
|
&& (packet->payload[2] == 0x00)) {
|
||||||
|
struct tpkt *t = (struct tpkt*)packet->payload;
|
||||||
|
u_int16_t len = ntohs(t->len);
|
||||||
|
|
||||||
|
if(packet->payload_packet_len == len) {
|
||||||
|
/*
|
||||||
|
We need to check if this packet is in reality
|
||||||
|
a RDP (Remote Desktop) packet encapsulated on TPTK
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(packet->payload[4] == (packet->payload_packet_len - sizeof(struct tpkt) - 1)) {
|
||||||
|
/* ISO 8073/X.224 */
|
||||||
|
if((packet->payload[5] == 0xE0 /* CC Connect Request */)
|
||||||
|
|| (packet->payload[5] == 0xD0 /* CC Connect Confirm */)) {
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_RDP, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flow->l4.tcp.h323_valid_packets++;
|
||||||
|
|
||||||
|
if(flow->l4.tcp.h323_valid_packets >= 2) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* This is not H.323 */
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_H323);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(packet->udp != NULL) {
|
||||||
|
sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "calculated dport over udp.\n");
|
||||||
|
|
||||||
|
if(packet->payload[0] == 0x80 && packet->payload[1] == 0x08 && (packet->payload[2] == 0xe7 || packet->payload[2] == 0x26) &&
|
||||||
|
packet->payload[4] == 0x00 && packet->payload[5] == 0x00)
|
||||||
|
{
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* H323 */
|
||||||
|
if(sport == 1719 || dport == 1719)
|
||||||
|
{
|
||||||
|
if(packet->payload[0] == 0x16 && packet->payload[1] == 0x80 && packet->payload[4] == 0x06 && packet->payload[5] == 0x00)
|
||||||
|
{
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(packet->payload_packet_len >= 20 || packet->payload_packet_len <= 117)
|
||||||
|
{
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_H323, ndpi_struct, NDPI_LOG_DEBUG, "found H323 broadcast.\n");
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_H323, NDPI_REAL_PROTOCOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_H323);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* halflife2_and_mods.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_HALFLIFE2
|
||||||
|
|
||||||
|
|
||||||
|
static void ndpi_int_halflife2_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HALFLIFE2, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_halflife2(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.udp.halflife2_stage == 0) {
|
||||||
|
if (packet->payload_packet_len >= 20
|
||||||
|
&& get_u_int32_t(packet->payload, 0) == 0xFFFFFFFF
|
||||||
|
&& get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0x30303000)) {
|
||||||
|
flow->l4.udp.halflife2_stage = 1 + packet->packet_direction;
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HALFLIFE2, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"halflife2 client req detected, waiting for server reply\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (flow->l4.udp.halflife2_stage == 2 - packet->packet_direction) {
|
||||||
|
if (packet->payload_packet_len >= 20
|
||||||
|
&& get_u_int32_t(packet->payload, 0) == 0xFFFFFFFF
|
||||||
|
&& get_u_int32_t(packet->payload, packet->payload_packet_len - 4) == htonl(0x30303000)) {
|
||||||
|
ndpi_int_halflife2_add_connection(ndpi_struct, flow);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HALFLIFE2, ndpi_struct, NDPI_LOG_DEBUG, "halflife2 server reply detected\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HALFLIFE2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,981 @@
|
|||||||
|
/*
|
||||||
|
* http.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_HTTP
|
||||||
|
|
||||||
|
static void ndpi_int_http_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow,
|
||||||
|
u_int32_t protocol) {
|
||||||
|
|
||||||
|
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
/* This is HTTP and it is not a sub protocol (e.g. skype or dropbox) */
|
||||||
|
|
||||||
|
ndpi_search_tcp_or_udp(ndpi_struct, flow);
|
||||||
|
|
||||||
|
/* If no custom protocol has been detected */
|
||||||
|
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
if(protocol != NDPI_PROTOCOL_HTTP) {
|
||||||
|
ndpi_search_tcp_or_udp(ndpi_struct, flow);
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, protocol, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
} else {
|
||||||
|
ndpi_int_reset_protocol(flow);
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, protocol, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flow->http_detected = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef NDPI_CONTENT_FLASH
|
||||||
|
static void flash_check_http_payload(struct ndpi_detection_module_struct
|
||||||
|
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
const u_int8_t *pos;
|
||||||
|
|
||||||
|
if(packet->empty_line_position_set == 0 || (packet->empty_line_position + 10) > (packet->payload_packet_len))
|
||||||
|
return;
|
||||||
|
|
||||||
|
pos = &packet->payload[packet->empty_line_position] + 2;
|
||||||
|
|
||||||
|
|
||||||
|
if(memcmp(pos, "FLV", 3) == 0 && pos[3] == 0x01 && (pos[4] == 0x01 || pos[4] == 0x04 || pos[4] == 0x05)
|
||||||
|
&& pos[5] == 0x00 && pos[6] == 0x00 && pos[7] == 0x00 && pos[8] == 0x09) {
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_CONTENT_FLASH, ndpi_struct, NDPI_LOG_DEBUG, "Flash content in http detected\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_CONTENT_FLASH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_CONTENT_AVI
|
||||||
|
static void avi_check_http_payload(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_CONTENT_AVI, ndpi_struct, NDPI_LOG_DEBUG, "called avi_check_http_payload: %u %u %u\n",
|
||||||
|
packet->empty_line_position_set, flow->l4.tcp.http_empty_line_seen, packet->empty_line_position);
|
||||||
|
|
||||||
|
if(packet->empty_line_position_set == 0 && flow->l4.tcp.http_empty_line_seen == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(packet->empty_line_position_set != 0 && ((packet->empty_line_position + 20) > (packet->payload_packet_len))
|
||||||
|
&& flow->l4.tcp.http_empty_line_seen == 0) {
|
||||||
|
flow->l4.tcp.http_empty_line_seen = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flow->l4.tcp.http_empty_line_seen == 1) {
|
||||||
|
if(packet->payload_packet_len > 20 && memcmp(packet->payload, "RIFF", 4) == 0
|
||||||
|
&& memcmp(packet->payload + 8, "AVI LIST", 8) == 0) {
|
||||||
|
NDPI_LOG(NDPI_CONTENT_AVI, ndpi_struct, NDPI_LOG_DEBUG, "Avi content in http detected\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_CONTENT_AVI);
|
||||||
|
}
|
||||||
|
flow->l4.tcp.http_empty_line_seen = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packet->empty_line_position_set != 0) {
|
||||||
|
// check for avi header
|
||||||
|
// for reference see http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/avirifffilereference.asp
|
||||||
|
u_int32_t p = packet->empty_line_position + 2;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_CONTENT_AVI, ndpi_struct, NDPI_LOG_DEBUG, "p = %u\n", p);
|
||||||
|
|
||||||
|
if((p + 16) <= packet->payload_packet_len && memcmp(&packet->payload[p], "RIFF", 4) == 0
|
||||||
|
&& memcmp(&packet->payload[p + 8], "AVI LIST", 8) == 0) {
|
||||||
|
NDPI_LOG(NDPI_CONTENT_AVI, ndpi_struct, NDPI_LOG_DEBUG, "Avi content in http detected\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_CONTENT_AVI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_TEAMVIEWER
|
||||||
|
static void teamviewer_check_http_payload(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
const u_int8_t *pos;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_TEAMVIEWER, ndpi_struct, NDPI_LOG_DEBUG, "called teamviewer_check_http_payload: %u %u %u\n",
|
||||||
|
packet->empty_line_position_set, flow->l4.tcp.http_empty_line_seen, packet->empty_line_position);
|
||||||
|
|
||||||
|
if(packet->empty_line_position_set == 0 || (packet->empty_line_position + 5) > (packet->payload_packet_len))
|
||||||
|
return;
|
||||||
|
|
||||||
|
pos = &packet->payload[packet->empty_line_position] + 2;
|
||||||
|
|
||||||
|
if(pos[0] == 0x17 && pos[1] == 0x24) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_TEAMVIEWER, ndpi_struct, NDPI_LOG_DEBUG, "TeamViewer content in http detected\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_TEAMVIEWER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef NDPI_PROTOCOL_RTSP
|
||||||
|
static void rtsp_parse_packet_acceptline(struct ndpi_detection_module_struct
|
||||||
|
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
if(packet->accept_line.len >= 28 && memcmp(packet->accept_line.ptr, "application/x-rtsp-tunnelled", 28) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_RTSP, ndpi_struct, NDPI_LOG_DEBUG, "RTSP accept line detected\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_RTSP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void setHttpUserAgent(struct ndpi_flow_struct *flow, char *ua) {
|
||||||
|
if(!strcmp(ua, "Windows NT 5.0")) ua = "Windows 2000";
|
||||||
|
else if(!strcmp(ua, "Windows NT 5.1")) ua = "Windows XP";
|
||||||
|
else if(!strcmp(ua, "Windows NT 5.2")) ua = "Windows Server 2003";
|
||||||
|
else if(!strcmp(ua, "Windows NT 6.0")) ua = "Windows Vista";
|
||||||
|
// else if(!strcmp(ua, "Windows NT 7.0")) ua = "Windows 7";
|
||||||
|
else if(!strcmp(ua, "Windows NT 6.1")) ua = "Windows 7";
|
||||||
|
else if(!strcmp(ua, "Windows NT 6.2")) ua = "Windows 8";
|
||||||
|
else if(!strcmp(ua, "Windows NT 6.3")) ua = "Windows 8.1";
|
||||||
|
|
||||||
|
//printf("==> %s\n", ua);
|
||||||
|
snprintf((char*)flow->detected_os, sizeof(flow->detected_os), "%s", ua);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void parseHttpSubprotocol(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) {
|
||||||
|
// int i = 0;
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
if(packet->iph /* IPv4 only */) {
|
||||||
|
/*
|
||||||
|
Twitter Inc. TWITTER-NETWORK (NET-199-59-148-0-1) 199.59.148.0 - 199.59.151.255
|
||||||
|
199.59.148.0/22
|
||||||
|
*/
|
||||||
|
if(((ntohl(packet->iph->saddr) & 0xFFFFFC00 /* 255.255.252.0 */) == 0xC73B9400 /* 199.59.148.0 */)
|
||||||
|
|| ((ntohl(packet->iph->daddr) & 0xFFFFFC00 /* 255.255.252.0 */) == 0xC73B9400 /* 199.59.148.0 */)) {
|
||||||
|
packet->detected_protocol_stack[0] = NDPI_SERVICE_TWITTER;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
CIDR: 69.53.224.0/19
|
||||||
|
OriginAS: AS2906
|
||||||
|
NetName: NETFLIX-INC
|
||||||
|
*/
|
||||||
|
if(((ntohl(packet->iph->saddr) & 0xFFFFE000 /* 255.255.224.0 */) == 0x4535E000 /* 69.53.224.0 */)
|
||||||
|
|| ((ntohl(packet->iph->daddr) & 0xFFFFE000 /* 255.255.224.0 */) == 0x4535E000 /* 69.53.224.0 */)) {
|
||||||
|
packet->detected_protocol_stack[0] = NDPI_SERVICE_NETFLIX;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((flow->l4.tcp.http_stage == 0)
|
||||||
|
|| (flow->http.url && flow->http_detected)) {
|
||||||
|
/* Try matching subprotocols */
|
||||||
|
// ndpi_match_string_subprotocol(ndpi_struct, flow, (char*)packet->host_line.ptr, packet->host_line.len);
|
||||||
|
|
||||||
|
if(ndpi_struct->http_dissect_response) {
|
||||||
|
if(flow->http.url && flow->http_detected)
|
||||||
|
ndpi_match_string_subprotocol(ndpi_struct, flow, (char *)&flow->http.url[7], strlen((const char *)&flow->http.url[7]));
|
||||||
|
} else
|
||||||
|
ndpi_match_string_subprotocol(ndpi_struct, flow, (char *)flow->host_server_name, strlen((const char *)flow->host_server_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
NOTE
|
||||||
|
|
||||||
|
ndpi_parse_packet_line_info @ ndpi_main.c
|
||||||
|
is the code that parses the packet
|
||||||
|
*/
|
||||||
|
static void check_content_type_and_change_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
#ifdef NDPI_CONTENT_MPEG
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_AVI
|
||||||
|
#endif
|
||||||
|
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||||
|
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||||
|
|
||||||
|
u_int8_t a;
|
||||||
|
|
||||||
|
if(ndpi_struct->http_dissect_response) {
|
||||||
|
if((flow->http.url == NULL)
|
||||||
|
&& (packet->http_url_name.len > 0)
|
||||||
|
&& (packet->host_line.len > 0)) {
|
||||||
|
int len = packet->http_url_name.len + packet->host_line.len + 7 + 1; /* "http://" */
|
||||||
|
|
||||||
|
flow->http.url = ndpi_malloc(len);
|
||||||
|
if(flow->http.url) {
|
||||||
|
strncpy(flow->http.url, "http://", 7);
|
||||||
|
strncpy(&flow->http.url[7], (char*)packet->host_line.ptr, packet->host_line.len);
|
||||||
|
strncpy(&flow->http.url[7+packet->host_line.len], (char*)packet->http_url_name.ptr,
|
||||||
|
packet->http_url_name.len);
|
||||||
|
flow->http.url[len-1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flow->packet.http_method.len < 3)
|
||||||
|
flow->http.method = HTTP_METHOD_UNKNOWN;
|
||||||
|
else {
|
||||||
|
switch(flow->packet.http_method.ptr[0]) {
|
||||||
|
case 'O': flow->http.method = HTTP_METHOD_OPTIONS; break;
|
||||||
|
case 'G': flow->http.method = HTTP_METHOD_GET; break;
|
||||||
|
case 'H': flow->http.method = HTTP_METHOD_HEAD; break;
|
||||||
|
|
||||||
|
case 'P':
|
||||||
|
switch(flow->packet.http_method.ptr[1]) {
|
||||||
|
case 'O': flow->http.method = HTTP_METHOD_POST; break;
|
||||||
|
case 'U': flow->http.method = HTTP_METHOD_PUT; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'D': flow->http.method = HTTP_METHOD_DELETE; break;
|
||||||
|
case 'T': flow->http.method = HTTP_METHOD_TRACE; break;
|
||||||
|
case 'C': flow->http.method = HTTP_METHOD_CONNECT; break;
|
||||||
|
default:
|
||||||
|
flow->http.method = HTTP_METHOD_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((flow->http.content_type == NULL) && (packet->content_line.len > 0)) {
|
||||||
|
int len = packet->content_line.len + 1;
|
||||||
|
|
||||||
|
flow->http.content_type = ndpi_malloc(len);
|
||||||
|
if(flow->http.content_type) {
|
||||||
|
strncpy(flow->http.content_type, (char*)packet->content_line.ptr,
|
||||||
|
packet->content_line.len);
|
||||||
|
flow->http.content_type[packet->content_line.len] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packet->user_agent_line.ptr != NULL && packet->user_agent_line.len != 0) {
|
||||||
|
/* Format:
|
||||||
|
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) ....
|
||||||
|
*/
|
||||||
|
if(packet->user_agent_line.len > 7) {
|
||||||
|
char ua[256];
|
||||||
|
u_int mlen = ndpi_min(packet->user_agent_line.len, sizeof(ua)-1);
|
||||||
|
|
||||||
|
strncpy(ua, (const char *)packet->user_agent_line.ptr, mlen);
|
||||||
|
ua[mlen] = '\0';
|
||||||
|
|
||||||
|
if(strncmp(ua, "Mozilla", 7) == 0) {
|
||||||
|
char *parent = strchr(ua, '(');
|
||||||
|
|
||||||
|
if(parent) {
|
||||||
|
char *token, *end;
|
||||||
|
|
||||||
|
parent++;
|
||||||
|
end = strchr(parent, ')');
|
||||||
|
if(end) end[0] = '\0';
|
||||||
|
|
||||||
|
token = strsep(&parent, ";");
|
||||||
|
if(token) {
|
||||||
|
if((strcmp(token, "X11") == 0)
|
||||||
|
|| (strcmp(token, "compatible") == 0)
|
||||||
|
|| (strcmp(token, "Linux") == 0)
|
||||||
|
|| (strcmp(token, "Macintosh") == 0)
|
||||||
|
) {
|
||||||
|
token = strsep(&parent, ";");
|
||||||
|
if(token && (token[0] == ' ')) token++; /* Skip space */
|
||||||
|
|
||||||
|
if(token
|
||||||
|
&& ((strcmp(token, "U") == 0)
|
||||||
|
|| (strncmp(token, "MSIE", 4) == 0))) {
|
||||||
|
token = strsep(&parent, ";");
|
||||||
|
if(token && (token[0] == ' ')) token++; /* Skip space */
|
||||||
|
|
||||||
|
if(token && (strncmp(token, "Update", 6) == 0)) {
|
||||||
|
token = strsep(&parent, ";");
|
||||||
|
|
||||||
|
if(token && (token[0] == ' ')) token++; /* Skip space */
|
||||||
|
|
||||||
|
if(token && (strncmp(token, "AOL", 3) == 0)) {
|
||||||
|
token = strsep(&parent, ";");
|
||||||
|
|
||||||
|
if(token && (token[0] == ' ')) token++; /* Skip space */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(token)
|
||||||
|
setHttpUserAgent(flow, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "User Agent Type Line found %.*s\n",
|
||||||
|
packet->user_agent_line.len, packet->user_agent_line.ptr);
|
||||||
|
|
||||||
|
if((!ndpi_struct->http_dissect_response) || flow->http_detected)
|
||||||
|
ndpi_match_content_subprotocol(ndpi_struct, flow,
|
||||||
|
(char*)packet->user_agent_line.ptr,
|
||||||
|
packet->user_agent_line.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for host line */
|
||||||
|
if(packet->host_line.ptr != NULL) {
|
||||||
|
u_int len;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HOST Line found %.*s\n",
|
||||||
|
packet->host_line.len, packet->host_line.ptr);
|
||||||
|
|
||||||
|
if((!ndpi_struct->http_dissect_response) || flow->http_detected)
|
||||||
|
ndpi_match_content_subprotocol(ndpi_struct, flow,
|
||||||
|
(char*)packet->host_line.ptr,
|
||||||
|
packet->host_line.len);
|
||||||
|
|
||||||
|
/* Copy result for nDPI apps */
|
||||||
|
len = ndpi_min(packet->host_line.len, sizeof(flow->host_server_name)-1);
|
||||||
|
strncpy((char*)flow->host_server_name, (char*)packet->host_line.ptr, len);
|
||||||
|
flow->host_server_name[len] = '\0', flow->server_id = flow->dst;
|
||||||
|
|
||||||
|
len = ndpi_min(packet->forwarded_line.len, sizeof(flow->nat_ip)-1);
|
||||||
|
strncpy((char*)flow->nat_ip, (char*)packet->forwarded_line.ptr, len);
|
||||||
|
flow->nat_ip[len] = '\0';
|
||||||
|
|
||||||
|
if(!ndpi_struct->http_dissect_response)
|
||||||
|
parseHttpSubprotocol(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if((flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)
|
||||||
|
&& ((!ndpi_struct->http_dissect_response) || flow->http_detected))
|
||||||
|
ndpi_match_string_subprotocol(ndpi_struct, flow,
|
||||||
|
(char *)flow->host_server_name,
|
||||||
|
strlen((const char *)flow->host_server_name));
|
||||||
|
|
||||||
|
if((flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN)
|
||||||
|
&& ((!ndpi_struct->http_dissect_response) || flow->http_detected)
|
||||||
|
&& (packet->http_origin.len > 0))
|
||||||
|
ndpi_match_string_subprotocol(ndpi_struct, flow,
|
||||||
|
(char *)packet->http_origin.ptr,
|
||||||
|
packet->http_origin.len);
|
||||||
|
|
||||||
|
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_HTTP) {
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, packet->detected_protocol_stack[0]);
|
||||||
|
return; /* We have identified a sub-protocol so we're done */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ndpi_struct->http_dissect_response && flow->http_detected)
|
||||||
|
parseHttpSubprotocol(ndpi_struct, flow);
|
||||||
|
|
||||||
|
/* check for accept line */
|
||||||
|
if(packet->accept_line.ptr != NULL) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "Accept Line found %.*s\n",
|
||||||
|
packet->accept_line.len, packet->accept_line.ptr);
|
||||||
|
#ifdef NDPI_PROTOCOL_RTSP
|
||||||
|
if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(ndpi_struct->detection_bitmask, NDPI_PROTOCOL_RTSP) != 0) {
|
||||||
|
rtsp_parse_packet_acceptline(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search for line startin with "Icy-MetaData" */
|
||||||
|
#ifdef NDPI_CONTENT_MPEG
|
||||||
|
for (a = 0; a < packet->parsed_lines; a++) {
|
||||||
|
if(packet->line[a].len > 11 && memcmp(packet->line[a].ptr, "Icy-MetaData", 12) == 0) {
|
||||||
|
NDPI_LOG(NDPI_CONTENT_MPEG, ndpi_struct, NDPI_LOG_DEBUG, "MPEG: Icy-MetaData found.\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_CONTENT_MPEG);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef NDPI_CONTENT_AVI
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(packet->content_line.ptr != NULL && packet->content_line.len != 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "Content Type Line found %.*s\n",
|
||||||
|
packet->content_line.len, packet->content_line.ptr);
|
||||||
|
|
||||||
|
if((!ndpi_struct->http_dissect_response) || flow->http_detected)
|
||||||
|
ndpi_match_content_subprotocol(ndpi_struct, flow, (char*)packet->content_line.ptr, packet->content_line.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check user agent here too */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void check_http_payload(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "called check_http_payload.\n");
|
||||||
|
|
||||||
|
#ifdef NDPI_CONTENT_FLASH
|
||||||
|
if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(ndpi_struct->detection_bitmask, NDPI_CONTENT_FLASH) != 0)
|
||||||
|
flash_check_http_payload(ndpi_struct, flow);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_AVI
|
||||||
|
if(NDPI_COMPARE_PROTOCOL_TO_BITMASK(ndpi_struct->detection_bitmask, NDPI_CONTENT_AVI) != 0)
|
||||||
|
avi_check_http_payload(ndpi_struct, flow);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_TEAMVIEWER
|
||||||
|
teamviewer_check_http_payload(ndpi_struct, flow);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this functions checks whether the packet begins with a valid http request
|
||||||
|
* @param ndpi_struct
|
||||||
|
* @returnvalue 0 if no valid request has been found
|
||||||
|
* @returnvalue >0 indicates start of filename but not necessarily in packet limit
|
||||||
|
*/
|
||||||
|
static u_int16_t http_request_url_offset(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "====>>>> HTTP: %c%c%c%c [len: %u]\n",
|
||||||
|
packet->payload[0], packet->payload[1], packet->payload[2], packet->payload[3],
|
||||||
|
packet->payload_packet_len);
|
||||||
|
|
||||||
|
/* FIRST PAYLOAD PACKET FROM CLIENT */
|
||||||
|
/* check if the packet starts with POST or GET */
|
||||||
|
if(packet->payload_packet_len >= 4 && memcmp(packet->payload, "GET ", 4) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: GET FOUND\n");
|
||||||
|
return 4;
|
||||||
|
} else if(packet->payload_packet_len >= 5 && memcmp(packet->payload, "POST ", 5) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: POST FOUND\n");
|
||||||
|
return 5;
|
||||||
|
} else if(packet->payload_packet_len >= 8 && memcmp(packet->payload, "OPTIONS ", 8) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: OPTIONS FOUND\n");
|
||||||
|
return 8;
|
||||||
|
} else if(packet->payload_packet_len >= 5 && memcmp(packet->payload, "HEAD ", 5) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: HEAD FOUND\n");
|
||||||
|
return 5;
|
||||||
|
} else if(packet->payload_packet_len >= 4 && memcmp(packet->payload, "PUT ", 4) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: PUT FOUND\n");
|
||||||
|
return 4;
|
||||||
|
} else if(packet->payload_packet_len >= 7 && memcmp(packet->payload, "DELETE ", 7) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: DELETE FOUND\n");
|
||||||
|
return 7;
|
||||||
|
} else if(packet->payload_packet_len >= 8 && memcmp(packet->payload, "CONNECT ", 8) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: CONNECT FOUND\n");
|
||||||
|
return 8;
|
||||||
|
} else if(packet->payload_packet_len >= 9 && memcmp(packet->payload, "PROPFIND ", 9) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: PROFIND FOUND\n");
|
||||||
|
return 9;
|
||||||
|
} else if(packet->payload_packet_len >= 7 && memcmp(packet->payload, "REPORT ", 7) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: REPORT FOUND\n");
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void http_bitmask_exclude(struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP);
|
||||||
|
#ifdef NDPI_PROTOCOL_WINDOWS_UPDATE
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_WINDOWS_UPDATE);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_MPEG
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_CONTENT_MPEG);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_QUICKTIME
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_CONTENT_QUICKTIME);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_WINDOWSMEDIA
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_CONTENT_WINDOWSMEDIA);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_REALMEDIA
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_CONTENT_REALMEDIA);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_AVI
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_CONTENT_AVI);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_CONTENT_OGG
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_CONTENT_OGG);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_MOVE
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MOVE);
|
||||||
|
#endif
|
||||||
|
#ifdef NDPI_PROTOCOL_XBOX
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_XBOX);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void _org_ndpi_search_http_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;
|
||||||
|
|
||||||
|
u_int16_t filename_start;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "search http\n");
|
||||||
|
|
||||||
|
/* set client-server_direction */
|
||||||
|
if(flow->l4.tcp.http_setup_dir == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "initializes http to stage: 1 \n");
|
||||||
|
flow->l4.tcp.http_setup_dir = 1 + packet->packet_direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(NDPI_COMPARE_PROTOCOL_TO_BITMASK
|
||||||
|
(ndpi_struct->generic_http_packet_bitmask, packet->detected_protocol_stack[0]) != 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"protocol might be detected earlier as http jump to payload type detection\n");
|
||||||
|
goto http_parse_detection;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flow->l4.tcp.http_setup_dir == 1 + packet->packet_direction) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "http stage: 1\n");
|
||||||
|
|
||||||
|
if(flow->l4.tcp.http_wait_for_retransmission) {
|
||||||
|
if(!packet->tcp_retransmission) {
|
||||||
|
if(flow->packet_counter <= 5) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "still waiting for retransmission\n");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "retransmission not found, exclude\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flow->l4.tcp.http_stage == 0) {
|
||||||
|
filename_start = http_request_url_offset(ndpi_struct, flow);
|
||||||
|
if(filename_start == 0) {
|
||||||
|
if(packet->payload_packet_len >= 7 && memcmp(packet->payload, "HTTP/1.", 7) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP response found (truncated flow ?)\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "filename not found, exclude\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// parse packet
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if(packet->parsed_lines <= 1) {
|
||||||
|
/* parse one more packet .. */
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "just one line, search next packet\n");
|
||||||
|
|
||||||
|
packet->http_method.ptr = packet->line[0].ptr;
|
||||||
|
packet->http_method.len = filename_start - 1;
|
||||||
|
flow->l4.tcp.http_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// parsed_lines > 1 here
|
||||||
|
if(packet->line[0].len >= (9 + filename_start)
|
||||||
|
&& memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) == 0) {
|
||||||
|
u_int16_t proto_id;
|
||||||
|
|
||||||
|
packet->http_url_name.ptr = &packet->payload[filename_start];
|
||||||
|
packet->http_url_name.len = packet->line[0].len - (filename_start + 9);
|
||||||
|
|
||||||
|
packet->http_method.ptr = packet->line[0].ptr;
|
||||||
|
packet->http_method.len = filename_start - 1;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "http structure detected, adding\n");
|
||||||
|
|
||||||
|
if(filename_start == 8 && (memcmp(packet->payload, "CONNECT ", 8) == 0)) /* nathan@getoffmalawn.com */
|
||||||
|
proto_id = NDPI_PROTOCOL_HTTP_CONNECT;
|
||||||
|
else {
|
||||||
|
if((packet->http_url_name.len > 7) && (!strncmp((const char*)packet->http_url_name.ptr, "http://", 7)))
|
||||||
|
proto_id = NDPI_PROTOCOL_HTTP_PROXY;
|
||||||
|
else {
|
||||||
|
proto_id = NDPI_PROTOCOL_HTTP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, proto_id);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
/* HTTP found, look for host... */
|
||||||
|
if(packet->host_line.ptr != NULL) {
|
||||||
|
/* aaahh, skip this direction and wait for a server reply here */
|
||||||
|
flow->l4.tcp.http_stage = 2;
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP START HOST found\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP START HOST found\n");
|
||||||
|
|
||||||
|
/* host not found, check in next packet after */
|
||||||
|
flow->l4.tcp.http_stage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if(flow->l4.tcp.http_stage == 1) {
|
||||||
|
/* SECOND PAYLOAD TRAFFIC FROM CLIENT, FIRST PACKET MIGHT HAVE BEEN HTTP... */
|
||||||
|
/* UNKNOWN TRAFFIC, HERE FOR HTTP again.. */
|
||||||
|
// parse packet
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if(packet->parsed_lines <= 1) {
|
||||||
|
/* wait some packets in case request is split over more than 2 packets */
|
||||||
|
if(flow->packet_counter < 5) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"line still not finished, search next packet\n");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
/* stop parsing here */
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP: PACKET DOES NOT HAVE A LINE STRUCTURE\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// http://www.slideshare.net/DSPIP/rtsp-analysis-wireshark
|
||||||
|
if(packet->line[0].len >= 9 && memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) == 0) {
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP START HTTP found in 2. packet, check host here...\n");
|
||||||
|
/* HTTP found, look for host... */
|
||||||
|
flow->l4.tcp.http_stage = 2;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* We have received a response for a previously identified partial HTTP request */
|
||||||
|
|
||||||
|
if((packet->parsed_lines == 1) && (packet->packet_direction == 1 /* server -> client */)) {
|
||||||
|
/*
|
||||||
|
In apache if you do "GET /\n\n" the response comes without any header so we can assume that
|
||||||
|
this can be the case
|
||||||
|
*/
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: REQUEST NOT HTTP CONFORM\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
|
||||||
|
http_parse_detection:
|
||||||
|
if(flow->l4.tcp.http_setup_dir == 1 + packet->packet_direction) {
|
||||||
|
/* we have something like http here, so check for host and content type if possible */
|
||||||
|
if(flow->l4.tcp.http_stage == 0 || flow->l4.tcp.http_stage == 3) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP RUN MAYBE NEXT GET/POST...\n");
|
||||||
|
// parse packet
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
/* check for url here */
|
||||||
|
filename_start = http_request_url_offset(ndpi_struct, flow);
|
||||||
|
if(filename_start != 0 && packet->parsed_lines > 1 && packet->line[0].len >= (9 + filename_start)
|
||||||
|
&& memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) == 0) {
|
||||||
|
packet->http_url_name.ptr = &packet->payload[filename_start];
|
||||||
|
packet->http_url_name.len = packet->line[0].len - (filename_start + 9);
|
||||||
|
|
||||||
|
packet->http_method.ptr = packet->line[0].ptr;
|
||||||
|
packet->http_method.len = filename_start - 1;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "next http action, "
|
||||||
|
"resetting to http and search for other protocols later.\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
}
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
/* HTTP found, look for host... */
|
||||||
|
if(packet->host_line.ptr != NULL) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP RUN MAYBE NEXT HOST found, skipping all packets from this direction\n");
|
||||||
|
/* aaahh, skip this direction and wait for a server reply here */
|
||||||
|
flow->l4.tcp.http_stage = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP RUN MAYBE NEXT HOST NOT found, scanning one more packet from this direction\n");
|
||||||
|
flow->l4.tcp.http_stage = 1;
|
||||||
|
} else if(flow->l4.tcp.http_stage == 1) {
|
||||||
|
// parse packet and maybe find a packet info with host ptr,...
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP RUN second packet scanned\n");
|
||||||
|
/* HTTP found, look for host... */
|
||||||
|
flow->l4.tcp.http_stage = 2;
|
||||||
|
}
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP skipping client packets after second packet\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* server response */
|
||||||
|
if(flow->l4.tcp.http_stage > 0) {
|
||||||
|
/* first packet from server direction, might have a content line */
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if(packet->empty_line_position_set != 0 || flow->l4.tcp.http_empty_line_seen == 1) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "empty line. check_http_payload.\n");
|
||||||
|
check_http_payload(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flow->l4.tcp.http_stage == 2) {
|
||||||
|
flow->l4.tcp.http_stage = 3;
|
||||||
|
} else {
|
||||||
|
flow->l4.tcp.http_stage = 0;
|
||||||
|
}
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP response first or second packet scanned,new stage is: %u\n", flow->l4.tcp.http_stage);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP response next packet skipped\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************************/
|
||||||
|
|
||||||
|
static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
u_int16_t filename_start;
|
||||||
|
|
||||||
|
/* Check if we so far detected the protocol in the request or not. */
|
||||||
|
if (flow->l4.tcp.http_stage == 0) {
|
||||||
|
flow->http_detected = 0;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP stage %d: \n",
|
||||||
|
flow->l4.tcp.http_stage);
|
||||||
|
|
||||||
|
filename_start = http_request_url_offset(ndpi_struct, flow);
|
||||||
|
|
||||||
|
|
||||||
|
if (filename_start == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"Filename HTTP not found, we look for possible truncate flow...\n");
|
||||||
|
if (packet->payload_packet_len >= 7 && memcmp(packet->payload, "HTTP/1.", 7) == 0) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP response found (truncated flow ?)\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "Exclude HTTP\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"Filename HTTP found: %d, we look for line info..\n", filename_start);
|
||||||
|
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if (packet->parsed_lines <= 1) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"Found just one line, we will look further for the next packet...\n");
|
||||||
|
|
||||||
|
packet->http_method.ptr = packet->line[0].ptr;
|
||||||
|
packet->http_method.len = filename_start - 1;
|
||||||
|
|
||||||
|
/* Encode the direction of the packet in the stage, so we will know when we need to look for the response packet. */
|
||||||
|
flow->l4.tcp.http_stage = packet->packet_direction + 1; // packet_direction 0: stage 1, packet_direction 1: stage 2
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"Found more than one line, we look further for the next packet...\n");
|
||||||
|
|
||||||
|
if(packet->line[0].len >= (9 + filename_start)
|
||||||
|
&& memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) == 0) {
|
||||||
|
|
||||||
|
packet->http_url_name.ptr = &packet->payload[filename_start];
|
||||||
|
packet->http_url_name.len = packet->line[0].len - (filename_start + 9);
|
||||||
|
|
||||||
|
packet->http_method.ptr = packet->line[0].ptr;
|
||||||
|
packet->http_method.len = filename_start - 1;
|
||||||
|
|
||||||
|
if((packet->http_url_name.len > 7)
|
||||||
|
&& (!strncmp((const char*) packet->http_url_name.ptr, "http://", 7))) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP_PROXY Found.\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_PROXY);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filename_start == 8 && (memcmp(packet->payload, "CONNECT ", 8) == 0)) /* nathan@getoffmalawn.com */
|
||||||
|
{
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP_CONNECT Found.\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_CONNECT);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP START Found, we will look for sub-protocols (content and host)...\n");
|
||||||
|
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if(packet->host_line.ptr != NULL) {
|
||||||
|
/*
|
||||||
|
nDPI is pretty scrupoulous about HTTP so it waits until the
|
||||||
|
HTTP response is received just to check that it conforms
|
||||||
|
with the HTTP specs. However this might be a waste of time as
|
||||||
|
in 99.99% of the cases is like that.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(!ndpi_struct->http_dissect_response) {
|
||||||
|
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) /* No subprotocol found */
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
} else {
|
||||||
|
flow->http_detected = 1;
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP START Found, we will look further for the response...\n");
|
||||||
|
flow->l4.tcp.http_stage = packet->packet_direction + 1; // packet_direction 0: stage 1, packet_direction 1: stage 2
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP: REQUEST NOT HTTP CONFORM\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
} else if ((flow->l4.tcp.http_stage == 1) || (flow->l4.tcp.http_stage == 2)) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP stage %u: \n",
|
||||||
|
flow->l4.tcp.http_stage);
|
||||||
|
|
||||||
|
/* At first check, if this is for sure a response packet (in another direction. If not, if http is detected do nothing now and return,
|
||||||
|
* otherwise check the second packet for the http request . */
|
||||||
|
if ((flow->l4.tcp.http_stage - packet->packet_direction) == 1) {
|
||||||
|
|
||||||
|
if (flow->http_detected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
" SECOND PAYLOAD TRAFFIC FROM CLIENT, FIRST PACKET MIGHT HAVE BEEN HTTP...UNKNOWN TRAFFIC, HERE FOR HTTP again.. \n");
|
||||||
|
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if (packet->parsed_lines <= 1) {
|
||||||
|
/* wait some packets in case request is split over more than 2 packets */
|
||||||
|
if (flow->packet_counter < 5) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"line still not finished, search next packet\n");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
/* stop parsing here */
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP: PACKET DOES NOT HAVE A LINE STRUCTURE\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// http://www.slideshare.net/DSPIP/rtsp-analysis-wireshark
|
||||||
|
if (packet->line[0].len >= 9
|
||||||
|
&& memcmp(&packet->line[0].ptr[packet->line[0].len - 9], " HTTP/1.", 8) == 0) {
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "Found HTTP.\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
"HTTP START Found in 2. packet, we will look further for the response....\n");
|
||||||
|
flow->http_detected = 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is a packet in another direction. Check if we find the proper response. */
|
||||||
|
/* We have received a response for a previously identified partial HTTP request */
|
||||||
|
|
||||||
|
if ((packet->parsed_lines == 1) && (packet->packet_direction == 1 /* server -> client */)) {
|
||||||
|
/*
|
||||||
|
In apache if you do "GET /\n\n" the response comes without any header so we can assume that
|
||||||
|
this can be the case
|
||||||
|
*/
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "Found HTTP. (apache)\n");
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we already detected the http request, we can add the connection and then check for the sub-protocol*/
|
||||||
|
if (flow->http_detected)
|
||||||
|
ndpi_int_http_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP);
|
||||||
|
|
||||||
|
/* Parse packet line and we look for the subprotocols */
|
||||||
|
ndpi_parse_packet_line_info(ndpi_struct, flow);
|
||||||
|
check_content_type_and_change_protocol(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if (packet->empty_line_position_set != 0 || flow->l4.tcp.http_empty_line_seen == 1) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "empty line. check_http_payload.\n");
|
||||||
|
check_http_payload(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
flow->l4.tcp.http_stage = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_http_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
/* Break after 20 packets. */
|
||||||
|
if (flow->packet_counter > 20) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "Exclude HTTP.\n");
|
||||||
|
http_bitmask_exclude(flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(packet->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP, ndpi_struct, NDPI_LOG_DEBUG, "HTTP detection...\n");
|
||||||
|
ndpi_check_http_tcp(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ********************************* */
|
||||||
|
|
||||||
|
ndpi_http_method ndpi_get_http_method(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
if(!flow)
|
||||||
|
return(HTTP_METHOD_UNKNOWN);
|
||||||
|
else
|
||||||
|
return(flow->http.method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ********************************* */
|
||||||
|
|
||||||
|
char* ndpi_get_http_url(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
if((!flow) || (!flow->http.url))
|
||||||
|
return("");
|
||||||
|
else
|
||||||
|
return(flow->http.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ********************************* */
|
||||||
|
|
||||||
|
char* ndpi_get_http_content_type(struct ndpi_detection_module_struct *ndpi_mod,
|
||||||
|
struct ndpi_flow_struct *flow) {
|
||||||
|
if((!flow) || (!flow->http.content_type))
|
||||||
|
return("");
|
||||||
|
else
|
||||||
|
return(flow->http.content_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* http_activesync.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_HTTP_APPLICATION_ACTIVESYNC
|
||||||
|
static void ndpi_int_activesync_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, NDPI_CORRELATED_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_activesync(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
|
if (packet->tcp != NULL) {
|
||||||
|
|
||||||
|
if (packet->payload_packet_len > 150
|
||||||
|
&& ((memcmp(packet->payload, "OPTIONS /Microsoft-Server-ActiveSync?", 37) == 0)
|
||||||
|
|| (memcmp(packet->payload, "POST /Microsoft-Server-ActiveSync?", 34) == 0))) {
|
||||||
|
ndpi_int_activesync_add_connection(ndpi_struct, flow);
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, ndpi_struct, NDPI_LOG_DEBUG,
|
||||||
|
" flow marked as ActiveSync \n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC, ndpi_struct, NDPI_LOG_DEBUG, "exclude activesync\n");
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_HTTP_APPLICATION_ACTIVESYNC);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* iax.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_IAX
|
||||||
|
|
||||||
|
#define NDPI_IAX_MAX_INFORMATION_ELEMENTS 15
|
||||||
|
|
||||||
|
static void ndpi_int_iax_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
ndpi_int_add_connection(ndpi_struct, flow, NDPI_PROTOCOL_IAX, NDPI_REAL_PROTOCOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ndpi_search_setup_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
u_int8_t i;
|
||||||
|
u_int16_t packet_len;
|
||||||
|
|
||||||
|
if ( /* 1. iax is udp based, port 4569 */
|
||||||
|
(packet->udp->source == htons(4569) || packet->udp->dest == htons(4569))
|
||||||
|
/* check for iax new packet */
|
||||||
|
&& packet->payload_packet_len >= 12
|
||||||
|
/* check for dst call id == 0, do not check for highest bit (packet retransmission) */
|
||||||
|
// && (ntohs(get_u_int16_t(packet->payload, 2)) & 0x7FFF) == 0
|
||||||
|
/* check full IAX packet */
|
||||||
|
&& (packet->payload[0] & 0x80) != 0
|
||||||
|
/* outbound seq == 0 */
|
||||||
|
&& packet->payload[8] == 0
|
||||||
|
/* inbound seq == 0 || 1 */
|
||||||
|
&& (packet->payload[9] == 0 || packet->payload[9] == 0x01)
|
||||||
|
/* */
|
||||||
|
&& packet->payload[10] == 0x06
|
||||||
|
/* IAX type: 0-15 */
|
||||||
|
&& packet->payload[11] <= 15) {
|
||||||
|
|
||||||
|
if (packet->payload_packet_len == 12) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_IAX, ndpi_struct, NDPI_LOG_DEBUG, "found IAX.\n");
|
||||||
|
ndpi_int_iax_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
packet_len = 12;
|
||||||
|
for (i = 0; i < NDPI_IAX_MAX_INFORMATION_ELEMENTS; i++) {
|
||||||
|
packet_len = packet_len + 2 + packet->payload[packet_len + 1];
|
||||||
|
if (packet_len == packet->payload_packet_len) {
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_IAX, ndpi_struct, NDPI_LOG_DEBUG, "found IAX.\n");
|
||||||
|
ndpi_int_iax_add_connection(ndpi_struct, flow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (packet_len > packet->payload_packet_len) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_IAX);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ndpi_search_iax(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
|
||||||
|
{
|
||||||
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
// struct ndpi_flow_struct *flow=ndpi_struct->flow;
|
||||||
|
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||||
|
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||||
|
|
||||||
|
if(packet->udp
|
||||||
|
&& (packet->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN))
|
||||||
|
ndpi_search_setup_iax(ndpi_struct, flow);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user