Skip to content

Commit

Permalink
added no save parameter to iclass dump. Also adjusted the text for th…
Browse files Browse the repository at this point in the history
…e other places.
  • Loading branch information
iceman1001 committed Oct 20, 2023
1 parent c8f5c54 commit 272cb2b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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]
- Modified `hf iclass calcnewkey` - Added calculations for old key elite and new key non elite (@Antiklesys)
- Changed `hf iclass dump` - now allow no save of dumped data (@iceman1001)
- Changed `hf iclass calcnewkey` - Added calculations for old key elite and new key non elite (@Antiklesys)
- Changed the CLI prompt to show tcp/udp if used (@iceman1001)
- Changed `hw ping` - now shows transfer time (@doegox)
- Added `hf mf encodehid` - writes HID legacy credential to a empty MFC (@iceman1001)
Expand Down
24 changes: 14 additions & 10 deletions client/src/cmdhf14b.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,17 +1537,21 @@ static int CmdHF14BDump(const char *Cmd) {

print_sr_blocks(data, cardsize, card.uid);

if (nosave == false) {
// save to file
if (fnlen < 1) {
PrintAndLogEx(INFO, "using UID as filename");
char *fptr = filename + snprintf(filename, sizeof(filename), "hf-14b-");
FillFileNameByUID(fptr, SwapEndian64(card.uid, card.uidlen, 8), "-dump", card.uidlen);
}

size_t datalen = (lastblock + 2) * ST25TB_SR_BLOCK_SIZE;
pm3_save_dump(filename, data, datalen, jsf14b_v2);
if (nosave) {
PrintAndLogEx(INFO, "Called with no save option");
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}

// save to file
if (fnlen < 1) {
PrintAndLogEx(INFO, "using UID as filename");
char *fptr = filename + snprintf(filename, sizeof(filename), "hf-14b-");
FillFileNameByUID(fptr, SwapEndian64(card.uid, card.uidlen, 8), "-dump", card.uidlen);
}

size_t datalen = (lastblock + 2) * ST25TB_SR_BLOCK_SIZE;
pm3_save_dump(filename, data, datalen, jsf14b_v2);
}

return switch_off_field_14b();
Expand Down
8 changes: 8 additions & 0 deletions client/src/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ static int CmdHFiClassDump(const char *Cmd) {
arg_lit0("z", "dense", "dense dump output style"),
arg_lit0(NULL, "force", "force unsecure card read"),
arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"),
arg_lit0(NULL, "ns", "no save to file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
Expand Down Expand Up @@ -1840,6 +1841,7 @@ static int CmdHFiClassDump(const char *Cmd) {
bool dense_output = g_session.dense_output || arg_get_lit(ctx, 9);
bool force = arg_get_lit(ctx, 10);
bool shallow_mod = arg_get_lit(ctx, 11);
bool nosave = arg_get_lit(ctx, 12);

CLIParserFree(ctx);

Expand Down Expand Up @@ -2085,6 +2087,12 @@ static int CmdHFiClassDump(const char *Cmd) {
// print the dump
printIclassDumpContents(tag_data, 1, (bytes_got / 8), bytes_got, dense_output);

if (nosave) {
PrintAndLogEx(INFO, "Called with no save option");
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}

// use CSN as filename
if (filename[0] == 0) {
strcat(filename, "hf-iclass-");
Expand Down
34 changes: 19 additions & 15 deletions client/src/cmdhfmfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,23 +2665,27 @@ static int CmdHF14AMfUDump(const char *Cmd) {

printMFUdumpEx(&dump_file_data, pages, start_page);

if (nosave == false) {
// user supplied filename?
if (fnlen < 1) {
PrintAndLogEx(INFO, "Using UID as filename");
uint8_t uid[7] = {0};
memcpy(uid, (uint8_t *)&dump_file_data.data, 3);
memcpy(uid + 3, (uint8_t *)&dump_file_data.data + 4, 4);
strcat(filename, "hf-mfu-");
FillFileNameByUID(filename, uid, "-dump", sizeof(uid));
}
if (nosave) {
PrintAndLogEx(INFO, "Called with no save option");
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}

// user supplied filename?
if (fnlen < 1) {
PrintAndLogEx(INFO, "Using UID as filename");
uint8_t uid[7] = {0};
memcpy(uid, (uint8_t *)&dump_file_data.data, 3);
memcpy(uid + 3, (uint8_t *)&dump_file_data.data + 4, 4);
strcat(filename, "hf-mfu-");
FillFileNameByUID(filename, uid, "-dump", sizeof(uid));
}

uint16_t datalen = pages * MFU_BLOCK_SIZE + MFU_DUMP_PREFIX_LENGTH;
pm3_save_dump(filename, (uint8_t *)&dump_file_data, datalen, jsfMfuMemory);
uint16_t datalen = pages * MFU_BLOCK_SIZE + MFU_DUMP_PREFIX_LENGTH;
pm3_save_dump(filename, (uint8_t *)&dump_file_data, datalen, jsfMfuMemory);

if (is_partial) {
PrintAndLogEx(WARNING, "Partial dump created. (%d of %d blocks)", pages, card_mem_size);
}
if (is_partial) {
PrintAndLogEx(WARNING, "Partial dump created. (%d of %d blocks)", pages, card_mem_size);
}

return PM3_SUCCESS;
Expand Down
8 changes: 7 additions & 1 deletion client/src/cmdlft55xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,8 +2298,14 @@ static int CmdT55xxDump(const char *Cmd) {
}
}

if (nosave) {
PrintAndLogEx(INFO, "Called with no save option");
PrintAndLogEx(NORMAL, "");
return PM3_SUCCESS;
}

// all ok, save dump to file
if (success && nosave == false) {
if (success) {

// set default filename, if not set by user
if (strlen(filename) == 0) {
Expand Down

0 comments on commit 272cb2b

Please sign in to comment.