mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
hf mf mad - deals with user supplied keys in a different order now
This commit is contained in:
parent
49f684c31a
commit
cdbd4d7d1e
1 changed files with 26 additions and 9 deletions
|
@ -4869,28 +4869,45 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
bool verbose = arg_get_lit(ctx, 1);
|
bool verbose = arg_get_lit(ctx, 1);
|
||||||
uint8_t aid[2] = {0};
|
uint8_t aid[2] = {0};
|
||||||
int aidlen;
|
int aidlen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 2, aid, &aidlen);
|
CLIGetHexWithReturn(ctx, 2, aid, &aidlen);
|
||||||
uint8_t key[6] = {0};
|
uint8_t userkey[6] = {0};
|
||||||
int keylen;
|
int keylen = 0;
|
||||||
CLIGetHexWithReturn(ctx, 3, key, &keylen);
|
CLIGetHexWithReturn(ctx, 3, userkey, &keylen);
|
||||||
bool keyB = arg_get_lit(ctx, 4);
|
bool keyB = arg_get_lit(ctx, 4);
|
||||||
bool swapmad = arg_get_lit(ctx, 5);
|
bool swapmad = arg_get_lit(ctx, 5);
|
||||||
bool decodeholder = arg_get_lit(ctx, 6);
|
bool decodeholder = arg_get_lit(ctx, 6);
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (aidlen != 2 && !decodeholder && keylen > 0) {
|
|
||||||
PrintAndLogEx(WARNING, "Using default MAD keys instead");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t sector0[16 * 4] = {0};
|
uint8_t sector0[16 * 4] = {0};
|
||||||
uint8_t sector10[16 * 4] = {0};
|
uint8_t sector10[16 * 4] = {0};
|
||||||
|
|
||||||
|
bool got_first = true;
|
||||||
if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector0)) {
|
if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector0)) {
|
||||||
PrintAndLogEx(ERR, "error, read sector 0. 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");
|
||||||
|
got_first = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// User supplied key
|
||||||
|
if (got_first == false && keylen == 6) {
|
||||||
|
if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, userkey, sector0)) {
|
||||||
|
PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't the custom key is wrong");
|
||||||
|
} else {
|
||||||
|
got_first = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both default and user supplied key failed
|
||||||
|
if (got_first == false) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (aidlen != 2 && !decodeholder) {
|
||||||
|
// PrintAndLogEx(WARNING, "Using default MAD keys instead");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(INFO, "--- " _CYAN_("MIFARE App Directory Information") " ----------------");
|
PrintAndLogEx(INFO, "--- " _CYAN_("MIFARE App Directory Information") " ----------------");
|
||||||
PrintAndLogEx(INFO, "-----------------------------------------------------");
|
PrintAndLogEx(INFO, "-----------------------------------------------------");
|
||||||
|
@ -4921,7 +4938,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
||||||
|
|
||||||
// user specified key
|
// user specified key
|
||||||
if (keylen == 6) {
|
if (keylen == 6) {
|
||||||
memcpy(akey, key, 6);
|
memcpy(akey, userkey, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t aaid = 0x0004;
|
uint16_t aaid = 0x0004;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue