Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom suffix for hf mf autopwn to -o argument #2703

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, --output <fn> filename suffix for dump and key files
zxkmm marked this conversation as resolved.
Show resolved Hide resolved
-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
Loading