1 local getopt
= require('getopt')
2 local ansicolors
= require('ansicolors')
8 This is a script that tries to bring back a chinese magic card (1k generation1)
9 from the dead when it's block 0 has been written with bad values.
10 or mifare Ultralight magic card which answers to chinese backdoor commands
13 -- target a Ultralight based card
14 1. script run hf_mf_magicrevive -u
18 script run hf_mf_magicrevive [-h] [-u]
22 -u try to revive a bricked magic Ultralight tag w 7 bytes UID.
25 -- A debug printout-function
26 local function dbg(args
)
27 if not DEBUG
then return end
28 if type(args
) == 'table' then
39 -- This is only meant to be used when errors occur
40 local function oops(err
)
42 core
.clearCommandBuffer()
52 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
54 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
56 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
60 local function cmdUltralight()
62 [0] = 'hf 14a raw -k -a -b 7 40',
63 [1] = 'hf 14a raw -k -a 43',
64 [2] = 'hf 14a raw -c -a A2005380712A',
65 [3] = 'hf 14a raw -k -a -b 7 40',
66 [4] = 'hf 14a raw -k -a 43',
67 [5] = 'hf 14a raw -c -a A2010200D980',
68 [6] = 'hf 14a raw -k -a -b 7 40',
69 [7] = 'hf 14a raw -k -a 43',
70 [8] = 'hf 14a raw -c -a A2025B480000',
71 [9] = 'hf 14a raw -c -a 5000',
74 local function cmdClassic()
76 [0] = 'hf 14a raw -k -a -b 7 40',
77 [1] = 'hf 14a raw -k -a 43',
78 [2] = 'hf 14a raw -c -k -a A000',
79 [3] = 'hf 14a raw -c -k -a 01020304049802000000000000001001',
80 [4] = 'hf 14a raw -c -a 5000',
83 local function cmdRestoreST()
87 arr
[i
] = 'hf mf csetbl --blk '..blk
..' -d FFFFFFFFFFFFFF078000FFFFFFFFFFFF'
91 local function sendCmds( cmds
)
95 core
.console( cmds
[i
] )
96 core
.clearCommandBuffer()
101 -- The main entry point
106 local isUltralight
= false
108 -- Read the parameters
109 for o
, a
in getopt
.getopt(args
, 'hu') do
110 if o
== 'h' then return help() end
111 if o
== 'u' then isUltralight
= true end
114 core
.clearCommandBuffer()
117 sendCmds ( cmdUltralight() )
119 sendCmds( cmdClassic() )
120 sendCmds( cmdRestoreST() )