mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
commit
bb62550b0d
5 changed files with 36 additions and 36 deletions
|
@ -1479,42 +1479,42 @@ int lf_em410x_watch(int findone, uint32_t *high, uint64_t *low) {
|
||||||
int type = Em410xDecode(dest, &size, &idx, &hi, &lo);
|
int type = Em410xDecode(dest, &size, &idx, &hi, &lo);
|
||||||
if (type & 0x1) {
|
if (type & 0x1) {
|
||||||
Dbprintf("EM TAG ID: " _GREEN_("%02x%08x") " - ( %05d_%03d_%08d )",
|
Dbprintf("EM TAG ID: " _GREEN_("%02x%08x") " - ( %05d_%03d_%08d )",
|
||||||
(uint32_t)(lo >> 32),
|
(uint32_t)(lo >> 32),
|
||||||
(uint32_t)lo,
|
(uint32_t)lo,
|
||||||
(uint32_t)(lo & 0xFFFF),
|
(uint32_t)(lo & 0xFFFF),
|
||||||
(uint32_t)((lo >> 16LL) & 0xFF),
|
(uint32_t)((lo >> 16LL) & 0xFF),
|
||||||
(uint32_t)(lo & 0xFFFFFF));
|
(uint32_t)(lo & 0xFFFFFF));
|
||||||
}
|
}
|
||||||
if (type & 0x2) {
|
if (type & 0x2) {
|
||||||
Dbprintf("EM XL TAG ID: " _GREEN_("%06x%08x%08x") " - ( %05d_%03d_%08d )",
|
Dbprintf("EM XL TAG ID: " _GREEN_("%06x%08x%08x") " - ( %05d_%03d_%08d )",
|
||||||
hi,
|
hi,
|
||||||
(uint32_t)(lo >> 32),
|
(uint32_t)(lo >> 32),
|
||||||
(uint32_t)lo,
|
(uint32_t)lo,
|
||||||
(uint32_t)(lo & 0xFFFF),
|
(uint32_t)(lo & 0xFFFF),
|
||||||
(uint32_t)((lo >> 16LL) & 0xFF),
|
(uint32_t)((lo >> 16LL) & 0xFF),
|
||||||
(uint32_t)(lo & 0xFFFFFF));
|
(uint32_t)(lo & 0xFFFFFF));
|
||||||
}
|
}
|
||||||
if (type & 0x4) {
|
if (type & 0x4) {
|
||||||
uint64_t data = (lo << 20) >> 20;
|
uint64_t data = (lo << 20) >> 20;
|
||||||
// Convert back to Short ID
|
// Convert back to Short ID
|
||||||
uint64_t id = ((uint64_t)hi << 16 ) | (lo >> 48);
|
uint64_t id = ((uint64_t)hi << 16) | (lo >> 48);
|
||||||
if ((data & 0xFFFFFFFF) == 0) {
|
if ((data & 0xFFFFFFFF) == 0) {
|
||||||
Dbprintf("EM TAG ID: " _GREEN_("%02x%08x") " - ( %05d_%03d_%08d ) Electra "_GREEN_("%i"),
|
Dbprintf("EM TAG ID: " _GREEN_("%02x%08x") " - ( %05d_%03d_%08d ) Electra "_GREEN_("%i"),
|
||||||
(uint32_t)(id >> 32),
|
(uint32_t)(id >> 32),
|
||||||
(uint32_t)id,
|
(uint32_t)id,
|
||||||
(uint32_t)(id & 0xFFFF),
|
(uint32_t)(id & 0xFFFF),
|
||||||
(uint32_t)((id >> 16LL) & 0xFF),
|
(uint32_t)((id >> 16LL) & 0xFF),
|
||||||
(uint32_t)(id & 0xFFFFFF),
|
(uint32_t)(id & 0xFFFFFF),
|
||||||
(uint32_t)(data >> 32));
|
(uint32_t)(data >> 32));
|
||||||
} else {
|
} else {
|
||||||
Dbprintf("EM TAG ID: " _GREEN_("%02x%08x") " - ( %05d_%03d_%08d ) on 128b frame with data "_GREEN_("%03x%08x"),
|
Dbprintf("EM TAG ID: " _GREEN_("%02x%08x") " - ( %05d_%03d_%08d ) on 128b frame with data "_GREEN_("%03x%08x"),
|
||||||
(uint32_t)(id >> 32),
|
(uint32_t)(id >> 32),
|
||||||
(uint32_t)id,
|
(uint32_t)id,
|
||||||
(uint32_t)(id & 0xFFFF),
|
(uint32_t)(id & 0xFFFF),
|
||||||
(uint32_t)((id >> 16LL) & 0xFF),
|
(uint32_t)((id >> 16LL) & 0xFF),
|
||||||
(uint32_t)(id & 0xFFFFFF),
|
(uint32_t)(id & 0xFFFFFF),
|
||||||
(uint32_t)(data >> 32),
|
(uint32_t)(data >> 32),
|
||||||
(uint32_t)data);
|
(uint32_t)data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((type > 0) && findone) {
|
if ((type > 0) && findone) {
|
||||||
|
|
|
@ -114,7 +114,7 @@ void printEM410x(uint32_t hi, uint64_t id, bool verbose, int type) {
|
||||||
if (type & 0x4) { // Short Extended ID
|
if (type & 0x4) { // Short Extended ID
|
||||||
uint64_t data = (id << 20) >> 20;
|
uint64_t data = (id << 20) >> 20;
|
||||||
// Convert back to Short ID
|
// Convert back to Short ID
|
||||||
id = ((uint64_t)hi << 16 ) | (id >> 48);
|
id = ((uint64_t)hi << 16) | (id >> 48);
|
||||||
if ((data & 0xFFFFFFFF) == 0) {
|
if ((data & 0xFFFFFFFF) == 0) {
|
||||||
PrintAndLogEx(SUCCESS, "EM 410x ID "_GREEN_("%010" PRIX64)" Electra "_GREEN_("%03" PRIu64), id, data >> 32);
|
PrintAndLogEx(SUCCESS, "EM 410x ID "_GREEN_("%010" PRIX64)" Electra "_GREEN_("%03" PRIu64), id, data >> 32);
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,7 +137,7 @@ void printEM410x(uint32_t hi, uint64_t id, bool verbose, int type) {
|
||||||
}
|
}
|
||||||
PrintAndLogEx(SUCCESS, " Short ID details:");
|
PrintAndLogEx(SUCCESS, " Short ID details:");
|
||||||
// Convert back to Short ID
|
// Convert back to Short ID
|
||||||
id = ((uint64_t)hi << 16 ) | (id >> 48);
|
id = ((uint64_t)hi << 16) | (id >> 48);
|
||||||
}
|
}
|
||||||
if (type & (0x4 | 0x1)) { // Short Extended or Short ID
|
if (type & (0x4 | 0x1)) { // Short Extended or Short ID
|
||||||
//output 40 bit em id
|
//output 40 bit em id
|
||||||
|
|
|
@ -1822,7 +1822,7 @@ int DesfireFillFileList(DesfireContext *dctx, FileListS FileList, size_t *filesc
|
||||||
isoindx++;
|
isoindx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isoindx * 2 != buflen)
|
if (isoindx * 2 != buflen)
|
||||||
PrintAndLogEx(WARNING, "Wrong ISO ID list length. must be %zu but %zu", buflen, isoindx * 2);
|
PrintAndLogEx(WARNING, "Wrong ISO ID list length. must be %zu but %zu", buflen, isoindx * 2);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,7 +42,7 @@ static bool CommandCanUseAnyChannel(uint8_t cmd) {
|
||||||
|
|
||||||
static const AllowedChannelModesS AllowedChannelModes[] = {
|
static const AllowedChannelModesS AllowedChannelModes[] = {
|
||||||
{MFDES_SELECT_APPLICATION, DACd40, DCCNative, DCMPlain},
|
{MFDES_SELECT_APPLICATION, DACd40, DCCNative, DCMPlain},
|
||||||
|
|
||||||
{MFDES_CREATE_APPLICATION, DACd40, DCCNative, DCMMACed},
|
{MFDES_CREATE_APPLICATION, DACd40, DCCNative, DCMMACed},
|
||||||
{MFDES_DELETE_APPLICATION, DACd40, DCCNative, DCMMACed},
|
{MFDES_DELETE_APPLICATION, DACd40, DCCNative, DCMMACed},
|
||||||
{MFDES_GET_APPLICATION_IDS, DACd40, DCCNative, DCMMACed},
|
{MFDES_GET_APPLICATION_IDS, DACd40, DCCNative, DCMMACed},
|
||||||
|
@ -159,7 +159,7 @@ static const uint8_t EV1D40TransmitMAC[] = {
|
||||||
static bool DesfireEV1D40TransmitMAC(DesfireContext *ctx, uint8_t cmd) {
|
static bool DesfireEV1D40TransmitMAC(DesfireContext *ctx, uint8_t cmd) {
|
||||||
if (ctx->secureChannel != DACd40 && ctx->secureChannel != DACEV1)
|
if (ctx->secureChannel != DACd40 && ctx->secureChannel != DACEV1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (int i = 0; i < ARRAY_LENGTH(EV1D40TransmitMAC); i++)
|
for (int i = 0; i < ARRAY_LENGTH(EV1D40TransmitMAC); i++)
|
||||||
if (EV1D40TransmitMAC[i] == cmd)
|
if (EV1D40TransmitMAC[i] == cmd)
|
||||||
return true;
|
return true;
|
||||||
|
@ -178,7 +178,7 @@ static const uint8_t D40ReceiveMAC[] = {
|
||||||
static bool DesfireEV1D40ReceiveMAC(DesfireContext *ctx, uint8_t cmd) {
|
static bool DesfireEV1D40ReceiveMAC(DesfireContext *ctx, uint8_t cmd) {
|
||||||
if (ctx->secureChannel != DACd40)
|
if (ctx->secureChannel != DACd40)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (int i = 0; i < ARRAY_LENGTH(D40ReceiveMAC); i++)
|
for (int i = 0; i < ARRAY_LENGTH(D40ReceiveMAC); i++)
|
||||||
if (D40ReceiveMAC[i] == cmd)
|
if (D40ReceiveMAC[i] == cmd)
|
||||||
return true;
|
return true;
|
||||||
|
@ -214,12 +214,12 @@ static void DesfireSecureChannelEncodeD40(DesfireContext *ctx, uint8_t cmd, uint
|
||||||
} else if (ctx->commMode == DCMEncrypted || ctx->commMode == DCMEncryptedWithPadding) {
|
} else if (ctx->commMode == DCMEncrypted || ctx->commMode == DCMEncryptedWithPadding) {
|
||||||
if (srcdatalen <= hdrlen)
|
if (srcdatalen <= hdrlen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t paddinglen = (ctx->commMode == DCMEncryptedWithPadding) ? 1 : 0;
|
uint8_t paddinglen = (ctx->commMode == DCMEncryptedWithPadding) ? 1 : 0;
|
||||||
rlen = padded_data_length(srcdatalen + 2 + paddinglen - hdrlen, desfire_get_key_block_length(ctx->keyType)) + hdrlen; // 2 - crc16
|
rlen = padded_data_length(srcdatalen + 2 + paddinglen - hdrlen, desfire_get_key_block_length(ctx->keyType)) + hdrlen; // 2 - crc16
|
||||||
memcpy(data, &srcdata[hdrlen], srcdatalen - hdrlen);
|
memcpy(data, &srcdata[hdrlen], srcdatalen - hdrlen);
|
||||||
iso14443a_crc_append(data, srcdatalen - hdrlen);
|
iso14443a_crc_append(data, srcdatalen - hdrlen);
|
||||||
|
|
||||||
// add padding
|
// add padding
|
||||||
if (paddinglen > 0)
|
if (paddinglen > 0)
|
||||||
data[srcdatalen - hdrlen + 2] = 0x80;
|
data[srcdatalen - hdrlen + 2] = 0x80;
|
||||||
|
@ -269,11 +269,11 @@ static void DesfireSecureChannelEncodeEV1(DesfireContext *ctx, uint8_t cmd, uint
|
||||||
uint8_t paddinglen = (ctx->commMode == DCMEncryptedWithPadding) ? 1 : 0;
|
uint8_t paddinglen = (ctx->commMode == DCMEncryptedWithPadding) ? 1 : 0;
|
||||||
rlen = padded_data_length(srcdatalen + 4 + paddinglen - hdrlen, desfire_get_key_block_length(ctx->keyType));
|
rlen = padded_data_length(srcdatalen + 4 + paddinglen - hdrlen, desfire_get_key_block_length(ctx->keyType));
|
||||||
data[0] = cmd;
|
data[0] = cmd;
|
||||||
|
|
||||||
// crc
|
// crc
|
||||||
memcpy(&data[1], srcdata, srcdatalen);
|
memcpy(&data[1], srcdata, srcdatalen);
|
||||||
desfire_crc32_append(data, srcdatalen + 1);
|
desfire_crc32_append(data, srcdatalen + 1);
|
||||||
|
|
||||||
// add padding
|
// add padding
|
||||||
if (paddinglen > 0)
|
if (paddinglen > 0)
|
||||||
data[srcdatalen + 1 + 4] = 0x80;
|
data[srcdatalen + 1 + 4] = 0x80;
|
||||||
|
|
|
@ -9864,6 +9864,6 @@
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"commands_extracted": 587,
|
"commands_extracted": 587,
|
||||||
"extracted_by": "PM3Help2JSON v1.00",
|
"extracted_by": "PM3Help2JSON v1.00",
|
||||||
"extracted_on": "2021-08-04T12:46:55"
|
"extracted_on": "2021-08-04T21:00:22"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue