]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
10 years agoCUDA: Update the inspection engine to inform the cuda module that it 1171/head
Anoop Saldanha [Fri, 25 Jul 2014 07:50:28 +0000 (13:20 +0530)] 
CUDA: Update the inspection engine to inform the cuda module that it
doesn't need the gpu results and to release the packet for the next run.

Previously the inspection engine wouldn't inform the cuda module, if it
didn't need the results.  As a consequence, when the packet is next taken
for re-use, and if the packet is still being processed by the cuda module,
the engine would wait till the cuda module frees the packet.

This commits updates this functionality to inform the cuda module to
release the packet for the afore-mentioned case.

10 years agoCheck replist is not NULL inline before doing any processing.
Ken Steele [Fri, 17 Oct 2014 15:42:48 +0000 (11:42 -0400)] 
Check replist is not NULL inline before doing any processing.

The replist is often NULL, so it is worth checking that case before making
the function call do perform work on the list.

10 years agodetect-dce-opnum: add sanity check
Eric Leblond [Wed, 15 Oct 2014 17:38:20 +0000 (19:38 +0200)] 
detect-dce-opnum: add sanity check

Specifying the option dce_opnum without value was triggering a
segfault.

10 years agoFix typo in configure message about nfnetlink
Ken Steele [Thu, 2 Oct 2014 21:17:02 +0000 (17:17 -0400)] 
Fix typo in configure message about nfnetlink

10 years agopcap-log: add option to honor pass rules
Victor Julien [Mon, 4 Aug 2014 13:36:42 +0000 (15:36 +0200)] 
pcap-log: add option to honor pass rules

Add option (disabled by default) to honor pass rules. This means that
when a pass rule matches in a flow, it's packets are no longer stored
by the pcap-log module.

10 years agoBug 1230: Check all SigMatch lists for a named byte_extract variable.
Jason Ish [Mon, 29 Sep 2014 16:00:06 +0000 (10:00 -0600)] 
Bug 1230: Check all SigMatch lists for a named byte_extract variable.

10 years agoBug 1230: Simple test case demonstrating failure.
Jason Ish [Mon, 29 Sep 2014 15:37:03 +0000 (09:37 -0600)] 
Bug 1230: Simple test case demonstrating failure.

10 years agoSuppress ARM valgrind warning
Victor Julien [Sat, 18 Oct 2014 19:47:52 +0000 (21:47 +0200)] 
Suppress ARM valgrind warning

Not Suricata related, so suppress.

10 years agoSpeed up SigMatchGetLastSMFromLists()
Ken Steele [Tue, 7 Oct 2014 14:17:21 +0000 (10:17 -0400)] 
Speed up SigMatchGetLastSMFromLists()

SigMatchGetLastSMFromLists() is finding the sm with the largest
index among all of the values returned from SigMatchGetLastSM() on
the set of (list and type) tuples passed as arguments.

The function was creating an array of the types, then creating an array
of the results of SigMatchGetLastSM(), sorting that list completely, then
only returning the first values from the list.

The new code, gets one set of arguments from the variable arguments, calls
SigMatchGetLastSM() and if the returned sm has a larger index, keeps that
as the last sm.

10 years agotcp session reuse: reset detect state 1153/head
Victor Julien [Tue, 7 Oct 2014 09:27:54 +0000 (11:27 +0200)] 
tcp session reuse: reset detect state

Reset the detect state on TCP session reuse. We reset the app layer,
so we need to reset the stateful detection as well.

10 years agodetect state: always lock de_state_m
Victor Julien [Tue, 7 Oct 2014 09:25:25 +0000 (11:25 +0200)] 
detect state: always lock de_state_m

Always lock the de_state_m on access, also at flow recycle or
cleanup.

10 years agoconfigure.ac: Moved libpcap before libpfring
Mats Klepsland [Wed, 1 Oct 2014 15:33:58 +0000 (17:33 +0200)] 
configure.ac: Moved libpcap before libpfring

Moved the libpcap section in configure.ac before libpfring to
enable libpfring to use the specified libpcap includes and
libraries when testing for libpfring support.

Bug #1294

10 years agorunmode-pfring: Fixed typo s/fron/from/
Mats Klepsland [Wed, 1 Oct 2014 14:39:48 +0000 (16:39 +0200)] 
runmode-pfring: Fixed typo s/fron/from/

10 years agorunmode-pfring: Suppress errors when using DNA/ZC
Mats Klepsland [Wed, 1 Oct 2014 14:34:30 +0000 (16:34 +0200)] 
runmode-pfring: Suppress errors when using DNA/ZC

