From e7c0caabcf9b7976f6c5ca051a6dc12a35e351af Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Thu, 12 Aug 2021 17:28:29 +0300 Subject: [PATCH] add verbosity --- client/src/cmdhfmfdes.c | 4 +++- client/src/mifare/desfirecore.c | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index c481d6c42..4383ede4f 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -3886,7 +3886,9 @@ static int CmdHF14ADesCreateTrMACFile(const char *Cmd) { "Create Transaction MAC file in the application. Application master key needs to be provided or flag --no-auth set (depend on application settings).", "--rawrights have priority over the separate rights settings.\n" "Key/mode/etc of the authentication depends on application settings\n" - "hf mfdes createmacfile --aid 123456 --fid 01 --rawrights 1F30 --mackey 00112233445566778899aabbccddeeff --mackeyver 01 -> create transaction mac file with parameters. Rights from default. Authentication with defaults from `default` command\n" + "Write right should be always 0xF. Read-write right should be 0xF if you not need to submit CommitReaderID command each time transaction starts\n" + "\n" + "hf mfdes createmacfile --aid 123456 --fid 01 --rawrights 0FF0 --mackey 00112233445566778899aabbccddeeff --mackeyver 01 -> create transaction mac file with parameters. Rights from default. Authentication with defaults from `default` command\n" "hf mfdes createmacfile --aid 123456 --fid 01 --amode plain --rrights free --wrights deny --rwrights free --chrights key0 --mackey 00112233445566778899aabbccddeeff -> create file app=123456, file=01, with key, and mentioned rights with defaults from `default` command\n" "hf mfdes createmacfile -n 0 -t des -k 0000000000000000 -f none --aid 123456 --fid 01 -> execute with default factory setup. key and keyver == 0x00..00"); diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index 07f85170d..b422f564d 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -2424,6 +2424,28 @@ void DesfirePrintCreateFileSettings(uint8_t filetype, uint8_t *data, size_t len) PrintAndLogEx(SUCCESS, "Access rights : %04x", MemLeToUint2byte(&data[xlen])); DesfirePrintAccessRight(&data[xlen]); xlen += 2; + + // https://www.nxp.com/docs/en/data-sheet/MF2DLHX0.pdf + // page 14 + // TransactionMAC file + if (filetype == 0x05) { + uint8_t read = 0; + uint8_t write = 0; + uint8_t readwrite = 0; + uint8_t change = 0; + DesfireDecodeFileAcessMode(&data[xlen - 2], &read, &write, &readwrite, &change); + if (write != 0x0f) + PrintAndLogEx(WARNING, "descr. : Write right should be set to F because write " _RED_("not allowed") "."); + + if (readwrite == 0x0f) + PrintAndLogEx(SUCCESS, "descr. : ReadWrite right is %01X, CommitReaderID command disabled", readwrite); + else if (readwrite == 0x0e) + PrintAndLogEx(SUCCESS, "descr. : ReadWrite right is %01X, CommitReaderID command enabled with free access", readwrite); + else if (readwrite <= 0x04) + PrintAndLogEx(SUCCESS, "descr. : ReadWrite right is %01X, CommitReaderID command enabled with key 0x0%01x", readwrite, readwrite); + else + PrintAndLogEx(WARNING, "descr. : ReadWrite right must me 0..4,E,F instead of is %01X.", readwrite); + } uint8_t reclen = 0; DesfirePrintFileSettDynPart(filetype, &data[xlen], len - xlen, &reclen, true);