mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
chg: 'script run mifare_autopwn' added the prng_test, to make sure it only attacks weak cards.
This commit is contained in:
parent
d5153b2446
commit
6df9012de5
1 changed files with 49 additions and 32 deletions
|
@ -26,25 +26,23 @@ Output files from this operation:
|
||||||
-- Some utilities
|
-- Some utilities
|
||||||
-------------------------------
|
-------------------------------
|
||||||
local DEBUG = false
|
local DEBUG = false
|
||||||
local MIFARE_AUTH_KEYA = 0x60
|
|
||||||
local MIFARE_AUTH_KEYB = 0x61
|
|
||||||
---
|
---
|
||||||
-- A debug printout-function
|
-- A debug printout-function
|
||||||
function dbg(args)
|
local function dbg(args)
|
||||||
if DEBUG then
|
if DEBUG then
|
||||||
print(":: ", args)
|
print(":: ", args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- This is only meant to be used when errors occur
|
-- This is only meant to be used when errors occur
|
||||||
function oops(err)
|
local function oops(err)
|
||||||
print("ERROR: ",err)
|
print("ERROR: ",err)
|
||||||
return nil,err
|
return nil,err
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Usage help
|
-- Usage help
|
||||||
function help()
|
local function help()
|
||||||
print(desc)
|
print(desc)
|
||||||
print("Example usage")
|
print("Example usage")
|
||||||
print(example)
|
print(example)
|
||||||
|
@ -54,7 +52,7 @@ end
|
||||||
-- Waits for a mifare card to be placed within the vicinity of the reader.
|
-- Waits for a mifare card to be placed within the vicinity of the reader.
|
||||||
-- @return if successfull: an table containing card info
|
-- @return if successfull: an table containing card info
|
||||||
-- @return if unsuccessfull : nil, error
|
-- @return if unsuccessfull : nil, error
|
||||||
function wait_for_mifare()
|
local function wait_for_mifare()
|
||||||
while not core.ukbhit() do
|
while not core.ukbhit() do
|
||||||
res, err = reader.read1443a()
|
res, err = reader.read1443a()
|
||||||
if res then return res end
|
if res then return res end
|
||||||
|
@ -63,7 +61,7 @@ function wait_for_mifare()
|
||||||
return nil, "Aborted by user"
|
return nil, "Aborted by user"
|
||||||
end
|
end
|
||||||
|
|
||||||
function nested(key,sak)
|
local function nested(key,sak)
|
||||||
local typ = 1
|
local typ = 1
|
||||||
if 0x18 == sak then --NXP MIFARE Classic 4k | Plus 4k | Ev1 4k
|
if 0x18 == sak then --NXP MIFARE Classic 4k | Plus 4k | Ev1 4k
|
||||||
typ = 4
|
typ = 4
|
||||||
|
@ -82,7 +80,7 @@ function nested(key,sak)
|
||||||
core.console(cmd)
|
core.console(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
function dump(uid)
|
local function dump(uid)
|
||||||
core.console("hf mf dump")
|
core.console("hf mf dump")
|
||||||
-- Save the global args, those are *our* arguments
|
-- Save the global args, those are *our* arguments
|
||||||
local myargs = args
|
local myargs = args
|
||||||
|
@ -97,10 +95,22 @@ function dump(uid)
|
||||||
-- Set back args. Not that it's used, just for the karma...
|
-- Set back args. Not that it's used, just for the karma...
|
||||||
args = myargs
|
args = myargs
|
||||||
end
|
end
|
||||||
|
--
|
||||||
|
-- performs a test if tag nonce uses weak or hardend prng
|
||||||
|
local function perform_prng_test()
|
||||||
|
|
||||||
|
local isweak = core.detect_prng()
|
||||||
|
if isweak == 1 then
|
||||||
|
dbg('PRNG detection : WEAK nonce detected')
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
dbg('PRNG detection : HARDEND nonce detected')
|
||||||
|
return false
|
||||||
|
end
|
||||||
---
|
---
|
||||||
-- The main entry point
|
-- The main entry point
|
||||||
function main(args)
|
local function main(args)
|
||||||
|
|
||||||
local verbose, exit, res, uid, err, _, sak
|
local verbose, exit, res, uid, err, _, sak
|
||||||
local seen_uids = {}
|
local seen_uids = {}
|
||||||
|
@ -121,9 +131,15 @@ function main(args)
|
||||||
-- Seen already?
|
-- Seen already?
|
||||||
uid = res.uid
|
uid = res.uid
|
||||||
sak = res.sak
|
sak = res.sak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if not seen_uids[uid] then
|
if not seen_uids[uid] then
|
||||||
-- Store it
|
-- Store it
|
||||||
seen_uids[uid] = uid
|
seen_uids[uid] = uid
|
||||||
|
|
||||||
|
-- check if PRNG is WEAK
|
||||||
|
if perform_prng_test() then
|
||||||
print("Card found, commencing crack on UID", uid)
|
print("Card found, commencing crack on UID", uid)
|
||||||
-- Crack it
|
-- Crack it
|
||||||
local key, cnt
|
local key, cnt
|
||||||
|
@ -132,8 +148,8 @@ function main(args)
|
||||||
elseif err == -2 then return oops("Card is not vulnerable to Darkside attack (doesn't send NACK on authentication requests).")
|
elseif err == -2 then return oops("Card is not vulnerable to Darkside attack (doesn't send NACK on authentication requests).")
|
||||||
elseif err == -3 then return oops("Card is not vulnerable to Darkside attack (its random number generator is not predictable).")
|
elseif err == -3 then return oops("Card is not vulnerable to Darkside attack (its random number generator is not predictable).")
|
||||||
elseif err == -4 then return oops([[
|
elseif err == -4 then return oops([[
|
||||||
Card is not vulnerable to Darkside attack (its random number generator seems to be based on the wellknown
|
Card is not vulnerable to Darkside attack (its random number generator seems to be based on the wellknown
|
||||||
generating polynomial with 16 effective bits only, but shows unexpected behaviour.]])
|
generating polynomial with 16 effective bits only, but shows unexpected behaviour.]])
|
||||||
elseif err == -5 then return oops("Aborted via keyboard.")
|
elseif err == -5 then return oops("Aborted via keyboard.")
|
||||||
end
|
end
|
||||||
-- The key is actually 8 bytes, so a
|
-- The key is actually 8 bytes, so a
|
||||||
|
@ -148,6 +164,7 @@ generating polynomial with 16 effective bits only, but shows unexpected behaviou
|
||||||
nested(key,sak)
|
nested(key,sak)
|
||||||
-- Dump info
|
-- Dump info
|
||||||
dump(uid)
|
dump(uid)
|
||||||
|
end
|
||||||
print_message = true
|
print_message = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue