mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
style
This commit is contained in:
parent
3a18fe6ea1
commit
fb0eb35710
5 changed files with 89 additions and 89 deletions
122
client/cmdhfmf.c
122
client/cmdhfmf.c
|
@ -370,7 +370,7 @@ static int usage_hf14_ekeyprn(void) {
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
PrintAndLogEx(NORMAL, " hf mf ekeyprn 1");
|
PrintAndLogEx(NORMAL, " hf mf ekeyprn 1");
|
||||||
PrintAndLogEx(NORMAL, " hf mf ekeyprn d");
|
PrintAndLogEx(NORMAL, " hf mf ekeyprn d");
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1615,11 +1615,11 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
|
||||||
|
|
||||||
if (!know_target_key && nonce_file_read == false) {
|
if (!know_target_key && nonce_file_read == false) {
|
||||||
|
|
||||||
// check if tag doesn't have static/fixed nonce
|
// check if tag doesn't have static/fixed nonce
|
||||||
if (detect_classic_static_nonce() != 0) {
|
if (detect_classic_static_nonce() != 0) {
|
||||||
PrintAndLogEx(WARNING, "Static/fixed nonce detected. Quitting...");
|
PrintAndLogEx(WARNING, "Static/fixed nonce detected. Quitting...");
|
||||||
return PM3_EOPABORTED;
|
return PM3_EOPABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t key64 = 0;
|
uint64_t key64 = 0;
|
||||||
// check if we can authenticate to sector
|
// check if we can authenticate to sector
|
||||||
|
@ -2580,11 +2580,11 @@ out:
|
||||||
|
|
||||||
if (createDumpFile) {
|
if (createDumpFile) {
|
||||||
|
|
||||||
char *fptr = GenerateFilename("hf-mf-", "-key.bin");
|
char *fptr = GenerateFilename("hf-mf-", "-key.bin");
|
||||||
if (createMfcKeyDump(fptr, sectorsCnt, e_sector) != PM3_SUCCESS) {
|
if (createMfcKeyDump(fptr, sectorsCnt, e_sector) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Failed to save keys to file");
|
PrintAndLogEx(ERR, "Failed to save keys to file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
|
@ -2854,10 +2854,10 @@ out:
|
||||||
PrintAndLogEx(INFO, "found keys:");
|
PrintAndLogEx(INFO, "found keys:");
|
||||||
|
|
||||||
//print keys
|
//print keys
|
||||||
if ( SectorsCnt == 1)
|
if (SectorsCnt == 1)
|
||||||
printKeyTableEx(SectorsCnt, e_sector, GetSectorFromBlockNo(blockNo));
|
printKeyTableEx(SectorsCnt, e_sector, GetSectorFromBlockNo(blockNo));
|
||||||
else
|
else
|
||||||
printKeyTable(SectorsCnt, e_sector);
|
printKeyTable(SectorsCnt, e_sector);
|
||||||
|
|
||||||
if (transferToEml) {
|
if (transferToEml) {
|
||||||
// fast push mode
|
// fast push mode
|
||||||
|
@ -2867,13 +2867,13 @@ out:
|
||||||
uint8_t blockno = FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1;
|
uint8_t blockno = FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1;
|
||||||
mfEmlGetMem(block, blockno, 1);
|
mfEmlGetMem(block, blockno, 1);
|
||||||
|
|
||||||
if (e_sector[i].foundKey[0])
|
if (e_sector[i].foundKey[0])
|
||||||
num_to_bytes(e_sector[i].Key[0], 6, block);
|
num_to_bytes(e_sector[i].Key[0], 6, block);
|
||||||
|
|
||||||
if (e_sector[i].foundKey[1])
|
if (e_sector[i].foundKey[1])
|
||||||
num_to_bytes(e_sector[i].Key[1], 6, block + 10);
|
num_to_bytes(e_sector[i].Key[1], 6, block + 10);
|
||||||
|
|
||||||
if (i == SectorsCnt - 1) {
|
if (i == SectorsCnt - 1) {
|
||||||
// Disable fast mode on last packet
|
// Disable fast mode on last packet
|
||||||
conn.block_after_ACK = false;
|
conn.block_after_ACK = false;
|
||||||
}
|
}
|
||||||
|
@ -2887,7 +2887,7 @@ out:
|
||||||
if (createMfcKeyDump(fptr, SectorsCnt, e_sector) != PM3_SUCCESS) {
|
if (createMfcKeyDump(fptr, SectorsCnt, e_sector) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(ERR, "Failed to save keys to file");
|
PrintAndLogEx(ERR, "Failed to save keys to file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
|
@ -3314,7 +3314,7 @@ static int CmdHF14AMfKeyBrute(const char *Cmd) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void printKeyTable(uint8_t sectorscnt, sector_t *e_sector) {
|
void printKeyTable(uint8_t sectorscnt, sector_t *e_sector) {
|
||||||
return printKeyTableEx(sectorscnt, e_sector, 0);
|
return printKeyTableEx(sectorscnt, e_sector, 0);
|
||||||
}
|
}
|
||||||
void printKeyTableEx(uint8_t sectorscnt, sector_t *e_sector, uint8_t start_sector) {
|
void printKeyTableEx(uint8_t sectorscnt, sector_t *e_sector, uint8_t start_sector) {
|
||||||
char strA[12 + 1] = {0};
|
char strA[12 + 1] = {0};
|
||||||
|
@ -3335,31 +3335,31 @@ void printKeyTableEx(uint8_t sectorscnt, sector_t *e_sector, uint8_t start_secto
|
||||||
|
|
||||||
if (e_sector[i].foundKey[0] > 1) {
|
if (e_sector[i].foundKey[0] > 1) {
|
||||||
PrintAndLogEx(NORMAL, "|%03d| %s | " _YELLOW_("%c")"| %s | " _YELLOW_("%c")"|"
|
PrintAndLogEx(NORMAL, "|%03d| %s | " _YELLOW_("%c")"| %s | " _YELLOW_("%c")"|"
|
||||||
, i
|
, i
|
||||||
, strA, e_sector[i].foundKey[0]
|
, strA, e_sector[i].foundKey[0]
|
||||||
, strB, e_sector[i].foundKey[1]
|
, strB, e_sector[i].foundKey[1]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, "|%03d| %s | " _YELLOW_("%d")"| %s | " _YELLOW_("%d")"|"
|
PrintAndLogEx(NORMAL, "|%03d| %s | " _YELLOW_("%d")"| %s | " _YELLOW_("%d")"|"
|
||||||
, start_sector
|
, start_sector
|
||||||
, strA, e_sector[i].foundKey[0]
|
, strA, e_sector[i].foundKey[0]
|
||||||
, strB, e_sector[i].foundKey[1]
|
, strB, e_sector[i].foundKey[1]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrintAndLogEx(NORMAL, "|---|----------------|---|----------------|---|");
|
PrintAndLogEx(NORMAL, "|---|----------------|---|----------------|---|");
|
||||||
|
|
||||||
if (e_sector[0].foundKey[0] > 1) {
|
if (e_sector[0].foundKey[0] > 1) {
|
||||||
PrintAndLogEx(NORMAL, "( "
|
PrintAndLogEx(NORMAL, "( "
|
||||||
_YELLOW_("D") ":Dictionary / "
|
_YELLOW_("D") ":Dictionary / "
|
||||||
_YELLOW_("S") ":darkSide / "
|
_YELLOW_("S") ":darkSide / "
|
||||||
_YELLOW_("U") ":User / "
|
_YELLOW_("U") ":User / "
|
||||||
_YELLOW_("R") ":Reused / "
|
_YELLOW_("R") ":Reused / "
|
||||||
_YELLOW_("N") ":Nested / "
|
_YELLOW_("N") ":Nested / "
|
||||||
_YELLOW_("H") ":Hardnested / "
|
_YELLOW_("H") ":Hardnested / "
|
||||||
_YELLOW_("A") ":keyA "
|
_YELLOW_("A") ":keyA "
|
||||||
")"
|
")"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, "(" _YELLOW_("0") ": Failed / " _YELLOW_("1") ": Success)");
|
PrintAndLogEx(NORMAL, "(" _YELLOW_("0") ": Failed / " _YELLOW_("1") ": Success)");
|
||||||
}
|
}
|
||||||
|
@ -3615,7 +3615,7 @@ static int CmdHF14AMfEKeyPrn(const char *Cmd) {
|
||||||
bool errors = false, createDumpFile = false;
|
bool errors = false, createDumpFile = false;
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
char ctmp = tolower(param_getchar(Cmd, cmdp));
|
char ctmp = tolower(param_getchar(Cmd, cmdp));
|
||||||
switch (ctmp) {
|
switch (ctmp) {
|
||||||
case 'd':
|
case 'd':
|
||||||
createDumpFile = true;
|
createDumpFile = true;
|
||||||
|
@ -3623,18 +3623,18 @@ static int CmdHF14AMfEKeyPrn(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
return usage_hf14_ekeyprn();
|
return usage_hf14_ekeyprn();
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '4':
|
case '4':
|
||||||
sectors_cnt = NumOfSectors(ctmp);
|
sectors_cnt = NumOfSectors(ctmp);
|
||||||
if (sectors_cnt == 0) return usage_hf14_ekeyprn();
|
if (sectors_cnt == 0) return usage_hf14_ekeyprn();
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||||
errors = true;
|
errors = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// validations
|
// validations
|
||||||
|
@ -3647,14 +3647,14 @@ static int CmdHF14AMfEKeyPrn(const char *Cmd) {
|
||||||
if (res != sectors_cnt)
|
if (res != sectors_cnt)
|
||||||
return PM3_EMALLOC;
|
return PM3_EMALLOC;
|
||||||
|
|
||||||
// read UID from EMUL
|
// read UID from EMUL
|
||||||
if (mfEmlGetMem(data, 0, 1) != PM3_SUCCESS) {
|
if (mfEmlGetMem(data, 0, 1) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, "error get block %d", 0);
|
PrintAndLogEx(WARNING, "error get block %d", 0);
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(uid, data, sizeof(uid));
|
memcpy(uid, data, sizeof(uid));
|
||||||
|
|
||||||
// download keys from EMUL
|
// download keys from EMUL
|
||||||
for (int i = 0; i < sectors_cnt; i++) {
|
for (int i = 0; i < sectors_cnt; i++) {
|
||||||
|
@ -3662,26 +3662,26 @@ static int CmdHF14AMfEKeyPrn(const char *Cmd) {
|
||||||
if (mfEmlGetMem(data, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1) != PM3_SUCCESS) {
|
if (mfEmlGetMem(data, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1) != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, "error get block %d", FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1);
|
PrintAndLogEx(WARNING, "error get block %d", FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1);
|
||||||
e_sector[i].foundKey[0] = false;
|
e_sector[i].foundKey[0] = false;
|
||||||
e_sector[i].foundKey[1] = false;
|
e_sector[i].foundKey[1] = false;
|
||||||
} else {
|
} else {
|
||||||
e_sector[i].foundKey[0] = true;
|
e_sector[i].foundKey[0] = true;
|
||||||
e_sector[i].Key[0] = bytes_to_num(data, 6);
|
e_sector[i].Key[0] = bytes_to_num(data, 6);
|
||||||
e_sector[i].foundKey[1] = true;
|
e_sector[i].foundKey[1] = true;
|
||||||
e_sector[i].Key[1] = bytes_to_num(data + 10, 6);
|
e_sector[i].Key[1] = bytes_to_num(data + 10, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// print keys
|
// print keys
|
||||||
printKeyTable(sectors_cnt, e_sector);
|
printKeyTable(sectors_cnt, e_sector);
|
||||||
|
|
||||||
// dump the keys
|
// dump the keys
|
||||||
if (createDumpFile) {
|
if (createDumpFile) {
|
||||||
|
|
||||||
fptr += sprintf(fptr, "hf-mf-");
|
fptr += sprintf(fptr, "hf-mf-");
|
||||||
FillFileNameByUID(fptr + strlen(fptr), uid, "-key", sizeof(uid));
|
FillFileNameByUID(fptr + strlen(fptr), uid, "-key", sizeof(uid));
|
||||||
|
|
||||||
createMfcKeyDump(filename, sectors_cnt, e_sector);
|
createMfcKeyDump(filename, sectors_cnt, e_sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
|
@ -324,7 +324,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
*nested_worker_thread(void *arg) {
|
*nested_worker_thread(void *arg) {
|
||||||
struct Crypto1State *p1;
|
struct Crypto1State *p1;
|
||||||
StateList_t *statelist = arg;
|
StateList_t *statelist = arg;
|
||||||
statelist->head.slhead = lfsr_recovery32(statelist->ks1, statelist->nt ^ statelist->uid);
|
statelist->head.slhead = lfsr_recovery32(statelist->ks1, statelist->nt_enc ^ statelist->uid);
|
||||||
|
|
||||||
for (p1 = statelist->head.slhead; * (uint64_t *)p1 != 0; p1++) {};
|
for (p1 = statelist->head.slhead; * (uint64_t *)p1 != 0; p1++) {};
|
||||||
|
|
||||||
|
@ -391,10 +391,10 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||||
statelists[i].uid = uid;
|
statelists[i].uid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&statelists[0].nt, package->nt_a, sizeof(package->nt_a));
|
memcpy(&statelists[0].nt_enc, package->nt_a, sizeof(package->nt_a));
|
||||||
memcpy(&statelists[0].ks1, package->ks_a, sizeof(package->ks_a));
|
memcpy(&statelists[0].ks1, package->ks_a, sizeof(package->ks_a));
|
||||||
|
|
||||||
memcpy(&statelists[1].nt, package->nt_b, sizeof(package->nt_b));
|
memcpy(&statelists[1].nt_enc, package->nt_b, sizeof(package->nt_b));
|
||||||
memcpy(&statelists[1].ks1, package->ks_b, sizeof(package->ks_b));
|
memcpy(&statelists[1].ks1, package->ks_b, sizeof(package->ks_b));
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,14 +422,14 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||||
savestate = *p1;
|
savestate = *p1;
|
||||||
while (Compare16Bits(p1, &savestate) == 0 && p1 <= statelists[0].tail.sltail) {
|
while (Compare16Bits(p1, &savestate) == 0 && p1 <= statelists[0].tail.sltail) {
|
||||||
*p3 = *p1;
|
*p3 = *p1;
|
||||||
lfsr_rollback_word(p3, statelists[0].nt ^ statelists[0].uid, 0);
|
lfsr_rollback_word(p3, statelists[0].nt_enc ^ statelists[0].uid, 0);
|
||||||
p3++;
|
p3++;
|
||||||
p1++;
|
p1++;
|
||||||
}
|
}
|
||||||
savestate = *p2;
|
savestate = *p2;
|
||||||
while (Compare16Bits(p2, &savestate) == 0 && p2 <= statelists[1].tail.sltail) {
|
while (Compare16Bits(p2, &savestate) == 0 && p2 <= statelists[1].tail.sltail) {
|
||||||
*p4 = *p2;
|
*p4 = *p2;
|
||||||
lfsr_rollback_word(p4, statelists[1].nt ^ statelists[1].uid, 0);
|
lfsr_rollback_word(p4, statelists[1].nt_enc ^ statelists[1].uid, 0);
|
||||||
p4++;
|
p4++;
|
||||||
p2++;
|
p2++;
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||||
PrintAndLogEx(SUCCESS, "target block:%3u key type: %c -- found valid key [ " _YELLOW_("%s") "]",
|
PrintAndLogEx(SUCCESS, "target block:%3u key type: %c -- found valid key [ " _YELLOW_("%s") "]",
|
||||||
package->block,
|
package->block,
|
||||||
package->keytype ? 'B' : 'A',
|
package->keytype ? 'B' : 'A',
|
||||||
sprint_hex(resultKey, 6)
|
sprint_hex(resultKey, 6)
|
||||||
);
|
);
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct {
|
||||||
uint32_t uid;
|
uint32_t uid;
|
||||||
uint32_t blockNo;
|
uint32_t blockNo;
|
||||||
uint32_t keyType;
|
uint32_t keyType;
|
||||||
uint32_t nt;
|
uint32_t nt_enc;
|
||||||
uint32_t ks1;
|
uint32_t ks1;
|
||||||
} StateList_t;
|
} StateList_t;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue