]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 years agosuricatasc: don't use find -delete 3175/head
Jason Ish [Thu, 18 Jan 2018 12:42:19 +0000 (06:42 -0600)] 
suricatasc: don't use find -delete

For when -delete isn't supported by find. Instead use
-print0 with xargs -0.

7 years agodoc: document file-store v2
Jason Ish [Wed, 17 Jan 2018 13:51:38 +0000 (07:51 -0600)] 
doc: document file-store v2

7 years agofilestore: only allow one filestore to be enabled
Jason Ish [Fri, 12 Jan 2018 20:46:31 +0000 (14:46 -0600)] 
filestore: only allow one filestore to be enabled

There is probably not too much bad about enabling both, but
open file counts can get messy with both enabled. And v1
should be schedule for deprecation soon enough.

7 years agofilestore (old): register global stat in init func
Jason Ish [Fri, 12 Jan 2018 20:43:01 +0000 (14:43 -0600)] 
filestore (old): register global stat in init func

This doesn't need to be registered from suricata.c. And moving
it to the init function makes sure its only registered if
the logger is actually enabled.

7 years agofilestore2: warn once for file errors
Jason Ish [Fri, 12 Jan 2018 19:35:51 +0000 (13:35 -0600)] 
filestore2: warn once for file errors

Track each type of error warning and only log it once. Also create
a new stat, file_store.fs_errors to count each file system type
error (open, rename, unlink).

Also remove exit stats, they are of limited value.

7 years agoutil-error: define SC_ERR_MAX
Jason Ish [Fri, 12 Jan 2018 18:56:42 +0000 (12:56 -0600)] 
util-error: define SC_ERR_MAX

7 years agosuricatactl: a new python script for misc. tasks
Jason Ish [Tue, 9 Jan 2018 13:51:26 +0000 (07:51 -0600)] 
suricatactl: a new python script for misc. tasks

Use a new directory, Python to host the Suricata python modules.
One entry point is suricatactl, a control script for
miscalleneous tasks. Currently onl filestore pruning
is implemented.

7 years agofilestore v2: use fileinfo records as metadata
Jason Ish [Mon, 8 Jan 2018 20:09:01 +0000 (14:09 -0600)] 
filestore v2: use fileinfo records as metadata

As fileinfo records are logged to the main eve log, disable
metadata by default. But when enabled, just use the fileinfo
record.

Metadata is stored in a file named:
  <sha256>.<seconds>.<file_id>.json

where the sha256 is the same as the file logged, the seconds
is the unix timestamp in seconds for the fileinfo record,
and the file_id is an atomically incremented integer per
Suricata instance.

This should allow for each occurrence of the same file to have
its own metadata file. But a collision is expected when running
Suricata repeatedly over the same pcap, as that would be the
exact same occurrence of a file.

7 years agofile extract: force sha256 even if truncated
Jason Ish [Mon, 8 Jan 2018 19:39:56 +0000 (13:39 -0600)] 
file extract: force sha256 even if truncated

Even if a file is truncated, force the SHA256 if force sha256
is set to yes.

The new file store requires the sha256 regardless of the file
state if it is to be logged, as the filename is based on the
sha256.

7 years agofilestore v2 - initial version
Jason Ish [Thu, 4 Jan 2018 20:28:29 +0000 (14:28 -0600)] 
filestore v2 - initial version

Filestore v2 is starts as a copy of log-filestore with the
following changes.

- NSS is required as file names as based on the SHA256.
- Work/tmp files are stored in a temp. directory, then
  moved into a directory tree where the directory names
  are the first 2 characters of the hex SHA256.
- Removes the need for a waldo file or pid in the filenames.

7 years agoconfigure: check for utime.h and utime()
Jason Ish [Mon, 8 Jan 2018 21:11:54 +0000 (15:11 -0600)] 
configure: check for utime.h and utime()

7 years agooutput-json-file: let caller decide if file is stored
Jason Ish [Thu, 18 Jan 2018 12:17:00 +0000 (06:17 -0600)] 
output-json-file: let caller decide if file is stored

Mainly for the filestore module, which may have its own
knowledge of the file being stored before others.

7 years agoeve/fileinfo: split record creation from writing
Jason Ish [Mon, 8 Jan 2018 19:41:34 +0000 (13:41 -0600)] 
eve/fileinfo: split record creation from writing

Split the building of the fileinfo record from the writing
of the record so the building can be called from other code.
Specifically the new filestore output which uses fileinfo
records as the metadata.

7 years agoutil-error: new error: SC_ERR_CREATE_DIRECTORY
Jason Ish [Thu, 4 Jan 2018 17:14:42 +0000 (11:14 -0600)] 
util-error: new error: SC_ERR_CREATE_DIRECTORY

For logging directory create errors.

7 years agoSCPathExists - function to see if a path exists
Jason Ish [Thu, 4 Jan 2018 17:11:06 +0000 (11:11 -0600)] 
SCPathExists - function to see if a path exists

Returns true if path exists, otherwise false.

7 years agocreate directory: final arg to control full path or prefix
Jason Ish [Thu, 4 Jan 2018 17:07:50 +0000 (11:07 -0600)] 
create directory: final arg to control full path or prefix

Give SCCreateDirectoryTree a new argument, final. If true the
full path will be created as a directory. If false, the last
component will not be created as a directory (current
behaviour).

7 years agocreate directory: fix strlcpy usage
Jason Ish [Thu, 4 Jan 2018 17:04:52 +0000 (11:04 -0600)] 
create directory: fix strlcpy usage

The final character was being cut off.

7 years agoutil: move SCCreateDirectoryTree to util-path
Jason Ish [Thu, 4 Jan 2018 16:06:31 +0000 (10:06 -0600)] 
util: move SCCreateDirectoryTree to util-path

Renames SCLogCreateDirectoryTree to SCCreateDirectoryTree
and move into a util module for re-use.

Also moves SCMkDir from suricata-common.h to the more
appropriately names util-path.h.

I would have prefered to use util-file for file related options
but that is already used by file store utilities. util-path
is close enough for file related operations.

7 years agooutput: introduce init return type
Jason Ish [Thu, 11 Jan 2018 22:34:33 +0000 (16:34 -0600)] 
output: introduce init return type

The new OutputInitResult is a struct return type that allows
logger init functions to return a NULL context without
raising error.

Instead of returning NULL to signal error, the "ok" field will
be set to false. If ok, but the ctx is NULL, then silently
move on to the next logger.

Use case: multiple versions of a specific logger, and one
implementation decides the configuration is not for that
implemenation. It can return NULL, ok.

7 years agothresholds: fix issues with host based thresholds 3168/head
Victor Julien [Tue, 16 Jan 2018 10:54:39 +0000 (11:54 +0100)] 
thresholds: fix issues with host based thresholds

The flow manager thread (that also runs the host cleanup code) would
sometimes free a host before it's thresholds are timed out. This would
lead to misdetection or too many alerts.

This was mostly (only?) visible on slower systems. And was caused by a
mismatch between time concepts of the async flow manager thread and the
packet threads, resulting in the flow manager using a timestamp that
was before the threshold entry creation ts. This would lead to an
integer underflow in the timeout check, leading to a incorrect conclusion
that the threshold entry was timed out.

To address this,  check if the 'check' timestamp is not before the creation
timestamp.

7 years agostream/midstream: be more liberal with window
Victor Julien [Wed, 17 Jan 2018 12:04:54 +0000 (13:04 +0100)] 
stream/midstream: be more liberal with window

Use the wscale setting when updating the window, even if it's very
high.

7 years agothreads: don't crash in slow shutdown 3157/head
Victor Julien [Mon, 15 Jan 2018 17:16:47 +0000 (18:16 +0100)] 
threads: don't crash in slow shutdown

If TmThreadDrainPacketThreads would take more than 60 seconds, the wait
loop that follows it would reach 'timeout' condition immediately. This
would lead to a null ptr deref of 'tv'.

Fix by not counting the TmThreadDrainPacketThreads and also not doing
the null ptr deref in any case.

7 years agotime: Force init cached_minute_start array
Maurizio Abba [Thu, 11 Jan 2018 14:34:37 +0000 (14:34 +0000)] 
time: Force init cached_minute_start array

In offline mode, if the starting timestamp is 0 suricata will never
initialize cached_minute_start array. This cause the timestamp to be
ignored when needed (e.g., in fast.log).

This commit will force the initialization of this array.

