mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-02 21:54:10 +08:00
FIX: Since some changes in "hf mf chk" usbcommand package, this script has not been working. It now calls and gets the results back from the device.
CHG: changed the output listing to look like the other key-tables.
This commit is contained in:
parent
4ce2037b2a
commit
62254ea5a7
1 changed files with 36 additions and 18 deletions
|
@ -14,13 +14,32 @@ local cmds = require('commands')
|
||||||
local keys = require('mf_default_keys')
|
local keys = require('mf_default_keys')
|
||||||
-- Ability to read what card is there
|
-- Ability to read what card is there
|
||||||
local reader = require('read14a')
|
local reader = require('read14a')
|
||||||
|
local getopt = require('getopt')
|
||||||
|
|
||||||
|
local OR = bit32.bor
|
||||||
|
local LSHIFT = bit32.lshift
|
||||||
|
|
||||||
local desc =
|
example =[[
|
||||||
("This script implements check keys. It utilises a large list of default keys (currently %d keys).\
|
script run mfkeys
|
||||||
If you want to add more, just put them inside mf_default_keys.lua. "):format(#keys)
|
]]
|
||||||
|
author = "Iceman"
|
||||||
|
usage = "script run mfkeys"
|
||||||
|
desc = ("This script implements Mifare check keys. It utilises a large list of default keys (currently %d keys).\
|
||||||
|
If you want to add more, just put them inside /lualibs/mf_default_keys.lua\n"):format(#keys) ..
|
||||||
|
[[
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
-h : this help
|
||||||
|
]]
|
||||||
|
|
||||||
local TIMEOUT = 10000 -- 10 seconds
|
local TIMEOUT = 10000 -- 10 seconds
|
||||||
|
---
|
||||||
|
-- Usage help
|
||||||
|
function help()
|
||||||
|
print(desc)
|
||||||
|
print("Example usage")
|
||||||
|
print(example)
|
||||||
|
end
|
||||||
|
|
||||||
--[[This may be moved to a separate library at some point]]
|
--[[This may be moved to a separate library at some point]]
|
||||||
local utils =
|
local utils =
|
||||||
|
@ -81,7 +100,6 @@ local function checkCommand(command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function checkBlock(blockNo, keys, keyType)
|
function checkBlock(blockNo, keys, keyType)
|
||||||
-- The command data is only 512 bytes, each key is 6 bytes, meaning that we can send max 85 keys in one go.
|
-- The command data is only 512 bytes, each key is 6 bytes, meaning that we can send max 85 keys in one go.
|
||||||
-- If there's more, we need to split it up
|
-- If there's more, we need to split it up
|
||||||
|
@ -91,12 +109,10 @@ function checkBlock(blockNo, keys, keyType)
|
||||||
local n,data = remaining, nil
|
local n,data = remaining, nil
|
||||||
if remaining > 85 then n = 85 end
|
if remaining > 85 then n = 85 end
|
||||||
local data = table.concat(keys,"",start,n)
|
local data = table.concat(keys,"",start,n)
|
||||||
--print("data",data)
|
|
||||||
--print("data len", #data)
|
|
||||||
print(("Testing block %d, keytype %d, with %d keys"):format(blockNo, keyType, n))
|
print(("Testing block %d, keytype %d, with %d keys"):format(blockNo, keyType, n))
|
||||||
local command = Command:new{cmd = cmds.CMD_MIFARE_CHKKEYS,
|
local command = Command:new{cmd = cmds.CMD_MIFARE_CHKKEYS,
|
||||||
arg1 = blockNo,
|
arg1 = OR(blockNo, LSHIFT(keyType,8) ),
|
||||||
arg2 = keyType,
|
arg2 = 0,
|
||||||
arg3 = n,
|
arg3 = n,
|
||||||
data = data}
|
data = data}
|
||||||
local status = checkCommand(command)
|
local status = checkCommand(command)
|
||||||
|
@ -108,19 +124,19 @@ function checkBlock(blockNo, keys, keyType)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- A function to display the results
|
-- A function to display the results
|
||||||
|
-- TODO: iceman 2016, still screws up output when a key is not found.
|
||||||
local function displayresults(results)
|
local function displayresults(results)
|
||||||
local sector, blockNo, keyA, keyB,_
|
local sector, blockNo, keyA, keyB,_
|
||||||
|
|
||||||
print("________________________________________")
|
print("|---|----------------|---|----------------|---|")
|
||||||
print("|Sector|Block| A | B |")
|
print("|sec|key A |res|key B |res|")
|
||||||
print("|--------------------------------------|")
|
print("|---|----------------|---|----------------|---|")
|
||||||
|
|
||||||
for sector,_ in pairs(results) do
|
for sector,_ in pairs(results) do
|
||||||
blockNo, keyA, keyB = unpack(_)
|
blockNo, keyA, keyB = unpack(_)
|
||||||
|
print(("|%03d| %s | 1 | %s | 1 |"):format(sector, keyA, keyB ))
|
||||||
print(("| %3d | %3d |%s|%s|"):format(sector, blockNo, keyA, keyB ))
|
|
||||||
end
|
end
|
||||||
print("|--------------------------------------|")
|
print("|---|----------------|---|----------------|---|")
|
||||||
|
|
||||||
end
|
end
|
||||||
-- A little helper to place an item first in the list
|
-- A little helper to place an item first in the list
|
||||||
|
@ -164,18 +180,20 @@ local function dumptofile(results)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function main( args)
|
local function main( args)
|
||||||
|
|
||||||
print(desc);
|
-- Arguments for the script
|
||||||
|
for o, a in getopt.getopt(args, 'h') do
|
||||||
|
if o == "h" then return help() end
|
||||||
|
end
|
||||||
|
|
||||||
result, err = reader.read1443a()
|
result, err = reader.read1443a()
|
||||||
if not result then
|
if not result then
|
||||||
print(err)
|
print(err)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
print(("Found a %s tag"):format(result.name))
|
|
||||||
|
|
||||||
|
print(("Found a %s tag"):format(result.name))
|
||||||
|
|
||||||
core.clearCommandBuffer()
|
core.clearCommandBuffer()
|
||||||
local blockNo
|
local blockNo
|
||||||
|
|
Loading…
Reference in a new issue