maur keys
[RRG-proxmark3.git] / client / luascripts / hf_legic_buffer2card.lua
blobb6eee9f8664c29cf781922bf4c9bd8a7f8ac5fc9
1 local utils = require('utils')
2 local getopt = require('getopt')
3 local ansicolors = require('ansicolors')
4 -- this script writes bytes 8 to 256 on the Legic MIM256
6 copyright = ''
7 author = 'Mosci'
8 version = 'v1.0.3'
9 desc =
11 This is a script which writes value 0x01 to bytes from
12 position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024)
13 -- (created with 'hf legic dump -f my_dump.hex') --
15 example = [[
16 script run hf_legic_buffer2card
18 usage = [[
19 script run hf_legic_buffer2card -h
21 arguments = [[
22 -h - Help text
25 ---
26 -- This is only meant to be used when errors occur
27 local function oops(err)
28 print('ERROR:', err)
29 core.clearCommandBuffer()
30 return nil, err
31 end
32 ---
33 -- Usage help
34 local function help()
35 print(copyright)
36 print(author)
37 print(version)
38 print(desc)
39 print(ansicolors.cyan..'Usage'..ansicolors.reset)
40 print(usage)
41 print(ansicolors.cyan..'Arguments'..ansicolors.reset)
42 print(arguments)
43 print(ansicolors.cyan..'Example usage'..ansicolors.reset)
44 print(example)
45 end
47 -- simple loop-write from 0x07 to 0xff
48 function main()
50 -- parse arguments for the script
51 for o, a in getopt.getopt(args, 'h') do
52 if o == 'h' then return help() end
53 end
55 local cmd = ''
56 local i
57 for i = 7, 255 do
58 cmd = ('hf legic wrbl -o %02x -d 01'):format(i)
59 print(cmd)
60 core.clearCommandBuffer()
61 core.console(cmd)
63 -- got a 'cmd-buffer overflow' on my mac - so just wait a little
64 -- works without that pause on my linux-box
65 utils.Sleep(0.1)
66 end
67 end
69 main()