7 years agoNTP: ensure parser name is not freed after registration
Pierre Chifflier [Sat, 13 Jan 2018 15:09:26 +0000 (16:09 +0100)] 
NTP: ensure parser name is not freed after registration

7 years agoutil-time: Add function to convert timespec to epoch millis
Danny Browning [Sat, 13 Jan 2018 14:45:25 +0000 (07:45 -0700)] 
util-time: Add function to convert timespec to epoch millis

7 years agodestate: test cleanups
Victor Julien [Wed, 10 Jan 2018 15:24:08 +0000 (16:24 +0100)] 
destate: test cleanups

7 years agohttp: clean up & improve unittests
Victor Julien [Wed, 10 Jan 2018 11:59:52 +0000 (12:59 +0100)] 
http: clean up & improve unittests

7 years agoconf: add function to get child with default
Eric Leblond [Sat, 6 Jan 2018 09:01:55 +0000 (10:01 +0100)] 
conf: add function to get child with default

7 years agoaf-packet: synchronize flags sizes
Eric Leblond [Fri, 5 Jan 2018 21:32:34 +0000 (22:32 +0100)] 
af-packet: synchronize flags sizes

They are passed from config to threads so they need to be of the
same size.

7 years agoprint: Escape backslash in PrintRawUriFp
Maurizio Abba [Thu, 11 Jan 2018 15:21:06 +0000 (15:21 +0000)] 
print: Escape backslash in PrintRawUriFp

PrintRawUriFp does not properly escape backslash. This causes confusion
between a \ character and an hex-encoded character. PrintRawUriBuffer,
instead, correctly does backslash-encoding.
Adding proper escaping of backslash to PrintRawUriFp.

7 years agoRust: remove deprecated functions LoggerFlags::get_logged/set_logged 3140/head
Pierre Chifflier [Thu, 11 Jan 2018 17:54:28 +0000 (18:54 +0100)] 
Rust: remove deprecated functions LoggerFlags::get_logged/set_logged

7 years agoNTP: update logger to use new API
Pierre Chifflier [Thu, 11 Jan 2018 07:17:23 +0000 (08:17 +0100)] 
NTP: update logger to use new API

7 years agooutput: add missing dnp3 profiling labels 3135/head
Victor Julien [Mon, 8 Jan 2018 19:37:28 +0000 (20:37 +0100)] 
output: add missing dnp3 profiling labels

7 years agologging: unique id's per log direction
Victor Julien [Mon, 8 Jan 2018 18:46:06 +0000 (19:46 +0100)] 
logging: unique id's per log direction

For loggers that register once per direction, use unique id's per
direction.

Reshuffle id's to keep tx log id's low so we can use u32 for tracking
logged loggers.

7 years agoapp-layer: use logger bits to avoid looping
Victor Julien [Thu, 5 Oct 2017 22:20:44 +0000 (00:20 +0200)] 
app-layer: use logger bits to avoid looping

Avoid looping in transaction output.

Update app-layer API to store the bits in one step
and retrieve the bits in a single step as well.

Update users of the API.

7 years agoapp-layer: register per proto logger bits
Victor Julien [Thu, 5 Oct 2017 19:07:41 +0000 (21:07 +0200)] 
app-layer: register per proto logger bits

Create a bitmap of the loggers per protocol. This is done at runtime
based on the loggers that are enabled. Take the logger_id for each
logger and store it as a bitmap in the app-layer protcol storage.

Goal is to be able to use it as an expectation later.

7 years agodetect: put inspect code for MATCH-list into func 3133/head
Victor Julien [Sat, 7 Oct 2017 13:01:27 +0000 (15:01 +0200)] 
detect: put inspect code for MATCH-list into func

Introduce DetectRunInspectRulePacketMatches to inspect the signatures
match list.

7 years agodetect: move detect cleanup into util func
Victor Julien [Sat, 7 Oct 2017 10:17:39 +0000 (12:17 +0200)] 
detect: move detect cleanup into util func

7 years agodetect: move packet hdr inspect into util func
Victor Julien [Sat, 7 Oct 2017 10:15:03 +0000 (12:15 +0200)] 
detect: move packet hdr inspect into util func

