Commit Graph

4929 Commits (238ff23111f78073c4ebefe9fc1de72ea54a74d3)
 

Author SHA1 Message Date
Eric Leblond 238ff23111 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 ago
Eric Leblond 919377d4a5 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 ago
Victor Julien 70efc66e33 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 ago
Victor Julien 1af39d55cf 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 ago
Victor Julien 010a334e1a json alert: fix action
It would give 'Pass' as an action when the rule is set to 'alert'.
11 years ago
Victor Julien e04b5f0dca 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 ago
Victor Julien 5d96ea570f 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 ago
Victor Julien 305da0248d 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 ago
Victor Julien 3e7714aca2 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 ago
Victor Julien c5041d35d5 Fix live reload
Fix memsets clearing out of bounds memory on live reload, causing
crashes and corrupted backtraces.

Bug #1128.
11 years ago
Victor Julien fdb1bd9668 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 ago
Victor Julien 845cbcce90 Update ChangeLog for 2.0rc2 release 11 years ago
Victor Julien 4436526a05 yaml: comment out example config
Comment out htp settings that should only serve as an example.
11 years ago
Victor Julien 3fa4712ab6 yaml: increase default memcaps
Increase default flow and stream reassembly memcaps.
11 years ago
Victor Julien 60a79c8220 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 ago
Victor Julien a3020b5306 eve-log: output cleanup
Suppress debug messages and print in a nicer way which modules are
being enabled.
11 years ago
Victor Julien ed877c64d1 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 ago
Eric Leblond 6c3c234ca5 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 ago
Eric Leblond 1fa4233d67 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 ago
Victor Julien 0f70e8f225 OpenBSD: set correct magic path
For all 5.x OpenBSDs it seems the magic path is:
    /usr/local/share/misc/magic.mgc
11 years ago
Eric Leblond cf30adcedc ipfw: fix build
Buildbot reported:
 runmode-ipfw.c: In function 'RunModeIpsIPFWAuto':
 runmode-ipfw.c:85: error: implicit declaration of function 'LiveDeviceHasNoStats'
11 years ago
Eric Leblond 606e19124b http: add info message about memcap
Display a message about http memcap when it is set in config file.
11 years ago
Victor Julien f00703acc1 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 ago
Victor Julien 00d2f2d627 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 ago
Victor Julien 88e9c85e36 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 ago
Victor Julien 872bb5664e 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 ago
Victor Julien 684d787567 Coverity fix
Coverity 992695, fix potential array index with negative int. Very unlikely
case at rule keyword parsing stage.
11 years ago
Victor Julien ddf9b417d7 configure: simplify OpenBSD handling
Treat all OpenBSD versions in the same way. No more -fgnu89-inline.
11 years ago
Victor Julien 1e21b9f5a9 Disable emerging-icmp in default config
The file has no active rules by default.
11 years ago
Victor Julien a746095569 make install-full: get correct version of ET
Version 2.0.
11 years ago
Victor Julien f6bb867df8 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 ago
Victor Julien 0967f0777c 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 ago
Victor Julien 669b351dad 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 ago
Victor Julien b877cf6158 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 ago
Victor Julien 65b228ccfd ssh: improve large and fragmented banner handling
Including tests.
11 years ago
Victor Julien b4aeb43af1 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 ago
Victor Julien 294ff49f6d 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 ago
Victor Julien b792234dd0 ssh: clean up flags 11 years ago
Victor Julien b5afe2b51f ssh: reenable ssh.protoversion keyword 11 years ago
Victor Julien 6c0162bf26 ssh: reenable ssh.softwareversion keyword 11 years ago
Victor Julien 884cecd9af ssh: handle fragmented banner
Cleanups.
11 years ago
Victor Julien 32fcdfe6eb ssh: server support, cleanups 11 years ago
Victor Julien 3648adb533 ssh: record parser 11 years ago
Victor Julien a3c9832b90 ssh: reenable parser as stub
Reenable the SSH parser. It now compiles, however the actual parsing
code is still disabled (commented out).
11 years ago
Eric Leblond e00b5ca191 classification: add category to some stream rules
All stream events signatures deserve a category.
11 years ago
Eric Leblond 79de8c8f4b runmode: remove unused variable.
default_mode_auto is not used anymore and can be removed.
11 years ago
Eric Leblond a6bb86a9e0 Exit if BPF filter file is specified in IPS mode
This patch adds a check that was missing when specifying BPF filter
from a file. Suricata behavior should have been the same as when
BPF filter is specified on command line.
11 years ago
Eric Leblond 941cfe1641 ipfw: fix operator error in test
Fix warning spotted by clang on FreeBSD:

source-ipfw.c:241:49: warning: use of logical '||' with constant operand [-Wconstant-logical-operand]
        if (suricata_ctl_flags & (SURICATA_STOP || SURICATA_KILL)) {
                                                ^  ~~~~~~~~~~~~~
source-ipfw.c:241:49: note: use '|' for a bitwise operation
        if (suricata_ctl_flags & (SURICATA_STOP || SURICATA_KILL)) {
                                                ^~
                                                |

Use same logic as the one used in other capture mode.
11 years ago
Eric Leblond 9f6527dc16 ipfw: improve exit message
This patch synchronizes the exit message with what is done in
NFQ capture mode.
11 years ago
Eric Leblond 1c48a81f91 ipfw: update running modes to hide device stats
This patch adds call to the function used to disable the display
of live device stats at exit.
11 years ago