PF_RING DNA/ZC don't use cluster-id and cluster-type. Therefore,
skip setting these values if DNA/ZC is being used.

Bug #1048

10 years agolua detect: expose stream payload
Victor Julien [Wed, 24 Sep 2014 14:05:27 +0000 (16:05 +0200)] 
lua detect: expose stream payload

Allow a script to set the 'stream' buffer type. This will add the
script to the PMATCH list.

Example script:
alert tcp any any -> any any (content:"html"; lua:stream.lua; sid:1;)

    function init (args)
        local needs = {}
        needs["stream"] = tostring(true)
        return needs
    end

    -- return match via table
    function match(args)
        local result = {}

        b = tostring(args["stream"])
        o = tostring(args["offset"])

        bo = string.sub(b, o);
        print (bo)

        return result
    end

    return 0

10 years agoComment out in the action-order section, as its not needed if
Jason Ish [Wed, 17 Sep 2014 17:55:29 +0000 (11:55 -0600)] 
Comment out in the action-order section, as its not needed if
the default configuration is used.

10 years agoDon't require an action-order configuration section. If not present,
Jason Ish [Wed, 17 Sep 2014 17:52:12 +0000 (11:52 -0600)] 
Don't require an action-order configuration section. If not present,
use the defaults.

10 years agofilestore: fix parsing bug
Victor Julien [Tue, 30 Sep 2014 07:56:41 +0000 (09:56 +0200)] 
filestore: fix parsing bug

Filestore keyword can have options or no options, and the parser
was enforcing the NOOPT flag too strictly.

Bug #1288

10 years agoflow json log: add 'shutdown' as flow end reason 1143/head
Victor Julien [Wed, 1 Oct 2014 07:09:15 +0000 (09:09 +0200)] 
flow json log: add 'shutdown' as flow end reason

When engine shuts down all flows in the hash are logged out. They
may not have timed out yet. So they are forced. Log the reason to
be 'shutdown'.

10 years agoflow: fix flow logging at shutdown
Victor Julien [Tue, 30 Sep 2014 13:24:24 +0000 (15:24 +0200)] 
flow: fix flow logging at shutdown

Move all flows from the hash to the recycler at shutdown.

Bug #1260

10 years agooutput-lua: set proper callbacks for HTTP 1142/head
Victor Julien [Tue, 30 Sep 2014 11:37:30 +0000 (13:37 +0200)] 
output-lua: set proper callbacks for HTTP

Enable the relevant HTTP callbacks.

Bug #1287

10 years agooutput-lua: add config to yaml
Victor Julien [Tue, 30 Sep 2014 11:27:52 +0000 (13:27 +0200)] 
output-lua: add config to yaml

Disabled by default.

10 years agooutput-lua: add script-dir config param
Victor Julien [Tue, 30 Sep 2014 11:19:09 +0000 (13:19 +0200)] 
output-lua: add script-dir config param

Add 'scripts-dir' config directive that is prepended to the script
names to form a path. If ommited or empty, script are opened from
the CWD.

10 years agoyaml: add eve flow and netflow entries
Victor Julien [Tue, 30 Sep 2014 09:12:47 +0000 (11:12 +0200)] 
yaml: add eve flow and netflow entries

Added, commented out by default.

Bug #1257.

10 years agossh: convert error message to debug statement
Victor Julien [Thu, 18 Sep 2014 08:13:18 +0000 (10:13 +0200)] 
ssh: convert error message to debug statement

Don't print errors based on traffic issues.

10 years agoapp-layer-ssh: fix banner parser
Eric Leblond [Fri, 12 Sep 2014 08:02:12 +0000 (10:02 +0200)] 
app-layer-ssh: fix banner parser

Carefully crafted SSH banner could result in parser error.

Signed-off-by: Eric Leblond <eric@regit.org>
10 years agoipv6: convert ext header pointers to const
Victor Julien [Wed, 17 Sep 2014 12:57:15 +0000 (14:57 +0200)] 
ipv6: convert ext header pointers to const

To prevent accidental writes into the orignal packet buffer, use
const pointers for the extension header pointers used by IPv6. This
will cause compiler warnings in case of writes.

10 years agoipv6: RH extension header parsing issue
Victor Julien [Wed, 17 Sep 2014 12:26:27 +0000 (14:26 +0200)] 
ipv6: RH extension header parsing issue

A logic error in the IPv6 Routing header parsing caused accidental
updating of the original packet buffer. The calculated extension
header lenght was set to the length field of the routing header,
causing it to be wrong.

This has 2 consequences:

1. defrag failure. As the now modified payload was used in defrag,
the decoding of the reassembled packet now contained a broken length
field for the routing header. This would lead to decoding failure.

The potential here is evasion, although it would trigger:
[1:2200014:1] SURICATA IPv6 truncated extension header

2. in IPS mode, especially the AF_PACKET mode, the modified and now
broken packet would be transmitted on the wire. It's likely that
end hosts and/or routers would reject this packet.

NFQ based IPS mode would be less affected, as it 'verdicts' based on
the packet handle. In case of replacing the packet (replace keyword
or stream normalization) it could broadcast the bad packet.

Additionally, the RH Type 0 address parsing was also broken. It too
would modify the original packet. As the result of this code was not
used anywhere else in the engine, this code is now disabled.

Reported-By: Rafael Schaefer <rschaefer@ernw.de>
10 years agoaf-packet: check pointers before use
Victor Julien [Mon, 22 Sep 2014 15:33:40 +0000 (17:33 +0200)] 
af-packet: check pointers before use

10 years agoaf-packet: force suricata in IPS mode when needed
Eric Leblond [Fri, 19 Sep 2014 14:54:00 +0000 (16:54 +0200)] 
af-packet: force suricata in IPS mode when needed

AF_PACKET is not setting the engine mode to IPS when some
interfaces are peered and use IPS mode. This is due to the
fact, it is possible to peer 2 interfaces and run an IPS on
them and have a third one that is running in normal IDS mode.

In fact this choice is the bad one as unwanted side effect is
that there is no drop log and that stream inline is not used.

To fix that, this patch puts suricata in IPS mode as soon as
there is two interfaces in IPS mode. And it displays a error
message to warn user that the accuracy of detection on IDS only
interfaces will be low.

10 years agorule parser: set flag for optionless keywords 1128/head
Victor Julien [Fri, 19 Sep 2014 11:39:37 +0000 (13:39 +0200)] 
rule parser: set flag for optionless keywords

If a keyword doesn't have an argument, it should set the SIGMATCH_NOOPT
flag so the parser knows.

10 years agorule parser: fix crashing on malformed options
Victor Julien [Fri, 19 Sep 2014 11:38:47 +0000 (13:38 +0200)] 
rule parser: fix crashing on malformed options

Fix crashing on malformed rule options like 'rev;1;'.

Bug 1254.

10 years agodetect: fix continue detection with amatch and tx 1126/head
Victor Julien [Thu, 18 Sep 2014 13:13:13 +0000 (15:13 +0200)] 
detect: fix continue detection with amatch and tx

When using AMATCH, continue detection would fail if the tx part
had already run. This lead to start detection rerunning, causing
multiple alerts for the same issue.

10 years agolua: fix http.request_line inspection
Victor Julien [Thu, 18 Sep 2014 11:37:18 +0000 (13:37 +0200)] 
lua: fix http.request_line inspection

As there is no inspection engine for request_line, the sigmatch was
added to the AMATCH list. However, no AppLayerMatch function for
lua scripts was defined.

This patch defines a AppLayerMatch function.

Bug #1273.

10 years agotls: fix a tls.fingerprint issue in debug mode
Victor Julien [Fri, 19 Sep 2014 08:40:20 +0000 (10:40 +0200)] 
tls: fix a tls.fingerprint issue in debug mode

Print proper variable so we don't NULL-deref.

Bug #1279.

10 years agosource-nfq: fix display of next queue
Eric Leblond [Tue, 2 Sep 2014 13:33:34 +0000 (15:33 +0200)] 
source-nfq: fix display of next queue

Suricata was displaying an invalid queue number as the value is
shift at the moment of its assignement.

10 years agosuricatasc: add -c flag to run command 1122/head
Eric Leblond [Sat, 6 Sep 2014 09:46:21 +0000 (11:46 +0200)] 
suricatasc: add -c flag to run command

Add -c flag to run command given as argument and return the raw
JSON result. For example, it is possible to run something like.
 $ suricatasc  -c "iface-stat eth0"
 {'message': {'pkts': 17838352, 'drop': 0, 'invalid-checksums': 1}, 'return': 'OK'}

10 years agosuricatasc: factorize command parsing
Eric Leblond [Sat, 6 Sep 2014 09:37:20 +0000 (11:37 +0200)] 
suricatasc: factorize command parsing

10 years agoBug fix: IPv6 addresses in negated range and IPv6 string into radix tree.
bmeeks8 [Fri, 5 Sep 2014 13:22:11 +0000 (09:22 -0400)] 
Bug fix: IPv6 addresses in negated range and IPv6 string into radix tree.

I found three somewhat serious IPv6 address bugs within the Suricata 2.0.x source code. Two are in the source module "detect-engine-address.c", and the third is in "util-radix-tree.c".

The first bug occurs within the function DetectAddressParse2(). When parsing an address string and a negated block is encountered (such as when parsing !$HOME_NET, for example), any corresponding IPv6 addresses were not getting added to the Group Heads in the DetectAddressList. Only IPv4 addresses were being added.

I discovered another bug related to IPv6 address ranges in the Signature Match Address Array comparison code for IPv6 addresses. The function DetectAddressMatchIPv6() walks a signature's source or destination match address list comparing each to the current packet's corresponding address value. The match address list consists of value pairs representing a lower and upper IP address range. If the packet's address is within that range (including equal to either the lower or upper bound), then a signature match flag is returned.

The original test of each signature match address to the packet was performed using a set of four compounded AND comparisons looking at each of the four 32-bit blocks that comprise an IPv6 address. The problem with the old comparison is that if ANY of the four 32-bit blocks failed the test, then a "no-match" was returned. This is incorrect. If one or more of the more significant 32-bit blocks met the condition, then it is a match no matter if some of the less significant 32-bit blocks did not meet the condition. Consider this example where Packet represents the packet address being checked, and Target represents the upper bound of a match address pair. We are testing if Packet is less than Target.

Packet -- 2001:0470 : 1f07:00e2 : 1988:01f1 : d468:27ab
Target -- 2001:0470 : 1f07:00e2 : a48c:2e52 : d121:101e

In this example the Packet's address is less than the target and it should give a match. However, the old code would compare each 32-bit block (shown spaced out above for clarity) and logically AND the result with the next least significant block comparison. If any of the four blocks failed the comparison, that kicked out the whole address. The flaw is illustrated above. The first two blocks are 2001:0470 and 1f07:00e2 and yield TRUE; the next less significant block is 1988:01f1 and a48c:2e52, and also yields TRUE (that is, Packet is less than Target); but the last block compare is FALSE (d468:27ab is not less than d121:101e). That last block is the least significant block, though, so its FALSE determination should not invalidate a TRUE from any of the more significant blocks. However, in the previous code using the compound logical AND block, that last least significant block would invalidate the tests done with the more significant blocks.

The other bug I found for IPv6 occurs when trying to parse and insert an IPv6 address into a Radix Tree using the function SCRadixAddKeyIPV6String(). The test for min and max values for an IPv6 CIDR mask incorrectly tests the upper limit as 32 when it should be 128 for an IPv6 address. I think this perhaps is an old copy-paste error if the IPv6 version of this function was initially copied from the corresponding IPv4 version directly above it in the code. Without this patch, the function will return null when you attempt to add an IPv6 network whose CIDR mask is larger than 32 (for example, the popular /64 mask will cause the function to return the NULL error condition).

(amended by Victor Julien)

10 years agolua: export packet keywords to detect scripts 1112/head
Victor Julien [Fri, 15 Aug 2014 12:04:44 +0000 (14:04 +0200)] 
lua: export packet keywords to detect scripts

Set packet pointer, so it's available to the lua keywords that
require it.

10 years agodetect-lua: register all 'output' keywords as well
Victor Julien [Thu, 14 Aug 2014 14:37:37 +0000 (16:37 +0200)] 
detect-lua: register all 'output' keywords as well

Register all keywords available to output scripts to the detect
scripts as well.

10 years agodetect-lua: set tx ptr
Victor Julien [Thu, 14 Aug 2014 14:33:37 +0000 (16:33 +0200)] 
detect-lua: set tx ptr

Set tx ptr so it can be used later by other keywords.

10 years agodetect: track current tx_id in det_ctx
Victor Julien [Thu, 14 Aug 2014 14:21:38 +0000 (16:21 +0200)] 
detect: track current tx_id in det_ctx

When using the inspection engines, track the current tx_id in the
thread storage the detect thread uses. As 0 is a valid tx_id, add
a simple bool that indicates if the tx_id field is set.

10 years agolua: move lua output code to generic lua file
Victor Julien [Tue, 5 Aug 2014 07:58:48 +0000 (09:58 +0200)] 
lua: move lua output code to generic lua file

So that other Lua scripts (detect) can also start using it.

10 years agolua: remove LogLua prefix and replace it with Lua
Victor Julien [Tue, 5 Aug 2014 07:26:59 +0000 (09:26 +0200)] 
lua: remove LogLua prefix and replace it with Lua

Preparing making code available to more than just output.

10 years agolua: move output http funcs to generic util file
Victor Julien [Mon, 4 Aug 2014 15:47:47 +0000 (17:47 +0200)] 
lua: move output http funcs to generic util file

