chg: adapting luascript to use new filename template for key files.

This commit is contained in:
iceman1001 2020-01-04 16:57:15 +01:00
commit e612ae3de4
5 changed files with 30 additions and 21 deletions

View file

@ -71,11 +71,14 @@ local function exitMsg(msg)
end end
--- ---
-- dumps all keys to file -- dumps all keys to file
local function dumptofile(keys) local function dumptofile(uid, keys)
dbg('dumping keys to file') dbg('dumping keys to file')
if utils.confirm('Do you wish to save the keys to dumpfile?') then if utils.confirm('Do you wish to save the keys to dumpfile?') then
local destination = utils.input('Select a filename to store to', 'dumpkeys.bin')
local filename = ('hf-mf-%s-key.bin'):format(uid);
local destination = utils.input('Select a filename to store to', filename)
local file = io.open(destination, 'wb') local file = io.open(destination, 'wb')
if file == nil then if file == nil then
print('Could not write to file ', destination) print('Could not write to file ', destination)
@ -172,7 +175,7 @@ local function main(args)
local keys, err = createKeys( uid ) local keys, err = createKeys( uid )
printKeys( keys ) printKeys( keys )
dumptofile( keys ) dumptofile( uid, keys )
end end
main(args) main(args)

View file

@ -76,11 +76,12 @@ local function exitMsg(msg)
end end
-- --
-- dumps all keys to file -- dumps all keys to file
local function dumptofile(keys) local function dumptofile(uid, keys)
dbg('dumping keys to file') dbg('dumping keys to file')
if utils.confirm('Do you wish to save the keys to dumpfile?') then if utils.confirm('Do you wish to save the keys to dumpfile?') then
local destination = utils.input('Select a filename to store to', 'dumpkeys.bin') local filename = ('hf-mf-%s-key.bin'):format(uid);
local destination = utils.input('Select a filename to store to', filename)
local file = io.open(destination, 'wb') local file = io.open(destination, 'wb')
if file == nil then if file == nil then
print('Could not write to file ', destination) print('Could not write to file ', destination)
@ -194,7 +195,7 @@ local function main(args)
local keys, err = createKeys( uid ) local keys, err = createKeys( uid )
printKeys( keys ) printKeys( keys )
dumptofile( keys ) dumptofile( uid, keys )
end end
main(args) main(args)

View file

@ -159,9 +159,10 @@ end
end end
-- --
-- dumps all keys to file -- dumps all keys to file
local function dumptofile(keys) local function dumptofile(uid, keys)
if utils.confirm('Do you wish to save the keys to dumpfile?') then if utils.confirm('Do you wish to save the keys to dumpfile?') then
local destination = utils.input('Select a filename to store to', 'dumpkeys.bin') local filename = ('hf-mf-%s-key.bin'):format(uid);
local destination = utils.input('Select a filename to store to', filename)
local file = io.open(destination, 'wb') local file = io.open(destination, 'wb')
if file == nil then if file == nil then
print('Could not write to file ', destination) print('Could not write to file ', destination)
@ -192,7 +193,7 @@ local function printkeys()
end end
--- ---
-- --
local function perform_check(numsectors) local function perform_check(uid, numsectors)
local keyType = 0 -- A=0, B=1 local keyType = 0 -- A=0, B=1
@ -237,7 +238,7 @@ local function perform_check(numsectors)
display_results(keys) display_results(keys)
-- save to dumpkeys.bin -- save to dumpkeys.bin
dumptofile(keys) dumptofile(uid, keys)
end end
-- --
-- shows tag information -- shows tag information
@ -282,7 +283,7 @@ local function main(args)
-- detect sectors and print taginfo -- detect sectors and print taginfo
numsectors = taginfo(tag) numsectors = taginfo(tag)
perform_check(numsectors) perform_check(tag.uid, numsectors)
end end
main( args) main( args)

View file

@ -97,7 +97,7 @@ local function nested(key,sak)
core.console(cmd) core.console(cmd)
end end
local function dump(uid, numsectors) local function dump_tag(uid, numsectors)
dbg('dumping tag memory') dbg('dumping tag memory')
local typ = 1 local typ = 1
@ -203,7 +203,7 @@ local function main(args)
-- Use nested attack -- Use nested attack
nested(key, sak) nested(key, sak)
-- Dump info -- Dump info
dump(uid, sak) dump_tag(uid, sak)
if #key == 12 then _exit = true end if #key == 12 then _exit = true end
else else

View file

@ -109,7 +109,6 @@ local function main(args)
local useNested = false local useNested = false
local usePreCalc = false local usePreCalc = false
local cmdReadBlockString = 'hf mf rdbl %d A %s' local cmdReadBlockString = 'hf mf rdbl %d A %s'
local input = "dumpkeys.bin"
local outputTemplate = os.date("toydump_%Y-%m-%d_%H%M%S"); local outputTemplate = os.date("toydump_%Y-%m-%d_%H%M%S");
-- Arguments for the script -- Arguments for the script
@ -132,13 +131,13 @@ local function main(args)
core.console( cmdSetDbgOff) core.console( cmdSetDbgOff)
utils.Sleep(0.5) utils.Sleep(0.5)
result, err = lib14a.read(false, true) tag, err = lib14a.read(false, true)
if not result then return oops(err) end if not tag then return oops(err) end
core.clearCommandBuffer() core.clearCommandBuffer()
-- Show tag info -- Show tag info
print((' Found tag %s'):format(result.name)) print((' Found tag %s'):format(tag.name))
dbg(('Using keyA : %s'):format(keyA)) dbg(('Using keyA : %s'):format(keyA))
@ -152,13 +151,18 @@ local function main(args)
local akeys = '' local akeys = ''
if usePreCalc then if usePreCalc then
local pre = require('precalc') local pre = require('precalc')
akeys = pre.GetAll(result.uid) akeys = pre.GetAll(tag.uid)
dbg(akeys) dbg(akeys)
else else
print('Loading dumpkeys.bin') local filename = ('hf-mf-%s-key.bin'):format(tag.uid);
local hex, err = utils.ReadDumpFile(input) print('loading '..filename)
local hex, err = utils.ReadDumpFile(filename)
if not hex then if not hex then
return oops(err) print('loading dumpkeys.bin')
hex, err = utils.ReadDumpFile('dumpkeys.bin')
if not hex then
return oops(err)
end
end end
akeys = hex:sub(0,12*16) akeys = hex:sub(0,12*16)
end end