hf mf: honour --ns in the FM11RF08S nonce recovery
`hf mf autopwn --ns` asks for no files, but on an FM11RF08S it wrote them anyway. no_save is read once and only gates the two save blocks at the end of autopwn; the static encrypted nonce is detected earlier and returns into HFMFSENRecover from five places, none of which saw the flag. The recovery path wrote the key file and the dump unconditionally, and now that the dump carries JSON as well, that was three files against a flag asking for none. no_save travels with the call now, and fm11_save_recovery_outputs returns before it names anything, printing the same "Called with no save option" line that `hf mf dump` and autopwn already print. The key table is still shown, so --ns reads the card and leaves nothing on disk. `hf mf sen` gains the same `--ns` option, so the flag does not depend on which command reached the recovery. --ns does not suppress `--keep-nonces`. That option exists only to write its evidence file, and a blanket no-save would leave no way to ask for the evidence without a dump. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
42b8fb8367
commit
e3be641809
4 files changed
+25
-14
No files matched your search
@@ -3,6 +3,8 @@ 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...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Added `hf mf sen --ns` - skip writing the key and dump files (@iceman1001)
|
||||
- Fixed `hf mf autopwn --ns` on FM11RF08S - the flag is now honoured by the static encrypted nonce recovery instead of being dropped (@iceman1001)
|
||||
- Added `hf mf sen --suffix` - generated files can be named `hf-mf-<uid>-<dump|key|nonces>-<suffix>` (@iceman1001)
|
||||
- Fixed `hf mf autopwn --suffix` on FM11RF08S - the suffix is now forwarded to the static encrypted nonce recovery instead of being dropped (@iceman1001)
|
||||
- Fixed `hf mf sen` and `hf mf autopwn` on FM11RF08S - the recovered card dump is now saved as JSON as well as BIN (@iceman1001)
|
||||
|
||||
@@ -72,9 +72,9 @@ typedef struct {
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
static int HFMFAutoPwnSEN(sector_t *e_sector, size_t sector_cnt, const char *suffix) {
|
||||
static int HFMFAutoPwnSEN(sector_t *e_sector, size_t sector_cnt, const char *suffix, bool no_save) {
|
||||
DropField();
|
||||
return HFMFSENRecover(false, false, false, false, 0, 0x1, true, e_sector, sector_cnt, suffix);
|
||||
return HFMFSENRecover(false, false, false, false, 0, 0x1, true, e_sector, sector_cnt, suffix, no_save);
|
||||
}
|
||||
|
||||
// Static array for Saflok key levels
|
||||
@@ -3367,7 +3367,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (has_staticnonce == NONCE_STATIC_ENC) {
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL);
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL, no_save);
|
||||
free(e_sector);
|
||||
free(fptr);
|
||||
return sen_res;
|
||||
@@ -3537,7 +3537,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||
if (known_key && ((has_staticnonce == NONCE_NORMAL) || (has_staticnonce == NONCE_FAIL))) {
|
||||
has_staticnonce = detect_classic_static_encrypted_nonce(mfFirstBlockOfSector(sectorno), keytype, key);
|
||||
if (has_staticnonce == NONCE_STATIC_ENC) {
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL);
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL, no_save);
|
||||
free(keyBlock);
|
||||
free(e_sector);
|
||||
free(fptr);
|
||||
@@ -3613,7 +3613,7 @@ noValidKeyFound:
|
||||
if (known_key && has_staticnonce == NONCE_NORMAL) {
|
||||
has_staticnonce = detect_classic_static_encrypted_nonce(mfFirstBlockOfSector(sectorno), keytype, key);
|
||||
if (has_staticnonce == NONCE_STATIC_ENC) {
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL);
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL, no_save);
|
||||
free(keyBlock);
|
||||
free(e_sector);
|
||||
free(fptr);
|
||||
@@ -3803,7 +3803,7 @@ tryNested:
|
||||
case PM3_ESTATIC_NONCE: {
|
||||
e_sector[current_sector_i].Key[current_key_type_i] = 0xffffffffffff;
|
||||
e_sector[current_sector_i].foundKey[current_key_type_i] = false;
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL);
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL, no_save);
|
||||
free(e_sector);
|
||||
free(fptr);
|
||||
return sen_res;
|
||||
@@ -3861,7 +3861,7 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack
|
||||
case PM3_ESTATIC_NONCE: {
|
||||
e_sector[current_sector_i].Key[current_key_type_i] = 0xffffffffffff;
|
||||
e_sector[current_sector_i].foundKey[current_key_type_i] = false;
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL);
|
||||
int sen_res = HFMFAutoPwnSEN(e_sector, sector_cnt, outfnlen ? outfilename : NULL, no_save);
|
||||
free(e_sector);
|
||||
free(fptr);
|
||||
return sen_res;
|
||||
|
||||
+15
-6
@@ -2743,7 +2743,12 @@ static void fm11_build_filename(char *dst, size_t dst_len, const iso14a_card_sel
|
||||
static int fm11_save_recovery_outputs(const iso14a_card_select_t *card, const iso14a_fm11rf08s_nonces_with_data_t *nonces,
|
||||
const uint64_t keys_found[FM11RF08S_SECTORS][2],
|
||||
const bool found_key[FM11RF08S_SECTORS][2],
|
||||
bool no_oob, bool has_data, const char *suffix) {
|
||||
bool no_oob, bool has_data, const char *suffix, bool no_save) {
|
||||
|
||||
if (no_save) {
|
||||
PrintAndLogEx(INFO, "Called with no save option");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
char fn[FILE_PATH_SIZE] = {0};
|
||||
fm11_build_filename(fn, sizeof(fn), card, "key", suffix);
|
||||
@@ -2883,7 +2888,8 @@ static int fm11_select_mifare_classic(iso14a_card_select_t *card_out) {
|
||||
|
||||
int HFMFSENRecover(bool keep_nonces, bool no_oob, bool reader_mode, bool offline_only,
|
||||
int max_online_candidates, uint8_t parity_mask, bool skip_default_key_check,
|
||||
const sector_t *known_sectors, size_t known_sector_count, const char *suffix) {
|
||||
const sector_t *known_sectors, size_t known_sector_count, const char *suffix,
|
||||
bool no_save) {
|
||||
|
||||
iso14a_card_select_t card = {0};
|
||||
iso14a_fm11rf08s_nonces_with_data_t nonces = {0};
|
||||
@@ -3258,7 +3264,7 @@ int HFMFSENRecover(bool keep_nonces, bool no_oob, bool reader_mode, bool offline
|
||||
if (offline_only) {
|
||||
fm11_sen_progress_footer();
|
||||
fm11_print_key_table(keys_found, found_key);
|
||||
retval = fm11_save_recovery_outputs(&card, &nonces, keys_found, found_key, no_oob, collected_with_data, suffix);
|
||||
retval = fm11_save_recovery_outputs(&card, &nonces, keys_found, found_key, no_oob, collected_with_data, suffix, no_save);
|
||||
PrintAndLogEx(SUCCESS, "time in sen " _YELLOW_("%.0f") " seconds", (float)(msclock() - t1) / 1000.0);
|
||||
goto out;
|
||||
}
|
||||
@@ -3476,7 +3482,7 @@ int HFMFSENRecover(bool keep_nonces, bool no_oob, bool reader_mode, bool offline
|
||||
|
||||
fm11_sen_progress_footer();
|
||||
fm11_print_key_table(keys_found, found_key);
|
||||
retval = fm11_save_recovery_outputs(&card, &nonces, keys_found, found_key, no_oob, collected_with_data, suffix);
|
||||
retval = fm11_save_recovery_outputs(&card, &nonces, keys_found, found_key, no_oob, collected_with_data, suffix, no_save);
|
||||
PrintAndLogEx(SUCCESS, "time in sen " _YELLOW_("%.0f") " seconds", (float)(msclock() - t1) / 1000.0);
|
||||
|
||||
out:
|
||||
@@ -3498,7 +3504,8 @@ int CmdHF14AMfSEN(const char *Cmd) {
|
||||
"hf mf sen --keep-nonces\n"
|
||||
"hf mf sen --no-oob\n"
|
||||
"hf mf sen --reader\n"
|
||||
"hf mf sen --suffix mycard\n");
|
||||
"hf mf sen --suffix mycard\n"
|
||||
"hf mf sen --ns\n");
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_lit0(NULL, "keep-nonces", "save collected nonce/data JSON evidence"),
|
||||
@@ -3509,6 +3516,7 @@ int CmdHF14AMfSEN(const char *Cmd) {
|
||||
arg_int0(NULL, "max-online-candidates", "<n>", "abort online phase if total candidates exceed this limit"),
|
||||
arg_str0(NULL, "parity-mask", "<hex>", "parity filter mask 1..F (default 1 = vetted staticnested_1nt behavior)"),
|
||||
arg_str0(NULL, "suffix", "<txt>", "Add this suffix to generated files"),
|
||||
arg_lit0(NULL, "ns", "no save to file (--keep-nonces still writes its evidence file)"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
@@ -3541,7 +3549,8 @@ int CmdHF14AMfSEN(const char *Cmd) {
|
||||
int sfxlen = 0;
|
||||
char suffix[FILE_PATH_SIZE] = {0};
|
||||
CLIParamStrToBuf(arg_get_str(ctx, 8), (uint8_t *)suffix, FILE_PATH_SIZE, &sfxlen);
|
||||
bool no_save = arg_get_lit(ctx, 9);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
return HFMFSENRecover(keep_nonces, no_oob, reader_mode, offline_only, max_online_candidates, parity_mask, false, NULL, 0, suffix);
|
||||
return HFMFSENRecover(keep_nonces, no_oob, reader_mode, offline_only, max_online_candidates, parity_mask, false, NULL, 0, suffix, no_save);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ extern "C" {
|
||||
extern const uint8_t fm11_backdoor_keys[FM11_BACKDOOR_KEY_COUNT][MIFARE_KEY_SIZE];
|
||||
|
||||
int fm11_collect_nonces(const uint8_t *key, iso14a_card_select_t *card, iso14a_fm11rf08s_nonces_with_data_t *nonces);
|
||||
int HFMFSENRecover(bool keep_nonces, bool no_oob, bool reader_mode, bool offline_only, int max_online_candidates, uint8_t parity_mask, bool skip_default_key_check, const sector_t *known_sectors, size_t known_sector_count, const char *suffix);
|
||||
int HFMFSENRecover(bool keep_nonces, bool no_oob, bool reader_mode, bool offline_only, int max_online_candidates, uint8_t parity_mask, bool skip_default_key_check, const sector_t *known_sectors, size_t known_sector_count, const char *suffix, bool no_save);
|
||||
int CmdHF14AMfSEN(const char *Cmd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in new issue
Block a user