+
+ result = {}
+ for sector=1,numSectors do
+
+ --[[
+ The mifare Classic 1k card has 16 sectors of 4 data blocks each.
+ The first 32 sectors of a mifare Classic 4k card consists of 4 data blocks and the remaining
+ 8 sectors consist of 16 data blocks.
+ --]]
+ local trgblockno = sector * 4 - 1
+ if sector > 32 then
+ trgblockno = 32 * 4 + (sector-32) * 16 -1
+ end
+
+ trgblockno = ("%02d"):format(trgblockno)
+
+ local succA = 1
+ local succB = 1
+ local errA, keyA = core.hardnested(blockno, keytype, key, trgblockno, '0', trgkey, 0,0,0,0)
+ keyA = keyA or ""
+ if errA == nil or errA > 0 then succA = 0 end
+
+ local errB, keyB = core.hardnested(blockno, keytype, key, trgblockno, '1', trgkey, 0,0,0,0)
+ keyB = keyB or ""
+ if errB == nil or errB > 0 then succB = 0 end
+ result[sector] = { succA, succB, utils.ConvertAsciiToHex(keyA), utils.ConvertAsciiToHex(keyB) }
+
+ -- Check if user aborted
+ if core.ukbhit() then
+ print("Aborted by user")
+ break
+ end