7 years agodetect-ftpdata: register keyword
Eric Leblond [Fri, 5 Jan 2018 15:58:18 +0000 (16:58 +0100)] 
detect-ftpdata: register keyword

Keyword registration was missing so the keyword was not existing.

7 years agorunmodes: fix single runmode bug with pcap
Maurizio Abba [Fri, 5 Jan 2018 18:03:42 +0000 (18:03 +0000)] 
runmodes: fix single runmode bug with pcap

Fix crash for suricata running with pcap option and single runmode.

Ticket: https://redmine.openinfosecfoundation.org/issues/2403

7 years agorust/nfs: improve file close handling
Victor Julien [Tue, 17 Oct 2017 08:19:00 +0000 (10:19 +0200)] 
rust/nfs: improve file close handling

7 years agorust/nfs: don't panic on malformed NFS traffic
Nick Price [Thu, 28 Dec 2017 16:11:17 +0000 (11:11 -0500)] 
rust/nfs: don't panic on malformed NFS traffic

Instead set events.

7 years agoaf-packet: free ring buffer at exit 3130/head
Eric Leblond [Mon, 1 Jan 2018 18:03:24 +0000 (19:03 +0100)] 
af-packet: free ring buffer at exit

7 years agorust/mingw: fix linker issues on mingw
Victor Julien [Thu, 21 Dec 2017 15:25:13 +0000 (16:25 +0100)] 
rust/mingw: fix linker issues on mingw

7 years agocuda: remove 3128/head
Victor Julien [Sat, 30 Dec 2017 13:55:26 +0000 (14:55 +0100)] 
cuda: remove

Remove CUDA support as it has been broken for a long time.

Ticket #2382.

7 years agoscan-build: fix memleak warning in port parsing 3117/head
Victor Julien [Thu, 21 Dec 2017 11:07:46 +0000 (12:07 +0100)] 
scan-build: fix memleak warning in port parsing

7 years agodetect/tos: minor cleanups
Victor Julien [Thu, 21 Dec 2017 11:02:33 +0000 (12:02 +0100)] 
detect/tos: minor cleanups

7 years agodetect/tos: fix memleak in error path
Victor Julien [Thu, 21 Dec 2017 11:00:28 +0000 (12:00 +0100)] 
detect/tos: fix memleak in error path

7 years agoscan-build: simplify FatalErrorOnInit macro
Victor Julien [Thu, 21 Dec 2017 10:10:52 +0000 (11:10 +0100)] 
scan-build: simplify FatalErrorOnInit macro

7 years agoscan-build: don't use memory wrappers
Victor Julien [Thu, 21 Dec 2017 10:01:12 +0000 (11:01 +0100)] 
scan-build: don't use memory wrappers

7 years agoscan-build: fix warning in radix tree
Victor Julien [Thu, 21 Dec 2017 10:00:28 +0000 (11:00 +0100)] 
scan-build: fix warning in radix tree

7 years agoscan-build: fix warning in streaming buffer
Victor Julien [Thu, 21 Dec 2017 09:59:03 +0000 (10:59 +0100)] 
scan-build: fix warning in streaming buffer

7 years agothreads: avoid NULL-ptr deref in thread init wait
Victor Julien [Thu, 21 Dec 2017 09:47:52 +0000 (10:47 +0100)] 
threads: avoid NULL-ptr deref in thread init wait

** CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
/src/tm-threads.c: 2135 in TmThreadWaitOnThreadInit()

________________________________________________________________________________________________________
*** CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
/src/tm-threads.c: 2135 in TmThreadWaitOnThreadInit()
2129         struct timeval cur_ts;
2130         gettimeofday(&start_ts, NULL);
2131
2132     again:
2133         gettimeofday(&cur_ts, NULL);
2134         if ((cur_ts.tv_sec - start_ts.tv_sec) > 120) {
>>>     CID 1426745:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "tv".
2135             SCLogError(SC_ERR_THREAD_INIT, "thread \"%s\" failed to "
2136                     "initialize in time: flags %04x", tv->name,
2137                     SC_ATOMIC_GET(tv->flags));
2138             return TM_ECODE_FAILED;
2139         }
2140

7 years agoRust: fix probing function prototype: change sign and add Flow
Pierre Chifflier [Wed, 29 Nov 2017 11:07:44 +0000 (12:07 +0100)] 
Rust: fix probing function prototype: change sign and add Flow

