mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-14 02:26:59 -07:00
fix 'hf iclass clone'
* Drop field after dump and clone functions * If dumping AA1 with Credit Key, authenticate as Debit Key * Initialize reader when beginning to clone
This commit is contained in:
parent
72096cac73
commit
98a94f7000
2 changed files with 11 additions and 7 deletions
|
@ -848,6 +848,9 @@ void iClass_Dump(uint8_t startblock, uint8_t numblks) {
|
|||
}
|
||||
}
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LED_D_OFF();
|
||||
|
||||
cmd_send(CMD_ACK, isOK, blkCnt, 0, readblockdata, blkCnt*8);
|
||||
|
||||
LED_A_OFF();
|
||||
|
@ -928,9 +931,10 @@ void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data) {
|
|||
else
|
||||
Dbprintf("Clone incomplete");
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LED_D_OFF();
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
|
||||
LED_A_OFF();
|
||||
}
|
||||
|
|
|
@ -877,11 +877,11 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
if (keyNbr < ICLASS_KEYS_MAX) {
|
||||
memcpy(KEY, iClass_Key_Table[keyNbr], 8);
|
||||
} else {
|
||||
PrintAndLog("\nERROR: Credit KeyNbr is invalid\n");
|
||||
PrintAndLog("\nERROR: Debit KeyNbr is invalid\n");
|
||||
errors = true;
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("\nERROR: Credit Key is incorrect length\n");
|
||||
PrintAndLog("\nERROR: Debit Key is incorrect length\n");
|
||||
errors = true;
|
||||
}
|
||||
cmdp += 2;
|
||||
|
@ -920,7 +920,6 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
|
||||
// if only credit key is given: try for AA1 as well (not for iclass but for some picopass this will work)
|
||||
if (!have_debit_key && have_credit_key) {
|
||||
use_credit_key = true;
|
||||
memcpy(KEY, CreditKEY, 8);
|
||||
}
|
||||
|
||||
|
@ -954,7 +953,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
}
|
||||
|
||||
// authenticate with debit key (or credit key if we have no debit key) and get div_key - later store in dump block 3
|
||||
if (!iClass_authenticate(tag_data, KEY, MAC, div_key, use_credit_key, elite, rawkey, NRMAC_replay, verbose)){
|
||||
if (!iClass_authenticate(tag_data, KEY, MAC, div_key, false, elite, rawkey, NRMAC_replay, verbose)) {
|
||||
DropField();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1361,7 +1360,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
|||
uint8_t tag_data[USB_CMD_DATA_SIZE/12][8];
|
||||
fseek(f, startblock*8, SEEK_SET);
|
||||
for (int i = 0; i < endblock - startblock + 1; i++) {
|
||||
if (fread(tag_data, 1, 8, f) == 0 ) {
|
||||
if (fread(&tag_data[i], 1, 8, f) == 0 ) {
|
||||
PrintAndLog("File reading error.");
|
||||
fclose(f);
|
||||
return 2;
|
||||
|
@ -1372,7 +1371,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
|||
uint8_t div_key[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
uint8_t CSN[8];
|
||||
|
||||
if (!iClass_select(CSN, true, false, false) || !iClass_authenticate(CSN, KEY, MAC, div_key, use_credit_key, elite, rawkey, false, true)) {
|
||||
if (!iClass_select(CSN, true, true, true) || !iClass_authenticate(CSN, KEY, MAC, div_key, use_credit_key, elite, rawkey, false, true)) {
|
||||
DropField();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1403,6 +1402,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
DropField();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue