add --hardreset to hf mf isen

This commit is contained in:
Philippe Teuwen committed 2024-08-07 16:09:11 +02:00
1 parent 5e99d98bf5
commit 099a37af91
6 files changed
+28 -15

No files matched your search

+13 -6
View File
@@ -9643,6 +9643,7 @@ static int CmdHF14AMfISEN(const char *Cmd) {
arg_str0(NULL, "key2", "<hex>", "nested key, 6 hex bytes (default=same)"),
arg_int0("n", NULL, "<dec>", "number of nonces (default=2)"),
arg_lit0(NULL, "reset", "reset between attempts, even if auth was successful"),
arg_lit0(NULL, "hardreset", "hard reset (RF off/on) between attempts, even if auth was successful"),
arg_lit0(NULL, "addread", "auth(blk)-read(blk)-auth(blk2)"),
arg_lit0(NULL, "addauth", "auth(blk)-auth(blk)-auth(blk2)"),
arg_lit0(NULL, "incblk2", "auth(blk)-auth(blk2)-auth(blk2+4)-..."),
@@ -9702,11 +9703,17 @@ static int CmdHF14AMfISEN(const char *Cmd) {
int nr_nested = arg_get_int_def(ctx, 11, 2);
bool reset = arg_get_lit(ctx, 12);
bool addread = arg_get_lit(ctx, 13);
bool addauth = arg_get_lit(ctx, 14);
bool incblk2 = arg_get_lit(ctx, 15);
bool corruptnrar = arg_get_lit(ctx, 16);
bool corruptnrarparity = arg_get_lit(ctx, 17);
bool hardreset = arg_get_lit(ctx, 13);
if (reset && hardreset) {
CLIParserFree(ctx);
PrintAndLogEx(WARNING, "Choose one single type of reset");
return PM3_EINVARG;
}
bool addread = arg_get_lit(ctx, 14);
bool addauth = arg_get_lit(ctx, 15);
bool incblk2 = arg_get_lit(ctx, 16);
bool corruptnrar = arg_get_lit(ctx, 17);
bool corruptnrarparity = arg_get_lit(ctx, 18);
CLIParserFree(ctx);
uint8_t dbg_curr = DBG_NONE;
@@ -9763,7 +9770,7 @@ static int CmdHF14AMfISEN(const char *Cmd) {
return PM3_EFAILED;
}
int res = detect_classic_static_encrypted_nonce_ex(blockn, keytype, key, blockn_nested, keytype_nested, key_nested, nr_nested, reset, addread, addauth, incblk2, corruptnrar, corruptnrarparity, true);
int res = detect_classic_static_encrypted_nonce_ex(blockn, keytype, key, blockn_nested, keytype_nested, key_nested, nr_nested, reset, hardreset, addread, addauth, incblk2, corruptnrar, corruptnrarparity, true);
if (res == NONCE_STATIC)
PrintAndLogEx(SUCCESS, "Static nonce......... " _YELLOW_("yes"));
if (res == NONCE_STATIC_ENC)
+3 -3
View File
@@ -1405,7 +1405,7 @@ returns:
2 = cmd failed
3 = has encrypted nonce
*/
int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type, uint8_t *key, uint8_t block_no_nested, uint8_t key_type_nested, uint8_t *key_nested, uint8_t nr_nested, bool reset, bool addread, bool addauth, bool incblk2, bool corruptnrar, bool corruptnrarparity, bool verbose) {
int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type, uint8_t *key, uint8_t block_no_nested, uint8_t key_type_nested, uint8_t *key_nested, uint8_t nr_nested, bool reset, bool hardreset, bool addread, bool addauth, bool incblk2, bool corruptnrar, bool corruptnrarparity, bool verbose) {
clearCommandBuffer();
uint8_t cdata[1 + 1 + MIFARE_KEY_SIZE + 1 + 1 + MIFARE_KEY_SIZE + 1 + 1 + 1 + 1 + 1 + 1 + 1] = { 0 };
cdata[0] = block_no;
@@ -1415,7 +1415,7 @@ int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type,
cdata[9] = key_type_nested;
memcpy(&cdata[10], key_nested, MIFARE_KEY_SIZE);
cdata[16] = nr_nested;
cdata[17] = reset;
cdata[17] = hardreset << 1 | reset;
cdata[18] = addread;
cdata[19] = addauth;
cdata[20] = incblk2;
@@ -1483,7 +1483,7 @@ int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type,
}
int detect_classic_static_encrypted_nonce(uint8_t block_no, uint8_t key_type, uint8_t *key) {
return detect_classic_static_encrypted_nonce_ex(block_no, key_type, key, block_no, key_type, key, 3, false, false, false, false, false, false, false);
return detect_classic_static_encrypted_nonce_ex(block_no, key_type, key, block_no, key_type, key, 3, false, false, false, false, false, false, false, false);
}
// try to see if card responses to "Chinese magic backdoor" commands.
+1 -1
View File
@@ -106,7 +106,7 @@ int detect_classic_prng(void);
int detect_classic_nackbug(bool verbose);
uint16_t detect_mf_magic(bool is_mfc, uint8_t key_type, uint64_t key);
int detect_classic_static_nonce(void);
int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type, uint8_t *key, uint8_t block_no_nested, uint8_t key_type_nested, uint8_t *key_nested, uint8_t nr_nested, bool reset, bool addread, bool addauth, bool incblk2, bool corruptnrar, bool corruptnrarparity, bool verbose);
int detect_classic_static_encrypted_nonce_ex(uint8_t block_no, uint8_t key_type, uint8_t *key, uint8_t block_no_nested, uint8_t key_type_nested, uint8_t *key_nested, uint8_t nr_nested, bool reset, bool hardreset, bool addread, bool addauth, bool incblk2, bool corruptnrar, bool corruptnrarparity, bool verbose);
int detect_classic_static_encrypted_nonce(uint8_t block_no, uint8_t key_type, uint8_t *key);
bool detect_mfc_ev1_signature(void);
int read_mfc_ev1_signature(uint8_t *signature);