]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
11 years agoproto-detect: masks cleanup 941/head
Victor Julien [Thu, 3 Apr 2014 14:42:42 +0000 (16:42 +0200)] 
proto-detect: masks cleanup

The direction specific masks were not used correctly. The toserver ones
were only used for 'dp' registrations, the toclient ones only for 'sp'.

The patch merges them.

11 years agoproto-detect: update port logic
Victor Julien [Thu, 3 Apr 2014 11:55:22 +0000 (13:55 +0200)] 
proto-detect: update port logic

If a flow matches both an 'sp' based PP registration and a 'dp' based,
until now we would only check the 'dp' one. This patch changes that. It
will inspect both.

11 years agoapp-layer: proto detection update
Victor Julien [Thu, 27 Mar 2014 15:13:08 +0000 (16:13 +0100)] 
app-layer: proto detection update

Instead of the notion of toserver and toclient protocol detection, use
destination port and source port.

Independent of the data direction, the flow's port settings will be used
to find the correct probing parser, where we first try the dest port,
and if that fails the source port.

Update the configuration file format, where toserver is replaced by 'dp'
and toclient by 'sp'. Toserver is intrepreted as 'dp' and toclient as
'sp' for backwards compatibility.

Example for dns:

    dns:
      # memcaps. Globally and per flow/state.
      #global-memcap: 16mb
      #state-memcap: 512kb

      # How many unreplied DNS requests are considered a flood.
      # If the limit is reached, app-layer-event:dns.flooded; will match.
      #request-flood: 500

      tcp:
        enabled: yes
        detection-ports:
          dp: 53
      udp:
        enabled: yes
        detection-ports:
          dp: 53

Like before, progress of protocol detection is tracked per flow direction.

Bug #1142.

11 years agostream: improve retransmission handling
Victor Julien [Wed, 16 Apr 2014 10:55:09 +0000 (12:55 +0200)] 
stream: improve retransmission handling

When connection are closing, don't reject retransmissions of data
packets.

Bug #1180.

11 years agorefactor IDS/IPS engine mode logic
Victor Julien [Tue, 15 Apr 2014 15:01:52 +0000 (17:01 +0200)] 
refactor IDS/IPS engine mode logic

Instead of error phrone externs with macro's, use functions with a local
static enum var instead.

- EngineModeIsIPS(): in IPS mode
- EngineModeIsIDS(): in IDS mode

To set the modes:

- EngineModeSetIDS(): IDS mode (default)
- EngineModeSetIPS(): IPS mode

Bug #1177.

11 years agoFix unaligned load in AC-TILE MPM.
Ken Steele [Tue, 15 Apr 2014 14:18:30 +0000 (10:18 -0400)] 
Fix unaligned load in AC-TILE MPM.

The SLOAD define using __insn_ld2s_L2 is used to provide a compiler
hint that the load will come from the L2 cache instead of the L1. It
also specifies that it is a 2 byte signed load. For the Tiny MPM, that
needs to be a 1-byte load, which is what is specified in util-ac-mpm-tile.c,
but the #undef was removing that definition.

11 years agodetect: fix alstate handling 940/head
Victor Julien [Tue, 15 Apr 2014 10:39:22 +0000 (12:39 +0200)] 
detect: fix alstate handling

Previously, the alstate use in the main detect loop was unsafe. The
alstate pointer would be set duing a lock, but it would again be used
after one or more lock/unlock cycles. If the data pointed to would
disappear, a dangling pointer would be the result.

Due to they way flows are cleaned up using reference counting and
such, changes of this happening were very small. However, at least
one path can lead to this situation. So it had to be fixed.

11 years agodetect: locking update continued
Victor Julien [Tue, 15 Apr 2014 10:23:21 +0000 (12:23 +0200)] 
detect: locking update continued

Make DeStateDetectContinueDetection get it's own alstate pointer instead
of using the one that was passed to it. We now get and use it only
inside a flow lock.

11 years agodetect: locking update
Victor Julien [Tue, 15 Apr 2014 09:18:47 +0000 (11:18 +0200)] 
detect: locking update

Make DeStateDetectStartDetection get it's own alstate pointer instead
of using the one that was passed to it. We now get and use it only
inside a flow lock.

11 years agodetect: cleanup
Victor Julien [Tue, 15 Apr 2014 09:05:17 +0000 (11:05 +0200)] 
detect: cleanup

Remove unused alstate and app layer flags arguments from
DetectEngineInspectPacketPayload()

11 years agodetect: modify AMATCH locking
Victor Julien [Tue, 15 Apr 2014 08:31:48 +0000 (10:31 +0200)] 
detect: modify AMATCH locking

This is an intrusive change. This patch modifies the way AMATCH
inspection uses locking.

So far, each keyword did it's own locking. This lead to a situation
where a 'alstate' pointer was passed around that was not always
protected by a lock.

This patch moves the locking to the Stateful detection functions.

11 years agoaf-packet: fix error handling 931/head
Eric Leblond [Fri, 11 Apr 2014 10:14:01 +0000 (12:14 +0200)] 
af-packet: fix error handling

Only exit from synchronization loop on poll error and not in case
of a timeout.

11 years agoutil-ioctl: only get MTU when iface name is set
Eric Leblond [Thu, 10 Apr 2014 09:05:46 +0000 (11:05 +0200)] 
util-ioctl: only get MTU when iface name is set

This patch fixes a warning message when suricata is started without
giving an interface name on the command line. The code was trying
to get the MTU even if pcap_dev was not set.

11 years agoFix 2 compiler warnings 930/head
Victor Julien [Sun, 13 Apr 2014 08:35:36 +0000 (10:35 +0200)] 
Fix 2 compiler warnings

FreeBSD 10 32-bit with clang 3.3:

log-tlslog.c:172:14: error: format specifies type 'long' but the argument has type 'time_t' (aka 'int') [-Werror,-Wformat]
             p->ts.tv_sec,
             ^~~~~~~~~~~~
1 error generated.

detect-engine-payload.c:508:27: warning: format specifies type 'long' but the argument has type 'time_t' (aka 'int') [-Wformat]
    printf("%ld.%06ld\n", tv_diff.tv_sec, (long int)tv_diff.tv_usec);
            ~~~           ^~~~~~~~~~~~~~
            %d
1 warning generated.

11 years agooutput-api: cleanup handling 926/head
Victor Julien [Thu, 10 Apr 2014 07:45:21 +0000 (09:45 +0200)] 
output-api: cleanup handling

Add output 'free list' that contains all the output ctx' that need
cleanup at shutdown. It differs from the runmode output list in that
it will also contain a 'parent' for the submodules that share the
context of it's parent.

11 years agooutput api: complete shutdown functions
Victor Julien [Thu, 10 Apr 2014 07:43:50 +0000 (09:43 +0200)] 
output api: complete shutdown functions

Add missing function for Filedata API. Clean up list in all functions.

11 years agotls-json: add cleanup function
Victor Julien [Thu, 10 Apr 2014 07:41:52 +0000 (09:41 +0200)] 
tls-json: add cleanup function

Properly clean up output context when shutting down.

11 years agodrop-json: fix cleanup
Victor Julien [Thu, 10 Apr 2014 07:40:42 +0000 (09:40 +0200)] 
drop-json: fix cleanup

Use proper function for sub-module cleanup. LogFileCtx is not managed
by the sub-module, so don't clean it.

11 years agoeve-log: fix mem leak at shutdown
Victor Julien [Thu, 10 Apr 2014 07:36:19 +0000 (09:36 +0200)] 
eve-log: fix mem leak at shutdown

Make sure we free all memory in the shutdown function.

11 years agossh-json: add clean up functions
Victor Julien [Thu, 10 Apr 2014 07:08:53 +0000 (09:08 +0200)] 
ssh-json: add clean up functions

Add clean up functions for the SSH json logger.

11 years agohttp-json: add missing cleanup functions
Victor Julien [Thu, 10 Apr 2014 06:35:51 +0000 (08:35 +0200)] 
http-json: add missing cleanup functions

Add cleanup functions.

11 years agofile-json: cleanup at shutdown
Victor Julien [Thu, 10 Apr 2014 06:27:10 +0000 (08:27 +0200)] 
file-json: cleanup at shutdown

Fix a memory leak at shutdown. Module didn't have a cleanup function.

11 years agodns-json: fix cleanup
Victor Julien [Thu, 10 Apr 2014 06:25:22 +0000 (08:25 +0200)] 
dns-json: fix cleanup

Use specialized cleanup function for sub-module case. Freeing the
LogFileCtx is not the responsibility of a sub-module.

11 years agoalert-json: fix cleanup
Victor Julien [Thu, 10 Apr 2014 06:24:08 +0000 (08:24 +0200)] 
alert-json: fix cleanup

Call specialized clean up function when running as a sub-module.

11 years agolog-tls: run Disable at shutdown
Victor Julien [Thu, 10 Apr 2014 06:20:57 +0000 (08:20 +0200)] 
log-tls: run Disable at shutdown

Call OutputTlsLoggerDisable at cleanup.

11 years agodrop loggers: call disable func
Victor Julien [Thu, 10 Apr 2014 06:19:06 +0000 (08:19 +0200)] 
drop loggers: call disable func

Call OutputDropLoggerDisable() on cleanup.

11 years agooutput: add Disable funcs to mirror Enable
Victor Julien [Thu, 10 Apr 2014 06:13:38 +0000 (08:13 +0200)] 
output: add Disable funcs to mirror Enable

For the loggers that we allow only one instance for: tls, ssh, drop, we
track active loggers through Output*Enable functions. Add Disable
functions to mirror this. They are to be called from the shutdown funcs
those loggers use.

11 years agounified2: fix memory leak at shutdown
Victor Julien [Thu, 10 Apr 2014 06:11:34 +0000 (08:11 +0200)] 
unified2: fix memory leak at shutdown

Module didn't properly free output context at shutdown. Led to a leak
in Unix Socket mode.

11 years agooutput: clean file desc at exit. 925/head
Eric Leblond [Wed, 9 Apr 2014 13:04:45 +0000 (15:04 +0200)] 
output: clean file desc at exit.

This is a beginning of implementation for bug #1660:
 https://redmine.openinfosecfoundation.org/issues/1160

This patch adds a cleaning function for each logger of new type
(packet, tx and file). These functions are called in RunModeShutDown().

The state of this patch is that it is crashing suricata when sending
pcap to analyse:
 - At first pcap if tx and file cleaning function are called
 - At second pcap if only packet cleaning function is called

The cause in first case is unknown. In second case this is due to
the necessity of cleaning the list of logger registered to a logging
type.

11 years agoTLS: add detection for malicious heartbeats (AKA heartbleed) 924/head
Pierre Chifflier [Wed, 9 Apr 2014 07:52:00 +0000 (09:52 +0200)] 
TLS: add detection for malicious heartbeats (AKA heartbleed)

The OpenSSL implementation of RFC 6520 (Heartbeat extension) does not
check the payload length correctly, resulting in a copy of at most 64k
of memory from the server (ref: CVE-2014-0160).
This patch adds support for decoding heartbeat messages (if not
encrypted), and checking several parts (type, length and padding).
When an anomaly is detected, a TLS event is raised.

11 years agoerf-file: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 12:14:38 +0000 (13:14 +0100)] 
erf-file: clean up decode thread local storage

Clean up the thread local data the decode portion of ERF users.

Bug #978

11 years agoendace-dag: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 12:11:03 +0000 (13:11 +0100)] 
endace-dag: clean up decode thread local storage

Clean up the thread local data the decode portion of DAG uses.

Bug #978

11 years agompipe: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 12:07:43 +0000 (13:07 +0100)] 
mpipe: clean up decode thread local storage

Clean up the thread local data the decode portion of mpipe uses.

Bug #978

11 years agoipfw: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 12:05:40 +0000 (13:05 +0100)] 
ipfw: clean up decode thread local storage

Clean up the thread local data the decode portion of ipfw uses.

Bug #978

11 years agonapatech: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 12:02:31 +0000 (13:02 +0100)] 
napatech: clean up decode thread local storage

Clean up the thread local data the decode portion of napatech uses.

Bug #978

11 years agopcap: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 11:17:41 +0000 (12:17 +0100)] 
pcap: clean up decode thread local storage

Clean up the thread local data the decode portion of pcap uses.

Bug #978

11 years agopfring: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 11:14:04 +0000 (12:14 +0100)] 
pfring: clean up decode thread local storage

Clean up the thread local data the decode portion of pfring uses.

Bug #978

11 years agonfq: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 11:05:23 +0000 (12:05 +0100)] 
nfq: clean up decode thread local storage

Clean up the thread local data the decode portion of nfq uses.

Bug #978

11 years agoaf-packet: clean up decode thread local storage
Victor Julien [Fri, 28 Mar 2014 11:01:12 +0000 (12:01 +0100)] 
af-packet: clean up decode thread local storage

Clean up the thread local data of the decode part of afpacket.

Bug #978

11 years agodrmemory: remove bug 978 suppression
Victor Julien [Wed, 5 Mar 2014 11:22:40 +0000 (12:22 +0100)] 
drmemory: remove bug 978 suppression

Bug is fixed, so suppression is no longer needed.

Bug #978.

11 years agopcap-file: clean up decode thread local storage
Victor Julien [Wed, 5 Mar 2014 11:21:00 +0000 (12:21 +0100)] 
pcap-file: clean up decode thread local storage

Clean up the thread local data the decode portion of pcap-file use.

Bug #978.

11 years agodecode: introduce DecodeThreadVarsFree
Victor Julien [Wed, 5 Mar 2014 11:18:57 +0000 (12:18 +0100)] 
decode: introduce DecodeThreadVarsFree

As a mirror of DecodeThreadVarsAlloc, DecodeThreadVarsFree is used
to free the memory that DecodeThreadVarsAlloc alloc'd, including
AppLayer storage.

11 years agoapp-layer: cleanups
Victor Julien [Wed, 5 Mar 2014 11:17:20 +0000 (12:17 +0100)] 
app-layer: cleanups

Clean up AppLayerParserThreadCtxAlloc and AppLayerParserThreadCtxFree.
Both used confusing variables in loops, with the wrong types.

11 years agoForce pidfile creation of --pidfile.
Jason Ish [Wed, 26 Mar 2014 15:51:27 +0000 (09:51 -0600)] 
Force pidfile creation of --pidfile.

A pidfile can be useful when not in daemon mode, for example
when running under a process supervisor.

11 years agojson: somewhere along the way IP/port pairs had gotten swapped in 915/head
Tom DeCanio [Wed, 2 Apr 2014 01:03:28 +0000 (18:03 -0700)] 
json: somewhere along the way  IP/port pairs had gotten swapped in
http and ssh eve logs

11 years agoChange configure to allow statically linking libpcre.
Ken Steele [Tue, 11 Mar 2014 15:34:45 +0000 (11:34 -0400)] 
Change configure to allow statically linking libpcre.

Statically linking libpcre requires using -lpthread, which is added
when building Suricata, but not while checking for libpcre in configure.

11 years agotls: no event on 'new session ticket' in handshake 908/head
Victor Julien [Sat, 8 Mar 2014 15:10:09 +0000 (16:10 +0100)] 
tls: no event on 'new session ticket' in handshake

Don't set an event on encountering a 'new session ticket' (4) record
in the TLS handshake.

11 years agoipv6: add support for PAD1
Victor Julien [Sat, 8 Mar 2014 13:35:56 +0000 (14:35 +0100)] 
ipv6: add support for PAD1

Support PAD1 in IPv6 HOP options header and DST options header.

11 years agoicmpv6: add multicast types
Victor Julien [Sat, 8 Mar 2014 13:12:47 +0000 (14:12 +0100)] 
icmpv6: add multicast types

Only add them to check if the code is 0 and to make sure the default
case doesn't set an 'unknown type' event.

11 years agoTLS: register patterns for tls-alerts
Victor Julien [Wed, 12 Mar 2014 21:52:00 +0000 (22:52 +0100)] 
TLS: register patterns for tls-alerts

Register patterns for when server has an alert as the first message.

11 years agodetect state: fix indent 906/head
Victor Julien [Wed, 12 Mar 2014 14:08:27 +0000 (15:08 +0100)] 
detect state: fix indent

AMATCH block was indented too far.

11 years agodetect state: remove alproto check for AMATCH
Victor Julien [Wed, 12 Mar 2014 14:07:16 +0000 (15:07 +0100)] 
detect state: remove alproto check for AMATCH

Not all AMATCHes set a alproto.

11 years agoFix app-layer-protocol FP on multi TX flow
Victor Julien [Wed, 12 Mar 2014 12:57:30 +0000 (13:57 +0100)] 
Fix app-layer-protocol FP on multi TX flow

In case of multiple transactions, the stored AMATCH list would not have
been reset, but it would still be reconsidered. Even though none would
match, the engine would still conclude that the rule matched.

11 years agoUpdate Changelog for 2.0 release suricata-2.0
Victor Julien [Tue, 25 Mar 2014 08:46:44 +0000 (09:46 +0100)] 
Update Changelog for 2.0 release

11 years agotls: fix problem with tls.store keyword 904/head
Eric Leblond [Fri, 21 Mar 2014 10:15:47 +0000 (11:15 +0100)] 
tls: fix problem with tls.store keyword

Pierre Chifflier pointed out that a rule like:
 alert tls any any -> any any (msg:"TLS store"; tls.issuerdn:!"C=FR"; tls.store;)
