]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/tracetest.lua
FIX: arguments took too much.
[proxmark3-svn] / client / scripts / tracetest.lua
CommitLineData
0a43c396 1local cmds = require('commands')
2local getopt = require('getopt')
3local bin = require('bin')
4local utils = require('utils')
5local dumplib = require('html_dumplib')
6
7example =[[
8 1. script run tracetest
9 2. script run tracetest -o
10
11]]
12author = "Iceman"
13usage = "script run tracetest -o <filename>"
14desc =[[
15This script will load several traces files in ../traces/ folder and do
16"data load"
17"lf search"
18
19Arguments:
20 -h : this help
21 -o : logfile name
22]]
23
24local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
25local DEBUG = true -- the debug flag
26---
27-- A debug printout-function
28function 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
42end
43---
44-- This is only meant to be used when errors occur
45function oops(err)
46 print("ERROR: ",err)
47end
48---
49-- Usage help
50function help()
51 print(desc)
52 print("Example usage")
53 print(example)
54end
55--
56-- Exit message
57function ExitMsg(msg)
58 print( string.rep('--',20) )
59 print( string.rep('--',20) )
60 print(msg)
61 print()
62end
63
64
65local 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
86dab516 77 for o, arg in getopt.getopt(args, 'ho:') do
0a43c396 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
86dab516 98 local cmdLFSEARCH = "lf search 1"
0a43c396 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
129end
130main(args)
Impressum, Datenschutz