Move output Http functions to util-lua-http.c so that detect can use
it later.

10 years agoRename Lua code to just Lua
Victor Julien [Fri, 1 Aug 2014 14:29:53 +0000 (16:29 +0200)] 
Rename Lua code to just Lua

As we support regular Lua as well as LuaJIT, it makes more sense to call
it all Lua.

10 years agolua: use LuaPushStringBuffer in more places
Victor Julien [Fri, 1 Aug 2014 13:34:37 +0000 (15:34 +0200)] 
lua: use LuaPushStringBuffer in more places

Replace existing workarounds with LuaPushStringBuffer

10 years agolua: LuaPushStringBuffer optimization
Victor Julien [Fri, 1 Aug 2014 10:41:17 +0000 (12:41 +0200)] 
lua: LuaPushStringBuffer optimization

Only use a temp buffer when really necessary, which is when the
buffer size is not a multiple of 4.

10 years agolua: move LuaPushStringBuffer to the generic util-lua.c
Victor Julien [Fri, 1 Aug 2014 10:32:38 +0000 (12:32 +0200)] 
lua: move LuaPushStringBuffer to the generic util-lua.c

10 years agolua: rename LuaReturnStringBuffer to LuaPushStringBuffer
Victor Julien [Fri, 1 Aug 2014 10:29:17 +0000 (12:29 +0200)] 
lua: rename LuaReturnStringBuffer to LuaPushStringBuffer

LuaPushStringBuffer is a wrapper for lua_pushlstring, so the new name
better reflects it's function.

10 years agooutput-lua: add SCFlowStats
Victor Julien [Thu, 31 Jul 2014 16:02:40 +0000 (18:02 +0200)] 
output-lua: add SCFlowStats

SCFlowStats gets the packet and byte counts per flow:
    tscnt, tsbytes, tccnt, tcbytes = SCFlowStats()

10 years agooutput lua: expose flow logging api
Victor Julien [Tue, 29 Jul 2014 15:36:42 +0000 (17:36 +0200)] 
output lua: expose flow logging api

Allow use of the Flow Logging API through Lua scripts.

Minimal script:

function init (args)
    local needs = {}
    needs["type"] = "flow"
    return needs
end

function setup (args)
end

function log(args)
    startts = SCFlowTimeString()
    ipver, srcip, dstip, proto, sp, dp = SCFlowTuple()
    print ("Flow IPv" .. ipver .. " src " .. srcip .. " dst " .. dstip ..
            " proto " .. proto .. " sp " .. sp .. " dp " .. dp)
end

function deinit (args)
end

10 years agolua-output: add SCStreamingBuffer
Victor Julien [Wed, 25 Jun 2014 13:25:53 +0000 (15:25 +0200)] 
lua-output: add SCStreamingBuffer

Add SCStreamingBuffer lua function to retrieve the data passed
to the script per streaming API invocation.

Example:

    function log(args)
        data = SCStreamingBuffer()
        hex_dump(data)
    end

10 years agooutput-lua: add support for streaming api
Victor Julien [Tue, 24 Jun 2014 20:40:33 +0000 (22:40 +0200)] 
output-lua: add support for streaming api

Add support to lua output for the streaming api. This allows for a
script to subscribe itself to streaming tcp data and http body data.

10 years agooutput-lua: give access to packet payload
Victor Julien [Wed, 2 Apr 2014 22:09:57 +0000 (00:09 +0200)] 
output-lua: give access to packet payload

Add SCPacketPayload()

Example:
    function log(args)
        p = SCPacketPayload()
        print(p)
    end

10 years agooutput-lua: expose http body data
Victor Julien [Mon, 31 Mar 2014 13:05:15 +0000 (15:05 +0200)] 
output-lua: expose http body data

Make normalized body data available to the script through
HttpGetRequestBody and HttpGetResponseBody.

There no guarantees that all of the body will be availble.

Example:
    function log(args)
        a, o, e = HttpGetResponseBody();
        --print("offset " .. o .. " end " .. e)

        for n, v in ipairs(a) do
            print(v)
        end
    end

10 years agooutput-lua: add HttpGetRequestHost callback
Victor Julien [Fri, 28 Mar 2014 16:24:22 +0000 (17:24 +0100)] 
output-lua: add HttpGetRequestHost callback

Get the host from libhtp's tx->request_hostname, which can either be
the host portion of the url or the host portion of the Host header.

Example:

    http_host = HttpGetRequestHost()
    if http_host == nil then
        http_host = "<hostname unknown>"
    end