was alerting but not storing the certificate. If the filter was
removed:
 alert tls any any -> any any (msg:"TLS store"; tls.store;)
then tls.store is working as expected.

This was linked with fact that logging is only done once for a SSL
state. So without filter, once we have the info we can log and we
run the storage. But when there is a filter, we log and then there
is a filter analysis and alerting. And as logging as already be done
we don't enter in the logging function and there is no storage.

This patch forces the entrance in the log function when there is a
request for TLS storage. And it adds an exit in the logging function
to only do the storage part if the TLS state has already being logged.

11 years agoUpdate Changelog for 2.0rc3 release suricata-2.0rc3
Victor Julien [Tue, 18 Mar 2014 12:10:27 +0000 (13:10 +0100)] 
Update Changelog for 2.0rc3 release

11 years agoyaml: remove rbn, add tls
Victor Julien [Tue, 18 Mar 2014 12:36:56 +0000 (13:36 +0100)] 
yaml: remove rbn, add tls

Remove rbn rule files from default rule list. The files are empty
causing a warning.

Add tls-event.rules to the default list.

11 years agoaf-packet: fix init sync with no traffic 899/head
Victor Julien [Tue, 18 Mar 2014 09:46:30 +0000 (10:46 +0100)] 
af-packet: fix init sync with no traffic

Previously the sync code would depend on traffic to complete. This
patch adds poll support and can complete the setup if the poll timeout
is reached as well.

Part of bug #1130.

11 years agoaf-packet: move packet fanout code 898/head
Eric Leblond [Mon, 17 Mar 2014 12:58:06 +0000 (13:58 +0100)] 
af-packet: move packet fanout code

The sooner is the better for that caode as these means we will get
all sockets binded to fanout group as fast as possible.

11 years agoaf-packet: synchronize reading start
Eric Leblond [Tue, 11 Mar 2014 08:48:34 +0000 (09:48 +0100)] 
af-packet: synchronize reading start

This patch is updating af-packet to discard packets that have been
sent to a socket before all socket in a fanout group have been setup.
Without this, there is no way to assure that all packets for a single
flow will be treated by the same thread.

Tests have been done on a system with an ixgbe network card. When using
'cluster_flow' load balancing and disactivating receive hash on the iface:
 ethtool -K IFACE rxhash off
then suricata is behaving as expected and all packets for a single flow
are treated by the same thread.

For some unknown reason, this is not the case when using cluster_cpu. It
seems that in that case the load balancing is not perfect on the card side.

The rxhash offloading has a direct impact on the cluster_flow load balancing
because load balancing is done by using a generic hash key attached to
each skb. This hash can be computed by the network card or can be
computed by the kernel. In the xase of a ixgbe network card, it seems there
is some issue with the hash key for TCP. This explains why it is necessary to
remove the rxhash offloading to have a correct behavior. This could also
explain why cluster_cpu is currently failing because the card is using the
same hash key computation to do the RSS queues load balancing.

11 years agofast-log: restore logging of Drop/wDrop 894/head
Victor Julien [Fri, 14 Mar 2014 08:50:16 +0000 (09:50 +0100)] 
fast-log: restore logging of Drop/wDrop

Restore drop print logic. Probably got lost in large refactoring round
introducing log APIs.

Bug #1138.

11 years agodetect: allow alias registration for rule keywords 893/head
Victor Julien [Thu, 13 Mar 2014 16:09:28 +0000 (17:09 +0100)] 
detect: allow alias registration for rule keywords

This allows for registering a keyword under another name while keeping
the old name active and supported.

Do this for 'luajit', which can now also be used as just 'lua'.

11 years agojson alert: fix action 892/head
Victor Julien [Tue, 4 Mar 2014 13:41:45 +0000 (14:41 +0100)] 
json alert: fix action

It would give 'Pass' as an action when the rule is set to 'alert'.

11 years agoeve-http: register with app-layer api 890/head
Victor Julien [Wed, 12 Mar 2014 08:31:34 +0000 (09:31 +0100)] 
eve-http: register with app-layer api

The HTTP module of Eve didn't register itself with the app-layer
for HTTP. This meant that if no other HTTP logger was active, the
HTTP logging in Eve wouldn't work.

This patch makes the HTTP Eve module register itself correctly.

Bug #1133.

11 years agoeve-file: set event_type to fileinfo 886/head
Victor Julien [Tue, 11 Mar 2014 16:15:05 +0000 (17:15 +0100)] 
eve-file: set event_type to fileinfo

