text
[RRG-proxmark3.git] / client / luascripts / data_mf_eml2html.lua
bloba77e7a6d36748fabc74ceb092e83835c633b5a17
1 -- The getopt-functionality is loaded from pm3/getopt.lua
2 -- Have a look there for further details
3 getopt = require('getopt')
4 bin = require('bin')
5 dumplib = require('html_dumplib')
6 local ansicolors = require('ansicolors')
8 copyright = ''
9 author = 'Martin Holst Swende'
10 version = 'v1.0.3'
11 desc = [[
12 This script takes a dumpfile on EML (ASCII) format and produces a html based dump, which is a
13 bit more easily analyzed.
15 example = [[
16 script run data_mf_eml2html -o dumpdata.eml
18 usage = [[
19 script run data_mf_eml2html [-i <file>] [-o <file>]
21 arguments = [[
22 -h This help
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.
28 -- Some globals
29 local DEBUG = false -- the debug flag
30 ---
31 -- A debug printout-function
32 local function dbg(args)
33 if not DEBUG then return end
34 if type(args) == 'table' then
35 local i = 1
36 while args[i] do
37 dbg(args[i])
38 i = i+1
39 end
40 else
41 print('###', args)
42 end
43 end
44 ---
45 -- This is only meant to be used when errors occur
46 local function oops(err)
47 print('[!!] ERROR:', err)
48 core.clearCommandBuffer()
49 return nil, err
50 end
51 ---
52 -- Usage help
53 local function help()
54 print(copyright)
55 print(author)
56 print(version)
57 print(desc)
58 print(ansicolors.cyan..'Usage'..ansicolors.reset)
59 print(usage)
60 print(ansicolors.cyan..'Arguments'..ansicolors.reset)
61 print(arguments)
62 print(ansicolors.cyan..'Example usage'..ansicolors.reset)
63 print(example)
64 end
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
74 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))
79 end
81 --[[
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.
85 --]]
86 main(args)