10 years agooutput-lua: http alproto check
Victor Julien [Fri, 21 Mar 2014 21:26:28 +0000 (22:26 +0100)] 
output-lua: http alproto check

10 years agooutput-lua: clean up flow lock handling
Victor Julien [Fri, 21 Mar 2014 21:26:37 +0000 (22:26 +0100)] 
output-lua: clean up flow lock handling

10 years agooutput-lua: alproto string callback
Victor Julien [Fri, 21 Mar 2014 13:25:04 +0000 (14:25 +0100)] 
output-lua: alproto string callback

SCFlowAppLayerProto: get alproto as string from the flow. If alproto
is not (yet) known, it returns "unknown".

    function log(args)
        alproto = SCFlowAppLayerProto()
        if alproto ~= nil then
            print (alproto)
        end
    end

10 years agooutput-lua: expose thread info
Victor Julien [Fri, 21 Mar 2014 08:40:54 +0000 (09:40 +0100)] 
output-lua: expose thread info

A new callback to give access to thread id, name and group name:
SCThreadInfo. It gives: tid (integer), tname (string), tgroup (string)

    function log(args)
        tid, tname, tgroup = SCThreadInfo()

10 years agooutput-lua: expose flow start time string
Victor Julien [Wed, 19 Mar 2014 17:38:29 +0000 (18:38 +0100)] 
output-lua: expose flow start time string

SCFlowTimeString: returns string form of start time of a flow

Example:

    function log(args)
        startts = SCFlowTimeString()
        ts = SCPacketTimeString()
        if ts == startts then
            print("new flow")
        end

10 years agooutput-lua: add file callbacks
Victor Julien [Wed, 19 Mar 2014 15:13:38 +0000 (16:13 +0100)] 
output-lua: add file callbacks

SCFileInfo: returns fileid (number), txid (number), name (string),
            size (number), magic (string), md5 in hex (string)

Example:

    function log(args)
        fileid, txid, name, size, magic, md5 = SCFileInfo()

SCFileState: returns state (string), stored (bool)

Example:
    function log(args)
        state, stored = SCFileState()

10 years agooutput-lua: add SCPacketTimeString
Victor Julien [Wed, 19 Mar 2014 11:36:01 +0000 (12:36 +0100)] 
output-lua: add SCPacketTimeString

Add SCPacketTimeString to get the packets time string in the format:
    11/24/2009-18:57:25.179869

Example use:

    function log(args)
        ts = SCPacketTimeString()

10 years agooutput-lua: rule info callback
Victor Julien [Mon, 17 Mar 2014 17:44:09 +0000 (18:44 +0100)] 
output-lua: rule info callback

SCRuleIds(): returns sid, rev, gid:

    function log(args)
        sid, rev, gid = SCRuleIds()

SCRuleMsg(): returns msg

    function log(args)
        msg = SCRuleMsg()

SCRuleClass(): returns class msg and prio:

    function log(args)
        class, prio = SCRuleClass()
        if class == nil then
            class = "unknown"
        end

10 years agolua: add SCFlowTuple lua function
Victor Julien [Fri, 14 Mar 2014 13:16:47 +0000 (14:16 +0100)] 
lua: add SCFlowTuple lua function

Like SCPacketTuple, only retrieves Tuple from the flow.

Minimal log function:

    function log(args)
        ipver, srcip, dstip, proto, sp, dp = SCFlowTuple()
        print ("Flow IPv" .. ipver .. " src " .. srcip .. " dst " .. dstip ..
               " proto " .. proto .. " sp " .. sp .. " dp " .. dp)
    end

10 years agodetect-lua: convert extensions to use flow wrappers
Victor Julien [Mon, 3 Mar 2014 13:11:00 +0000 (14:11 +0100)] 
detect-lua: convert extensions to use flow wrappers

Use the new flow wrapper functions in the lua flowvar and flowint
extensions.

10 years agolua: add flow store and retrieval wrappers
Victor Julien [Mon, 3 Mar 2014 13:09:18 +0000 (14:09 +0100)] 
lua: add flow store and retrieval wrappers

Add flow store and retrieval wrappers for accessing the flow through
Lua's lightuserdata method.

The flow functions store/retrieve a lock hint as well.

10 years agolua: introduce util-lua.[ch]
Victor Julien [Fri, 28 Feb 2014 15:18:48 +0000 (16:18 +0100)] 
lua: introduce util-lua.[ch]

Shared functions for all lua parts of the engine.

10 years agooutput-lua: add all packets logging support
Victor Julien [Mon, 24 Feb 2014 16:08:44 +0000 (17:08 +0100)] 
output-lua: add all packets logging support

