mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-04-16 17:35:03 +08:00
ADD; Some 7816 error codes
This commit is contained in:
parent
13629a71d3
commit
12b998cbd8
2 changed files with 104 additions and 25 deletions
client
78
client/lualibs/7816_error.lua
Normal file
78
client/lualibs/7816_error.lua
Normal file
|
@ -0,0 +1,78 @@
|
|||
--[[
|
||||
local _errorcodes = {
|
||||
SW_NO_ERROR = 0x9000,
|
||||
SW_BYTES_REMAINING_00 = 0x6100, -- Response bytes remaining
|
||||
SW_WARNING_STATE_UNCHANGED = 0x6200, -- Warning, card state unchanged =
|
||||
SW_WRONG_LENGTH = 0x6700, -- : Wrong length
|
||||
SW_WRONG_P1P2 = 0x6B00, -- : Incorrect parameters (P1,P2)
|
||||
SW_CORRECT_LENGTH_00 = 0x6C00, -- : Correct Expected Length (Le)
|
||||
SW_INS_NOT_SUPPORTED = 0x6D00, -- : INS value not supported
|
||||
SW_CLA_NOT_SUPPORTED = 0x6E00, -- : CLA value not supported
|
||||
SW_UNKNOWN = 0x6F00, -- : No precise diagnosis
|
||||
|
||||
SW_LOGICAL_CHANNEL_NOT_SUPPORTED = 0x6881, -- : Card does not support the operation on the specified logical channel
|
||||
SW_SECURE_MESSAGING_NOT_SUPPORTED = 0x6882, -- : Card does not support secure messaging
|
||||
SW_LAST_COMMAND_EXPECTED = 0x6883, -- : Last command in chain expected
|
||||
SW_COMMAND_CHAINING_NOT_SUPPORTED = 0x6884, -- : Command chaining not supported
|
||||
|
||||
SW_SECURITY_STATUS_NOT_SATISFIED = 0x6982, -- : Security condition not satisfied
|
||||
SW_FILE_INVALID = 0x6983, -- : File invalid
|
||||
SW_DATA_INVALID = 0x6984, -- : Data invalid
|
||||
SW_CONDITIONS_NOT_SATISFIED = 0x6985, -- : Conditions of use not satisfied
|
||||
SW_COMMAND_NOT_ALLOWED = 0x6986, -- : Command not allowed (no current EF)
|
||||
SW_APPLET_SELECT_FAILED = 0x6999, -- : Applet selection failed
|
||||
|
||||
SW_WRONG_DATA = 0x6A80, -- : Wrong data
|
||||
SW_FUNC_NOT_SUPPORTED = 0x6A81, -- : Function not supported
|
||||
SW_FILE_NOT_FOUND = 0x6A82, -- : File not found
|
||||
SW_RECORD_NOT_FOUND = 0x6A83, -- : Record not found
|
||||
SW_FILE_FULL = 0x6A84, -- : Not enough memory space in the file
|
||||
SW_INCORRECT_P1P2 = 0x6A86, -- : Incorrect parameters (P1,P2)
|
||||
}
|
||||
--]]
|
||||
local _errorcodes = {
|
||||
SW_NO_ERROR = '9000',
|
||||
SW_BYTES_REMAINING_00 = '6100', -- Response bytes remaining
|
||||
SW_WARNING_STATE_UNCHANGED = '6200', -- Warning', card state unchanged =
|
||||
SW_WRONG_LENGTH = '6700', -- : Wrong length
|
||||
SW_WRONG_P1P2 = '6B00', -- : Incorrect parameters (P1,P2)
|
||||
SW_CORRECT_LENGTH_00 = '6C00', -- : Correct Expected Length (Le)
|
||||
SW_INS_NOT_SUPPORTED = '6D00', -- : INS value not supported
|
||||
SW_CLA_NOT_SUPPORTED = '6E00', -- : CLA value not supported
|
||||
SW_UNKNOWN = '6F00', -- : No precise diagnosis
|
||||
|
||||
SW_LOGICAL_CHANNEL_NOT_SUPPORTED = '6881', -- : Card does not support the operation on the specified logical channel
|
||||
SW_SECURE_MESSAGING_NOT_SUPPORTED = '6882', -- : Card does not support secure messaging
|
||||
SW_LAST_COMMAND_EXPECTED = '6883', -- : Last command in chain expected
|
||||
SW_COMMAND_CHAINING_NOT_SUPPORTED = '6884', -- : Command chaining not supported
|
||||
|
||||
SW_SECURITY_STATUS_NOT_SATISFIED = '6982', -- : Security condition not satisfied
|
||||
SW_FILE_INVALID = '6983', -- : File invalid
|
||||
SW_DATA_INVALID = '6984', -- : Data invalid
|
||||
SW_CONDITIONS_NOT_SATISFIED = '6985', -- : Conditions of use not satisfied
|
||||
SW_COMMAND_NOT_ALLOWED = '6986', -- : Command not allowed (no current EF)
|
||||
SW_APPLET_SELECT_FAILED = '6999', -- : Applet selection failed
|
||||
|
||||
SW_WRONG_DATA = '6A80', -- : Wrong data
|
||||
SW_FUNC_NOT_SUPPORTED = '6A81', -- : Function not supported
|
||||
SW_FILE_NOT_FOUND = '6A82', -- : File not found
|
||||
SW_RECORD_NOT_FOUND = '6A83', -- : Record not found
|
||||
SW_FILE_FULL = '6A84', -- : Not enough memory space in the file
|
||||
SW_INCORRECT_P1P2 = '6A86', -- : Incorrect parameters (P1,P2)
|
||||
}
|
||||
|
||||
local _reverse_lookup,k,v = {}
|
||||
for k, v in pairs(_errorcodes) do
|
||||
_reverse_lookup[v] = k
|
||||
end
|
||||
|
||||
_errorcodes.tostring = function(command)
|
||||
if(type(command) == 'string') then
|
||||
return ("%s (%d)"):format(_reverse_lookup[command] or "ERROR UNDEFINED!", command)
|
||||
end
|
||||
if(type(command) == 'number') then
|
||||
return ("%s (%d)"):format(_reverse_lookup[ tostring(command)] or "ERROR UNDEFINED!", command)
|
||||
end
|
||||
return ("Error, numeric or string argument expected, got : %s"):format(tostring(command))
|
||||
end
|
||||
return _errorcodes
|
|
@ -2,6 +2,7 @@ local cmds = require('commands')
|
|||
local getopt = require('getopt')
|
||||
local lib14b = require('read14b')
|
||||
local utils = require('utils')
|
||||
local iso7816 = require('7816_error')
|
||||
|
||||
example = "script runs 14b raw commands to query a CAPLYPSO tag"
|
||||
author = "Iceman, 2016"
|
||||
|
@ -151,35 +152,35 @@ local function calypso_apdu_status(apdu)
|
|||
-- next two is APDU status bytes.
|
||||
local status = false
|
||||
local mess = 'FAIL'
|
||||
local sw = apdu:sub( #apdu-7, #apdu-4)
|
||||
if sw == '9000' then
|
||||
mess = 'OK'
|
||||
status = true
|
||||
end
|
||||
print ('SW', sw, mess )
|
||||
local sw = apdu:sub( #apdu-7, #apdu-4)
|
||||
desc, err = iso7816.tostring(sw)
|
||||
print ('SW', sw, desc, err )
|
||||
|
||||
status = ( sw == '9000' )
|
||||
|
||||
return status
|
||||
end
|
||||
|
||||
local _calypso_cmds = {
|
||||
["01.Select ICC file"] = '02 94 a4 08 00 04 3f 00 00 02',
|
||||
["02.ICC"] = '02 94 b2 01 041d',
|
||||
["03.Select EnvHol file"] = '02 94 a4 08 00 04 20 00 20 01',
|
||||
["04.EnvHol1"] = '02 94 b2 01 041d',
|
||||
["05.Select EvLog file"] = '02 94 a4 08 00 04 20 00 20 10',
|
||||
["06.EvLog1"] = '02 94 b2 01 041d',
|
||||
["07.EvLog2"] = '02 94 b2 02 041d',
|
||||
["08.EvLog3"] = '02 94 b2 03 041d',
|
||||
["09.Select ConList file"] ='02 94 a4 0800 04 2000 2050',
|
||||
["10.ConList"] = '02 94 b2 01 041d',
|
||||
["11.Select Contra file"] = '02 94 a4 0800 04 2000 2020',
|
||||
["12.Contra1"] = '02 94 b2 01 041d',
|
||||
["13.Contra2"] = '02 94 b2 02 041d',
|
||||
["14.Contra3"] = '02 94 b2 03 041d',
|
||||
["15.Contra4"] = '02 94 b2 04 041d',
|
||||
["16.Select Counter file"]= '02 94 a4 0800 04 2000 2069',
|
||||
["17.Counter"] = '02 94 b2 01 041d',
|
||||
["18.Select SpecEv file"]= '02 94 a4 08 0004 2000 2040',
|
||||
["19.SpecEv1"] = '02 94 b2 01 041d',
|
||||
["01.Select ICC file"] = '0294 a4 080004 3f00 0002',
|
||||
["02.ICC"] = '0294 b2 01 041d',
|
||||
["03.Select EnvHol file"] = '0294 a4 080004 2000 2001',
|
||||
["04.EnvHol1"] = '0294 b2 01 041d',
|
||||
["05.Select EvLog file"] = '0294 a4 080004 2000 2010',
|
||||
["06.EvLog1"] = '0294 b2 01 041d',
|
||||
["07.EvLog2"] = '0294 b2 02 041d',
|
||||
["08.EvLog3"] = '0294 b2 03 041d',
|
||||
["09.Select ConList file"] ='0294 a4 080004 2000 2050',
|
||||
["10.ConList"] = '0294 b2 01 041d',
|
||||
["11.Select Contra file"] = '0294 a4 080004 2000 2020',
|
||||
["12.Contra1"] = '0294 b2 01 041d',
|
||||
["13.Contra2"] = '0294 b2 02 041d',
|
||||
["14.Contra3"] = '0294 b2 03 041d',
|
||||
["15.Contra4"] = '0294 b2 04 041d',
|
||||
["16.Select Counter file"]= '0294 a4 080004 2000 2069',
|
||||
["17.Counter"] = '0294 b2 01 041d',
|
||||
["18.Select SpecEv file"]= '0294 a4 080004 2000 2040',
|
||||
["19.SpecEv1"] = '0294 b2 01 041d',
|
||||
}
|
||||
|
||||
---
|
||||
|
|
Loading…
Add table
Reference in a new issue