From 717ceecf1fcb53623e009ddd74c0917b98d473f4 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 21 Feb 2025 17:08:44 +0100 Subject: [PATCH] denote MAD sectors as decimal since public documentation --- client/src/cmdhfmf.c | 7 ------- client/src/cmdhfmfdes.c | 13 ++++++++++++- client/src/cmdhfmfp.c | 14 +++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 7034ab6f3..977a9cad2 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -121,13 +121,6 @@ static char *GenerateFilename(const char *prefix, const char *suffix) { // Each entry also stores whether the key was "found", defaults to false (0) static int initSectorTable(sector_t **src, size_t items) { - - // typedef struct { - // uint64_t Key[2]; - // uint8_t foundKey[2]; - // } sector_t; - - // This allocates based on the size of a single item (*src) = calloc(items, sizeof(sector_t)); if (*src == NULL) { return PM3_EMALLOC; diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 8a63b75ed..123760fcd 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -180,10 +180,21 @@ typedef struct { const char *comment; } mfdesCommonAID_t; +/* +PACS application id(s) - HID Factory, CP1000 Standard, Mobile, Custom and Elite +We have HID Factory, Field Encoder == CP1000 (?) +No mobile, Custom or Elite +*/ + static const mfdesCommonAID_t commonAids[] = { - // AID, name/comment + { 0x53494F, "\x53\x49\x4F", "SIO DESFire EV1 - HID Factory" }, + { 0xD3494F, "\xD3\x49\x4F", "SIO DESFire EV1 - Field Encoder" }, + { 0xD9494F, "\xD9\x49\x4F", "SIO DESFire EV1 - Field Encoder" }, + { 0xF484E3, "\xF4\x84\xE3", "SE Enhanced" }, + { 0xF484E4, "\xF4\x84\xE4", "SE Enhanced" }, { 0xF4812F, "\xf4\x81\x2f", "Gallagher card data application" }, { 0xF48120, "\xf4\x81\x20", "Gallagher card application directory" }, // Can be 0xF48120 - 0xF4812B, but I've only ever seen 0xF48120 + { 0xF47300, "\xf4\x73\x00", "Inner Range card application" }, }; static int CmdHelp(const char *Cmd); diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index bb3bbe58d..37e76a0f7 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -1812,7 +1812,7 @@ static int CmdHFMFPMAD(const char *Cmd) { } uint8_t sector0[16 * 4] = {0}; - uint8_t sector10[16 * 4] = {0}; + uint8_t sector16[16 * 4] = {0}; if (mfpReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector0, verbose)) { PrintAndLogEx(NORMAL, ""); @@ -1832,19 +1832,19 @@ static int CmdHFMFPMAD(const char *Cmd) { MAD1DecodeAndPrint(sector0, swapmad, verbose, &haveMAD2); if (haveMAD2) { - if (mfpReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector10, verbose)) { + if (mfpReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector16, verbose)) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(ERR, "error, read sector " _YELLOW_("0x10") ". Card doesn't have MAD or doesn't have MAD on default keys"); return PM3_ESOFT; } - MAD2DecodeAndPrint(sector10, swapmad, verbose); + MAD2DecodeAndPrint(sector16, swapmad, verbose); } if (aidlen == 2 || decodeholder) { uint16_t mad[7 + 8 + 8 + 8 + 8] = {0}; size_t madlen = 0; - if (MADDecode(sector0, sector10, mad, &madlen, swapmad)) { + if (MADDecode(sector0, sector16, mad, &madlen, swapmad)) { PrintAndLogEx(ERR, "can't decode MAD"); return PM3_EWRONGANSWER; } @@ -1990,7 +1990,7 @@ int CmdHFMFPNDEFRead(const char *Cmd) { } uint8_t sector0[MIFARE_1K_MAXBLOCK] = {0}; - uint8_t sector10[MIFARE_1K_MAXBLOCK] = {0}; + uint8_t sector16[MIFARE_1K_MAXBLOCK] = {0}; uint8_t data[MIFARE_4K_MAX_BYTES] = {0}; int datalen = 0; @@ -2015,7 +2015,7 @@ int CmdHFMFPNDEFRead(const char *Cmd) { if (verbose) PrintAndLogEx(INFO, "reading MAD v2 sector"); - if (mfpReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector10, verbose)) { + if (mfpReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector16, verbose)) { PrintAndLogEx(ERR, "error, read sector 0x10. card doesn't have MAD or doesn't have MAD on default keys"); PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndefread -k `") " with your custom key"); return PM3_ESOFT; @@ -2024,7 +2024,7 @@ int CmdHFMFPNDEFRead(const char *Cmd) { uint16_t mad[7 + 8 + 8 + 8 + 8] = {0}; size_t madlen = 0; - res = MADDecode(sector0, (haveMAD2 ? sector10 : NULL), mad, &madlen, false); + res = MADDecode(sector0, (haveMAD2 ? sector16 : NULL), mad, &madlen, false); if (res != PM3_SUCCESS) { PrintAndLogEx(ERR, "can't decode MAD"); return res;