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 and produces a html based dump, which is a
13 bit more easily analyzed.
16 script run data_mf_bin2html -o mifarecard_foo.html
19 script run data_mf_bin2html [-i <file>] [-o <file>]
23 -i <file> Specifies the dump-file (input). If omitted, 'dumpdata.bin' is used
24 -o <filename> Speciies the output file. If omitted, <curtime>.html is used.
27 -------------------------------
29 -------------------------------
32 -- A debug printout-function
33 local function dbg(args
)
34 if not DEBUG
then return end
35 if type(args
) == 'table' then
46 -- This is only meant to be used when errors occur
47 local function oops(err
)
48 print('[!!] ERROR:', err
)
49 core
.clearCommandBuffer()
59 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
61 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
63 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
67 local function main(args
)
69 local input
= 'dumpdata.bin'
70 local output
= os
.date('%Y-%m-%d_%H%M%S.html');
71 for o
, a
in getopt
.getopt(args
, 'i:o:h') do
72 if o
== 'h' then return help() end
73 if o
== 'i' then input
= a
end
74 if o
== 'o' then output
= a
end
76 local filename
, err
= dumplib
.convert_bin_to_html(input
,output
, 16)
77 if err
then return oops(err
) end
79 print(('[+] Wrote a HTML dump to the file %s'):format(filename
))
83 In the future, we may implement so that scripts are invoked directly
84 into a 'main' function, instead of being executed blindly. For future
85 compatibility, I have done so, but I invoke my main from here.