If the script needing a packet doesn't specify a filter, it will
be run against all packets. This patch adds the support for this
mode. It is a packet logger with a condition function that always
returns true.

10 years agooutput-lua: improve error checking for init()
Victor Julien [Mon, 24 Feb 2014 15:41:27 +0000 (16:41 +0100)] 
output-lua: improve error checking for init()

If init doesn't properly init the script, skip the script and error
out.

10 years agooutput-log: expose SCLog functions to lua scripts
Victor Julien [Fri, 21 Feb 2014 11:20:46 +0000 (12:20 +0100)] 
output-log: expose SCLog functions to lua scripts

The lua scripts can use SCLogDebug, SCLogInfo, SCLogNotice, SCLogWarning,
SCLogError. The latter 2 won't be able to add an error code though.

10 years agooutput-lua: make packet ptr available to all scripts
Victor Julien [Fri, 21 Feb 2014 09:17:16 +0000 (10:17 +0100)] 
output-lua: make packet ptr available to all scripts

TxLogger and Packet logger need it to be able to use the Tuple
callback.

10 years agooutput-lua: add SCLogPath callback
Victor Julien [Fri, 21 Feb 2014 08:37:39 +0000 (09:37 +0100)] 
output-lua: add SCLogPath callback

Add a lua callback for getting Suricata's log path, so that lua scripts
can easily get the logging directory Suricata uses.

Update the Setup logic to register callbacks before the scripts 'setup'
is called.

Example:

    name = "fast_lua.log"
    function setup (args)
        filename = SCLogPath() .. "/" .. name
        file = assert(io.open(filename, "a"))
    end

10 years agooutput-lua: TxLogger use proper stack function
Victor Julien [Fri, 21 Feb 2014 08:00:42 +0000 (09:00 +0100)] 
output-lua: TxLogger use proper stack function

Use proper wrapper to setup the stack.

10 years agooutput-lua: improve error handling and documentation
Victor Julien [Thu, 20 Feb 2014 16:58:15 +0000 (17:58 +0100)] 
output-lua: improve error handling and documentation

Better document the various functions and improve error handling.

10 years agooutput-lua: register common callbacks
Victor Julien [Thu, 20 Feb 2014 16:55:15 +0000 (17:55 +0100)] 
output-lua: register common callbacks

Clean up callback registration in the setup-stage and register
common callbacks.

10 years agooutput-lua: support File logging
Victor Julien [Thu, 20 Feb 2014 16:51:47 +0000 (17:51 +0100)] 
output-lua: support File logging

Add file logger support. The script uses:

function init (args)
    local needs = {}
    needs['type'] = 'file'
    return needs
end

The type is set to file to make it a file logger.

10 years agooutput-lua: rename LuaPacketLogger to ..Alerts
Victor Julien [Thu, 20 Feb 2014 16:49:51 +0000 (17:49 +0100)] 
output-lua: rename LuaPacketLogger to ..Alerts

As the script is called for each alert, not for each packet, name
the script LuaPacketLoggerAlerts.

10 years agooutput-lua: add stack utility functions
Victor Julien [Thu, 20 Feb 2014 14:57:00 +0000 (15:57 +0100)] 
output-lua: add stack utility functions

Add utility functions for placing things on the stack for use
by the scripts. Functions for numbers, strings and byte arrays.

Add callback for returing IP header info: ip version, src ip,
dst ip, proto, sp, dp (or type and code for icmp and icmpv6):
SCPacketTuple

10 years agooutput-lua: initial packet support
Victor Julien [Thu, 20 Feb 2014 14:47:50 +0000 (15:47 +0100)] 
output-lua: initial packet support

Add key for storing packet pointer in the lua stack and a utility
function to retrieve it from lua callbacks.

10 years agooutput-lua: move LuaPrintStack to common
Victor Julien [Thu, 20 Feb 2014 14:45:33 +0000 (15:45 +0100)] 
output-lua: move LuaPrintStack to common

It's a utility function that will be used in several other places
as well.

10 years agooutput-lua: add example packet log script
Victor Julien [Thu, 20 Feb 2014 08:39:24 +0000 (09:39 +0100)] 
output-lua: add example packet log script

Example packet log script that outputs to stdout in the alert-
fast log format.

10 years agooutput-lua: packet logger support
Victor Julien [Thu, 20 Feb 2014 08:36:16 +0000 (09:36 +0100)] 
output-lua: packet logger support

Through 'needs' the script init function can indicate it wants to
see packets and select a condition function. Currently only alerts
is an option:

    function init (args)
        local needs = {}
        needs["type"] = "packet"
        needs["filter"] = "alerts"
        return needs
    end

10 years agooutput-lua: new file for common functions
Victor Julien [Wed, 19 Feb 2014 12:49:35 +0000 (13:49 +0100)] 
output-lua: new file for common functions

Add output-lua-common.[ch] to store functions common to various parts
of the lua output framework.

10 years agooutput: Lua HTTP log initial implementation
Victor Julien [Tue, 11 Feb 2014 13:44:21 +0000 (14:44 +0100)] 
output: Lua HTTP log initial implementation

Initial version of a HTTP LUA logger. Execute lua scripts from the
Tx-log API.

10 years agooutput-lua: support submodules
Victor Julien [Wed, 19 Feb 2014 11:52:03 +0000 (12:52 +0100)] 
output-lua: support submodules

Use the OutputCtx::submodules list to register additional log modules.
Currently this is hardcoded to the 'lua' module.

10 years agooutput-lua: display warning if no lua support
Victor Julien [Wed, 19 Feb 2014 11:50:57 +0000 (12:50 +0100)] 
output-lua: display warning if no lua support

Display a warning that the lua module is not available if we're
not compiled against lua(jit).

10 years agooutput: add submodules list to OutputCtx
Victor Julien [Wed, 19 Feb 2014 11:46:50 +0000 (12:46 +0100)] 
output: add submodules list to OutputCtx

Add a list to the OutputCtx that can contain OutputModule structures.
This will be used by a 'parent' module to register submodules directly.

10 years agostreaming: pass tx_id to logger
Victor Julien [Wed, 18 Jun 2014 10:15:58 +0000 (12:15 +0200)] 
streaming: pass tx_id to logger

This way we can distinguish between various tx' in the logger.

10 years agostreaming-loggers: add configuration
Victor Julien [Tue, 17 Jun 2014 15:49:05 +0000 (17:49 +0200)] 
streaming-loggers: add configuration

Add a (disabled by default) config to the yaml

10 years agotcp-data-log: file and dir logging modes
Victor Julien [Fri, 13 Jun 2014 10:05:33 +0000 (12:05 +0200)] 
tcp-data-log: file and dir logging modes

Add a file logging mode, which logs all the data into a single log file.

Also, make the directory logging more configurable.

11 years agotcp-data: new streaming logger
Victor Julien [Sat, 5 Apr 2014 08:02:38 +0000 (10:02 +0200)] 
tcp-data: new streaming logger

tcp-data logs out reassembled stream data in a streaming fashion.

Records type to log into different directories.

11 years agostreaming logger: support Http Body logging
Victor Julien [Thu, 12 Jun 2014 09:42:00 +0000 (11:42 +0200)] 
streaming logger: support Http Body logging

Add an argument to the registration to indicate which iterator
needs to be used: Stream or HttpBody

Add HttpBody Iterator, calling the logger(s) for each Http body chunk.

11 years agooutput-streaming: StreamIterator
Victor Julien [Sat, 5 Apr 2014 08:00:27 +0000 (10:00 +0200)] 
output-streaming: StreamIterator

StreamIterator implementation for iterating over ACKed segments.

Flag each segment as logged when the log function has been called for it.

Set a 'OPEN' flag for the first segment in both directions.

Set a 'CLOSE' flag when the stream ends. If the last segment was already
logged, a empty CLOSE call is performed with NULL data.

11 years agooutput-streaming: a Log API for streaming data
Victor Julien [Fri, 4 Apr 2014 10:51:26 +0000 (12:51 +0200)] 
output-streaming: a Log API for streaming data

This patch adds a new Log API for streaming data such as TCP reassembled
data and HTTP body data. It could also replace Filedata API.

Each time a new chunk of data is available, the callback will be called.

11 years agoFix compiler warning about uninitialized variable in mpipe.
Ken Steele [Tue, 12 Aug 2014 23:57:41 +0000 (19:57 -0400)] 
Fix compiler warning about uninitialized variable in mpipe.

11 years agoSimple code fixes
Duarte Silva [Tue, 12 Aug 2014 17:13:52 +0000 (18:13 +0100)] 
Simple code fixes
- Removed unnecessary assignment of the data field
- Removed else condition (same function called for IPv4 and IPV6)
- Fixed constants to be a power of two (used in bitwise operations)

11 years agoOptimize Packet Ext data freeing
Victor Julien [Wed, 13 Aug 2014 14:33:50 +0000 (16:33 +0200)] 
Optimize Packet Ext data freeing

Move the logic of PacketFreeExtData into a macro 'PACKET_FREE_EXTDATA'.
It was called for each packet.