This commit is contained in:
iceman1001 2019-05-07 22:12:18 +02:00
parent 75325aef86
commit 2af7255f62
2 changed files with 14 additions and 12 deletions

View file

@ -31,21 +31,21 @@ local bxor = bit32.bxor
-- A debug printout-function -- A debug printout-function
local function dbg(args) local function dbg(args)
if not DEBUG then return end if not DEBUG then return end
if type(args) == 'table' then
if type(args) == "table" then
local i = 1 local i = 1
while args[i] do while args[i] do
dbg(args[i]) dbg(args[i])
i = i+1 i = i+1
end end
else else
print("###", args) print('###', args)
end end
end end
--- ---
-- This is only meant to be used when errors occur -- This is only meant to be used when errors occur
local function oops(err) local function oops(err)
print("ERROR: ",err) print('ERROR: ', err)
core.clearCommandBuffer()
return nil, err return nil, err
end end
--- ---
@ -57,10 +57,11 @@ local function help()
print(desc) print(desc)
print("Example usage") print("Example usage")
print(example) print(example)
print(usage)
end end
-- --
-- Exit message -- Exit message
function exitMsg(msg) local function exitMsg(msg)
print( string.rep('--',20) ) print( string.rep('--',20) )
print( string.rep('--',20) ) print( string.rep('--',20) )
print(msg) print(msg)
@ -138,6 +139,7 @@ local function pwdgen(uid)
local pwd3 = bxor( entry[4], uidbytes[7]) local pwd3 = bxor( entry[4], uidbytes[7])
return string.format('%02X%02X%02X%02X', pwd0, pwd1, pwd2, pwd3) return string.format('%02X%02X%02X%02X', pwd0, pwd1, pwd2, pwd3)
end end
-- --
-- main -- main
local function main(args) local function main(args)
@ -151,8 +153,8 @@ local function main(args)
-- Arguments for the script -- Arguments for the script
for o, a in getopt.getopt(args, 'hu:') do for o, a in getopt.getopt(args, 'hu:') do
if o == "h" then return help() end if o == 'h' then return help() end
if o == "u" then uid = a; useUID = true end if o == 'u' then uid = a; useUID = true end
end end
if useUID then if useUID then

View file

@ -135,11 +135,11 @@ local function main(args)
--13-14 --13-14
-- find tag -- find tag
result, err = lib14a.read(false, true) local card, err = lib14a.read(false, true)
if not result then return oops(err) end if not card then return oops(err) end
-- load keys -- load keys
local akeys = pre.GetAll(result.uid) local akeys = pre.GetAll(card.uid)
local keyA = akeys:sub(1, 12 ) local keyA = akeys:sub(1, 12 )
local b0 = readblock(0, keyA) local b0 = readblock(0, keyA)
@ -154,7 +154,7 @@ local function main(args)
core.clearCommandBuffer() core.clearCommandBuffer()
-- wipe card. -- wipe card.
local cmd = (csetuid..'%s %s %s w'):format(result.uid, atqa, sak) local cmd = (csetuid..'%s %s %s w'):format(card.uid, atqa, sak)
core.console(cmd) core.console(cmd)
core.clearCommandBuffer() core.clearCommandBuffer()