diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index b3ccbbe3b..24a7c9844 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -4499,6 +4499,7 @@ static int CmdHF14AMfMAD(const char *Cmd) { arg_str0("aA", "aid", "print all sectors with specified aid", NULL), arg_str0("kK", "key", "key for printing sectors", NULL), arg_lit0("bB", "keyb", "use key B for access printing sectors (by default: key A)"), + arg_lit0("", "be", "(optional, try BigEndian"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -4510,23 +4511,25 @@ static int CmdHF14AMfMAD(const char *Cmd) { int keylen; CLIGetHexWithReturn(ctx, 3, key, &keylen); bool keyB = arg_get_lit(4); +// bool use_be = arg_get_lit(5); CLIParserFree(ctx); if (aidlen != 2 && keylen > 0) { - PrintAndLogEx(WARNING, "do not need a key without aid."); + PrintAndLogEx(WARNING, "do not need a key without aid"); } uint8_t sector0[16 * 4] = {0}; uint8_t sector10[16 * 4] = {0}; if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector0)) { - PrintAndLogEx(ERR, "read sector 0 error. card don't have MAD or don't have MAD on default keys."); + PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't have MAD on default keys"); return PM3_ESOFT; } if (verbose) { + PrintAndLogEx(SUCCESS, "Raw:"); for (int i = 0; i < 4; i ++) - PrintAndLogEx(NORMAL, "[%d] %s", i, sprint_hex(§or0[i * 16], 16)); + PrintAndLogEx(INFO, "[%d] %s", i, sprint_hex(§or0[i * 16], 16)); } bool haveMAD2 = false; @@ -4534,7 +4537,7 @@ static int CmdHF14AMfMAD(const char *Cmd) { if (haveMAD2) { if (mfReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector10)) { - PrintAndLogEx(ERR, "read sector 0x10 error. card don't have MAD or don't have MAD on default keys."); + PrintAndLogEx(ERR, "error, read sector 0x10. card don't have MAD or don't have MAD on default keys"); return PM3_ESOFT; } @@ -4548,7 +4551,7 @@ static int CmdHF14AMfMAD(const char *Cmd) { uint16_t mad[7 + 8 + 8 + 8 + 8] = {0}; size_t madlen = 0; if (MADDecode(sector0, sector10, mad, &madlen)) { - PrintAndLogEx(ERR, "can't decode mad."); + PrintAndLogEx(ERR, "can't decode MAD"); return PM3_ESOFT; } @@ -4563,7 +4566,7 @@ static int CmdHF14AMfMAD(const char *Cmd) { uint8_t vsector[16 * 4] = {0}; if (mfReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, akey, vsector)) { PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(ERR, "read sector %d error.", i + 1); + PrintAndLogEx(ERR, "error, read sector %d", i + 1); return PM3_ESOFT; } diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index 36e847fa1..b4cf4907f 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -1297,6 +1297,7 @@ static int CmdHFMFPMAD(const char *Cmd) { arg_str0("aA", "aid", "print all sectors with aid", NULL), arg_str0("kK", "key", "key for printing sectors", NULL), arg_lit0("bB", "keyb", "use key B for access printing sectors (by default: key A)"), + arg_lit0("", "be", "(optional, try BigEndian"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -1309,11 +1310,12 @@ static int CmdHFMFPMAD(const char *Cmd) { int keylen; CLIGetHexWithReturn(ctx, 3, key, &keylen); bool keyB = arg_get_lit(4); +// bool use_be = arg_get_lit(5); CLIParserFree(ctx); if (aidlen != 2 && keylen > 0) { - PrintAndLogEx(WARNING, "do not need a key without aid."); + PrintAndLogEx(WARNING, "do not need a key without aid"); } uint8_t sector0[16 * 4] = {0}; @@ -1321,13 +1323,14 @@ static int CmdHFMFPMAD(const char *Cmd) { if (mfpReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector0, verbose)) { PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(ERR, "read sector 0 error. card don't have MAD or don't have MAD on default keys."); + PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't have MAD on default keys"); return 2; } if (verbose) { + PrintAndLogEx(SUCCESS, "Raw:"); for (int i = 0; i < 4; i ++) - PrintAndLogEx(NORMAL, "[%d] %s", i, sprint_hex(§or0[i * 16], 16)); + PrintAndLogEx(INFO, "[%d] %s", i, sprint_hex(§or0[i * 16], 16)); } bool haveMAD2 = false; @@ -1336,7 +1339,7 @@ static int CmdHFMFPMAD(const char *Cmd) { if (haveMAD2) { if (mfpReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector10, verbose)) { PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(ERR, "read sector 0x10 error. card don't have MAD or don't have MAD on default keys."); + PrintAndLogEx(ERR, "error, read sector 0x10. card don't have MAD or don't have MAD on default keys"); return 2; } @@ -1345,12 +1348,12 @@ static int CmdHFMFPMAD(const char *Cmd) { if (aidlen == 2) { uint16_t aaid = (aid[0] << 8) + aid[1]; - PrintAndLogEx(NORMAL, "\n-------------- AID 0x%04x ---------------", aaid); + PrintAndLogEx(INFO, "-------------- " _CYAN_("AID 0x%04x") " ---------------", aaid); uint16_t mad[7 + 8 + 8 + 8 + 8] = {0}; size_t madlen = 0; if (MADDecode(sector0, sector10, mad, &madlen)) { - PrintAndLogEx(ERR, "can't decode mad."); + PrintAndLogEx(ERR, "can't decode MAD"); return 10; } @@ -1365,7 +1368,7 @@ static int CmdHFMFPMAD(const char *Cmd) { uint8_t vsector[16 * 4] = {0}; if (mfpReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, akey, vsector, false)) { PrintAndLogEx(NORMAL, ""); - PrintAndLogEx(ERR, "read sector %d error.", i + 1); + PrintAndLogEx(ERR, "error, read sector %d error", i + 1); return 2; } diff --git a/client/src/mifare/mad.c b/client/src/mifare/mad.c index a746406c5..9887f0a77 100644 --- a/client/src/mifare/mad.c +++ b/client/src/mifare/mad.c @@ -140,29 +140,29 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) uint8_t GPB = sector0[3 * 16 + 9]; if (verbose) - PrintAndLogEx(INFO, "GPB: 0x%02x", GPB); + PrintAndLogEx(SUCCESS, "GPB: " _GREEN_("0x%02x"), GPB); // DA (MAD available) if (!(GPB & 0x80)) { - PrintAndLogEx(ERR, "DA=0! MAD not available."); + PrintAndLogEx(ERR, "DA = 0! MAD not available"); return PM3_ESOFT; } // MA (multi-application card) if (verbose) { if (GPB & 0x40) - PrintAndLogEx(INFO, "Multi application card."); + PrintAndLogEx(SUCCESS, "Multi application card"); else - PrintAndLogEx(INFO, "Single application card."); + PrintAndLogEx(SUCCESS, "Single application card"); } uint8_t MADVer = GPB & 0x03; if (verbose) - PrintAndLogEx(INFO, "MAD version: %d", MADVer); + PrintAndLogEx(SUCCESS, "MAD version: " _GREEN_("%d"), MADVer); // MAD version if ((MADVer != 0x01) && (MADVer != 0x02)) { - PrintAndLogEx(ERR, "Wrong MAD version: 0x%02x", MADVer); + PrintAndLogEx(ERR, "Wrong MAD version: " _RED_("0x%02x"), MADVer); return PM3_ESOFT; }; @@ -172,7 +172,7 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) int res = madCRCCheck(sector0, true, 1); if (verbose && res == PM3_SUCCESS) - PrintAndLogEx(INFO, "CRC8-MAD1 (%s)", _GREEN_("ok")); + PrintAndLogEx(SUCCESS, "CRC8-MAD1 (%s)", _GREEN_("ok")); if (MADVer == 2 && sector10) { int res2 = madCRCCheck(sector10, true, 2); @@ -180,7 +180,7 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2) res = res2; if (verbose && !res2) - PrintAndLogEx(INFO, "CRC8-MAD2 (%)", _GREEN_("ok")); + PrintAndLogEx(SUCCESS, "CRC8-MAD2 (%)", _GREEN_("ok")); } return res; @@ -191,7 +191,7 @@ int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen bool haveMAD2 = false; int res = MADCheck(sector0, sector10, false, &haveMAD2); if (res != PM3_SUCCESS) { - PrintAndLogEx(INFO, "Not a valid MAD"); + PrintAndLogEx(WARNING, "Not a valid MAD"); return res; } @@ -216,18 +216,12 @@ int MADDecode(uint8_t *sector0, uint8_t *sector10, uint16_t *mad, size_t *madlen int MAD1DecodeAndPrint(uint8_t *sector, bool verbose, bool *haveMAD2) { // check MAD1 only - int res = MADCheck(sector, NULL, verbose, haveMAD2); - if (verbose) { - if (res == PM3_SUCCESS) - PrintAndLogEx(INFO, "CRC8-MAD1 (%s)", _GREEN_("ok")); - else - PrintAndLogEx(INFO, "CRC8-MAD1 (%s)", _RED_("fail")); - } + MADCheck(sector, NULL, verbose, haveMAD2); // info byte uint8_t InfoByte = sector[16 + 1] & 0x3f; if (InfoByte) { - PrintAndLogEx(INFO, "Card publisher sector: " _GREEN_("0x%02x"), InfoByte); + PrintAndLogEx(SUCCESS, "Card publisher sector: " _GREEN_("0x%02x"), InfoByte); } else { if (verbose) PrintAndLogEx(WARNING, "Card publisher sector not present"); @@ -250,14 +244,14 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool verbose) { int res = madCRCCheck(sector, true, 2); if (verbose) { if (res == PM3_SUCCESS) - PrintAndLogEx(INFO, "CRC8-MAD2 (%s)", _GREEN_("ok")); + PrintAndLogEx(SUCCESS, "CRC8-MAD2 (%s)", _GREEN_("ok")); else - PrintAndLogEx(INFO, "CRC8-MAD2 (%s)", _RED_("fail")); + PrintAndLogEx(WARNING, "CRC8-MAD2 (%s)", _RED_("fail")); } uint8_t InfoByte = sector[1] & 0x3f; if (InfoByte) { - PrintAndLogEx(INFO, "MAD2 Card publisher sector: " _GREEN_("0x%02x"), InfoByte); + PrintAndLogEx(SUCCESS, "MAD2 Card publisher sector: " _GREEN_("0x%02x"), InfoByte); } else { if (verbose) PrintAndLogEx(WARNING, "Card publisher sector not present");