Skip to content

Instantly share code, notes, and snippets.

@inliniac
Created July 12, 2016 15:46
Show Gist options
  • Save inliniac/3097a919ffc5a67d4d7d6f2bee48b6b2 to your computer and use it in GitHub Desktop.
Save inliniac/3097a919ffc5a67d4d7d6f2bee48b6b2 to your computer and use it in GitHub Desktop.
Simple lua output script I use in QA
function init (args)
local needs = {}
needs["protocol"] = "smtp"
return needs
end
function setup (args)
smtp = 0
filename = SCLogPath() .. "/smtp-lua.log"
SCLogInfo(filename);
end
function log(args)
ts = SCPacketTimeString()
ipver, srcip, dstip, proto, sp, dp = SCFlowTuple()
file = assert(io.open(filename, "w"))
local a = SMTPGetMailFrom()
if (a) then
print(a)
end
local b = SMTPGetMimeField("x-mailer")
if(b) then
print(b)
end
local c = {}
c = SMTPGetRcptList()
for i, v in pairs(c) do
print(i, v)
end
local d = { }
d = SMTPGetMimeList()
for i, v in pairs(d) do
local e = SMTPGetMimeField(v)
print(i, v, e)
end
file:write ("SMTP::" .. a .. "::" .. b .. "::SMTP")
file:write("\n")
file:flush()
file.close(file)
smtp = smtp + 1
end
function deinit (args)
print ("SMTP transactions logged: " .. smtp);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment