Skip to content

Commit

Permalink
added support for loading flipper MFC/MFU dump files.\nFixed NFC DECO…
Browse files Browse the repository at this point in the history
…DE to identify and handle MFU dump files properly
  • Loading branch information
iceman1001 committed Nov 1, 2023
1 parent ca04f03 commit ae6ba39
Show file tree
Hide file tree
Showing 5 changed files with 395 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
- Fixed `nfc decode` - now properly handles MFU dump files (@iceman1001)
- Added support for loading Flipper MCT/MFU dump files (@iceman1001)
- Changed `data bmap` - now default `-m` is 8 (@iceman1001)
- Added support for NTAG424 cards. (@dankar)
- Additional fixes to configcard code for keyroll mode based on nfc-iclass output (@Antiklesys)
Expand Down
47 changes: 33 additions & 14 deletions client/src/cmdnfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,45 @@ static int CmdNfcDecode(const char *Cmd) {
return res;
}

// convert from MFC dump file to a pure NDEF byte array
if (HasMADKey(dump)) {
PrintAndLogEx(SUCCESS, "MFC dump file detected. Converting...");
uint8_t ndef[4096] = {0};
uint16_t ndeflen = 0;

if (convert_mad_to_arr(dump, bytes_read, ndef, &ndeflen) != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Failed converting, aborting...");
free(dump);
return PM3_ESOFT;
uint8_t *tmp = dump;

// if not MIFARE Classic default sizes, assume its Ultralight/NTAG
if (bytes_read != 4096 || bytes_read != 2048 || bytes_read != 1024 || bytes_read != 320) {

uint8_t **pd = &tmp;
mfu_df_e df = detect_mfu_dump_format(pd, verbose);
if (df == MFU_DF_OLDBIN) {
tmp += OLD_MFU_DUMP_PREFIX_LENGTH + (4 * 4);
bytes_read -= OLD_MFU_DUMP_PREFIX_LENGTH + ( 4 * 4);
} else if (df == MFU_DF_NEWBIN) {
tmp += MFU_DUMP_PREFIX_LENGTH + (4 * 4);
bytes_read -= MFU_DUMP_PREFIX_LENGTH + ( 4 * 4);
}
pd = NULL;

memcpy(dump, ndef, ndeflen);
bytes_read = ndeflen;
} else {

// convert from MFC dump file to a pure NDEF byte array
if (HasMADKey(tmp)) {
PrintAndLogEx(SUCCESS, "MFC dump file detected. Converting...");
uint8_t ndef[4096] = {0};
uint16_t ndeflen = 0;

if (convert_mad_to_arr(tmp, bytes_read, ndef, &ndeflen) != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Failed converting, aborting...");
free(dump);
return PM3_ESOFT;
}

memcpy(tmp, ndef, ndeflen);
bytes_read = ndeflen;
}
}

res = NDEFDecodeAndPrint(dump, bytes_read, verbose);
res = NDEFDecodeAndPrint(tmp, bytes_read, verbose);
if (res != PM3_SUCCESS) {
PrintAndLogEx(INFO, "Trying to parse NDEF records w/o NDEF header");
res = NDEFRecordsDecodeAndPrint(dump, bytes_read, verbose);
res = NDEFRecordsDecodeAndPrint(tmp, bytes_read, verbose);
}

free(dump);
Expand Down
Loading

0 comments on commit ae6ba39

Please sign in to comment.