1 -- The getopt-functionality is loaded from pm3/getopt.lua
2 -- Have a look there for further details
3 getopt
= require('getopt')
5 dumplib
= require('html_dumplib')
6 local ansicolors
= require('ansicolors')
9 author
= 'Martin Holst Swende'
12 This script takes a dumpfile on EML (ASCII) format and produces a html based dump, which is a
13 bit more easily analyzed.
16 script run data_mf_eml2html -o dumpdata.eml
19 script run data_mf_eml2html [-i <file>] [-o <file>]
23 -i <file> Specifies the dump-file (input). If omitted, 'dumpdata.eml' is used
24 -o <filename> Speciies the output file. If omitted, <curdate>.html is used.
29 local DEBUG
= false -- the debug flag
31 -- A debug printout-function
32 local function dbg(args
)
33 if not DEBUG
then return end
34 if type(args
) == 'table' then
45 -- This is only meant to be used when errors occur
46 local function oops(err
)
47 print('[!!] ERROR:', err
)
48 core
.clearCommandBuffer()
58 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
60 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
62 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
66 local function main(args
)
68 local input
= 'dumpdata.eml'
69 local output
= os
.date('%Y-%m-%d_%H%M%S.html');
70 for o
, a
in getopt
.getopt(args
, 'i:o:h') do
71 if o
== 'h' then return help() end
72 if o
== 'i' then input
= a
end
73 if o
== 'o' then output
= a
end
75 local filename
, err
= dumplib
.convert_eml_to_html(input
,output
)
76 if err
then return oops(err
) end
78 print(('[+] Wrote a HTML dump to the file %s'):format(filename
))
82 In the future, we may implement so that scripts are invoked directly
83 into a 'main' function, instead of being executed blindly. For future
84 compatibility, I have done so, but I invoke my main from here.