7 years agomingw: improve ipaddress parsing 3112/head
Victor Julien [Mon, 11 Dec 2017 17:18:28 +0000 (18:18 +0100)] 
mingw: improve ipaddress parsing

7 years agomingw: fix issues in pcap directory code
Victor Julien [Mon, 11 Dec 2017 12:32:47 +0000 (13:32 +0100)] 
mingw: fix issues in pcap directory code

Fix issues with 'stat' and explicitly skip . and ..

7 years agomingw: wrapper for usleep in threads
Victor Julien [Mon, 27 Nov 2017 13:31:45 +0000 (14:31 +0100)] 
mingw: wrapper for usleep in threads

usleep on MinGW doesn't behave as expected. Added replacement
wrapper around 'Sleep(msec)'. As that has msec resolution and
not a usec resolution, change the various thread init and stop
functions to test for the actual time waited instead of counting
the usecs passed to usleep.

7 years agomingw/cygwin: explicitly disable unix socket
Victor Julien [Mon, 27 Nov 2017 08:06:03 +0000 (09:06 +0100)] 
mingw/cygwin: explicitly disable unix socket

7 years agomingw: use c:\Program Files\Suricata for w64
Victor Julien [Mon, 27 Nov 2017 07:51:35 +0000 (08:51 +0100)] 
mingw: use c:\Program Files\Suricata for w64

7 years agoipv6: add string validation function
Victor Julien [Sun, 26 Nov 2017 10:17:57 +0000 (11:17 +0100)] 
ipv6: add string validation function

7 years agoipv4: add string validation function
Victor Julien [Sun, 26 Nov 2017 10:09:19 +0000 (11:09 +0100)] 
ipv4: add string validation function

7 years agodecode/mime: improve ip address validation
Victor Julien [Sun, 26 Nov 2017 08:58:03 +0000 (09:58 +0100)] 
decode/mime: improve ip address validation

inet_pton on Windows/MinGW is very liberal, so do manual validation
of IP address formatting.

7 years agomingw: work around mingw more liberal ip parsing
Victor Julien [Sat, 25 Nov 2017 13:23:35 +0000 (14:23 +0100)] 
mingw: work around mingw more liberal ip parsing

7 years agoconsole: no color for native windows build
Victor Julien [Sat, 25 Nov 2017 09:34:34 +0000 (10:34 +0100)] 
console: no color for native windows build

7 years agomingw: disable pid checking from pidfile
Victor Julien [Mon, 17 Jul 2017 14:20:22 +0000 (16:20 +0200)] 
mingw: disable pid checking from pidfile

kill() call is not supported in MinGW

7 years agomingw: fix 'struct tm' compilation issue
Victor Julien [Mon, 17 Jul 2017 14:19:32 +0000 (16:19 +0200)] 
mingw: fix 'struct tm' compilation issue

7 years agostrptime: add implementation from NetBSD
Victor Julien [Mon, 17 Jul 2017 13:26:43 +0000 (15:26 +0200)] 
strptime: add implementation from NetBSD

As MinGW doesn't come with strptime take the BSD licensed
implementation from NetBSD. More specifically, the one from

https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-libkml/strptime.c

It's slightly modified to get rid on 'uint'.

7 years agomingw: add SCNtohl and SCNtohs macro's
Victor Julien [Mon, 17 Jul 2017 11:45:44 +0000 (13:45 +0200)] 
mingw: add SCNtohl and SCNtohs macro's

On MinGW the result of ntohl needs to be casted to uint32_t and
the result of ntohs to uint16_t. To avoid doing this everywhere
add SCNtohl and SCNtohs macros.

7 years agomingw: fix use of undefined USR2 signal
Victor Julien [Mon, 17 Jul 2017 11:22:58 +0000 (13:22 +0200)] 
mingw: fix use of undefined USR2 signal

7 years agomingw: fix compilation of signals code
Victor Julien [Mon, 17 Jul 2017 09:02:47 +0000 (11:02 +0200)] 
mingw: fix compilation of signals code

7 years agomingw: work around mingw mkdir
Victor Julien [Sat, 15 Jul 2017 07:40:11 +0000 (09:40 +0200)] 
mingw: work around mingw mkdir

mingw doesn't come with a posix compliant mkdir as it only takes
a single argument.

7 years agoeve: remove json format option - was not used
Jason Ish [Mon, 11 Dec 2017 21:31:58 +0000 (15:31 -0600)] 
eve: remove json format option - was not used

7 years agoeve.flow: removed unused http parameters
Jason Ish [Tue, 19 Dec 2017 22:50:25 +0000 (16:50 -0600)] 
eve.flow: removed unused http parameters

7 years agoeve: fix context datatype used in init functions
Jason Ish [Tue, 19 Dec 2017 21:49:27 +0000 (15:49 -0600)] 
eve: fix context datatype used in init functions

Many were using AlertJsonThread instead of OutputJsonCtx,
but as the datatypes were similar enough no harm was done.

Now that they are using their proper datatype, removed
AlertJsonThread from output.h as its no longer used.

7 years agoeve.dnp3: removed unsed context field
Jason Ish [Tue, 19 Dec 2017 21:46:31 +0000 (15:46 -0600)] 
eve.dnp3: removed unsed context field

7 years agoeve.flow: remove "hi" log message
Jason Ish [Tue, 19 Dec 2017 21:44:17 +0000 (15:44 -0600)] 
eve.flow: remove "hi" log message

7 years agoeve.netflow: remove "hi" log message
Jason Ish [Tue, 19 Dec 2017 21:43:50 +0000 (15:43 -0600)] 
eve.netflow: remove "hi" log message

7 years agorust: add --enable-rust-debug
Victor Julien [Wed, 20 Dec 2017 13:14:34 +0000 (14:14 +0100)] 
rust: add --enable-rust-debug

Add option to put Rust code in non-'--release' mode, preserving
debug symbols.

Until now Suricata would have to be compiled with --enable-debug for
this.

7 years agohostbits: fix test setup 3108/head
Victor Julien [Sat, 14 Oct 2017 21:14:31 +0000 (23:14 +0200)] 
hostbits: fix test setup

7 years agofile_data: move tests into tests/
Victor Julien [Sat, 14 Oct 2017 08:09:57 +0000 (10:09 +0200)] 
file_data: move tests into tests/

7 years agofile_data: unify inspect engines
Victor Julien [Thu, 12 Oct 2017 16:19:23 +0000 (18:19 +0200)] 
file_data: unify inspect engines

Call HTTP from the generic file_data engine.

7 years agofile_data: smtp file_data to generic file_data
Victor Julien [Fri, 29 Sep 2017 21:09:15 +0000 (23:09 +0200)] 
file_data: smtp file_data to generic file_data

Generalize the SMTP file_data inspection into a 'files'
file_data inspection that can be used for any protocol
that uses the File API.

7 years agodetect: minor cleanup
Victor Julien [Sun, 8 Oct 2017 16:28:30 +0000 (18:28 +0200)] 
detect: minor cleanup

7 years agoapp-layer: use bool for 'HasDecoderEvents'
Victor Julien [Sun, 8 Oct 2017 16:23:22 +0000 (18:23 +0200)] 
app-layer: use bool for 'HasDecoderEvents'

7 years agodetect: no tcp flags in mask for pseudo packets
Victor Julien [Tue, 7 Nov 2017 10:28:01 +0000 (11:28 +0100)] 
detect: no tcp flags in mask for pseudo packets

7 years agodetect/mpm: micro optimization in setup
Victor Julien [Sun, 17 Dec 2017 19:08:12 +0000 (20:08 +0100)] 
detect/mpm: micro optimization in setup

7 years agodetect: remove old simd references
Victor Julien [Sun, 8 Oct 2017 12:28:19 +0000 (14:28 +0200)] 
detect: remove old simd references

7 years agodecode/vlan: don't consider ARP 'unknown'
Victor Julien [Wed, 20 Dec 2017 08:30:42 +0000 (09:30 +0100)] 
decode/vlan: don't consider ARP 'unknown'

7 years agopfring: minor code cleanups
Victor Julien [Wed, 20 Dec 2017 08:03:33 +0000 (09:03 +0100)] 
pfring: minor code cleanups

7 years agopfring: add warning for stripped vlan header case
Victor Julien [Wed, 20 Dec 2017 07:57:29 +0000 (08:57 +0100)] 
pfring: add warning for stripped vlan header case

