hf mf rdbl - uses NG
This commit is contained in:
@@ -49,6 +49,7 @@ local lsh = bit32.lshift
|
||||
local rsh = bit32.rshift
|
||||
|
||||
-- Some globals
|
||||
local PM3_SUCCESS = 0
|
||||
local FOO = 'AF62D2EC0491968CC52A1A7165F865FE'
|
||||
local BAR = '286329204469736E65792032303133'
|
||||
local MIS = '0A14FD0507FF4BCD026BA83F0A3B89A9'
|
||||
@@ -463,20 +464,19 @@ local function getblockdata(response)
|
||||
if not response then
|
||||
return nil, 'No response from device'
|
||||
end
|
||||
|
||||
local count, cmd, arg0 = bin.unpack('LL', response)
|
||||
if arg0 == 1 then
|
||||
local count, arg1, arg2, data = bin.unpack('LLH511', response, count)
|
||||
return data:sub(1, 32)
|
||||
if response.Status == PM3_SUCCESS then
|
||||
return response.Data
|
||||
else
|
||||
return nil, "Couldn't read block.. ["..arg0.."]"
|
||||
return nil, "Couldn't read block.. ["..response.Status.."]"
|
||||
end
|
||||
end
|
||||
|
||||
local function readblock( blocknum, key )
|
||||
local function readblock( blockno, key )
|
||||
-- Read block N
|
||||
local c = Command:newMIX{cmd = cmds.CMD_MIFARE_READBL, arg1 = blocknum, data = key}
|
||||
local b, err = getblockdata(c:sendMIX())
|
||||
local keytype = '00'
|
||||
local data = ('%02x%s%s'):format(blockno, keytype, key)
|
||||
local c = Command:newNG{cmd = cmds.CMD_MIFARE_READBL, data = data}
|
||||
local b, err = getblockdata(c:sendNG(false))
|
||||
if not b then return oops(err) end
|
||||
return b
|
||||
end
|
||||
|
||||
@@ -40,6 +40,9 @@ Arguments:
|
||||
023c - Special
|
||||
0020 - Swapforce
|
||||
]]
|
||||
|
||||
local PM3_SUCCESS = 0
|
||||
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
local function oops(err)
|
||||
@@ -63,20 +66,19 @@ local function getblockdata(response)
|
||||
if not response then
|
||||
return nil, 'No response from device'
|
||||
end
|
||||
|
||||
local count, cmd, arg0 = bin.unpack('LL', response)
|
||||
if arg0 == 1 then
|
||||
local count, arg1, arg2, data = bin.unpack('LLH511', response, count)
|
||||
return data:sub(1, 32)
|
||||
if response.Status == PM3_SUCCESS then
|
||||
return response.Data
|
||||
else
|
||||
return nil, "Couldn't read block.. ["..arg0.."]"
|
||||
return nil, "Couldn't read block.. ["..response.Status.."]"
|
||||
end
|
||||
end
|
||||
|
||||
local function readblock( blocknum, keyA )
|
||||
-- Read block N
|
||||
local c = Command:newMIX{cmd = cmds.CMD_MIFARE_READBL, arg1 = blocknum, data = keyA}
|
||||
local b, err = getblockdata(c:sendMIX())
|
||||
local keytype = '00'
|
||||
local data = ('%02x%s%s'):format(blocknum, keytype, keyA)
|
||||
local c = Command:newNG{cmd = cmds.CMD_MIFARE_READBL, data = data}
|
||||
local b, err = getblockdata(c:sendNG(false))
|
||||
if not b then return oops(err) end
|
||||
return b
|
||||
end
|
||||
|
||||
@@ -35,6 +35,8 @@ Arguments:
|
||||
-p : Use the precalc to find all keys
|
||||
-o : filename for the saved dumps
|
||||
]]
|
||||
|
||||
local PM3_SUCCESS = 0
|
||||
local RANDOM = '20436F707972696768742028432920323031302041637469766973696F6E2E20416C6C205269676874732052657365727665642E20'
|
||||
local DEBUG = false -- the debug flag
|
||||
local numBlocks = 64
|
||||
@@ -91,13 +93,10 @@ local function getblockdata(response)
|
||||
if not response then
|
||||
return nil, 'No response from device'
|
||||
end
|
||||
|
||||
local count, cmd, arg0 = bin.unpack('LL', response)
|
||||
if arg0 == 1 then
|
||||
local count, arg1, arg2, data = bin.unpack('LLH511', response, count)
|
||||
return data:sub(1, 32)
|
||||
if response.Status == PM3_SUCCESS then
|
||||
return response.Data
|
||||
else
|
||||
return nil, "Couldn't read block.. ["..arg0.."]"
|
||||
return nil, "Couldn't read block.. ["..response.Status.."]"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -167,16 +166,21 @@ local function main(args)
|
||||
local block0, block1
|
||||
-- Read block 0
|
||||
dbg('Reading block 0')
|
||||
cmd = Command:newMIX{cmd = cmds.CMD_MIFARE_READBL, arg1 = 0, data = keyA}
|
||||
block0, err = getblockdata(cmd:sendMIX(false))
|
||||
local blockno = '00'
|
||||
local keytype = '00'
|
||||
local data = ('%s%s%s'):format(blockno, keytype, keyA)
|
||||
cmd = Command:newNG{cmd = cmds.CMD_MIFARE_READBL, data = data}
|
||||
block0, err = getblockdata(cmd:sendNG(false))
|
||||
if not block0 then return oops(err) end
|
||||
|
||||
core.clearCommandBuffer()
|
||||
|
||||
-- Read block 1
|
||||
dbg('Reading block 1')
|
||||
cmd = Command:newMIX{cmd = cmds.CMD_MIFARE_READBL, arg1 = 1, data = keyA}
|
||||
block1, err = getblockdata(cmd:sendMIX(false))
|
||||
local blockno = '01'
|
||||
data = ('%s%s%s'):format(blockno, keytype, keyA)
|
||||
cmd = Command:newNG{cmd = cmds.CMD_MIFARE_READBL, data = data}
|
||||
block1, err = getblockdata(cmd:sendNG(false))
|
||||
if not block1 then return oops(err) end
|
||||
|
||||
core.clearCommandBuffer()
|
||||
@@ -203,8 +207,9 @@ local function main(args)
|
||||
|
||||
pos = (math.floor( blockNo / 4 ) * 12)+1
|
||||
key = akeys:sub(pos, pos + 11 )
|
||||
cmd = Command:newMIX{cmd = cmds.CMD_MIFARE_READBL, arg1 = blockNo, data = key}
|
||||
local blockdata, err = getblockdata(cmd:sendMIX(false))
|
||||
data = ('%02x%s%s'):format(blockNo, keytype, key)
|
||||
cmd = Command:newNG{cmd = cmds.CMD_MIFARE_READBL, data = data}
|
||||
local blockdata, err = getblockdata(cmd:sendNG(false))
|
||||
if not blockdata then return oops(err) end
|
||||
|
||||
if blockNo%4 ~= 3 then
|
||||
|
||||
Reference in New Issue
Block a user