mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
gave 14b commands some serious love and overhaul. package handling for APDU and different selects is improved. return codes now consequent
This commit is contained in:
parent
5709d8959d
commit
82aa6ac08c
11 changed files with 350 additions and 337 deletions
|
@ -29,6 +29,9 @@ Check there for details about data format and how commands are interpreted on th
|
|||
device-side.
|
||||
]]
|
||||
|
||||
local PM3_SUCCESS = 0
|
||||
|
||||
-- iceman, todo: return payload from ISO14b APDU is a struct now. iso14b_raw_apdu_response_t
|
||||
local function calypso_parse(result)
|
||||
if result.Oldarg0 >= 0 then
|
||||
local len = result.Oldarg0 * 2
|
||||
|
@ -112,9 +115,7 @@ end
|
|||
local function calypso_send_cmd_raw(data, ignoreresponse )
|
||||
|
||||
local flags = lib14b.ISO14B_COMMAND.ISO14B_APDU
|
||||
-- flags = lib14b.ISO14B_COMMAND.ISO14B_RAW +
|
||||
-- lib14b.ISO14B_COMMAND.ISO14B_APPEND_CRC
|
||||
local flags = lib14b.ISO14B_COMMAND.ISO14B_APDU
|
||||
|
||||
data = data or ""
|
||||
-- LEN of data, half the length of the ASCII-string hex string
|
||||
-- 2 bytes flags
|
||||
|
@ -129,7 +130,7 @@ local function calypso_send_cmd_raw(data, ignoreresponse )
|
|||
local c = Command:newNG{cmd = cmds.CMD_HF_ISO14443B_COMMAND, data = senddata}
|
||||
local result, err = c:sendNG(ignoreresponse, 2000)
|
||||
if result then
|
||||
if result.Oldarg0 >= 0 then
|
||||
if result.status == PM3_SUCCESS then
|
||||
return calypso_parse(result)
|
||||
else
|
||||
err = 'card response failed'
|
||||
|
@ -144,7 +145,7 @@ end
|
|||
-- writes it in the tree in decimal format.
|
||||
local function calypso_card_num(card)
|
||||
if not card then return end
|
||||
local card_num = tonumber( card.uid:sub(1,8),16 )
|
||||
local card_num = tonumber( card.uid:sub(1, 8), 16)
|
||||
print('')
|
||||
print('Card UID ' ..ansicolors.green..card.uid:format('%x')..ansicolors.reset)
|
||||
print('Card Number ' ..ansicolors.green..string.format('%u', card_num)..ansicolors.reset)
|
||||
|
@ -156,7 +157,7 @@ local function calypso_apdu_status(apdu)
|
|||
-- last two is CRC
|
||||
-- next two is APDU status bytes.
|
||||
local mess = 'FAIL'
|
||||
local sw = apdu:sub( #apdu-7, #apdu-4)
|
||||
local sw = apdu:sub( #apdu - 7 , #apdu - 4)
|
||||
desc, err = iso7816.tostring(sw)
|
||||
--print ('SW', sw, desc, err )
|
||||
local status = ( sw == '9000' )
|
||||
|
@ -250,7 +251,7 @@ function main(args)
|
|||
for i, apdu in spairs(_calypso_cmds) do
|
||||
print('>> '..ansicolors.yellow..i..ansicolors.reset)
|
||||
apdu = apdu:gsub('%s+', '')
|
||||
data, err = calypso_send_cmd_raw(apdu , false)
|
||||
data, err = calypso_send_cmd_raw(apdu, false)
|
||||
if err then
|
||||
print('<< '..err)
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue