style
[RRG-proxmark3.git] / client / luascripts / init_rdv4.lua
blob08574a2fe6ca55c57b784092667b894b1c9c41ca
1 local getopt = require('getopt')
2 local ansicolors = require('ansicolors')
3 local utils = require('utils')
5 copyright = 'Copyright (c) 2019 IceSQL AB. All rights reserved.'
6 author = 'Christian Herrmann'
7 version = 'v1.0.3'
8 desc = [[
9 This script initialize a Proxmark3 RDV4.0 with
10 - uploading dictionary files to flashmem
11 - configuring the LF T55X7 device settings
13 example = [[
14 script run init_rdv4
16 usage = [[
17 script run init_rdv4 -h
19 arguments = [[
20 -h : this help
23 local DEBUG = true
24 ---
25 -- A debug printout-function
26 local function dbg(args)
27 if not DEBUG then return end
28 if type(args) == 'table' then
29 local i = 1
30 while args[i] do
31 dbg(args[i])
32 i = i+1
33 end
34 else
35 print('###', args)
36 end
37 end
38 ---
39 -- This is only meant to be used when errors occur
40 local function oops(err)
41 print('ERROR:', err)
42 core.clearCommandBuffer()
43 return nil, err
44 end
45 ---
46 -- Usage help
47 local function help()
48 print(copyright)
49 print(author)
50 print(version)
51 print(desc)
52 print(ansicolors.cyan..'Usage'..ansicolors.reset)
53 print(usage)
54 print(ansicolors.cyan..'Arguments'..ansicolors.reset)
55 print(arguments)
56 print(ansicolors.cyan..'Example usage'..ansicolors.reset)
57 print(example)
58 end
59 ---
60 -- The main entry point
61 function main(args)
62 local dash = string.rep('--', 20)
64 print( dash )
65 print( dash )
66 print()
68 -- Read the parameters
69 for o, a in getopt.getopt(args, 'h') do
70 if o == 'h' then return help() end
71 end
73 print('Prepping your Proxmark3 RDV4')
75 -- Upload dictionaries
76 print('Uploading dictionaries to RDV4 flashmemory')
77 print(dash)
78 core.console('mem load -f mfc_default_keys --mfc')
79 core.console('mem load -f t55xx_default_pwds --t55xx')
80 core.console('mem load -f iclass_default_keys --iclass')
81 print(dash)
83 -- T55x7 Device configuration
84 print('Configure T55XX device side to match RDV4')
85 print(dash)
86 core.console('lf t55xx deviceconfig --r0 -a 29 -b 17 -c 15 -d 47 -e 15 -p')
87 utils.Sleep(1)
88 core.console('lf t55xx deviceconfig --r1 -a 29 -b 17 -c 18 -d 50 -e 15 -p')
89 utils.Sleep(1)
90 core.console('lf t55xx deviceconfig --r2 -a 29 -b 17 -c 18 -d 40 -e 15 -p')
91 utils.Sleep(1)
92 core.console('lf t55xx deviceconfig --r3 -a 29 -b 17 -c 15 -d 31 -e 15 -f 47 -g 63 -p')
93 utils.Sleep(1)
95 print('')
96 print('')
97 core.console('hw status')
98 print(dash)
100 print('all done!')
104 main(args)