To remain constistent with the other logs, set the event type to
the same name as the structure containing the defails. In this
case fileinfo.

Part of bug #1127.

11 years agoeve-files: file -> fileinfo 885/head
Victor Julien [Tue, 11 Mar 2014 14:48:10 +0000 (15:48 +0100)] 
eve-files: file -> fileinfo

Due to what appears to be an issue in logstash, the 'file' part of
the file event types was masked by a field that logstash-forwarder
added itself.

Since logstash-forwarder is an important part of the logstash stack,
this patch works around the issue by renaming our 'file' structure
to 'fileinfo', thus resolving the naming conflict.

Bug #1127

11 years agoeve-http: print <unknown> like in eve-files 884/head
Victor Julien [Tue, 11 Mar 2014 11:11:33 +0000 (12:11 +0100)] 
eve-http: print <unknown> like in eve-files

When UA or Host are unknown, print <unknown> instead of <useragent
unknown> or <hostname unknown>.

Bug #1131.

11 years agoFix live reload 883/head
Victor Julien [Mon, 10 Mar 2014 11:39:19 +0000 (12:39 +0100)] 
Fix live reload

Fix memsets clearing out of bounds memory on live reload, causing
crashes and corrupted backtraces.

Bug #1128.

11 years agopfring: call enable_ring after set_cluster 881/head
Victor Julien [Mon, 10 Mar 2014 07:54:40 +0000 (08:54 +0100)] 
pfring: call enable_ring after set_cluster

Move pfring_enable_ring to the start of ReceivePfringLoop() so that
it's guaranteed to be called after all threads have called
pfring_set_cluster first.

This is necessary because pfring will already make packets available
to thread N, while thread N+1 is still registering itself. This leads
to cases where the first packet(s) of a flow are processed by a
different thread in Suricata than the later ones.

This is a race condition only at start up. New flows after the pfring
initialization is complete will not be influenced by this.

Bug #1129.

11 years agoUpdate ChangeLog for 2.0rc2 release suricata-2.0rc2
Victor Julien [Thu, 6 Mar 2014 12:24:23 +0000 (13:24 +0100)] 
Update ChangeLog for 2.0rc2 release

11 years agoyaml: comment out example config 879/head
Victor Julien [Thu, 6 Mar 2014 11:35:53 +0000 (12:35 +0100)] 
yaml: comment out example config

Comment out htp settings that should only serve as an example.

11 years agoyaml: increase default memcaps
Victor Julien [Thu, 6 Mar 2014 11:35:20 +0000 (12:35 +0100)] 
yaml: increase default memcaps

Increase default flow and stream reassembly memcaps.

11 years agoeve-log: enable in default config
Victor Julien [Thu, 6 Mar 2014 11:34:22 +0000 (12:34 +0100)] 
eve-log: enable in default config

In the default config, eve-log is now enabled by default. All loggers
except 'drop' are enabled.

11 years agoeve-log: output cleanup
Victor Julien [Thu, 6 Mar 2014 11:33:14 +0000 (12:33 +0100)] 
eve-log: output cleanup

Suppress debug messages and print in a nicer way which modules are
being enabled.

11 years agoBug 611: fix for iponly 878/head
Victor Julien [Wed, 5 Mar 2014 09:43:30 +0000 (10:43 +0100)] 
Bug 611: fix for iponly

Fix Bug 611 for ip-only rules as well. If 'alert ip' rule has ports,
don't match on protocols that don't have ports. Like ICMP.

Bug #611.

11 years agooutput-json: update timestamp format
Eric Leblond [Wed, 5 Mar 2014 21:39:10 +0000 (22:39 +0100)] 
output-json: update timestamp format

This patch updates the timestamp format used in eve loggin.
It uses a ISO 8601 comptatible string. This allow tools parsing
the output to easily detect adn/or use the timestamp.

In the EVE JSON output, the value of the timestamp key has been
changed to 'timestamp' (instead of 'time'). This allows tools
like Splunk to detect the timestamp and use it without configuration.

Logstash configuration is simple:

input {
   file {
      path => [ "/usr/local/var/log/suricata/eve.json" ]
      codec =>   json
      type => "suricata-log"
   }
}

filter {
   if [type] == "suricata-log" {
      date {
        match => [ "timestamp", "ISO8601" ]
      }
   }
}

In splunk, auto detection of the fle format is failling and it seems
you need to define a type to parse JSON in
$SPLUNK_DIR/etc/system/local/props.conf:

