make style
This commit is contained in:
1 parent
44d7c54be7
commit
ee8b9ca74b
14 files changed
+229
-170
No files matched your search
+13
-13
@@ -1449,7 +1449,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
arg_lit0("v", "verbose", "verbose output"),
|
||||
arg_lit0(NULL, "d6", "decode as block 6"),
|
||||
arg_lit0("z", "dense", "dense dump output style"),
|
||||
arg_lit0(NULL, "ns", "no save to file"),
|
||||
arg_lit0(NULL, "ns", "no save to file"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(clictx, Cmd, argtable, false);
|
||||
@@ -1619,18 +1619,18 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
} else {
|
||||
|
||||
// use the first block (CSN) for filename
|
||||
char *fptr = calloc(50, sizeof(uint8_t));
|
||||
if (fptr == false) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
free(decrypted);
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
// use the first block (CSN) for filename
|
||||
char *fptr = calloc(50, sizeof(uint8_t));
|
||||
if (fptr == false) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
free(decrypted);
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
strcat(fptr, "hf-iclass-");
|
||||
FillFileNameByUID(fptr, hdr->csn, "-dump-decrypted", sizeof(hdr->csn));
|
||||
strcat(fptr, "hf-iclass-");
|
||||
FillFileNameByUID(fptr, hdr->csn, "-dump-decrypted", sizeof(hdr->csn));
|
||||
|
||||
pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass);
|
||||
pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass);
|
||||
free(fptr);
|
||||
}
|
||||
|
||||
@@ -1645,8 +1645,8 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
||||
// decode block 6
|
||||
bool has_values = (memcmp(decrypted + (8 * 6), empty, 8) != 0) && (memcmp(decrypted + (8 * 6), zeros, 8) != 0);
|
||||
if (has_values && use_sc) {
|
||||
DecodeBlock6(decrypted + (8 * 6));
|
||||
}
|
||||
DecodeBlock6(decrypted + (8 * 6));
|
||||
}
|
||||
|
||||
// decode block 7-8-9
|
||||
iclass_decode_credentials(decrypted);
|
||||
|
||||
@@ -3375,7 +3375,7 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||
|
||||
uint16_t singleSectorParams = 0;
|
||||
if (blockn != -1) {
|
||||
singleSectorParams = (blockn & 0xFF)| keytype << 8 | 1 << 15;
|
||||
singleSectorParams = (blockn & 0xFF) | keytype << 8 | 1 << 15;
|
||||
}
|
||||
if (use_flashmemory) {
|
||||
PrintAndLogEx(SUCCESS, "Using dictionary in flash memory");
|
||||
|
||||
@@ -264,7 +264,7 @@ int mfCheckKeys_fast_ex(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChun
|
||||
if (curr_keys) {
|
||||
uint64_t foo = bytes_to_num(resp.data.asBytes, 6);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(SUCCESS, _GREEN_("Key %s for block %2i found: %012" PRIx64), (singleSectorParams >> 8) & 1 ? "B":"A", singleSectorParams & 0xFF, foo);
|
||||
PrintAndLogEx(SUCCESS, _GREEN_("Key %s for block %2i found: %012" PRIx64), (singleSectorParams >> 8) & 1 ? "B" : "A", singleSectorParams & 0xFF, foo);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -605,16 +605,16 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||
|
||||
if (package->keytype < 2) {
|
||||
PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c -- found valid key [ " _GREEN_("%s") " ]",
|
||||
package->block,
|
||||
package->keytype ? 'B' : 'A',
|
||||
sprint_hex_inrow(resultKey, 6)
|
||||
);
|
||||
package->block,
|
||||
package->keytype ? 'B' : 'A',
|
||||
sprint_hex_inrow(resultKey, 6)
|
||||
);
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %02x -- found valid key [ " _GREEN_("%s") " ]",
|
||||
package->block,
|
||||
MIFARE_AUTH_KEYA + package->keytype,
|
||||
sprint_hex_inrow(resultKey, 6)
|
||||
);
|
||||
package->block,
|
||||
MIFARE_AUTH_KEYA + package->keytype,
|
||||
sprint_hex_inrow(resultKey, 6)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -628,14 +628,14 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||
out:
|
||||
if (package->keytype < 2) {
|
||||
PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %c",
|
||||
package->block,
|
||||
package->keytype ? 'B' : 'A'
|
||||
);
|
||||
package->block,
|
||||
package->keytype ? 'B' : 'A'
|
||||
);
|
||||
} else {
|
||||
PrintAndLogEx(SUCCESS, "\nTarget block %4u key type %02x",
|
||||
package->block,
|
||||
MIFARE_AUTH_KEYA + package->keytype
|
||||
);
|
||||
package->block,
|
||||
MIFARE_AUTH_KEYA + package->keytype
|
||||
);
|
||||
}
|
||||
free(statelists[0].head.slhead);
|
||||
free(statelists[1].head.slhead);
|
||||
@@ -1430,17 +1430,17 @@ int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type,
|
||||
}
|
||||
if (verbose && (resp.data.asBytes[0] == NONCE_STATIC_ENC)) {
|
||||
uint32_t uid = resp.data.asBytes[1] << 24 |
|
||||
resp.data.asBytes[2] << 16 |
|
||||
resp.data.asBytes[3] << 8 |
|
||||
resp.data.asBytes[4];
|
||||
resp.data.asBytes[2] << 16 |
|
||||
resp.data.asBytes[3] << 8 |
|
||||
resp.data.asBytes[4];
|
||||
uint32_t nt = resp.data.asBytes[5] << 24 |
|
||||
resp.data.asBytes[6] << 16 |
|
||||
resp.data.asBytes[7] << 8 |
|
||||
resp.data.asBytes[8];
|
||||
resp.data.asBytes[6] << 16 |
|
||||
resp.data.asBytes[7] << 8 |
|
||||
resp.data.asBytes[8];
|
||||
uint32_t ntenc = resp.data.asBytes[9] << 24 |
|
||||
resp.data.asBytes[10] << 16 |
|
||||
resp.data.asBytes[11] << 8 |
|
||||
resp.data.asBytes[12];
|
||||
resp.data.asBytes[10] << 16 |
|
||||
resp.data.asBytes[11] << 8 |
|
||||
resp.data.asBytes[12];
|
||||
uint8_t ntencparenc = resp.data.asBytes[13];
|
||||
|
||||
// recompute nt on client, just because
|
||||
@@ -1457,24 +1457,24 @@ int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type,
|
||||
ntencparenc >>= 4;
|
||||
// [...] Additionally, the bit of keystream used to encrypt the parity bits is reused to encrypt the next bit of plaintext.
|
||||
// we can decrypt first 3 parity bits, not last one as it's using future keystream
|
||||
uint8_t ksp = (((ks >> 16)&1) << 3) | (((ks >> 8)&1) << 2) | (((ks >> 0)&1) << 1);
|
||||
uint8_t ksp = (((ks >> 16) & 1) << 3) | (((ks >> 8) & 1) << 2) | (((ks >> 0) & 1) << 1);
|
||||
uint8_t ntencpar = ntencparenc ^ ksp;
|
||||
if (validate_prng_nonce(nt)) {
|
||||
PrintAndLogEx(INFO, "nTenc " _GREEN_("%08x") " par {" _YELLOW_("%i%i%i%i") "}=" _YELLOW_("%i%i%ix") " | ks " _GREEN_("%08x") " | nT " _GREEN_("%08x") " par " _YELLOW_("%i%i%i%i")" | lfsr16 index " _GREEN_("%i"),
|
||||
ntenc,
|
||||
(ntencparenc >> 3) & 1, (ntencparenc >> 2) & 1, (ntencparenc >> 1) & 1, ntencparenc & 1,
|
||||
(ntencpar >> 3) & 1, (ntencpar >> 2) & 1, (ntencpar >> 1) & 1,
|
||||
ks, nt,
|
||||
oddparity8((nt>>24) & 0xFF), oddparity8((nt>>16) & 0xFF), oddparity8((nt>>8) & 0xFF), oddparity8(nt & 0xFF),
|
||||
nonce_distance(0, nt));
|
||||
ntenc,
|
||||
(ntencparenc >> 3) & 1, (ntencparenc >> 2) & 1, (ntencparenc >> 1) & 1, ntencparenc & 1,
|
||||
(ntencpar >> 3) & 1, (ntencpar >> 2) & 1, (ntencpar >> 1) & 1,
|
||||
ks, nt,
|
||||
oddparity8((nt >> 24) & 0xFF), oddparity8((nt >> 16) & 0xFF), oddparity8((nt >> 8) & 0xFF), oddparity8(nt & 0xFF),
|
||||
nonce_distance(0, nt));
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "nTenc " _GREEN_("%08x") " par {" _YELLOW_("%i%i%i%i") "}=" _YELLOW_("%i%i%ix") " | ks " _YELLOW_("%08x") " | nT " _YELLOW_("%08x") " par " _YELLOW_("%i%i%i%i") " | " _RED_("not lfsr16") " (wrong key)",
|
||||
ntenc,
|
||||
(ntencparenc >> 3) & 1, (ntencparenc >> 2) & 1, (ntencparenc >> 1) & 1, ntencparenc & 1,
|
||||
(ntencpar >> 3) & 1, (ntencpar >> 2) & 1, (ntencpar >> 1) & 1,
|
||||
ks, nt,
|
||||
oddparity8((nt>>24) & 0xFF), oddparity8((nt>>16) & 0xFF), oddparity8((nt>>8) & 0xFF), oddparity8(nt & 0xFF)
|
||||
);
|
||||
ntenc,
|
||||
(ntencparenc >> 3) & 1, (ntencparenc >> 2) & 1, (ntencparenc >> 1) & 1, ntencparenc & 1,
|
||||
(ntencpar >> 3) & 1, (ntencpar >> 2) & 1, (ntencpar >> 1) & 1,
|
||||
ks, nt,
|
||||
oddparity8((nt >> 24) & 0xFF), oddparity8((nt >> 16) & 0xFF), oddparity8((nt >> 8) & 0xFF), oddparity8(nt & 0xFF)
|
||||
);
|
||||
}
|
||||
}
|
||||
return resp.data.asBytes[0];
|
||||
|
||||
@@ -337,6 +337,7 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "hf mf help" },
|
||||
{ 1, "hf mf list" },
|
||||
{ 0, "hf mf info" },
|
||||
{ 0, "hf mf isen" },
|
||||
{ 0, "hf mf darkside" },
|
||||
{ 0, "hf mf nested" },
|
||||
{ 1, "hf mf hardnested" },
|
||||
|
||||
Reference in new issue
Block a user