]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/e.lua
fix reveng memory bug + @iceman1001 s scripting
[proxmark3-svn] / client / scripts / e.lua
CommitLineData
2e163546 1local getopt = require('getopt')
2local utils = require('utils')
3
4example = "script calculates many checksums (CRC) over the provided hex input"
5author = "Iceman"
6desc =
7[[
8This script calculates many checksums (CRS) over the provided hex input.
9
10Arguments:
11 -b data in hex
12 -w width of the CRC algorithm. <optional> defaults to all known CRC presets.
13Examples :
14 script run e -b 010203040506070809
15 script run e -b 010203040506070809 -w 16
16]]
17
18---
19-- A debug printout-function
20function dbg(args)
21 if DEBUG then
22 print("###", args)
23 end
24end
25---
26-- This is only meant to be used when errors occur
27function oops(err)
28 print("ERROR: ",err)
29 return nil,err
30end
31---
32-- Usage help
33function help()
34 print(desc)
35 print("Example usage")
36 print(example)
37end
38---
39-- The main entry point
40function main(args)
41
42 local data = '01020304'
43 local width = 0
44
45 -- Read the parameters
46 for o, a in getopt.getopt(args, 'hb:w:') do
47 if o == "h" then return help() end
48 if o == "b" then data = utils.ConvertHexToa end
49 if o == "w" then width = a end
50 end
51
52 print('Width of CRC: '..width..' bytes: '..data)
53 print('')
54 print('Model','CRC', 'CRC_Reverse')
55
56 local lists = core.reveng_models(width)
57 for _,i in pairs(lists) do
58 local one = core.reveng_runmodel(i, data, 0,0)
59 local two = core.reveng_runmodel(i, data, 1,0)
60
61 print(i, one, two)
62 end
63
64 if 1 == 1 then
65 return
66 end
67end
68
69main(args)
Impressum, Datenschutz