[suricata]
KV_MODE = json
NO_BINARY_CHECK = 1
TRUNCATE = 0

Then you can simply declare the log file in
$SPLUNK_DIR/etc/system/local/inputs.conf:

[monitor:///usr/local/var/log/suricata/eve.json]
sourcetype = suricata

In both cases the timestamp are correctly imported by
the tools.

11 years agopfring: get vlan id from header
Eric Leblond [Tue, 4 Feb 2014 15:33:30 +0000 (16:33 +0100)] 
pfring: get vlan id from header

PF_RING is delivering the packet with VLAN header stripped. This
patch updates the code to get the information from PF_RING extended
header information.

This patch uses the new function SCKernelVersionIsAtLeast to know
that we've got a old kernel that do not strip the VLAN header from
the message before sending it to userspace.

11 years agoOpenBSD: set correct magic path
Victor Julien [Thu, 6 Mar 2014 07:57:35 +0000 (08:57 +0100)] 
OpenBSD: set correct magic path

For all 5.x OpenBSDs it seems the magic path is:
    /usr/local/share/misc/magic.mgc

11 years agoipfw: fix build 876/head
Eric Leblond [Wed, 5 Mar 2014 21:18:02 +0000 (22:18 +0100)] 
ipfw: fix build

Buildbot reported:
 runmode-ipfw.c: In function 'RunModeIpsIPFWAuto':
 runmode-ipfw.c:85: error: implicit declaration of function 'LiveDeviceHasNoStats'

11 years agohttp: add info message about memcap
Eric Leblond [Mon, 3 Mar 2014 16:57:10 +0000 (17:57 +0100)] 
http: add info message about memcap

Display a message about http memcap when it is set in config file.

11 years agoFix False Positive of rules with ports on portless protocols 872/head
Victor Julien [Tue, 4 Mar 2014 16:49:36 +0000 (17:49 +0100)] 
Fix False Positive of rules with ports on portless protocols

In case of 'alert ip' rules that have ports, the port checks would
be bypassed for non-port protocols, such as ICMP. This would lead to
a rule matching: a false positive.

This patch adds a check. If the rule has a port setting other than
'any' and the protocol is not TCP, UDP or SCTP, then we rule won't
match.

Rules with 'alert ip' and ports are rare, so the impact should be
minimal.

Bug #611.

11 years agoFix BytesToString indexing array using wrong index 870/head
Victor Julien [Tue, 4 Mar 2014 11:42:16 +0000 (12:42 +0100)] 
Fix BytesToString indexing array using wrong index

This would lead to reading past the end of the buffer and also writing
past the end of the newly allocated buffer.

Bug #1121

11 years agojson output: fix vlan byte order in output 869/head
Victor Julien [Tue, 4 Mar 2014 10:30:08 +0000 (11:30 +0100)] 
json output: fix vlan byte order in output

VLAN functions/macros return vlan id in host byte order, so no need
to convert them in output functions.

11 years agoFix null dereference in eve-log
Victor Julien [Tue, 4 Mar 2014 10:13:37 +0000 (11:13 +0100)] 
Fix null dereference in eve-log

Eve-log would call GET_VLAN_ID on the packets vlan header if p->vlan_idx
was bigger than 0. GET_VLAN_ID would then unconditionally dereference
p->vlanh[0] or [1]. However, there are a number of cases in which these
pointers are not set. Defrag pseudo packets, AF_PACKET and in the future
PF_RING, do set the id's, but not the header pointers.

This patch adds 2 new macro's which are wrappers around a function:

VLAN_GET_ID1 and VLAN_GET_ID2 get the id's by calling DecodeVLANGetId.

This function will return the correct id.

Bug #1120.

11 years agoCoverity fix
Victor Julien [Tue, 4 Mar 2014 08:55:59 +0000 (09:55 +0100)] 
Coverity fix

Coverity 992695, fix potential array index with negative int. Very unlikely
case at rule keyword parsing stage.

11 years agoconfigure: simplify OpenBSD handling
Victor Julien [Wed, 26 Feb 2014 21:01:52 +0000 (22:01 +0100)] 
configure: simplify OpenBSD handling

Treat all OpenBSD versions in the same way. No more -fgnu89-inline.

11 years agoDisable emerging-icmp in default config
Victor Julien [Wed, 26 Feb 2014 16:59:21 +0000 (17:59 +0100)] 
Disable emerging-icmp in default config

The file has no active rules by default.

11 years agomake install-full: get correct version of ET
Victor Julien [Wed, 26 Feb 2014 16:58:01 +0000 (17:58 +0100)] 
make install-full: get correct version of ET

Version 2.0.

11 years agossh: fix scan-build warnings 867/head
Victor Julien [Sun, 2 Mar 2014 10:57:13 +0000 (11:57 +0100)] 
ssh: fix scan-build warnings

app-layer-ssh.c:165:5: warning: Value stored to 'input_len' is never read
    input_len -= 1;
    ^            ~
1 warning generated.

app-layer-ssh.c:160:5: warning: Value stored to 'input_len' is never read
    input_len -= 4;
    ^            ~
1 warning generated.

11 years agossh: improve banner checking
Victor Julien [Sun, 2 Mar 2014 10:08:49 +0000 (11:08 +0100)] 
ssh: improve banner checking

Don't use input_len as banner length. Instead, look for banner end
to calculate banner length.

Add test for banner buffering corner case.

11 years agossh: fixes for minor scan-build warnings
Victor Julien [Sun, 2 Mar 2014 09:27:43 +0000 (10:27 +0100)] 
ssh: fixes for minor scan-build warnings

/usr/share/clang/scan-build/ccc-analyzer -DHAVE_CONFIG_H -I. -I..   -I./../libhtp/  -I/usr/include/nspr   -I/usr/include/nss -I/usr/include/nspr   -DLOCAL_STATE_DIR=\"/usr/local/var\" -g -O2 -Wall -Wno-unused-parameter -std=gnu99 -DHAVE_LIBNET11 -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -DHAVE_LIBNET_ICMPV6_UNREACH  -I/usr/include -DLIBPCAP_VERSION_MAJOR=1 -DHAVE_PCAP_SET_BUFF -DHAVE_LIBCAP_NG -DREVISION="51e0dee" -MT app-layer-ssh.o -MD -MP -MF .deps/app-layer-ssh.Tpo -c -o app-layer-ssh.o app-layer-ssh.c
app-layer-ssh.c:164:5: warning: Value stored to 'input' is never read
    input += 1;
    ^        ~
app-layer-ssh.c:165:5: warning: Value stored to 'input_len' is never read
    input_len -= 1;
    ^            ~
app-layer-ssh.c:212:13: warning: Value stored to 'ret' is never read
            ret = 0;
            ^     ~
3 warnings generated.

11 years agossh: add json logger
Victor Julien [Sat, 1 Mar 2014 22:12:29 +0000 (23:12 +0100)] 
ssh: add json logger

Sub module of eve-log, but can also run separately as ssh-json-log. Only
one at a time though.

11 years agossh: improve large and fragmented banner handling
Victor Julien [Sat, 1 Mar 2014 21:23:18 +0000 (22:23 +0100)] 
ssh: improve large and fragmented banner handling

Including tests.

11 years agossh: disable inspection in encrypted phase
Victor Julien [Sat, 1 Mar 2014 17:11:19 +0000 (18:11 +0100)] 
ssh: disable inspection in encrypted phase

When both sides of the session have completed the encryption setup,
flag the stream to disable detection.

11 years agossh: allow for space characters in the software version
Victor Julien [Sat, 1 Mar 2014 17:09:20 +0000 (18:09 +0100)] 
ssh: allow for space characters in the software version

Previously the software version would only contain up to the first
space.

E.g. in SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu3

It would contain "OpenSSH_4.7p1".

This patch changes the behavior to:

"OpenSSH_4.7p1 Debian-8ubuntu3"

11 years agossh: clean up flags
Victor Julien [Sat, 1 Mar 2014 16:32:27 +0000 (17:32 +0100)] 
ssh: clean up flags

11 years agossh: reenable ssh.protoversion keyword
Victor Julien [Sat, 1 Mar 2014 16:07:15 +0000 (17:07 +0100)] 
ssh: reenable ssh.protoversion keyword

11 years agossh: reenable ssh.softwareversion keyword
Victor Julien [Sat, 1 Mar 2014 15:59:26 +0000 (16:59 +0100)] 
ssh: reenable ssh.softwareversion keyword

11 years agossh: handle fragmented banner
Victor Julien [Sat, 1 Mar 2014 15:50:07 +0000 (16:50 +0100)] 
ssh: handle fragmented banner

Cleanups.

11 years agossh: server support, cleanups
Victor Julien [Sat, 1 Mar 2014 14:49:54 +0000 (15:49 +0100)] 
ssh: server support, cleanups