mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08:00
add record manipulation commands
This commit is contained in:
parent
9bcb30256e
commit
dbe85e731f
4 changed files with 41 additions and 4 deletions
|
@ -1116,7 +1116,7 @@ int DesfireWriteFile(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32
|
|||
}
|
||||
|
||||
int DesfireValueFileOperations(DesfireContext *dctx, uint8_t fid, uint8_t operation, uint32_t *value) {
|
||||
uint8_t data[250] = {0};
|
||||
uint8_t data[10] = {0};
|
||||
data[0] = fid;
|
||||
size_t datalen = (operation == MFDES_GET_VALUE) ? 1 : 5;
|
||||
if (value)
|
||||
|
@ -1132,6 +1132,35 @@ int DesfireValueFileOperations(DesfireContext *dctx, uint8_t fid, uint8_t operat
|
|||
return res;
|
||||
}
|
||||
|
||||
int DesfireReadRecords(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint32_t reccount, uint8_t *resp, size_t *resplen) {
|
||||
uint8_t data[10] = {0};
|
||||
data[0] = fnum;
|
||||
Uint3byteToMemLe(&data[1], recnum);
|
||||
Uint3byteToMemLe(&data[4], reccount);
|
||||
|
||||
return DesfireCommand(dctx, MFDES_READ_RECORDS, data, 7, resp, resplen, -1);
|
||||
}
|
||||
|
||||
int DesfireWriteRecord(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_t len, uint8_t *data) {
|
||||
uint8_t xdata[1024] = {0};
|
||||
xdata[0] = fnum;
|
||||
Uint3byteToMemLe(&xdata[1], offset);
|
||||
Uint3byteToMemLe(&xdata[4], len);
|
||||
memcpy(&xdata[7], data, len);
|
||||
|
||||
return DesfireCommandTxData(dctx, MFDES_WRITE_RECORD, xdata, 7 + len);
|
||||
}
|
||||
|
||||
int DesfireUpdateRecord(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint32_t offset, uint32_t len, uint8_t *data) {
|
||||
uint8_t xdata[1024] = {0};
|
||||
xdata[0] = fnum;
|
||||
Uint3byteToMemLe(&xdata[1], recnum);
|
||||
Uint3byteToMemLe(&xdata[4], offset);
|
||||
Uint3byteToMemLe(&xdata[7], len);
|
||||
memcpy(&xdata[10], data, len);
|
||||
|
||||
return DesfireCommandTxData(dctx, MFDES_UPDATE_RECORD, xdata, 10 + len);
|
||||
}
|
||||
|
||||
uint8_t DesfireKeyAlgoToType(DesfireCryptoAlgorythm keyType) {
|
||||
switch (keyType) {
|
||||
|
|
|
@ -107,5 +107,8 @@ int DesfireClearRecordFile(DesfireContext *dctx, uint8_t fnum);
|
|||
|
||||
int DesfireReadFile(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_t len, uint8_t *resp, size_t *resplen);
|
||||
int DesfireWriteFile(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_t len, uint8_t *data);
|
||||
int DesfireReadRecords(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint32_t reccount, uint8_t *resp, size_t *resplen);
|
||||
int DesfireWriteRecord(DesfireContext *dctx, uint8_t fnum, uint32_t offset, uint32_t len, uint8_t *data);
|
||||
int DesfireUpdateRecord(DesfireContext *dctx, uint8_t fnum, uint32_t recnum, uint32_t offset, uint32_t len, uint8_t *data);
|
||||
|
||||
#endif // __DESFIRECORE_H
|
||||
|
|
|
@ -61,7 +61,7 @@ static const AllowedChannelModesS AllowedChannelModes[] = {
|
|||
{MFDES_LIMITED_CREDIT, DACd40, DCCNative, DCMMACed},
|
||||
{MFDES_READ_RECORDS, DACd40, DCCNative, DCMMACed},
|
||||
{MFDES_WRITE_RECORD, DACd40, DCCNative, DCMMACed},
|
||||
{MFDES_UPDATE_RECORD1, DACd40, DCCNative, DCMMACed},
|
||||
{MFDES_UPDATE_RECORD, DACd40, DCCNative, DCMMACed},
|
||||
{MFDES_UPDATE_RECORD2, DACd40, DCCNativeISO, DCMMACed},
|
||||
{MFDES_INIT_KEY_SETTINGS, DACd40, DCCNative, DCMMACed},
|
||||
{MFDES_FINALIZE_KEY_SETTINGS, DACd40, DCCNative, DCMMACed},
|
||||
|
@ -122,6 +122,9 @@ static const CmdHeaderLengthsS CmdHeaderLengths[] = {
|
|||
{MFDES_CREATE_TRANS_MAC_FILE, 5},
|
||||
{MFDES_READ_DATA, 7},
|
||||
{MFDES_WRITE_DATA, 7},
|
||||
{MFDES_READ_RECORDS, 7},
|
||||
{MFDES_WRITE_RECORD, 7},
|
||||
{MFDES_UPDATE_RECORD, 10},
|
||||
};
|
||||
|
||||
static uint8_t DesfireGetCmdHeaderLen(uint8_t cmd) {
|
||||
|
|
|
@ -435,11 +435,13 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
|
|||
#define MFDES_GET_FREE_MEMORY 0x6E
|
||||
#define MFDES_GET_DF_NAMES 0x6D
|
||||
#define MFDES_GET_FILE_IDS 0x6F
|
||||
#define MFDES_WRITE_RECORD2 0x8B
|
||||
#define MFDES_WRITE_DATA2 0x8D
|
||||
#define MFDES_ABORT_TRANSACTION 0xA7
|
||||
#define MFDES_READ_RECORDS2 0xAB
|
||||
#define MFDES_READ_DATA2 0xAD
|
||||
#define MFDES_ADDITIONAL_FRAME 0xAF
|
||||
#define MFDES_UPDATE_RECORD1 0xBA
|
||||
#define MFDES_UPDATE_RECORD2 0xBA
|
||||
#define MFDES_READ_RECORDS 0xBB
|
||||
#define MFDES_READ_DATA 0xBD
|
||||
#define MFDES_CREATE_CYCLIC_RECORD_FILE 0xC0
|
||||
|
@ -455,7 +457,7 @@ ISO 7816-4 Basic interindustry commands. For command APDU's.
|
|||
#define MFDES_CREATE_STD_DATA_FILE 0xCD
|
||||
#define MFDES_CREATE_TRANS_MAC_FILE 0xCE
|
||||
#define MFDES_DELETE_APPLICATION 0xDA
|
||||
#define MFDES_UPDATE_RECORD2 0xDB
|
||||
#define MFDES_UPDATE_RECORD 0xDB
|
||||
#define MFDES_DEBIT 0xDC
|
||||
#define MFDES_DELETE_FILE 0xDF
|
||||
#define MFDES_CLEAR_RECORD_FILE 0xEB
|
||||
|
|
Loading…
Reference in a new issue