From 5be7e8f9a3da9b3dfaf0b6024126efaade531a7e Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Sun, 7 Jun 2026 16:17:27 +0300 Subject: [PATCH] Add --dfname param to 'hf mfdes read' --- client/src/cmdhfmfdes.c | 8 +++++--- doc/commands.json | 4 +++- doc/desfire.md | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 1fb5f1057..4f0659871 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -7328,6 +7328,7 @@ static int CmdHF14ADesReadData(const char *Cmd) { "hf mfdes read --aid 123456 --fid 10 --type data -c iso -> read file via ISO channel: app=123456, short iso id=10, offset=0.\n" "hf mfdes read --aid 123456 --fileisoid 1000 --type data -c iso -> read file via ISO channel: app=123456, iso id=1000, offset=0. Select via native ISO wrapper\n" "hf mfdes read --isoid 0102 --fileisoid 1000 --type data -c iso -> read file via ISO channel: app iso id=0102, iso id=1000, offset=0. Select via ISO commands\n" + "hf mfdes read --dfname D2760000850100 --fid 01 -> select DF by name and read file 01\n" "hf mfdes read --isoid 0102 --fileisoid 1100 --type record -c iso --offset 000005 --length 000001 -> get one record (number 5) from file 1100 via iso commands\n" "hf mfdes read --isoid 0102 --fileisoid 1100 --type record -c iso --offset 000005 --length 000000 -> get all record (from 5 to 1) from file 1100 via iso commands\n" "hf mfdes read --isoid df01 --fid 00 --schann lrp -t aes --length 000010 -> read via lrp channel\n" @@ -7352,6 +7353,7 @@ static int CmdHF14ADesReadData(const char *Cmd) { arg_str0("o", "offset", "", "File Offset (3 hex bytes, big endian). For records - record number (0 - lastest record). (def: 0)"), arg_str0("l", "length", "", "Length to read (3 hex bytes, big endian -> 000000 = Read all data). For records - records count (0 - all). (def: 0)"), arg_str0(NULL, "isoid", "", "Application ISO ID (ISO DF ID) (2 hex bytes, big endian)"), + arg_str0(NULL, "dfname", "", "Application ISO DF Name (1-16 hex bytes, big endian)"), arg_str0(NULL, "fileisoid", "", "File ISO ID (ISO DF ID) (2 hex bytes, big endian). Works only for ISO read commands"), arg_lit0(NULL, "isochain", "use iso chaining commands. Switched on by default if secure channel = lrp"), arg_param_end @@ -7366,7 +7368,7 @@ static int CmdHF14ADesReadData(const char *Cmd) { int securechann = defaultSecureChannel; uint32_t id = 0x000000; DesfireISOSelectWay selectway = ISW6bAID; - int res = CmdDesGetSessionParameters(ctx, &dctx, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 0, &securechann, DCMMACed, &id, &selectway); + int res = CmdDesGetSessionParameters(ctx, &dctx, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 18, &securechann, DCMMACed, &id, &selectway); if (res) { CLIParserFree(ctx); return res; @@ -7398,12 +7400,12 @@ static int CmdHF14ADesReadData(const char *Cmd) { uint32_t fileisoid = 0x0000; bool fileisoidpresent = false; - if (CLIGetUint32Hex(ctx, 18, 0x0000, &fileisoid, &fileisoidpresent, 2, "File ISO ID (for DF) must have 2 bytes length")) { + if (CLIGetUint32Hex(ctx, 19, 0x0000, &fileisoid, &fileisoidpresent, 2, "File ISO ID (for DF) must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } - dctx.isoChaining = arg_get_lit(ctx, 19); + dctx.isoChaining = arg_get_lit(ctx, 20); SetAPDULogging(APDULogging); CLIParserFree(ctx); diff --git a/doc/commands.json b/doc/commands.json index 840b53b75..9c42c9e15 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -7270,6 +7270,7 @@ "hf mfdes read --aid 123456 --fid 10 --type data -c iso -> read file via ISO channel: app=123456, short iso id=10, offset=0.", "hf mfdes read --aid 123456 --fileisoid 1000 --type data -c iso -> read file via ISO channel: app=123456, iso id=1000, offset=0. Select via native ISO wrapper", "hf mfdes read --isoid 0102 --fileisoid 1000 --type data -c iso -> read file via ISO channel: app iso id=0102, iso id=1000, offset=0. Select via ISO commands", + "hf mfdes read --dfname D2760000850100 --fid 01 -> select DF by name and read file 01", "hf mfdes read --isoid 0102 --fileisoid 1100 --type record -c iso --offset 000005 --length 000001 -> get one record (number 5) from file 1100 via iso commands", "hf mfdes read --isoid 0102 --fileisoid 1100 --type record -c iso --offset 000005 --length 000000 -> get all record (from 5 to 1) from file 1100 via iso commands", "hf mfdes read --isoid df01 --fid 00 --schann lrp -t aes --length 000010 -> read via lrp channel", @@ -7295,10 +7296,11 @@ "-o, --offset File Offset (3 hex bytes, big endian). For records - record number (0 - lastest record). (def: 0)", "-l, --length Length to read (3 hex bytes, big endian -> 000000 = Read all data). For records - records count (0 - all). (def: 0)", "--isoid Application ISO ID (ISO DF ID) (2 hex bytes, big endian)", + "--dfname Application ISO DF Name (1-16 hex bytes, big endian)", "--fileisoid File ISO ID (ISO DF ID) (2 hex bytes, big endian). Works only for ISO read commands", "--isochain use iso chaining commands. Switched on by default if secure channel = lrp" ], - "usage": "hf mfdes read [-hav] [-n ] [-t ] [-k ] [--kdf ] [-i ] [-m ] [-c ] [--schann ] [--aid ] [--fid ] [--no-auth] [--type ] [-o ] [-l ] [--isoid ] [--fileisoid ] [--isochain]" + "usage": "hf mfdes read [-hav] [-n ] [-t ] [-k ] [--kdf ] [-i ] [-m ] [-c ] [--schann ] [--aid ] [--fid ] [--no-auth] [--type ] [-o ] [-l ] [--isoid ] [--dfname ] [--fileisoid ] [--isochain]" }, "hf mfdes selectapp": { "command": "hf mfdes selectapp", diff --git a/doc/desfire.md b/doc/desfire.md index 1462e76fe..c89ea8ae8 100644 --- a/doc/desfire.md +++ b/doc/desfire.md @@ -282,6 +282,8 @@ Create standard file with mac access mode and specified access settings. access `hf mfdes read --aid 123456 --fid 01` - autodetect file type (with `hf mfdes getfilesettings`) and read its contents +`hf mfdes read --dfname D2760000850100 --fid 01` - select an application by ISO DF name and read file 01 + `hf mfdes read --aid 123456 --fid 01 --type record --offset 000000 --length 000001` - read one last record from a record file *read via ISO command set:* @@ -579,5 +581,3 @@ or in the LRP mode Switch LRP mode on `hf mfdes setconfig --appisoid df01 -t aes -s ev2 --param 05 --data 00000000010000000000` - -