Skip to content

Instantly share code, notes, and snippets.

@inliniac
Created July 12, 2016 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inliniac/083dd01b3c4ce91180448b45d7d6e35d to your computer and use it in GitHub Desktop.
Save inliniac/083dd01b3c4ce91180448b45d7d6e35d to your computer and use it in GitHub Desktop.
QA smtp lua script
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