diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 655ebfbf2..20983ff38 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -6216,7 +6216,7 @@ static int CmdHF14ADesCreateFile(const char *Cmd) { if (useraw && sdatalen > 0) { filetype = rawftype; memcpy(&data[1], sdata, sdatalen); - datalen += sdatalen; + datalen = 1 + sdatalen; } else { useraw = false; } @@ -6394,21 +6394,17 @@ static int CmdHF14ADesCreateValueFile(const char *Cmd) { if (verbose) PrintAndLogEx(INFO, "App: %06x. File num: 0x%02x type: 0x%02x data[%d]: %s", appid, data[0], filetype, datalen, sprint_hex(data, datalen)); + DesfirePrintCreateFileSettings(filetype, data, datalen); + res = DesfireCreateFile(&dctx, filetype, data, datalen, true); + if (res != PM3_SUCCESS) { + PrintAndLogEx(ERR, "Desfire CreateFile command " _RED_("error") ". Result: %d", res); + DropField(); + return PM3_ESOFT; + } - - - - - - - - - - - - + PrintAndLogEx(SUCCESS, "Value file %02x in the app %06x created " _GREEN_("successfully"), data[0], appid); DropField(); return PM3_SUCCESS; diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index bb5b70c1e..684738f24 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -1371,7 +1371,7 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len) return; } - bool isoidpresent = ftyperec->mayHaveISOfid; // TODO!!! + bool isoidpresent = ftyperec->mayHaveISOfid && (len == ftyperec->len + 2 + 1); PrintAndLogEx(INFO, "---- " _CYAN_("Create file settings") " ----"); PrintAndLogEx(SUCCESS, "File type : %s", ftyperec->text); @@ -1380,8 +1380,10 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len) if (isoidpresent) { PrintAndLogEx(SUCCESS, "File ISO number : 0x%02x%02x", data[xlen], data[xlen + 1]); xlen += 2; + } else { + PrintAndLogEx(SUCCESS, "File ISO number : n/a"); } - + PrintAndLogEx(SUCCESS, "File comm mode : %s", GetDesfireCommunicationMode(data[xlen] & 0x03)); bool addaccess = ((data[xlen] & 0x80) != 0); PrintAndLogEx(SUCCESS, "Additional access: %s", (addaccess) ? "Yes" : "No");