Commit | Line | Data |
---|---|---|
5b1311fb MHS |
1 | local getopt = require('getopt')\r |
2 | local bin = require('bin')\r | |
3 | local dumplib = require('html_dumplib')\r | |
4 | \r | |
5 | example =[[\r | |
6 | 1. script run emul2dump\r | |
7 | 2. script run emul2dump -i myfile.eml\r | |
8 | 3. script run emul2dump -i myfile.eml -o myfile.bin\r | |
9 | ]]\r | |
10 | author = "Iceman"\r | |
11 | usage = "script run emul2dump [-i <file>] [-o <file>]"\r | |
12 | desc =[[\r | |
13 | This script takes an dumpfile on EML (ASCII) format and converts it to the PM3 dumpbin file to be used with "hf mf restore"\r | |
14 | \r | |
15 | Arguments:\r | |
16 | -h This help\r | |
17 | -i <filename> Specifies the dump-file (input). If omitted, 'dumpdata.eml' is used \r | |
18 | -o <filename> Specifies the output file. If omitted, <currdate>.bin is used. \r | |
19 | ]]\r | |
20 | \r | |
21 | --- \r | |
22 | -- This is only meant to be used when errors occur\r | |
23 | function oops(err)\r | |
24 | print("ERROR: ",err)\r | |
25 | end\r | |
26 | --- \r | |
27 | -- Usage help\r | |
28 | function help()\r | |
29 | print(desc)\r | |
30 | print("Example usage")\r | |
31 | print(example)\r | |
32 | end\r | |
33 | --\r | |
34 | -- Exit message\r | |
35 | function ExitMsg(msg)\r | |
36 | print( string.rep('--',20) )\r | |
37 | print( string.rep('--',20) )\r | |
38 | print(msg)\r | |
39 | print()\r | |
40 | end\r | |
41 | \r | |
42 | local function main(args)\r | |
43 | \r | |
44 | local input = "dumpdata.eml"\r | |
45 | local output = os.date("%Y-%m-%d_%H%M%S.bin");\r | |
46 | \r | |
47 | -- Arguments for the script\r | |
48 | for o, a in getopt.getopt(args, 'hi:o:') do\r | |
49 | if o == "h" then return help() end \r | |
50 | if o == "i" then input = a end\r | |
51 | if o == "o" then output = a end\r | |
52 | end\r | |
53 | \r | |
54 | local filename, err = dumplib.convert_eml_to_bin(input,output)\r | |
55 | if err then return oops(err) end\r | |
56 | \r | |
57 | ExitMsg(("Wrote a BIN dump to the file %s"):format(filename))\r | |
58 | end\r | |
59 | \r | |
60 | main(args) |