Skip to content

Commit

Permalink
Merge pull request #2703 from zxkmm/custom_write_file_name_tail
Browse files Browse the repository at this point in the history
Add custom suffix for hf mf autopwn to -o argument
  • Loading branch information
iceman1001 authored Jan 4, 2025
2 parents 17338e2 + b997a91 commit 73b3b4d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
- Added simulation function to `hf iclass legrec` (@antiklesys)
- Added keys from Momentum firmware projects. (@onovy)
- Added Dutch Statistics Agency default key (@eagle00789)
- Changed hf mf autopwn - now allows for custom suffix (@zxkmm)

## [Orca.4.19552][2024-11-22]
- Fixed `hf_legic.lua` - removed bit32 commands from the script (@diorch1968)
Expand Down
52 changes: 35 additions & 17 deletions client/src/cmdhfmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
arg_lit0("a", NULL, "Input key A (def)"),
arg_lit0("b", NULL, "Input key B"),
arg_str0("f", "file", "<fn>", "filename of dictionary"),
arg_str0("o", NULL, "<fn>", "filename suffix for dump and key files"),
arg_lit0(NULL, "slow", "Slower acquisition (required by some non standard cards)"),
arg_lit0("l", "legacy", "legacy mode (use the slow `hf mf chk`)"),
arg_lit0("v", "verbose", "verbose output"),
Expand Down Expand Up @@ -2501,29 +2502,34 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
char filename[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 5), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen);

bool slow = arg_get_lit(ctx, 6);
bool legacy_mfchk = arg_get_lit(ctx, 7);
bool verbose = arg_get_lit(ctx, 8);
int outfnlen = 0;
char outfilename[FILE_PATH_SIZE] = {0};
CLIParamStrToBuf(arg_get_str(ctx, 6), (uint8_t *)outfilename, FILE_PATH_SIZE, &outfnlen);


bool slow = arg_get_lit(ctx, 7);
bool legacy_mfchk = arg_get_lit(ctx, 8);
bool verbose = arg_get_lit(ctx, 9);

bool no_save = arg_get_lit(ctx, 9);
bool no_save = arg_get_lit(ctx, 10);

bool m0 = arg_get_lit(ctx, 10);
bool m1 = arg_get_lit(ctx, 11);
bool m2 = arg_get_lit(ctx, 12);
bool m4 = arg_get_lit(ctx, 13);
bool m0 = arg_get_lit(ctx, 11);
bool m1 = arg_get_lit(ctx, 12);
bool m2 = arg_get_lit(ctx, 13);
bool m4 = arg_get_lit(ctx, 14);

bool in = arg_get_lit(ctx, 14);
bool in = arg_get_lit(ctx, 15);
#if defined(COMPILER_HAS_SIMD_X86)
bool im = arg_get_lit(ctx, 15);
bool is = arg_get_lit(ctx, 16);
bool ia = arg_get_lit(ctx, 17);
bool i2 = arg_get_lit(ctx, 18);
bool im = arg_get_lit(ctx, 16);
bool is = arg_get_lit(ctx, 17);
bool ia = arg_get_lit(ctx, 18);
bool i2 = arg_get_lit(ctx, 19);
#endif
#if defined(COMPILER_HAS_SIMD_AVX512)
bool i5 = arg_get_lit(ctx, 19);
bool i5 = arg_get_lit(ctx, 20);
#endif
#if defined(COMPILER_HAS_SIMD_NEON)
bool ie = arg_get_lit(ctx, 15);
bool ie = arg_get_lit(ctx, 16);
#endif

CLIParserFree(ctx);
Expand Down Expand Up @@ -2691,7 +2697,13 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
}

// read uid to generate a filename for the key file
char *fptr = GenerateFilename("hf-mf-", "-key.bin");
char suffix[FILE_PATH_SIZE];
if (outfnlen) {
snprintf(suffix, sizeof(suffix), "-key-%s.bin", outfilename);
} else {
snprintf(suffix, sizeof(suffix), "-key.bin");
}
char *fptr = GenerateFilename("hf-mf-", suffix);

// check if tag doesn't have static nonce
int has_staticnonce = detect_classic_static_nonce();
Expand Down Expand Up @@ -3219,7 +3231,13 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
}

free(fptr);
fptr = GenerateFilename("hf-mf-", "-dump");

if (outfnlen) {
snprintf(suffix, sizeof(suffix), "-dump-%s", outfilename);
} else {
snprintf(suffix, sizeof(suffix), "-dump");
}
fptr = GenerateFilename("hf-mf-", suffix);
if (fptr == NULL) {
free(dump);
free(e_sector);
Expand Down
1 change: 1 addition & 0 deletions doc/cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ Options:
-a Input key A (def)
-b Input key B
-f, --file <fn> filename of dictionary
-o <fn> filename suffix for dump and key files
-s, --slow Slower acquisition (required by some non standard cards)
-l, --legacy legacy mode (use the slow `hf mf chk`)
-v, --verbose verbose output (statistics)
Expand Down

0 comments on commit 73b3b4d

Please sign in to comment.