1 local cmds
= require('commands')
2 local lib15
= require('read15')
3 local getopt
= require('getopt')
4 local utils
= require('utils')
5 local ansicolors
= require('ansicolors')
7 copyright
= 'Copyright (c) 2018 IceSQL AB. All rights reserved.'
8 author
= 'Christian Herrmann'
11 This script tries to set UID on a IS15693 SLIX magic card
12 Remember the UID ->MUST<- start with 0xE0
16 -- ISO15693 slix magic tag
18 script run hf_15_magic -u E004013344556677
20 script run hf_15_magic -u E004013344556677 -a
23 script run hf_15_magic -h -u <uid>
27 -u <UID> : UID (16 hexsymbols)
28 -a : use offical pm3 repo ISO15 commands instead of iceman fork.
33 -- A debug printout-function
34 local function dbg(args
)
35 if not DEBUG
then return end
36 if type(args
) == 'table' then
47 -- This is only meant to be used when errors occur
48 local function oops(err
)
50 core
.clearCommandBuffer()
60 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
62 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
64 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
68 --- Set UID on magic command enabled on a ICEMAN based REPO
69 local function magicUID_iceman(b0
, b1
)
70 print('Using backdoor Magic tag function')
71 core
.console('hf 15 raw -2 -c 02213E00000000')
72 core
.console('hf 15 raw -2 -c 02213F69960000')
73 core
.console('hf 15 raw -2 -c 022138'..b1
)
74 core
.console('hf 15 raw -2 -c 022139'..b0
)
77 --- Set UID on magic command enabled, OFFICAL REPO
78 local function magicUID_offical(b0
, b1
)
79 print('Using backdoor Magic tag function OFFICAL REPO')
80 core
.console('hf 15 cmd raw -c 02213E00000000')
81 core
.console('hf 15 cmd raw -c 02213F69960000')
82 core
.console('hf 15 cmd raw -c 022138'..b1
)
83 core
.console('hf 15 cmd raw -c 022139'..b0
)
86 -- The main entry point
89 print( string.rep('--',20) )
90 print( string.rep('--',20) )
93 local uid
= 'E004013344556677'
94 local use_iceman
= true
96 -- Read the parameters
97 for o
, a
in getopt
.getopt(args
, 'hu:a') do
98 if o
== 'h' then return help() end
99 if o
== 'u' then uid
= a
end
100 if o
== 'a' then use_iceman
= false end
104 if uid
== nil then return oops('empty uid string') end
105 if #uid
== 0 then return oops('empty uid string') end
106 if #uid
~= 16 then return oops('uid wrong length. Should be 8 hex bytes') end
108 local bytes
= utils
.ConvertHexToBytes(uid
)
110 local block0
= string.format('%02X%02X%02X%02X', bytes
[4], bytes
[3], bytes
[2], bytes
[1])
111 local block1
= string.format('%02X%02X%02X%02X', bytes
[8], bytes
[7], bytes
[6], bytes
[5])
113 print('new UID | '..uid
)
115 core
.clearCommandBuffer()
118 magicUID_iceman(block0
, block1
)
120 magicUID_offical(block0
, block1
)