1 local getopt = require('getopt')
3 example = "script run remagic"
7 This is a script that tries to bring back a chinese magic card (1k generation1)
8 from the dead when it's block 0 has been written with bad values.
9 or mifare Ultralight magic card which answers to chinese backdoor commands
13 -u remagic a Ultralight tag w 7 bytes UID.
16 -- A debug printout-function
23 -- This is only meant to be used when errors occur
31 print("Example usage")
35 local function cmdUltralight()
39 [0] = "hf 14a raw -p -a -b 7 40",
40 [1] = "hf 14a raw -p -a 43",
41 [2] = "hf 14a raw -c -a A2005380712A",
42 [3] = "hf 14a raw -p -a -b 7 40",
43 [4] = "hf 14a raw -p -a 43",
44 [5] = "hf 14a raw -c -a A2010200D980",
45 [6] = "hf 14a raw -p -a -b 7 40",
46 [7] = "hf 14a raw -p -a 43",
47 [8] = "hf 14a raw -c -a A2025B480000",
48 [9] = "hf 14a raw -c -a 5000",
51 local function cmdClassic()
55 [0] = "hf 14a raw -p -a -b 7 40",
56 [1] = "hf 14a raw -p -a 43",
57 [2] = "hf 14a raw -c -p -a A000",
58 [3] = "hf 14a raw -c -p -a 01020304049802000000000000001001",
59 [4] = "hf 14a raw -c -a 5000",
62 local function cmdRestoreST()
66 arr[i] = "hf mf csetbl "..blk.." FFFFFFFFFFFFFF078000FFFFFFFFFFFF"
70 local function sendCmds( cmds )
74 core.console( cmds[i] )
79 -- The main entry point
84 local isUltralight = false
86 -- Read the parameters
87 for o, a in getopt.getopt(args, 'hu') do
88 if o == "h" then return help() end
89 if o == "u" then isUltralight = true end
92 core.clearCommandBuffer()
95 sendCmds ( cmdUltralight() )
97 sendCmds( cmdClassic() )
98 sendCmds( cmdRestoreST() )