1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local utils = require('utils')
4 local lib14a = require('read14a')
6 example = "script iterates over all possible sectors for a tag and runs hardnested attack against them to collect the keys."
10 This script iterates over all possible sectors for a tag and runs hardnested attack against them to collect the keys.
13 -k Known key, 6 bytes (12 hex digits)
15 script hard -b 112233445566
22 -- A debug printout-function
24 if not DEBUG then return end
26 if type(args) == "table" then
37 -- This is only meant to be used when errors occur
46 print("Example usage")
52 print( string.rep('--',20) )
53 print( string.rep('--',20) )
58 -- a simple selftest function,
59 local function selftest()
64 -- The main entry point
68 local keytype = 0 --A 01==B
69 local key = 'fc00018778f7'
73 -- Read the parameters
74 for o, a in getopt.getopt(args, 'hk:t') do
75 if o == "h" then return help() end
76 if o == "k" then key = a end
77 if o == "t" then return selftest() end
81 local cmdSetDbgOff = "hf mf dbg 0"
82 core.console( cmdSetDbgOff)
84 result, err = lib14a.read1443a(false)
88 core.clearCommandBuffer()
91 print((' Found tag %s'):format(result.name))
97 local trgblockno = ("%02d"):format(i)
98 local err, found_key = core.hardnested(blockno, keytype, key, trgblockno, trgkeytype, trgkey, 0,0,0,0)
100 table.insert( keys , { ["success"] = err, ["sector"] = i, ["type"] = trgkeytype, ["key"] = utils.ConvertAsciiToHex(found_key) } )
104 for k,v in pairs(keys) do
105 for a,b in pairs(v) do print(a,b) end