]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/scripts/mfkeys.lua
mfkeys.lua: Align empty cells in the table.
[proxmark3-svn] / client / scripts / mfkeys.lua
index 9471ad4bf3f8fb0283635a57427e518948ee5346..919dadb887cfc0e33d10c4ad5e0c6915a553fe14 100644 (file)
@@ -14,49 +14,15 @@ local cmds = require('commands')
 local keys = require('mf_default_keys')
 -- Ability to read what card is there
 local reader = require('read14a')
+-- Asks the user for input
+local utils = require('utils')
 
 
-local desc = 
-("This script implements check keys. It utilises a large list of default keys (currently %d keys).\
+local desc = ("This script implements check keys. \
+It utilises a large list of default keys (currently %d keys).\
 If you want to add more, just put them inside mf_default_keys.lua. "):format(#keys)
 
 local TIMEOUT = 10000 -- 10 seconds
-       
---[[This may be moved to a separate library at some point]]
-local utils = 
-{
-       --- 
-       -- Asks the user for Yes or No
-       confirm = function(message, ...)
-               local answer
-               message = message .. " [y]/[n] ?"
-               repeat
-                       io.write(message)
-                       io.flush()
-                       answer=io.read()
-                       if answer == 'Y' or answer == "y" then
-                               return true
-                       elseif answer == 'N' or answer == 'n' then 
-                               return false
-                       end
-               until false
-       end,
-       ---
-       -- Asks the user for input
-       input = function (message , default)
-               local answer
-               if default ~= nil then
-                       message = message .. " (default: ".. default.. " )"
-               end
-               message = message .." \n > "
-               io.write(message)
-               io.flush()
-               answer=io.read()
-               if answer == '' then answer = default end
-
-               return answer
-       end,
-}
 
 
 local function checkCommand(command)
@@ -86,6 +52,7 @@ 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. 
        -- If there's more, we need to split it up
        local start, remaining= 1, #keys
+       local arg1 = bit32.bor(bit32.lshift(keyType, 8), blockNo)
        local packets = {}
        while remaining > 0 do
                local n,data = remaining, nil
@@ -95,8 +62,8 @@ function checkBlock(blockNo, keys, keyType)
                --print("data len", #data)
                print(("Testing block %d, keytype %d, with %d keys"):format(blockNo, keyType, n))
                local command = Command:new{cmd = cmds.CMD_MIFARE_CHKKEYS, 
-                                                               arg1 = blockNo
-                                                               arg2 = keyType
+                                                               arg1 = arg1
+                                                               arg2 = 1
                                                                arg3 = n, 
                                                                data = data}
                local status = checkCommand(command)
@@ -118,7 +85,7 @@ local function displayresults(results)
        for sector,_ in pairs(results) do
                blockNo, keyA, keyB = unpack(_)
 
-               print(("| %3d  | %3d |%s|%s|"):format(sector, blockNo, keyA, keyB ))
+               print(("| %3d  | %3d |%12s|%12s|"):format(sector, blockNo, keyA, keyB))
        end
        print("|--------------------------------------|")
 
@@ -169,7 +136,7 @@ local function main( args)
 
        print(desc);
 
-       result, err = reader.read1443a()
+       result, err = reader.read14443a(false, true)
        if not result then
                print(err)
                return
Impressum, Datenschutz