According to PF_RING upstream the vlan header should never be stripped
from the packet PF_RING feeds to Suricata. But upstream also indicated
keeping the check would be a good "safety check".

So in addition to the check, add a warning that warns once (per thread
for implementation simplicity) if the vlan hdr does appear to be stripped
after all.

7 years agopfring: fix vlan handling issues
Victor Julien [Tue, 19 Dec 2017 19:17:39 +0000 (20:17 +0100)] 
pfring: fix vlan handling issues

When Suricata was monitoring traffic with a single vlan layer, the stats
and output instead showed 2. This was caused by the raw packets PF_RING
feeds Suricata would hold the vlan header, but the code assumed that
the header was stripped and the vlan_id passed to Suricata through
PF_RING's extended_hdr.parsed_pkt.

This patch adds the following logic: Check vlan id from the parser packet
PF_RING prepared. PF_RING sets the vlan_id based on its own parsing or
based on the hardware offload. It gives no indication on where the vlan_id
came from, so we rely on the vlan_offset field. If it's 0, we assume the
PF_RING parser did not see the vlan header and got it from the hardware
offload. In this case we will use this information directly, as we won't
get a raw vlan header later. If PF_RING did set the offset, we do the
parsing in the Suricata decoder so that we have full control.

PF_RING *should* put back the vlan header in all cases, and also set the
vlan_offset field, but as a extra precaution keep the check described
above.

Bug #2355.

7 years agoapp-layer-ftp: add memcap for ftp
Eric Leblond [Fri, 24 Nov 2017 15:59:34 +0000 (16:59 +0100)] 
app-layer-ftp: add memcap for ftp

Add a memory cap for the FTP protocol.

7 years agodoc: update file extraction document
Eric Leblond [Sun, 19 Nov 2017 19:27:17 +0000 (20:27 +0100)] 
doc: update file extraction document

Define the list of protocol parsers supporting extraction in one
single place following Andreas Herz' suggestion.

7 years agodoc: update following ftp-data changes
Eric Leblond [Sun, 19 Nov 2017 19:22:46 +0000 (20:22 +0100)] 
doc: update following ftp-data changes

7 years agodetect-ftpdata: match on ftp-data operation
Eric Leblond [Sun, 19 Nov 2017 19:21:08 +0000 (20:21 +0100)] 
detect-ftpdata: match on ftp-data operation

This keyword mathes on ftp operation STOR and RETR. It will allow
rules writer to select if the alert has to be on a put or a fetch
operation.

It is now possible to write a signature like:

  alert ftp-data any any -> any any (msg:"FTP data get firwmare"; ftdata_command:retr; sid:2; rev:1;)

to alert when a file is retrieved from a FTP server.

7 years agoapp-layer-ftp: add ftp-data support
Eric Leblond [Wed, 13 Sep 2017 14:48:29 +0000 (15:48 +0100)] 
app-layer-ftp: add ftp-data support

Use expectation to be able to identify connections that are
ftp data. It parses the PASV response, STOR message and the
RETR message to provide extraction of files.

Implementation in Rust of FTP messages parsing is available.

Also this patch changes some var name prefixed by ssh to ftp.

7 years agoapp-layer-expectation: expectation system
Eric Leblond [Tue, 12 Sep 2017 13:11:01 +0000 (14:11 +0100)] 
app-layer-expectation: expectation system

This patch provides a working expectation system. This will allow
suricata to have a way to identify parallel connections opened by
a protocol such as FTP.

Expectation are a chained list and there is a cleaning by timeout
of the entries.

This patch also defined a counter of expectations that is also
used to check if we need to query IPPairs. This way we only query
the IPPairs store if we have an expectation.

7 years agoapp-layer: add Flow to probing parser functions
Eric Leblond [Tue, 12 Sep 2017 15:43:41 +0000 (16:43 +0100)] 
app-layer: add Flow to probing parser functions

7 years agoflow: add parent_id field
Eric Leblond [Sat, 16 Sep 2017 12:28:22 +0000 (13:28 +0100)] 
flow: add parent_id field

This patch adds a parent_id field to the Flow structure that
contain the flow ID of the parent connection for protocol with
dynamic parallel connection opening like FTP.