mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-23 06:35:38 -07:00
Merge pull request #1992 from wh201906/restore
Auth both key A and key B with default password in `hf mf restore`
This commit is contained in:
commit
3c3de8d0c4
2 changed files with 14 additions and 32 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- Changed `hf mf restore` - Auth both key A and key B with default password (@wh201906)
|
||||||
- Changed `nfc decode -f` - now can detect and convert MFC dumpfiles to NDEF byte arrays (@iceman1001)
|
- Changed `nfc decode -f` - now can detect and convert MFC dumpfiles to NDEF byte arrays (@iceman1001)
|
||||||
- Changed `nfc decode` - now handles EXTERNAL RECORDS better (@iceman1001)
|
- Changed `nfc decode` - now handles EXTERNAL RECORDS better (@iceman1001)
|
||||||
- Fixed `nfc decode` - now handles NDEF Signature version1 records better (@iceman1001)
|
- Fixed `nfc decode` - now handles NDEF Signature version1 records better (@iceman1001)
|
||||||
|
|
|
@ -1109,7 +1109,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
||||||
"Restore MIFARE Classic dump file to tag.\n"
|
"Restore MIFARE Classic dump file to tag.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The key file and dump file will program the card sector trailers.\n"
|
"The key file and dump file will program the card sector trailers.\n"
|
||||||
"By default we authenticate to card with key B 0xFFFFFFFFFFFF.\n"
|
"By default we authenticate to card with key 0xFFFFFFFFFFFF.\n"
|
||||||
"If access rights in dump file is all zeros, it will be replaced with default values\n"
|
"If access rights in dump file is all zeros, it will be replaced with default values\n"
|
||||||
"\n"
|
"\n"
|
||||||
"`--uid` param is used for filename templates `hf-mf-<uid>-dump.bin` and `hf-mf-<uid>-key.bin.\n"
|
"`--uid` param is used for filename templates `hf-mf-<uid>-dump.bin` and `hf-mf-<uid>-key.bin.\n"
|
||||||
|
@ -1321,14 +1321,16 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
||||||
uint8_t wdata[26];
|
uint8_t wdata[26];
|
||||||
memcpy(wdata + 10, bldata, sizeof(bldata));
|
memcpy(wdata + 10, bldata, sizeof(bldata));
|
||||||
|
|
||||||
if (use_keyfile_for_auth) {
|
|
||||||
for (int8_t kt = MF_KEY_B; kt > -1; kt--) {
|
for (int8_t kt = MF_KEY_B; kt > -1; kt--) {
|
||||||
|
if (use_keyfile_for_auth) {
|
||||||
if (kt == MF_KEY_A)
|
if (kt == MF_KEY_A)
|
||||||
memcpy(wdata, keyA[s], 6);
|
memcpy(wdata, keyA[s], 6);
|
||||||
else
|
else
|
||||||
memcpy(wdata, keyB[s], 6);
|
memcpy(wdata, keyB[s], 6);
|
||||||
|
} else {
|
||||||
|
// use default key to authenticate for the write command
|
||||||
|
memcpy(wdata, default_key, 6);
|
||||||
|
}
|
||||||
PrintAndLogEx(INFO, "block %3d: %s", mfFirstBlockOfSector(s) + b, sprint_hex(bldata, sizeof(bldata)));
|
PrintAndLogEx(INFO, "block %3d: %s", mfFirstBlockOfSector(s) + b, sprint_hex(bldata, sizeof(bldata)));
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
@ -1350,27 +1352,6 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// use default key to authenticate for the write command
|
|
||||||
memcpy(wdata, default_key, 6);
|
|
||||||
PrintAndLogEx(INFO, "block %3d: %s", mfFirstBlockOfSector(s) + b, sprint_hex(bldata, sizeof(bldata)));
|
|
||||||
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommandMIX(CMD_HF_MIFARE_WRITEBL, mfFirstBlockOfSector(s) + b, MF_KEY_B, 0, wdata, sizeof(wdata));
|
|
||||||
PacketResponseNG resp;
|
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
|
||||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
|
||||||
if (isOK == 0) {
|
|
||||||
if (b == 0) {
|
|
||||||
PrintAndLogEx(INFO, "Writing to manufacture block w key B ( " _RED_("fail") " )");
|
|
||||||
} else {
|
|
||||||
PrintAndLogEx(FAILED, "Write to block %u w key B ( " _RED_("fail") " )", b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
|
||||||
}
|
|
||||||
} // end use_keyfile_for_auth
|
|
||||||
} // end loop B
|
} // end loop B
|
||||||
} // end loop S
|
} // end loop S
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue