]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/tracetest.lua
Merged with master
[proxmark3-svn] / client / scripts / tracetest.lua
CommitLineData
81740aa5 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
77 for o, arg in getopt.getopt(args, 'ho:') 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 = assert( io.popen(tracesEM))
88 for file in p:lines() do
89 table.insert(files, file)
90 end
91 p.close();
92
93 -- Find a set of traces staring with MOD
94 p = assert( io.popen(tracesMOD) )
95 for file in p:lines() do
96 table.insert(files, file)
97 end
98 p.close();
99
100 local cmdLFSEARCH = "lf search 1"
101
102 -- main loop
103 io.write('Starting to test traces > ')
104 for _,file in pairs(files) do
105
106 local x = "data load "..file
107 dbg(x)
108 core.console(x)
109
110 dbg(cmdLFSEARCH)
111 core.console(cmdLFSEARCH)
112
113 core.clearCommandBuffer()
114
115 if core.ukbhit() then
116 print("aborted by user")
117 break
118 end
119 end
120 io.write('\n')
121
122 -- Write dump to files
123 if not DEBUG then
124 local bar = dumplib.SaveAsText(emldata, outputTemplate..'.txt')
125 print(("Wrote output to: %s"):format(bar))
126 end
127
128 -- Show info
129 print( string.rep('--',20) )
130
131end
132main(args)
Impressum, Datenschutz