]> git.zerfleddert.de Git - proxmark3-svn/blob - client/scripts/tracetest.lua
f17f75672814ba7ce2b45e5926d6506cfdd48377
[proxmark3-svn] / client / scripts / tracetest.lua
1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local bin = require('bin')
4 local utils = require('utils')
5 local dumplib = require('html_dumplib')
6
7 example =[[
8 1. script run tracetest
9 2. script run tracetest -o
10
11 ]]
12 author = "Iceman"
13 usage = "script run tracetest -o <filename>"
14 desc =[[
15 This script will load several traces files in ../traces/ folder and do
16 "data load"
17 "lf search"
18
19 Arguments:
20 -h : this help
21 -o : logfile name
22 ]]
23
24 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
25 local DEBUG = true -- the debug flag
26 ---
27 -- A debug printout-function
28 function dbg(args)
29 if not DEBUG then
30 return
31 end
32
33 if type(args) == "table" then
34 local i = 1
35 while result[i] do
36 dbg(result[i])
37 i = i+1
38 end
39 else
40 print("###", args)
41 end
42 end
43 ---
44 -- This is only meant to be used when errors occur
45 function oops(err)
46 print("ERROR: ",err)
47 end
48 ---
49 -- Usage help
50 function help()
51 print(desc)
52 print("Example usage")
53 print(example)
54 end
55 --
56 -- Exit message
57 function ExitMsg(msg)
58 print( string.rep('--',20) )
59 print( string.rep('--',20) )
60 print(msg)
61 print()
62 end
63
64
65 local function main(args)
66
67 print( string.rep('--',20) )
68 print( string.rep('--',20) )
69
70 local cmdDataLoad = 'data load %s';
71 local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f"
72 local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f"
73
74 local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S")
75
76 -- Arguments for the script
77 for o, arg in getopt.getopt(args, 'hk:no:') do
78 if o == "h" then return help() end
79 if o == "o" then outputTemplate = arg end
80 end
81
82 core.clearCommandBuffer()
83
84 local files = {}
85
86 -- Find a set of traces staring with EM
87 local p = io.popen(tracesEM)
88 for file in p:lines() do
89 table.insert(files, file)
90 end
91
92 -- Find a set of traces staring with MOD
93 p = io.popen(tracesMOD)
94 for file in p:lines() do
95 table.insert(files, file)
96 end
97
98 local cmdLFSEARCH = "lf search"
99
100 -- main loop
101 io.write('Starting to test traces > ')
102 for _,file in pairs(files) do
103
104 local x = "data load "..file
105 dbg(x)
106 core.console(x)
107
108 dbg(cmdLFSEARCH)
109 core.console(cmdLFSEARCH)
110
111 core.clearCommandBuffer()
112
113 if core.ukbhit() then
114 print("aborted by user")
115 break
116 end
117 end
118 io.write('\n')
119
120 -- Write dump to files
121 if not DEBUG then
122 local bar = dumplib.SaveAsText(emldata, outputTemplate..'.txt')
123 print(("Wrote output to: %s"):format(bar))
124 end
125
126 -- Show info
127 print( string.rep('--',20) )
128
129 end
130 main(args)
Impressum, Datenschutz