]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
output-lua: add example packet log script
authorVictor Julien <victor@inliniac.net>
Thu, 20 Feb 2014 08:39:24 +0000 (09:39 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 15 Aug 2014 11:58:25 +0000 (13:58 +0200)
Example packet log script that outputs to stdout in the alert-
fast log format.

lua/fast.lua [new file with mode: 0644]

diff --git a/lua/fast.lua b/lua/fast.lua
new file mode 100644 (file)
index 0000000..4cb0e30
--- /dev/null
@@ -0,0 +1,38 @@
+-- simple fast-log to stdout lua module
+
+function init (args)
+    local needs = {}
+    needs["type"] = "packet"
+    needs["filter"] = "alerts"
+    return needs
+end
+
+function setup (args)
+    alerts = 0
+end
+
+function log(args)
+    sid = args['sid'];
+    rev = args['rev'];
+    gid = args['gid'];
+    msg = args['msg'];
+    srcip = args['srcip'];
+    dstip = args['dstip'];
+    ts = args['ts'];
+    class = args['class'];
+    prio = args['priority'];
+    proto = args['ipproto'];
+    sp = args['sp'];
+    dp = args['dp'];
+
+    print (ts .. "  [**] [" .. gid .. ":" .. sid .. ":" .. rev .. "] " ..
+           msg .. " [**] [Classification: " .. class .. "] [Priority: " ..
+           prio .. "] {" .. proto .. "} " ..
+           srcip .. ":" .. sp .. " -> " .. dstip .. ":" .. dp)
+
+    alerts = alerts + 1;
+end
+
+function deinit (args)
+    print ("Alerted " .. alerts .. " times");
+end