From 07524745746579ac5d39ee5d550dfb0bc994b006 Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Thu, 5 Nov 2026 20:24:02 +0200 Subject: [PATCH 01/15] Add new known FeliCa issuer identifiers --- client/resources/felica/issuers.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/resources/felica/issuers.json b/client/resources/felica/issuers.json index d8395f010..315f913f5 100644 --- a/client/resources/felica/issuers.json +++ b/client/resources/felica/issuers.json @@ -116,6 +116,18 @@ "system": "802B", "format": "packed" }, + { + "system": "80DE", + "prefix": "05D2", + "code": "KD", + "name": "IruCa", + "format": "packed", + "serial_group": 5 + }, + { + "system": "80DE", + "format": "packed" + }, { "system": "80E0", "prefix": "05D3", @@ -241,6 +253,14 @@ "system": "8B5D", "format": "epoch" }, + { + "system": "8C37", + "prefix": "0FDC", + "code": "FU", + "name": "ICOUSA", + "format": "epoch", + "serial_group": 4 + }, { "system": "FE00", "format": "epoch", From b6398169e788b6e6198e94055d1b1b532d55aed0 Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Thu, 5 Nov 2026 20:26:37 +0200 Subject: [PATCH 02/15] Add new known FeliCa systems and services --- .../felica/felica_system_code_list.json | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/client/resources/felica/felica_system_code_list.json b/client/resources/felica/felica_system_code_list.json index 1f4dfe37d..36ef08889 100644 --- a/client/resources/felica/felica_system_code_list.json +++ b/client/resources/felica/felica_system_code_list.json @@ -146,6 +146,13 @@ "type": "payment", "description": "nanaco e-money system" }, + { + "code": "0801", + "name": "DoCARD", + "region": "Japan", + "type": "transit", + "description": "Used by legacy DoCARD transit card (Dohoku Bus, Hokkaido)" + }, { "code": "12FC", "name": "NDEF Type 3 Tag", @@ -181,6 +188,20 @@ "type": "transit", "description": "Used by legacy Nagasaki Smart Card transit system (Nagasaki operators)" }, + { + "code": "8019", + "name": "Sony Finance", + "region": "Japan", + "type": "payment", + "description": "Sony Finance e-money system; used by K-Touch cards" + }, + { + "code": "801D", + "name": "Sony Finance", + "region": "Japan", + "type": "payment", + "description": "Marker system found on Edy cards issued by Sony Finance" + }, { "code": "801E", "name": "AMPM", @@ -209,6 +230,27 @@ "type": "transit", "description": "Used by Hokkaido Kitami Bus transit card" }, + { + "code": "8054", + "name": "PRONTO", + "region": "Japan", + "type": "payment", + "description": "Marker system found on Edy cards issued by PRONTO" + }, + { + "code": "8082", + "name": "ANA", + "region": "Japan", + "type": "loyalty", + "description": "Marker system found on ANA Mileage Club cards" + }, + { + "code": "80BB", + "name": "CLUB DAM", + "region": "Japan", + "type": "loyalty", + "description": "Used by Edy Club DAM Members Cards" + }, { "code": "80DE", "name": "IruCa", @@ -286,6 +328,13 @@ "type": "payment", "description": "Used by ANA QuicPay + Nanaco fob" }, + { + "code": "8188", + "name": "PokePark", + "region": "Japan", + "type": "payment", + "description": "Marker system found on Edy cards issued by PokePark" + }, { "code": "8194", "name": "Kagoshima", @@ -570,6 +619,13 @@ "type": "transit", "description": "Used by Ryuto transit card (Niigata Kotsu)" }, + { + "code": "8B61", + "name": "Kuroneko Members", + "region": "Japan", + "type": "loyalty", + "description": "Used by Kuroneko Members nanaco card (Yamato Transport)" + }, { "code": "8B98", "name": "RANDEN", @@ -591,6 +647,13 @@ "type": "payment", "description": "Marker system found on Edy cards issued by San in Shinpan" }, + { + "code": "8C37", + "name": "ICOUSA", + "region": "Japan", + "type": "transit", + "description": "Used by ICOUSA transit card (Kochi-area operators)" + }, { "code": "8CC1", "name": "Speedpass", @@ -752,6 +815,13 @@ "type": "general", "description": "Used by FeliCa Secure ID credentials" }, + { + "code": "966F", + "name": "Oshiharai", + "region": "Japan", + "type": "payment", + "description": "Marker system found on some Edy keychains" + }, { "code": "FE00", "name": "FeliCa Networks Common Area", @@ -779,6 +849,16 @@ } ] }, + { + "name": "ELIO", + "type": "payment", + "description": "ELIO e-money service found on K-Touch cards (Sony Finance)", + "nodes": [ + { + "code": "00233F26" + } + ] + }, { "name": "FeliCa Kazasu Folder", "type": "loyalty", @@ -814,6 +894,9 @@ "type": "loyalty", "description": "Karuwaza Club points and membership service", "nodes": [ + { + "code": "8026D726" + }, { "code": "8026FF26" } From 12f72fc6418a9a4d35df36964a22e694d5188633 Mon Sep 17 00:00:00 2001 From: kormax <3392860+kormax@users.noreply.github.com> Date: Thu, 5 Nov 2026 21:07:16 +0200 Subject: [PATCH 03/15] Allow FeliCa hidden environment discovery on SD2 cards --- client/src/cmdhffelica.c | 56 +++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/client/src/cmdhffelica.c b/client/src/cmdhffelica.c index 9efb6e350..bc1cbc4b6 100644 --- a/client/src/cmdhffelica.c +++ b/client/src/cmdhffelica.c @@ -141,6 +141,11 @@ static bool felica_is_lite_ic_type(uint8_t ic_type) { return (ic_type == 0xF0 || ic_type == 0xF1); } +static bool felica_pmm_is_sd2_or_newer(const uint8_t *pmm) { + // SD2+ officially starts with 0x44, but 0x38/0x3B also express those features + return (pmm != NULL && (pmm[1] == 0x38 || pmm[1] == 0x3B || (pmm[1] >= 0x44 && pmm[1] <= 0x7F))); +} + static bool felica_pmm_is_lite(const uint8_t *pmm) { return (pmm != NULL && pmm[0] == 0x00 && felica_is_lite_ic_type(pmm[1])); } @@ -2383,20 +2388,38 @@ static int discover_systems(uint8_t flags, const uint8_t *primary_idm, primary_system_code, primary_idm_polled, primary_pmm_polled); } - if (got_system_code_list == false) { - for (size_t i = 0; i < ARRAYLEN(FELICA_MANUAL_SYSTEM_PROBE_TARGETS); i++) { - uint8_t probed_idm[8] = {0}; - uint8_t probed_pmm[8] = {0}; - const uint16_t system_code = FELICA_MANUAL_SYSTEM_PROBE_TARGETS[i].system_code; - if (send_polling(flags, system_code, FELICA_POLLING_REQUEST_NO_DATA, - FELICA_POLLING_TIMEOUT_MS, polling_retries, false, - probed_idm, probed_pmm, NULL) != PM3_SUCCESS) { - continue; + // Probe systems manually, for the following reasons: + // * FeliCa Lite cards do not support RequestSystemCode + // * FeliCa Standard SD2 cards may host independent Lite/Secure ID environments + // not discoverable through RequestSystemCode + bool probe_selected = false; + const bool probe_allowed = got_system_code_list == false || + felica_pmm_is_lite(primary_pmm_polled) || + felica_pmm_is_sd2_or_newer(primary_pmm_polled); + for (size_t i = 0; probe_allowed && i < ARRAYLEN(FELICA_MANUAL_SYSTEM_PROBE_TARGETS); i++) { + const uint16_t system_code = FELICA_MANUAL_SYSTEM_PROBE_TARGETS[i].system_code; + bool known = false; + for (size_t j = 0; j < discovered_systems->count; j++) { + if (discovered_systems->systems[j].system_code == system_code) { + known = true; + break; } - - felica_add_unique_discovered_system(discovered_systems->systems, &discovered_systems->count, - system_code, probed_idm, probed_pmm); } + if (known) { + continue; + } + + uint8_t probed_idm[8] = {0}; + uint8_t probed_pmm[8] = {0}; + if (send_polling(flags, system_code, FELICA_POLLING_REQUEST_NO_DATA, + FELICA_POLLING_TIMEOUT_MS, polling_retries, false, + probed_idm, probed_pmm, NULL) != PM3_SUCCESS) { + continue; + } + + felica_add_unique_discovered_system(discovered_systems->systems, &discovered_systems->count, + system_code, probed_idm, probed_pmm); + probe_selected = true; } if (discovered_systems->count == 0) { @@ -2435,6 +2458,15 @@ static int discover_systems(uint8_t flags, const uint8_t *primary_idm, } discovered_systems->count = write_index; + // For SD2 cards, dedicated environments may have a more limited command set + // so we reselect the main Standard system + if (probe_selected && felica_pmm_is_sd2_or_newer(primary_pmm_polled)) { + uint8_t reselect_idm[8] = {0}; + send_polling(flags, FELICA_SYSTEM_CODE_WILDCARD, FELICA_POLLING_REQUEST_NO_DATA, + FELICA_POLLING_TIMEOUT_MS, polling_retries, false, + reselect_idm, NULL, NULL); + } + if (discovered_systems->count == 0) { return PM3_ERFTRANS; } From c73cc293ad1e4ad1eeb3c778c6500dcb748fa1b5 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 19:10:29 +0100 Subject: [PATCH 04/15] recovery: pad the AT91 bootrom to 0x102000 again caa76f57b ("Fix pm5 recovery image") also moved the AT91 pad from 0x00102000 to 0x00104000, but the AT91 boot area is 8 KB and the OS image starts at 0x102000. recovery.bin had every fullimage section 0x2000 too high and 0xFF at the OS entry, so a JTAG recovery would leave the bootrom in flash mode. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + recovery/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1d1f1b6..125427a8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 `recovery.bin` on the AT91 platforms - the bootrom is padded to 0x102000 again, so the OS image is at its load address (@matrix) - Updated `/Getting_Started_With_PM5.md` (@innocentbystanderproxmark) - Fixed `hf seos pacs`/`write` - 2K3DES GET/UPDATE DATA no longer fails silently with exit 236; print APDU exchange errors, check DES-CMAC, decode SELECT `85` at its real length, and use short-form `85` when the cryptogram is under 128 bytes - Fixed client build with `-march=x86-64-v3` (CentOS/RHEL 10 default) - false `-Wstringop-overflow` in the EMV AID list table (@r3wretrhy) diff --git a/recovery/Makefile b/recovery/Makefile index d3f23ee19..6f77814e1 100644 --- a/recovery/Makefile +++ b/recovery/Makefile @@ -41,7 +41,7 @@ ifeq ($(PLATFORM),PM5) $(Q)$(CROSS_OBJCOPY) --gap-fill=0xff --pad-to 0x08004000 -O binary $^ $@ else $(info [=] GENB $@) - $(Q)$(CROSS_OBJCOPY) --gap-fill=0xff --pad-to 0x00104000 -O binary $^ $@ + $(Q)$(CROSS_OBJCOPY) --gap-fill=0xff --pad-to 0x00102000 -O binary $^ $@ endif fullimage.bin: ../armsrc/obj/fullimage.elf From 8953c8d88d20cfc8591676ecce8f7a058bef2b04 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 20:44:38 +0100 Subject: [PATCH 05/15] CI: fix the macOS and ProxSpace builds, build in the WSL file system mfulc_des_brute added the Homebrew openssl@3.6 include directory, which the macOS runners no longer have, and -Wmissing-include-dirs under -Werror stopped the build. It now uses brew --prefix openssl, as #3734 did for mfd_aes_brute. Since MSYS2 filesystem 2026.10.18 /etc/profile runs post-install scripts on the first start only, so ProxSpace never installed its packages and the build found no arm-none-eabi-gcc. The workflow now runs ProxSpace's setup script when setup\installed is missing. The third mfulc_des_brute test in pm3_tests.sh is now labelled 3/3. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/windows.yml | 34 +++++++++++++++++++++------------- CHANGELOG.md | 3 +++ tools/mfulc_des_brute/Makefile | 5 +++-- tools/pm3_tests.sh | 2 +- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6cb9823c2..cf42ed83b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -99,7 +99,12 @@ jobs: for ($i = 1; $i -le $maxAttempts; $i++) { Write-Host "Attempt $i..." ./runme64.bat -c "exit" - if ($LASTEXITCODE -eq 0) { exit 0 } + # MSYS2 runs post-install scripts on its first start only since filesystem 2026.10.18, + # so ProxSpace's package setup (it writes setup\installed) is sourced here + if ($LASTEXITCODE -eq 0 -and -not (Test-Path setup\installed)) { + ./runme64.bat -c ". /etc/post-install/09-proxspace_setup.post" + } + if ($LASTEXITCODE -eq 0 -and (Test-Path setup\installed)) { exit 0 } if ($i -lt $maxAttempts) { Start-Sleep -Seconds $delay } } exit 1 @@ -204,29 +209,34 @@ jobs: - uses: actions/checkout@v6 + # builds on the Windows drive (/mnt/d) are slow from WSL 2 + - name: Copy the sources into the WSL file system + run: cp -a . ~/proxmark3 + - name: make clean - run: make clean + run: cd ~/proxmark3 && make clean - name: Build - run: make -j$((`nproc` + 1)) V=1 + run: cd ~/proxmark3 && make -j$((`nproc` + 1)) V=1 - name: Test - run: make check + run: cd ~/proxmark3 && make check - name: make clean - run: make clean + run: cd ~/proxmark3 && make clean - name: Build btaddon - run: make -j$((`nproc` + 1)) V=1 PLATFORM_EXTRAS=BTADDON + run: cd ~/proxmark3 && make -j$((`nproc` + 1)) V=1 PLATFORM_EXTRAS=BTADDON - name: Test btaddon - run: make check + run: cd ~/proxmark3 && make check - name: make clean - run: make clean + run: cd ~/proxmark3 && make clean - name: Prepare cmake build folders run: | + cd ~/proxmark3 mkdir -p client/build ln -s ../cmdscripts client/build/ ln -s ../luascripts client/build/ @@ -234,12 +244,10 @@ jobs: ln -s ../lualibs client/build/ - name: Initiate cmake environment - run: cmake .. - working-directory: client/build/ + run: cd ~/proxmark3/client/build && cmake .. - name: Build cmake - run: make -j$((`nproc` + 1)) VERBOSE=1 - working-directory: client/build/ + run: cd ~/proxmark3/client/build && make -j$((`nproc` + 1)) VERBOSE=1 - name: Test cmake - run: make client/check CHECKARGS="--clientbin ./client/build/proxmark3" + run: cd ~/proxmark3 && make client/check CHECKARGS="--clientbin ./client/build/proxmark3" diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1d1f1b6..f75f2d130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ 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 `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix) +- Fixed Windows ProxSpace CI - its package setup is sourced by the workflow, MSYS2 runs post-install scripts on the first start only (@matrix) +- Changed Windows WSL CI to build in the WSL file system (@matrix) - Updated `/Getting_Started_With_PM5.md` (@innocentbystanderproxmark) - Fixed `hf seos pacs`/`write` - 2K3DES GET/UPDATE DATA no longer fails silently with exit 236; print APDU exchange errors, check DES-CMAC, decode SELECT `85` at its real length, and use short-form `85` when the cryptogram is under 128 bytes - Fixed client build with `-march=x86-64-v3` (CentOS/RHEL 10 default) - false `-Wstringop-overflow` in the EMV AID list table (@r3wretrhy) diff --git a/tools/mfulc_des_brute/Makefile b/tools/mfulc_des_brute/Makefile index 0009385be..2b97d6c55 100644 --- a/tools/mfulc_des_brute/Makefile +++ b/tools/mfulc_des_brute/Makefile @@ -15,8 +15,9 @@ endif # OS X needs linking to openssl ifeq ($(USE_BREW),1) - MYCFLAGS += -I$(BREW_PREFIX)/opt/openssl@3/include -I$(BREW_PREFIX)/opt/openssl@3.6/include - MYLDFLAGS += -L$(BREW_PREFIX)/opt/openssl@3/lib -L$(BREW_PREFIX)/opt/openssl@3.6/lib + OPENSSL_PREFIX := $(shell brew --prefix openssl) + MYCFLAGS += -I$(OPENSSL_PREFIX)/include + MYLDFLAGS += -L$(OPENSSL_PREFIX)/lib endif ifeq ($(USE_MACPORTS),1) diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index 36f8a102b..6999c87d5 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -371,7 +371,7 @@ while true; do # ULCG if ! CheckExecute "mfulc_des_brute test 2/3" "$MFULCDESBRUTEBIN -c 49C1603621CCAA72 8122262EF5FA8DEB 48444C4A4044524200000000544E5846 3 4" "48444C4A40445242204E4042544E5846"; then break; fi # Reader RndB nonce key recovery - if ! CheckExecute "mfulc_des_brute test 2/3" "$MFULCDESBRUTEBIN -r EC9C5CF763244367 2283BFE8DEBE1780922327794D0706EF 48444C4A4044524200000000544E5846 3 4" "48444C4A40445242204E4042544E5846"; then break; fi + if ! CheckExecute "mfulc_des_brute test 3/3" "$MFULCDESBRUTEBIN -r EC9C5CF763244367 2283BFE8DEBE1780922327794D0706EF 48444C4A4044524200000000544E5846 3 4" "48444C4A40445242204E4042544E5846"; then break; fi fi if $TESTALL || $TESTCRYPTORF; then echo -e "\n${C_BLUE}Testing CryptoRF sma:${C_NC} ${CRYPTRFBRUTEBIN:=./tools/cryptorf/sma} ${CRYPTRF_MULTI_BRUTEBIN:=./tools/cryptorf/sma_multi}" From e9689307c89d63fb675f4020003cb4ce94dc3d36 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 21:28:47 +0100 Subject: [PATCH 06/15] CI: skip the slow Azure apt mirror, tidy the ProxSpace job The Ubuntu jobs drop azure.archive.ubuntu.com from the runner's mirror list. It sometimes serves at tens of kB/s, held apt-get install for up to 50 minutes and apt never fails over (actions/runner-images#14823). The ProxSpace job no longer asks for arm-none-eabi-gdb, which MSYS2 replaced with gdb-multiarch in 2023, and no longer persists the checkout credentials, whose cleanup failed with MSYS2's git on PATH. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ubuntu.yml | 24 ++++++++++++++++++++---- .github/workflows/windows.yml | 4 +++- CHANGELOG.md | 3 +-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index ed93c0a5e..7c1dc9a91 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -27,8 +27,12 @@ jobs: with: python-version: '3.12' + # azure.archive.ubuntu.com can serve at tens of kB/s and apt does not fail + # over on slowness (actions/runner-images#14823): use the Ubuntu archive - name: Update apt repos - run: sudo apt-get update + run: | + sudo sed -i '/azure\.archive\.ubuntu\.com/d' /etc/apt/apt-mirrors.txt + sudo apt-get update - name: Install dependencies run: sudo apt-get install -yqq make build-essential ca-certificates pkg-config libreadline-dev gcc-arm-none-eabi libnewlib-dev qt6-base-dev libbz2-dev liblz4-dev libbluetooth-dev libpython3-dev python3 python3-dev libpython3-all-dev liblua5.4-dev liblua5.4-0 lua5.4 sed libssl-dev libgd-dev @@ -57,8 +61,12 @@ jobs: with: python-version: '3.12' + # azure.archive.ubuntu.com can serve at tens of kB/s and apt does not fail + # over on slowness (actions/runner-images#14823): use the Ubuntu archive - name: Update apt repos - run: sudo apt-get update + run: | + sudo sed -i '/azure\.archive\.ubuntu\.com/d' /etc/apt/apt-mirrors.txt + sudo apt-get update - name: Install dependencies run: sudo apt-get install -yqq make build-essential ca-certificates pkg-config libreadline-dev gcc-arm-none-eabi libnewlib-dev qt6-base-dev libbz2-dev liblz4-dev libbluetooth-dev libpython3-dev python3 python3-dev libpython3-all-dev liblua5.4-dev liblua5.4-0 lua5.4 sed libssl-dev libgd-dev @@ -88,8 +96,12 @@ jobs: with: python-version: '3.12' + # azure.archive.ubuntu.com can serve at tens of kB/s and apt does not fail + # over on slowness (actions/runner-images#14823): use the Ubuntu archive - name: Update apt repos - run: sudo apt-get update + run: | + sudo sed -i '/azure\.archive\.ubuntu\.com/d' /etc/apt/apt-mirrors.txt + sudo apt-get update - name: Install dependencies run: sudo apt-get install -yqq make build-essential ca-certificates pkg-config libreadline-dev gcc-arm-none-eabi libnewlib-dev qt6-base-dev libbz2-dev liblz4-dev libbluetooth-dev libpython3-dev python3 python3-dev libpython3-all-dev liblua5.4-dev liblua5.4-0 lua5.4 sed libssl-dev libgd-dev @@ -130,8 +142,12 @@ jobs: with: python-version: '3.12' + # azure.archive.ubuntu.com can serve at tens of kB/s and apt does not fail + # over on slowness (actions/runner-images#14823): use the Ubuntu archive - name: Update apt repos - run: sudo apt-get update + run: | + sudo sed -i '/azure\.archive\.ubuntu\.com/d' /etc/apt/apt-mirrors.txt + sudo apt-get update - name: Install dependencies run: sudo apt-get install -yqq make build-essential ca-certificates pkg-config libreadline-dev gcc-arm-none-eabi libnewlib-dev qt6-base-dev libbz2-dev liblz4-dev libbluetooth-dev libpython3-dev python3 python3-dev libpython3-all-dev liblua5.4-dev liblua5.4-0 lua5.4 sed libssl-dev libgd-dev diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cf42ed83b..58a01d22c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,7 +56,6 @@ jobs: ############################## mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-arm-none-eabi-gcc - mingw-w64-ucrt-x86_64-arm-none-eabi-gdb mingw-w64-ucrt-x86_64-arm-none-eabi-binutils mingw-w64-ucrt-x86_64-arm-none-eabi-newlib mingw-w64-ucrt-x86_64-readline @@ -109,7 +108,10 @@ jobs: } exit 1 + # no credentials to clean up after the job, when MSYS2's git is first on PATH - uses: actions/checkout@v6 + with: + persist-credentials: false # Prepend MSYS2 tools to PATH only for steps after checkout, so actions/checkout # keeps using the runner's native git (MSYS2's git.exe mangles refs like diff --git a/CHANGELOG.md b/CHANGELOG.md index f75f2d130..ae78e2576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac ## [unreleased][unreleased] - Fixed `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix) -- Fixed Windows ProxSpace CI - its package setup is sourced by the workflow, MSYS2 runs post-install scripts on the first start only (@matrix) -- Changed Windows WSL CI to build in the WSL file system (@matrix) +- Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu skips the slow Azure apt mirror (@matrix) - Updated `/Getting_Started_With_PM5.md` (@innocentbystanderproxmark) - Fixed `hf seos pacs`/`write` - 2K3DES GET/UPDATE DATA no longer fails silently with exit 236; print APDU exchange errors, check DES-CMAC, decode SELECT `85` at its real length, and use short-form `85` when the cryptogram is under 128 bytes - Fixed client build with `-march=x86-64-v3` (CentOS/RHEL 10 default) - false `-Wstringop-overflow` in the EMV AID list table (@r3wretrhy) From 1e645dfd0a8ebb7373716066d23d85b002d36dd0 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 22:04:55 +0100 Subject: [PATCH 07/15] CI: update checkout, setup-python and upload-artifact to v7 actions/checkout v6 hands the Windows path of its credentials config to git config --unset as a regex, which MSYS2's git rejects in the ProxSpace job (actions/checkout#2528, fixed in v7.0.1). The persist-credentials: false added for it did not help and is dropped. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/fpga-pm3.yml | 4 ++-- .github/workflows/fpga-pm5.yml | 4 ++-- .github/workflows/macos.yml | 12 ++++++------ .github/workflows/ubuntu.yml | 16 ++++++++-------- .github/workflows/uniq.yaml | 2 +- .github/workflows/windows.yml | 7 ++----- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4f7990610..57a0d7301 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -53,7 +53,7 @@ jobs: if [ -f requirements.txt ]; then python3 -m pip install -r requirements.txt; fi - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/fpga-pm3.yml b/.github/workflows/fpga-pm3.yml index afe9a969c..9d122cbd2 100644 --- a/.github/workflows/fpga-pm3.yml +++ b/.github/workflows/fpga-pm3.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 # The image is 8 GB unpacked, so keep an eye on the runner's disk. - name: Pull the ISE image @@ -65,7 +65,7 @@ jobs: test "$size" -gt 1000 done - - uses: actions/upload-artifact@v6 + - uses: actions/upload-artifact@v7 with: name: fpga-pm3-bitstreams path: fpga/*.bit diff --git a/.github/workflows/fpga-pm5.yml b/.github/workflows/fpga-pm5.yml index 00076fff8..3684065fa 100644 --- a/.github/workflows/fpga-pm5.yml +++ b/.github/workflows/fpga-pm5.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Install oss-cad-suite run: | @@ -80,7 +80,7 @@ jobs: md5sum -c "$RUNNER_TEMP/bitstream.md5" - name: Upload the bitstream - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v7 with: name: fpga-pm5-bitstream path: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 25daedb8d..3b80c52c4 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -21,9 +21,9 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' @@ -65,9 +65,9 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' @@ -110,9 +110,9 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 7c1dc9a91..b197dc90e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -21,9 +21,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' @@ -55,9 +55,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' @@ -90,9 +90,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' @@ -136,9 +136,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v6 + - uses: actions/setup-python@v7 with: python-version: '3.12' diff --git a/.github/workflows/uniq.yaml b/.github/workflows/uniq.yaml index 210f6adf1..87b6dade8 100644 --- a/.github/workflows/uniq.yaml +++ b/.github/workflows/uniq.yaml @@ -18,7 +18,7 @@ jobs: check-unique: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: check unique keys in dic files shell: bash run: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 58a01d22c..a13e583aa 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -108,10 +108,7 @@ jobs: } exit 1 - # no credentials to clean up after the job, when MSYS2's git is first on PATH - - uses: actions/checkout@v6 - with: - persist-credentials: false + - uses: actions/checkout@v7 # Prepend MSYS2 tools to PATH only for steps after checkout, so actions/checkout # keeps using the runner's native git (MSYS2's git.exe mangles refs like @@ -209,7 +206,7 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 # builds on the Windows drive (/mnt/d) are slow from WSL 2 - name: Copy the sources into the WSL file system From 49e444b773b70e6f03d1b04b8701847961a73f2e Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 22:15:28 +0100 Subject: [PATCH 08/15] client: flash animation only on a terminal, exit 1 on failure Since cd5906674 the flash animation runs whatever stdout is, and a redirected flash of fullimage.elf wrote a 7 MB log. flash_pm3() replaced a flash error with the result of flash_stop_flashing(), always PM3_SUCCESS, so a failed flash ended with "All done". main() exited 0 after --flash, --dumpmem and --reboot-to-bootloader whatever happened. dumpmem printed its negative error code with %u. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 ++ client/src/flash.c | 10 ++++++---- client/src/proxmark3.c | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e135b090..c11771727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) +- Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix) - Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu skips the slow Azure apt mirror (@matrix) - Fixed `recovery.bin` on the AT91 platforms - the bootrom is padded to 0x102000 again, so the OS image is at its load address (@matrix) diff --git a/client/src/flash.c b/client/src/flash.c index 7366bc007..931d055de 100644 --- a/client/src/flash.c +++ b/client/src/flash.c @@ -1027,7 +1027,9 @@ int flash_write(flash_file_t *ctx, flash_dev_t *flash_dev) { void (*old_sigint)(int) = SIG_ERR; void (*old_sigwinch)(int) = SIG_ERR; - if (blocks > 50) { + // escape sequences only where they work, not in a redirected stdout + bool animate = (blocks > 50) && g_session.stdoutOnTTY; + if (animate) { old_sigint = signal(SIGINT, hadouken_on_sigint); #ifndef _WIN32 @@ -1045,7 +1047,7 @@ int flash_write(flash_file_t *ctx, flash_dev_t *flash_dev) { } if (write_block(baddr, ctx->ver_info->magic, data, block_size, flash_dev) < 0) { - if (blocks > 50) { + if (animate) { hadouken_stop(); restore_progress_signals(old_sigint, old_sigwinch); } @@ -1058,13 +1060,13 @@ int flash_write(flash_file_t *ctx, flash_dev_t *flash_dev) { length -= block_size; block++; - if (blocks > 50) { + if (animate) { pct = (int)(block * 100) / blocks; hadouken_set_progress(pct); } } - if (blocks > 50) { + if (animate) { hadouken_stop(); restore_progress_signals(old_sigint, old_sigwinch); } diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 7655800e0..4e7791dc3 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -978,7 +978,7 @@ finish: } else if (ret == PM3_EOPABORTED) { PrintAndLogEx(FAILED, "Aborted by user"); } else { - PrintAndLogEx(ERR, "Aborted on error %u", ret); + PrintAndLogEx(ERR, "Aborted on error %d", ret); } return ret; } @@ -1071,7 +1071,11 @@ finish: PrintAndLogEx(WARNING, "The flashing procedure failed, follow the suggested steps!"); } - ret = flash_stop_flashing(); + // the reset must not hide the error that ended the flashing + int stop_ret = flash_stop_flashing(); + if (ret == PM3_SUCCESS) { + ret = stop_ret; + } CloseProxmark(g_session.current_device); finish2: @@ -1500,18 +1504,18 @@ int main(int argc, char *argv[]) { } if (dumpmem_mode) { - dumpmem_pm3(port, dumpmem_filename, dumpmem_addr, dumpmem_len, dumpmem_raw); - exit(EXIT_SUCCESS); + int ret = dumpmem_pm3(port, dumpmem_filename, dumpmem_addr, dumpmem_len, dumpmem_raw); + exit((ret == PM3_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE); } if (flash_mode) { - flash_pm3(port, flash_num_files, flash_filenames, flash_can_write_bl, flash_force); - exit(EXIT_SUCCESS); + int ret = flash_pm3(port, flash_num_files, flash_filenames, flash_can_write_bl, flash_force); + exit((ret == PM3_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE); } if (reboot_bootloader_mode) { - reboot_bootloader_pm3(port); - exit(EXIT_SUCCESS); + int ret = reboot_bootloader_pm3(port); + exit((ret == PM3_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE); } if (script_cmd) { From aeb3705237883ca3893a5d80a91c925d1ffdd942 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 22:27:28 +0100 Subject: [PATCH 09/15] data rawdemod: stop cutting --max, --samples and --p2 clock to 8 bits The values went through uint8_t or & 0xFF, so --max 300 ran with 44 and --samples 1000 with 232. The --fs clocks stay 8-bit in the FSK demod and are now refused above 255. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmddata.c | 30 ++++++++++++++++++------------ tools/pm3_tests.sh | 3 +++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e135b090..00e44d29c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) - Fixed `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix) - Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu skips the slow Azure apt mirror (@matrix) - Fixed `recovery.bin` on the AT91 platforms - the bootrom is padded to 0x102000 again, so the OS image is at its load address (@matrix) diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 91f09ebcc..29f6ff0fe 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -474,8 +474,8 @@ static int Cmdaskmandemod(const char *Cmd) { uint16_t clk = (uint16_t)arg_get_int_def(ctx, 2, 0); bool invert = arg_get_lit(ctx, 3); bool st = arg_get_lit(ctx, 4); - uint8_t max_err = (uint8_t)arg_get_int_def(ctx, 5, 100) & 0xFF; - size_t max_len = (size_t)arg_get_int_def(ctx, 6, 0) & 0xFF; + int max_err = arg_get_int_def(ctx, 5, 100); + size_t max_len = (size_t)arg_get_int_def(ctx, 6, 0); CLIParserFree(ctx); return ASKDemod_ext(clk, invert, max_err, max_len, amplify, true, true, 1, &st); @@ -718,7 +718,7 @@ static int Cmdaskbiphdemod(const char *Cmd) { uint16_t clk = (uint16_t)arg_get_int_def(ctx, 1, 0); bool invert = arg_get_lit(ctx, 2); int offset = arg_get_int_def(ctx, 3, 0); - uint8_t max_err = (uint8_t)arg_get_int_def(ctx, 4, 50) & 0xFF; + int max_err = arg_get_int_def(ctx, 4, 50); CLIParserFree(ctx); return ASKbiphaseDemod(offset, clk, invert, max_err, true); @@ -751,8 +751,8 @@ static int Cmdaskrawdemod(const char *Cmd) { uint16_t clk = (uint16_t)arg_get_int_def(ctx, 2, 0); bool invert = arg_get_lit(ctx, 3); bool st = arg_get_lit(ctx, 4); - uint8_t max_err = (uint8_t)arg_get_int_def(ctx, 5, 100) & 0xFF; - size_t max_len = (size_t)arg_get_int_def(ctx, 6, 0) & 0xFF; + int max_err = arg_get_int_def(ctx, 5, 100); + size_t max_len = (size_t)arg_get_int_def(ctx, 6, 0); CLIParserFree(ctx); return ASKDemod_ext(clk, invert, max_err, max_len, amplify, true, false, 0, &st); @@ -1348,12 +1348,18 @@ static int CmdFSKrawdemod(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); - uint8_t clk = (uint8_t)arg_get_int_def(ctx, 1, 0) & 0xFF; + int clk = arg_get_int_def(ctx, 1, 0); bool invert = arg_get_lit(ctx, 2); - uint8_t fchigh = (uint8_t)arg_get_int_def(ctx, 3, 0) & 0xFF; - uint8_t fclow = (uint8_t)arg_get_int_def(ctx, 4, 0) & 0xFF; + int fchigh = arg_get_int_def(ctx, 3, 0); + int fclow = arg_get_int_def(ctx, 4, 0); CLIParserFree(ctx); + // the fsk demod holds them in a byte + if (clk < 0 || clk > 0xFF || fchigh < 0 || fchigh > 0xFF || fclow < 0 || fclow > 0xFF) { + PrintAndLogEx(FAILED, "Clock and field clocks must be 0 - 255"); + return PM3_EINVARG; + } + return FSKrawDemod(clk, invert, fchigh, fclow, true); } @@ -1694,7 +1700,7 @@ static int CmdNRZrawDemod(const char *Cmd) { uint16_t clk = (uint16_t)arg_get_int_def(ctx, 1, 0); bool invert = arg_get_lit(ctx, 2); - uint8_t max_err = (uint8_t)arg_get_int_def(ctx, 3, 100) & 0xFF; + int max_err = arg_get_int_def(ctx, 3, 100); CLIParserFree(ctx); return NRZrawDemod(clk, invert, max_err, true); @@ -1724,7 +1730,7 @@ int CmdPSK1rawDemod(const char *Cmd) { uint16_t clk = (uint16_t)arg_get_int_def(ctx, 1, 0); bool invert = arg_get_lit(ctx, 2); - uint8_t max_err = (uint8_t)arg_get_int_def(ctx, 3, 100) & 0xFF; + int max_err = arg_get_int_def(ctx, 3, 100); CLIParserFree(ctx); int ans = PSKDemod(clk, invert, max_err, true); @@ -1760,9 +1766,9 @@ static int CmdPSK2rawDemod(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); - uint8_t clk = (uint8_t)arg_get_int_def(ctx, 1, 0) & 0xFF; + uint16_t clk = (uint16_t)arg_get_int_def(ctx, 1, 0); bool invert = arg_get_lit(ctx, 2); - uint8_t max_err = (uint8_t)arg_get_int_def(ctx, 3, 100) & 0xFF; + int max_err = arg_get_int_def(ctx, 3, 100); CLIParserFree(ctx); int ans = PSKDemod(clk, invert, max_err, true); diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index 6999c87d5..675fdd4dd 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -471,6 +471,9 @@ while true; do if ! CheckExecute "data qrcode odd hex" "$CLIENTBIN -c 'data qrcode -d a' 2>&1" "QR data must contain an even number of hex digits"; then break; fi if ! CheckExecute "data qrcode spaced hex" "$CLIENTBIN -c 'data qrcode -d \"aa bb\"' 2>&1" "Spaces are not supported; encode a space byte as 20"; then break; fi if ! CheckExecute "data modulation keeps trace" "$CLIENTBIN -c 'data load -f traces/lf_Q5_mod-psk1-32-4.pm3; data modulation; data autocorr -w 99999'" "smaller than trace \\( 20000 samples \\)"; then break; fi + if ! CheckExecute "data rawdemod fs clock range" "$CLIENTBIN -c 'data rawdemod --fs -c 300' 2>&1" "Clock and field clocks must be 0 - 255"; then break; fi + if ! CheckExecute "data rawdemod ar samples" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri.pm3; data setdebugmode -1; data rawdemod --ar --samples 1000' 2>&1" "maxLen 1000"; then break; fi + if ! CheckExecute "data rawdemod am max errors" "$CLIENTBIN -c 'data load -f traces/lf_EM4102-1.pm3; data setdebugmode -1; data rawdemod --am --max 300' 2>&1" "maxErr 300"; then break; fi if ! CheckExecute "mfu pwdgen test" "$CLIENTBIN -c 'hf mfu pwdgen --test'" "Selftest ok"; then break; fi if ! CheckExecute "mfu keygen test" "$CLIENTBIN -c 'hf mfu keygen --uid 11223344556677'" "80 B1 C2 71 D8 A0"; then break; fi if ! CheckExecute "jooki encode test" "$CLIENTBIN -c 'hf jooki encode --test'" "04 28 F4 DA F0 4A 81 \( ok \)"; then break; fi From 2adeaa42a79982c2c61f59cc354facbf60b5a972 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 22:29:46 +0100 Subject: [PATCH 10/15] CI: skip the slow Azure apt mirror in CodeQL too CodeQL installs its packages with apt and stalls on azure.archive.ubuntu.com like the Ubuntu jobs did (actions/runner-images#14823). #3747 left this workflow out. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/codeql-analysis.yml | 6 +++++- CHANGELOG.md | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 57a0d7301..86a572e93 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,8 +39,12 @@ jobs: # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: + # azure.archive.ubuntu.com can serve at tens of kB/s and apt does not fail + # over on slowness (actions/runner-images#14823): use the Ubuntu archive - name: Update apt repos - run: sudo apt-get update + run: | + sudo sed -i '/azure\.archive\.ubuntu\.com/d' /etc/apt/apt-mirrors.txt + sudo apt-get update - name: Install dependencies run: sudo apt-get install -yqq make autoconf build-essential ca-certificates pkg-config libreadline-dev gcc-arm-none-eabi libnewlib-dev qtbase5-dev libbz2-dev liblz4-dev libbluetooth-dev libpython3-dev python3 python3-dev libpython3-all-dev liblua5.4-dev liblua5.4-0 lua5.4 sed libssl-dev diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e135b090..d6e347a3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac ## [unreleased][unreleased] - Fixed `mfulc_des_brute` build on macOS without `openssl@3.6` - OpenSSL is found with `brew --prefix openssl` as in `mfd_aes_brute` (@matrix) -- Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu skips the slow Azure apt mirror (@matrix) +- Fixed CI - ProxSpace installs its packages again, WSL builds in its own file system, Ubuntu and CodeQL skip the slow Azure apt mirror (@matrix) - Fixed `recovery.bin` on the AT91 platforms - the bootrom is padded to 0x102000 again, so the OS image is at its load address (@matrix) - Updated `/Getting_Started_With_PM5.md` (@innocentbystanderproxmark) - Fixed `hf seos pacs`/`write` - 2K3DES GET/UPDATE DATA no longer fails silently with exit 236; print APDU exchange errors, check DES-CMAC, decode SELECT `85` at its real length, and use short-form `85` when the cryptogram is under 128 bytes From 8024ab5ecb49395952b574f1290c58f05e5e8ed4 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 22:55:23 +0100 Subject: [PATCH 11/15] nfc: decode NULL, Lock Control and Memory Control TLVs as specified A NULL TLV has no length, so a run of them swallowed the TLVs after it. Lock and Memory Control sizes of 0 mean 256, the nibbles of their third byte are powers of two and the Memory Control size counts bytes. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/nfc/ndef.c | 46 +++++++++++++++++++++++++++---------------- tools/pm3_tests.sh | 4 ++++ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..c64c1b1d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 NDEF TLV decoding - a NULL TLV has no length, Lock and Memory Control sizes of 0 mean 256 and their page fields are powers of two (@matrix) - Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) - Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) diff --git a/client/src/nfc/ndef.c b/client/src/nfc/ndef.c index 1713bd199..85de2cda5 100644 --- a/client/src/nfc/ndef.c +++ b/client/src/nfc/ndef.c @@ -1440,12 +1440,17 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) { switch (ndef[indx]) { case 0x00: { - indx++; - uint16_t len = ndefTLVGetLength(&ndef[indx], &indx); - PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " ---"); - if (len) - PrintAndLogEx(WARNING, "NDEF NULL block size must be 0, got %d bytes", len); - indx += len; + // a NULL TLV is the T byte alone, without length + size_t run = 0; + while ((indx < ndefLen) && (ndef[indx] == 0x00)) { + indx++; + run++; + } + if (run == 1) { + PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " ---"); + } else { + PrintAndLogEx(SUCCESS, "--- " _CYAN_("NDEF NULL block") " --- x %zu", run); + } break; } case 0x01: { @@ -1458,15 +1463,16 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) { } else { uint8_t pages_addr = (ndef[indx] >> 4) & 0x0f; uint8_t byte_offset = ndef[indx] & 0x0f; - uint8_t Size = ndef[indx + 1]; - uint8_t BytesLockedPerLockBit = (ndef[indx + 2] >> 4) & 0x0f; - uint8_t bytes_per_page = ndef[indx + 2] & 0x0f; + // Type 2 Tag spec: Size 0 is 256 lock bits, both nibbles are powers of two + uint16_t Size = (ndef[indx + 1]) ? ndef[indx + 1] : 256; + uint16_t BytesLockedPerLockBit = 1 << ((ndef[indx + 2] >> 4) & 0x0f); + uint16_t bytes_per_page = 1 << (ndef[indx + 2] & 0x0f); PrintAndLogEx(SUCCESS, " Pages addr (number of pages).... %d", pages_addr); PrintAndLogEx(SUCCESS, " Byte offset (number of bytes)... %d", byte_offset); - PrintAndLogEx(SUCCESS, " Lock Area size in bits.......... %d ( %d bytes )", Size, Size / 8); - PrintAndLogEx(SUCCESS, " Number of bytes / page... %d", bytes_per_page); + PrintAndLogEx(SUCCESS, " Lock Area size in bits.......... %u ( %u bytes )", Size, (Size + 7) / 8); + PrintAndLogEx(SUCCESS, " Number of bytes / page... %u", bytes_per_page); PrintAndLogEx(SUCCESS, " Bytes Locked Per LockBit"); - PrintAndLogEx(SUCCESS, " number of bytes that each dynamic lock bit locks... %d", BytesLockedPerLockBit); + PrintAndLogEx(SUCCESS, " number of bytes that each dynamic lock bit locks... %u", BytesLockedPerLockBit); } indx += len; break; @@ -1481,11 +1487,12 @@ int NDEFDecodeAndPrint(uint8_t *ndef, size_t ndefLen, bool verbose) { } else { uint8_t pages_addr = (ndef[indx] >> 4) & 0x0f; uint8_t byte_offset = ndef[indx] & 0x0f; - uint8_t Size = ndef[indx + 1]; - uint8_t bytes_per_page = ndef[indx + 2] & 0x0f; + // Type 2 Tag spec: Size is in bytes, 0 is 256, the page size is a power of two + uint16_t Size = (ndef[indx + 1]) ? ndef[indx + 1] : 256; + uint16_t bytes_per_page = 1 << (ndef[indx + 2] & 0x0f); PrintAndLogEx(SUCCESS, "Pages addr (number of pages).... %u", pages_addr); PrintAndLogEx(SUCCESS, "Byte offset (number of bytes)... %u", byte_offset); - PrintAndLogEx(SUCCESS, "Reserved area size in bits...... %u ( %u bytes )", Size, Size / 8); + PrintAndLogEx(SUCCESS, "Reserved area size in bytes..... %u", Size); PrintAndLogEx(SUCCESS, " Number of bytes / page... %u", bytes_per_page); } indx += len; @@ -1541,8 +1548,13 @@ int NDEFGetTotalLength(uint8_t *ndef, size_t ndeflen, size_t *outlen) { size_t idx = 0; while (idx < ndeflen) { - if (ndef[idx] == 0x00 || - ndef[idx] == 0x01 || + // a NULL TLV is the T byte alone, no length + if (ndef[idx] == 0x00) { + idx++; + continue; + } + + if (ndef[idx] == 0x01 || ndef[idx] == 0x02 || ndef[idx] == 0x03 || ndef[idx] == 0xFD) { diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index 675fdd4dd..4b628edc0 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -493,6 +493,10 @@ while true; do if ! CheckExecute "nfc decode test apple wallet" "$CLIENTBIN -c 'nfc decode -d 031AD10116550077616C6C65743A2F2F61637469766174652F6E6663FE'" "activate/nfc"; then break; fi if ! CheckExecute "nfc decode test signature" "$CLIENTBIN -c 'nfc decode -d 03FF010194113870696C65742E65653A656B616172743A3266195F26063132303832325904202020205F28033233335F2701316E1B5A13333038363439303039303030323636343030355304EBF2CE704103000000AC536967010200803A2448FCA7D354A654A81BD021150D1A152D1DF4D7A55D2B771F12F094EAB6E5E10F2617A2F8DAD4FD38AFF8EA39B71C19BD42618CDA86EE7E144636C8E0E7CFC4096E19C3680E09C78A0CDBC05DA2D698E551D5D709717655E56FE3676880B897D2C70DF5F06ECE07C71435255144F8EE41AF110E7B180DA0E6C22FB8FDEF61800025687474703A2F2F70696C65742E65652F6372742F33303836343930302D303030312E637274FE'" "30864900-0001.crt"; then break; fi if ! CheckExecute "nfc decode test openprinter tag" "$CLIENTBIN -c 'nfc decode -d 03FF012F91013A55046E756D616B6572732E636F6D2F70726F64756374732F6162732D66696C616D656E743F76617269616E743D3436393434323937333836323932521CD26170706C69636174696F6E2F766E642E6F70656E7072696E74746167A10218AFBF041B000007D0FCAB45F9080009020A70414253204C656D6F6E2059656C6C6F770B684E756D616B6572730E1A69094200101903E81119041A1218F01343F9A800181DF93C29182218F01823190104182418AA1825185A18261864FF00'" "application/vnd.openprinttag"; then break; fi + if ! CheckExecute "nfc decode null tlv run" "$CLIENTBIN -c 'nfc decode -d 0000000300FE'" "NDEF NULL block --- x 3"; then break; fi + if ! CheckExecute "nfc decode lock control" "$CLIENTBIN -c 'nfc decode -d 0103A01044FE'" "number of bytes that each dynamic lock bit locks\.\.\. 16"; then break; fi + if ! CheckExecute "nfc decode lock control size 0" "$CLIENTBIN -c 'nfc decode -d 0103A00044FE'" "Lock Area size in bits\.{10} 256 \( 32 bytes \)"; then break; fi + if ! CheckExecute "nfc decode memory control" "$CLIENTBIN -c 'nfc decode -d 0203A03044FE'" "Reserved area size in bytes\.{5} 48"; then break; fi if ! CheckExecute "wiegand encode new" "$CLIENTBIN -c 'wiegand encode -w H10301 --fc 123 --cn 4567 --new'" "New PACS\\.{9} 0x 06BD88EB80"; then break; fi if ! CheckExecute "wiegand encode bin" "$CLIENTBIN -c 'wiegand encode --bin 1'" "Wiegand raw\\.{4} 03"; then break; fi From 3e7de8a116e84605a6b44ac6852f16c512a9a05d Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 23:42:11 +0100 Subject: [PATCH 12/15] wiegand: fix HPP32, H10320, S12906b, HGen37, format limits, list usage HPP32 wrote its card number 10 bits past the 32-bit frame, it now uses bits 13-30 as cardinfo shows. H10320 wrote its first digit over the leading one, so decode refused most numbers, and two of its parity masks had typos. S12906b needed ParityValid, which no caller sets. HGen37 decode checked bit 28 instead of 26. The limits of nine formats did not match the fields Pack writes. wiegand list printed the usage of wiegand info. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmdwiegand.c | 2 +- client/src/wiegand_formats.c | 51 ++++++++++++++++++------------------ doc/commands.json | 4 +-- tools/pm3_tests.sh | 33 +++++++++++++++++++++++ 5 files changed, 62 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..0319793e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 `wiegand` formats - HPP32, H10320 and S12906b encode as laid out, HGen37 decode checks the right parity bit, the limits of nine formats match their fields, `wiegand list -h` shows its own usage (@matrix) - Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) - Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) diff --git a/client/src/cmdwiegand.c b/client/src/cmdwiegand.c index ff4a1cc93..545b5b151 100644 --- a/client/src/cmdwiegand.c +++ b/client/src/cmdwiegand.c @@ -135,7 +135,7 @@ static int wiegand_encode_new_pacs_from_bin(const uint8_t *binarr, int blen, boo int CmdWiegandList(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "wiegand info", + CLIParserInit(&ctx, "wiegand list", "List available wiegand formats", "wiegand list" ); diff --git a/client/src/wiegand_formats.c b/client/src/wiegand_formats.c index 0791ac876..71658cb3e 100644 --- a/client/src/wiegand_formats.c +++ b/client/src/wiegand_formats.c @@ -384,7 +384,7 @@ static bool Pack_hpp32(int format_idx, wiegand_card_t *card, wiegand_message_t * packed->Length = 32; // Set number of bits set_linear_field(packed, card->FacilityCode, 1, 12); - set_linear_field(packed, card->CardNumber, 13, 29); + set_linear_field(packed, card->CardNumber, 13, 18); if (preamble) return add_HID_header(packed); @@ -398,7 +398,7 @@ static bool Unpack_hpp32(wiegand_message_t *packed, wiegand_card_t *card) { memset(card, 0, sizeof(wiegand_card_t)); card->FacilityCode = get_linear_field(packed, 1, 12); - card->CardNumber = get_linear_field(packed, 13, 29); + card->CardNumber = get_linear_field(packed, 13, 18); return true; } @@ -627,20 +627,20 @@ static bool Pack_H10320(int format_idx, wiegand_card_t *card, wiegand_message_t // This card is BCD-encoded rather than binary. Set the 4-bit groups independently. for (uint32_t idx = 0; idx < 8; idx++) { - set_linear_field(packed, (uint64_t)(card->CardNumber / pow(10, 7 - idx)) % 10, idx * 4, 4); + set_linear_field(packed, (uint64_t)(card->CardNumber / pow(10, 7 - idx)) % 10, 1 + idx * 4, 4); } set_bit_by_position(packed, evenparity32( - get_nonlinear_field(packed, 8, (uint8_t[]) {0, 4, 8, 12, 16, 20, 24, 28}) - ), 32); - set_bit_by_position(packed, oddparity32( get_nonlinear_field(packed, 8, (uint8_t[]) {1, 5, 9, 13, 17, 21, 25, 29}) ), 33); - set_bit_by_position(packed, evenparity32( - get_nonlinear_field(packed, 8, (uint8_t[]) {2, 6, 10, 14, 18, 22, 28, 30}) + set_bit_by_position(packed, oddparity32( + get_nonlinear_field(packed, 8, (uint8_t[]) {2, 6, 10, 14, 18, 22, 26, 30}) ), 34); set_bit_by_position(packed, evenparity32( - get_nonlinear_field(packed, 8, (uint8_t[]) {3, 7, 11, 15, 19, 23, 29, 31}) + get_nonlinear_field(packed, 8, (uint8_t[]) {3, 7, 11, 15, 19, 23, 27, 31}) ), 35); + set_bit_by_position(packed, evenparity32( + get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}) + ), 36); if (preamble) return add_HID_header(packed); return true; @@ -657,7 +657,7 @@ static bool Unpack_H10320(wiegand_message_t *packed, wiegand_card_t *card) { // This card is BCD-encoded rather than binary. Get the 4-bit groups independently. for (uint32_t idx = 0; idx < 8; idx++) { - uint64_t val = get_linear_field(packed, idx * 4, 4); + uint64_t val = get_linear_field(packed, 1 + idx * 4, 4); if (val > 9) { // Violation of BCD; Zero and exit. card->CardNumber = 0; @@ -667,10 +667,10 @@ static bool Unpack_H10320(wiegand_message_t *packed, wiegand_card_t *card) { } } card->ParityValid = - (get_bit_by_position(packed, 32) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {0, 4, 8, 12, 16, 20, 24, 28}))) && - (get_bit_by_position(packed, 33) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {1, 5, 9, 13, 17, 21, 25, 29}))) && - (get_bit_by_position(packed, 34) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {2, 6, 10, 14, 18, 22, 28, 30}))) && - (get_bit_by_position(packed, 35) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {3, 7, 11, 15, 19, 23, 29, 31}))); + (get_bit_by_position(packed, 33) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {1, 5, 9, 13, 17, 21, 25, 29}))) && + (get_bit_by_position(packed, 34) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {2, 6, 10, 14, 18, 22, 26, 30}))) && + (get_bit_by_position(packed, 35) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {3, 7, 11, 15, 19, 23, 27, 31}))) && + (get_bit_by_position(packed, 36) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}))); return true; } @@ -726,7 +726,6 @@ static bool Pack_S12906b(int format_idx, wiegand_card_t *card, wiegand_message_t if (!validate_card_limit(format_idx, card)) return false; if (card->FacilityCode != S12906b_FACILITY_CODE) return false; if (card->IssueLevel != 0u) return false; // This card does not support issue levels - if (!card->ParityValid) return false; // Cannot intentionally guess which parity caller wants to invalidate if (card->OEM != 0u) return false; // Card does not support OEM values packed->Length = 36; // Set number of bits @@ -950,7 +949,7 @@ static bool Unpack_HGeneric37(wiegand_message_t *packed, wiegand_card_t *card) { card->CardNumber = get_linear_field(packed, 4, 32); card->ParityValid = (get_bit_by_position(packed, 0) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {4, 8, 12, 16, 20, 24, 28, 32}))) && - (get_bit_by_position(packed, 2) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 28, 30, 34}))) && + (get_bit_by_position(packed, 2) == oddparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {6, 10, 14, 18, 22, 26, 30, 34}))) && (get_bit_by_position(packed, 3) == evenparity32(get_nonlinear_field(packed, 8, (uint8_t[]) {7, 11, 15, 19, 23, 27, 31, 35}))) ; return true; @@ -1562,16 +1561,16 @@ static const cardformat_t FormatTable[] = { {"ind29", Pack_ind29, Unpack_ind29, "Indala 29-bit", 29, {1, 1, 0, 0, 0, 0x00001FFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"ATSW30", Pack_ATSW30, Unpack_ATSW30, "ATS Wiegand 30-bit", 30, {1, 1, 0, 0, 1, 0x00000FFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"ADT31", Pack_ADT31, Unpack_ADT31, "HID ADT 31-bit", 31, {1, 1, 0, 0, 0, 0x0000000Fu, 0x00000000007FFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au - {"HCP32", Pack_hcp32, Unpack_hcp32, "HID Check Point 32-bit", 32, {1, 0, 0, 0, 0, 0x00000000u, 0x0000000000003FFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au - {"HPP32", Pack_hpp32, Unpack_hpp32, "HID Hewlett-Packard 32-bit", 32, {1, 1, 0, 0, 0, 0x00000FFFu, 0x000000001FFFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"HCP32", Pack_hcp32, Unpack_hcp32, "HID Check Point 32-bit", 32, {1, 0, 0, 0, 0, 0x00000000u, 0x0000000000FFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"HPP32", Pack_hpp32, Unpack_hpp32, "HID Hewlett-Packard 32-bit", 32, {1, 1, 0, 0, 0, 0x00000FFFu, 0x000000000003FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"Kastle", Pack_Kastle, Unpack_Kastle, "Kastle 32-bit", 32, {1, 1, 1, 0, 1, 0x000000FFu, 0x000000000000FFFFu, 0x0000001Fu, 0x00000000u}}, // from @xilni; PR #23 on RfidResearchGroup/proxmark3 {"Kantech", Pack_Kantech, Unpack_Kantech, "Indala/Kantech KFS 32-bit", 32, {1, 1, 0, 0, 0, 0x000000FFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"WIE32", Pack_wie32, Unpack_wie32, "Wiegand 32-bit", 32, {1, 1, 0, 0, 0, 0x00000FFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"D10202", Pack_D10202, Unpack_D10202, "HID D10202 33-bit", 33, {1, 1, 0, 0, 1, 0x0000007Fu, 0x0000000000FFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"H10306", Pack_H10306, Unpack_H10306, "HID H10306 34-bit", 34, {1, 1, 0, 0, 1, 0x0000FFFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // imported from old pack/unpack {"N10002", Pack_N10002, Unpack_N10002, "Honeywell/Northern N10002 34-bit", 34, {1, 1, 0, 0, 1, 0x0000FFFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from proxclone.com - {"Optus34", Pack_Optus, Unpack_Optus, "Indala Optus 34-bit", 34, {1, 1, 0, 0, 0, 0x000003FFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au - {"SMP34", Pack_Smartpass, Unpack_Smartpass, "Cardkey Smartpass 34-bit", 34, {1, 1, 1, 0, 0, 0x000003FFu, 0x000000000000FFFFu, 0x00000007u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"Optus34", Pack_Optus, Unpack_Optus, "Indala Optus 34-bit", 34, {1, 1, 0, 0, 0, 0x000007FFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"SMP34", Pack_Smartpass, Unpack_Smartpass, "Cardkey Smartpass 34-bit", 34, {1, 1, 1, 0, 0, 0x00001FFFu, 0x000000000000FFFFu, 0x00000007u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"BQT34", Pack_bqt34, Unpack_bqt34, "BQT 34-bit", 34, {1, 1, 0, 0, 1, 0x000000FFu, 0x0000000000FFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"C1k35s", Pack_C1k35s, Unpack_C1k35s, "HID Corporate 1000 35-bit std", 35, {1, 1, 0, 0, 1, 0x00000FFFu, 0x00000000000FFFFFu, 0x00000000u, 0x00000000u}}, // imported from old pack/unpack {"C15001", Pack_C15001, Unpack_C15001, "HID KeyScan 36-bit", 36, {1, 1, 0, 1, 1, 0x000000FFu, 0x000000000000FFFFu, 0x00000000u, 0x000003FFu}}, // from Proxmark forums @@ -1582,15 +1581,15 @@ static const cardformat_t FormatTable[] = { {"H10302", Pack_H10302, Unpack_H10302, "HID H10302 37-bit huge ID", 37, {1, 0, 0, 0, 1, 0x00000000u, 0x00000007FFFFFFFFu, 0x00000000u, 0x00000000u}}, // from Proxmark forums {"H10304", Pack_H10304, Unpack_H10304, "HID H10304 37-bit", 37, {1, 1, 0, 0, 1, 0x0000FFFFu, 0x000000000007FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"P10004", Pack_P10004, Unpack_P10004, "HID P10004 37-bit PCSC", 37, {1, 1, 0, 0, 0, 0x00001FFFu, 0x000000000003FFFFu, 0x00000000u, 0x00000000u}}, // from @bthedorff; PR #1559 - {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", 37, {1, 0, 0, 0, 1, 0x00000000u, 0x000000000007FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"HGen37", Pack_HGeneric37, Unpack_HGeneric37, "HID Generic 37-bit", 37, {1, 0, 0, 0, 1, 0x00000000u, 0x00000000FFFFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"MDI37", Pack_MDI37, Unpack_MDI37, "PointGuard MDI 37-bit", 37, {1, 1, 0, 0, 1, 0x0000000Fu, 0x000000001FFFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au - {"BQT38", Pack_bqt38, Unpack_bqt38, "BQT 38-bit", 38, {1, 1, 1, 0, 1, 0x00000FFFu, 0x000000000003FFFFu, 0x00000007u, 0x00000000u}}, // from cardinfo.barkweb.com.au - {"ISCS", Pack_iscs38, Unpack_iscs38, "ISCS 38-bit", 38, {1, 1, 0, 1, 1, 0x000003FFu, 0x0000000000FFFFFFu, 0x00000000u, 0x00000007u}}, // from cardinfo.barkweb.com.au - {"PW39", Pack_pw39, Unpack_pw39, "Pyramid 39-bit wiegand format", 39, {1, 1, 0, 0, 1, 0x0000FFFFu, 0x00000000000FFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"BQT38", Pack_bqt38, Unpack_bqt38, "BQT 38-bit", 38, {1, 1, 1, 0, 1, 0x00001FFFu, 0x000000000007FFFFu, 0x0000000Fu, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"ISCS", Pack_iscs38, Unpack_iscs38, "ISCS 38-bit", 38, {1, 1, 0, 1, 1, 0x000003FFu, 0x00000000003FFFFFu, 0x00000000u, 0x0000000Fu}}, // from cardinfo.barkweb.com.au + {"PW39", Pack_pw39, Unpack_pw39, "Pyramid 39-bit wiegand format", 39, {1, 1, 0, 0, 1, 0x0001FFFFu, 0x00000000000FFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"P10001", Pack_P10001, Unpack_P10001, "HID P10001 Honeywell 40-bit", 40, {1, 1, 0, 0, 0, 0x00000FFFu, 0x000000000000FFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au - {"Casi40", Pack_CasiRusco40, Unpack_CasiRusco40, "Casi-Rusco 40-bit", 40, {1, 0, 0, 0, 0, 0x00000000u, 0x000000FFFFFFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au + {"Casi40", Pack_CasiRusco40, Unpack_CasiRusco40, "Casi-Rusco 40-bit", 40, {1, 0, 0, 0, 0, 0x00000000u, 0x0000003FFFFFFFFFu, 0x00000000u, 0x00000000u}}, // from cardinfo.barkweb.com.au {"Verkada40", Pack_Verkada40, Unpack_Verkada40, "Verkada 40-bit", 40, {1, 1, 0, 0, 1, 0x000003FFu, 0x000000000FFFFFFFu, 0x00000000u, 0x00000000u}}, // Verkada 40-bit format - {"BC40", Pack_bc40, Unpack_bc40, "Bundy TimeClock 40-bit", 40, {1, 1, 0, 1, 1, 0x00000FFFu, 0x00000000000FFFFFu, 0x00000000u, 0x0000007Fu}}, // from + {"BC40", Pack_bc40, Unpack_bc40, "Bundy TimeClock 40-bit", 40, {1, 1, 0, 1, 1, 0x00000FFFu, 0x000000000007FFFFu, 0x00000000u, 0x0000007Fu}}, // from {"Defcon32", Pack_Defcon32, Unpack_Defcon32, "Custom Defcon RFCTF 42-bit", 42, {1, 1, 1, 0, 1, 0x0000FFFFu, 0x00000000000FFFFFu, 0x0000000Fu, 0x00000000u}}, // Created by (@micsen) for the CTF {"H800002", Pack_H800002, Unpack_H800002, "HID H800002 46-bit", 46, {1, 1, 0, 0, 1, 0x00003FFFu, 0x000000003FFFFFFFu, 0x00000000u, 0x00000000u}}, {"C1k48s", Pack_C1k48s, Unpack_C1k48s, "HID Corporate 1000 48-bit std", 48, {1, 1, 0, 0, 1, 0x003FFFFFu, 0x00000000007FFFFFu, 0x00000000u, 0x00000000u}}, // imported from old pack/unpack diff --git a/doc/commands.json b/doc/commands.json index fd2b16458..f497c5fcf 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -16806,12 +16806,12 @@ "options": [ "-h, --help This help" ], - "usage": "wiegand info [-h]" + "usage": "wiegand list [-h]" } }, "metadata": { "commands_extracted": 936, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2026-10-23T22:15:17+00:00" + "extracted_on": "2026-11-06T22:34:07+00:00" } } diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index 675fdd4dd..e4033a677 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -494,6 +494,7 @@ while true; do if ! CheckExecute "nfc decode test signature" "$CLIENTBIN -c 'nfc decode -d 03FF010194113870696C65742E65653A656B616172743A3266195F26063132303832325904202020205F28033233335F2701316E1B5A13333038363439303039303030323636343030355304EBF2CE704103000000AC536967010200803A2448FCA7D354A654A81BD021150D1A152D1DF4D7A55D2B771F12F094EAB6E5E10F2617A2F8DAD4FD38AFF8EA39B71C19BD42618CDA86EE7E144636C8E0E7CFC4096E19C3680E09C78A0CDBC05DA2D698E551D5D709717655E56FE3676880B897D2C70DF5F06ECE07C71435255144F8EE41AF110E7B180DA0E6C22FB8FDEF61800025687474703A2F2F70696C65742E65652F6372742F33303836343930302D303030312E637274FE'" "30864900-0001.crt"; then break; fi if ! CheckExecute "nfc decode test openprinter tag" "$CLIENTBIN -c 'nfc decode -d 03FF012F91013A55046E756D616B6572732E636F6D2F70726F64756374732F6162732D66696C616D656E743F76617269616E743D3436393434323937333836323932521CD26170706C69636174696F6E2F766E642E6F70656E7072696E74746167A10218AFBF041B000007D0FCAB45F9080009020A70414253204C656D6F6E2059656C6C6F770B684E756D616B6572730E1A69094200101903E81119041A1218F01343F9A800181DF93C29182218F01823190104182418AA1825185A18261864FF00'" "application/vnd.openprinttag"; then break; fi + if ! CheckExecute "wiegand list usage" "$CLIENTBIN -c 'wiegand list -h'" "wiegand list \[-h\]"; then break; fi if ! CheckExecute "wiegand encode new" "$CLIENTBIN -c 'wiegand encode -w H10301 --fc 123 --cn 4567 --new'" "New PACS\\.{9} 0x 06BD88EB80"; then break; fi if ! CheckExecute "wiegand encode bin" "$CLIENTBIN -c 'wiegand encode --bin 1'" "Wiegand raw\\.{4} 03"; then break; fi if ! CheckExecute "wiegand encode new bin" "$CLIENTBIN -c 'wiegand encode --bin 1 --new'" "New PACS\\.{9} 0x 0780"; then break; fi @@ -507,6 +508,38 @@ while true; do if ! CheckExecute "wiegand encode new bin 96-bit raw" "PAT=\$(printf '01%.0s' {1..48}); $CLIENTBIN -c \"wiegand encode --bin \$PAT --new --verbose\"" "Wiegand --raw\\.{4} 0x 01555555555555555555555555"; then break; fi if ! CheckExecute "wiegand encode new 48-bit" "$CLIENTBIN -c 'wiegand encode -w C1k48s --fc 42069 --cn 42069 --new'" "New PACS\\.{9} 0x 0000A4550148AB"; then break; fi if ! CheckExecute "wiegand decode raw over 96-bit" "$CLIENTBIN -c 'wiegand decode --raw 01555555555555555555555555' 2>&1" "Raw hex decode supports up to 96 Wiegand bits"; then break; fi + if ! CheckExecute "wiegand encode HCP32 max" "$CLIENTBIN -c 'wiegand encode -w HCP32 --cn 16777215 --new'" "New PACS\\.{9} 0x 007FFFFF80"; then break; fi + if ! CheckExecute "wiegand decode HCP32 max" "$CLIENTBIN -c 'wiegand decode --new 007FFFFF80'" "\[HCP32 +\] HID Check Point 32-bit +CN: 16777215"; then break; fi + if ! CheckExecute "wiegand encode HPP32 max" "$CLIENTBIN -c 'wiegand encode -w HPP32 --fc 4095 --cn 262143 --new'" "New PACS\\.{9} 0x 007FFFFFFE"; then break; fi + if ! CheckExecute "wiegand decode HPP32 max" "$CLIENTBIN -c 'wiegand decode --new 007FFFFFFE'" "\[HPP32 +\] HID Hewlett-Packard 32-bit +FC: 4095 CN: 262143"; then break; fi + if ! CheckExecute "wiegand encode HPP32 over max" "$CLIENTBIN -c 'wiegand encode -w HPP32 --fc 1 --cn 262144' 2>&1" "could not be encoded in the selected format"; then break; fi + if ! CheckExecute "wiegand encode Optus34 max" "$CLIENTBIN -c 'wiegand encode -w Optus34 --fc 2047 --cn 65535 --new'" "New PACS\\.{9} 0x 067FFF83FF80"; then break; fi + if ! CheckExecute "wiegand decode Optus34 max" "$CLIENTBIN -c 'wiegand decode --new 067FFF83FF80'" "\[Optus34 +\] Indala Optus 34-bit +FC: 2047 CN: 65535"; then break; fi + if ! CheckExecute "wiegand encode SMP34 max" "$CLIENTBIN -c 'wiegand encode -w SMP34 --fc 8191 --cn 65535 --issue 7 --new'" "New PACS\\.{9} 0x 067FFFFFFF80"; then break; fi + if ! CheckExecute "wiegand decode SMP34 max" "$CLIENTBIN -c 'wiegand decode --new 067FFFFFFF80'" "\[SMP34 +\] Cardkey Smartpass 34-bit +FC: 8191 CN: 65535 Issue: 7"; then break; fi + if ! CheckExecute "wiegand encode S12906b max" "$CLIENTBIN -c 'wiegand encode -w S12906b --fc 217 --cn 16777215 --new'" "New PACS\\.{9} 0x 046CDFFFFFE0"; then break; fi + if ! CheckExecute "wiegand decode S12906b max" "$CLIENTBIN -c 'wiegand decode --new 046CDFFFFFE0'" "\[S12906b +\] HID Simplex Grinnell 36-bit +FC: 217 CN: 16777215 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode H10320 max" "$CLIENTBIN -c 'wiegand encode -w H10320 --cn 99999999 --new'" "New PACS\\.{9} 0x 03CCCCCCCCA0"; then break; fi + if ! CheckExecute "wiegand decode H10320 max" "$CLIENTBIN -c 'wiegand decode --new 03CCCCCCCCA0'" "\[H10320 +\] HID H10320 37-bit BCD +CN: 99999999 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode H10320 12345678" "$CLIENTBIN -c 'wiegand encode -w H10320 --cn 12345678 --new'" "New PACS\\.{9} 0x 03891A2B3C60"; then break; fi + if ! CheckExecute "wiegand decode H10320 12345678" "$CLIENTBIN -c 'wiegand decode --new 03891A2B3C60'" "\[H10320 +\] HID H10320 37-bit BCD +CN: 12345678 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode HGen37 max" "$CLIENTBIN -c 'wiegand encode -w HGen37 --cn 4294967295 --new'" "New PACS\\.{9} 0x 032FFFFFFFF8"; then break; fi + if ! CheckExecute "wiegand decode HGen37 max" "$CLIENTBIN -c 'wiegand decode --new 032FFFFFFFF8'" "\[HGen37 +\] HID Generic 37-bit +CN: 4294967295 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode HGen37 parity" "$CLIENTBIN -c 'wiegand encode -w HGen37 --cn 512 --new'" "New PACS\\.{9} 0x 030000002008"; then break; fi + if ! CheckExecute "wiegand decode HGen37 parity" "$CLIENTBIN -c 'wiegand decode --new 030000002008'" "\[HGen37 +\] HID Generic 37-bit +CN: 512 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode BQT38 max" "$CLIENTBIN -c 'wiegand encode -w BQT38 --fc 8191 --cn 524287 --issue 15 --new'" "New PACS\\.{9} 0x 027FFFFFFFFC"; then break; fi + if ! CheckExecute "wiegand decode BQT38 max" "$CLIENTBIN -c 'wiegand decode --new 027FFFFFFFFC'" "\[BQT38 +\] BQT 38-bit +FC: 8191 CN: 524287 Issue: 15 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode ISCS max" "$CLIENTBIN -c 'wiegand encode -w ISCS --fc 1023 --cn 4194303 --oem 15 --new'" "New PACS\\.{9} 0x 027FFFFFFFFC"; then break; fi + if ! CheckExecute "wiegand decode ISCS max" "$CLIENTBIN -c 'wiegand decode --new 027FFFFFFFFC'" "\[ISCS +\] ISCS 38-bit +FC: 1023 CN: 4194303 OEM: 15 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode ISCS over max" "$CLIENTBIN -c 'wiegand encode -w ISCS --fc 1 --cn 4194304' 2>&1" "could not be encoded in the selected format"; then break; fi + if ! CheckExecute "wiegand encode PW39 max" "$CLIENTBIN -c 'wiegand encode -w PW39 --fc 131071 --cn 1048575 --new'" "New PACS\\.{9} 0x 017FFFFFFFFC"; then break; fi + if ! CheckExecute "wiegand decode PW39 max" "$CLIENTBIN -c 'wiegand decode --new 017FFFFFFFFC'" "\[PW39 +\] Pyramid 39-bit wiegand format +FC: 131071 CN: 1048575 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode Casi40 max" "$CLIENTBIN -c 'wiegand encode -w Casi40 --cn 274877906943 --new'" "New PACS\\.{9} 0x 007FFFFFFFFE"; then break; fi + if ! CheckExecute "wiegand decode Casi40 max" "$CLIENTBIN -c 'wiegand decode --new 007FFFFFFFFE'" "\[Casi40 +\] Casi-Rusco 40-bit +CN: 274877906943"; then break; fi + if ! CheckExecute "wiegand encode Casi40 over max" "$CLIENTBIN -c 'wiegand encode -w Casi40 --cn 274877906944' 2>&1" "could not be encoded in the selected format"; then break; fi + if ! CheckExecute "wiegand encode BC40 max" "$CLIENTBIN -c 'wiegand encode -w BC40 --fc 4095 --cn 524287 --oem 127 --new'" "New PACS\\.{9} 0x 00FFFFFFFFFC"; then break; fi + if ! CheckExecute "wiegand decode BC40 max" "$CLIENTBIN -c 'wiegand decode --new 00FFFFFFFFFC'" "\[BC40 +\] Bundy TimeClock 40-bit +FC: 4095 CN: 524287 OEM: 127 parity \( ok \)"; then break; fi + if ! CheckExecute "wiegand encode BC40 over max" "$CLIENTBIN -c 'wiegand encode -w BC40 --fc 1 --cn 524288' 2>&1" "could not be encoded in the selected format"; then break; fi if ! CheckExecute "wiegand decode raw" "$CLIENTBIN -c 'wiegand decode --raw 2006F623AE'" "FC: 123 CN: 4567 parity \( ok \)"; then break; fi if ! CheckExecute "wiegand decode bin over 96-bit" "PAT=\$(printf '01%.0s' {1..49}); $CLIENTBIN -c \"wiegand decode --bin \$PAT\" 2>&1" "Binary decode supports up to 96 Wiegand bits"; then break; fi if ! CheckExecute "wiegand decode new" "$CLIENTBIN -c 'wiegand decode --new 06BD88EB80'" "FC: 123 CN: 4567 parity \( ok \)"; then break; fi From 015ee1664ead4fed5248354d3c379831f1cd350c Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 7 Nov 2026 00:14:02 +0100 Subject: [PATCH 13/15] lf paradox: refuse FC above 255 and CN above 65535 clone and sim accepted FC up to 999 and CN up to 99999, but the frame holds 8 bits of FC and 16 of CN, so FC 300 wrote the card of FC 44. The clone hint also named lf paradox read, which does not exist. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmdlfparadox.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..f91efd607 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 `lf paradox clone` and `sim` - FC above 255 and CN above 65535 are refused instead of cut, the clone hint names `lf paradox reader` (@matrix) - Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) - Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) diff --git a/client/src/cmdlfparadox.c b/client/src/cmdlfparadox.c index 71aa19ebe..a37b14bb3 100644 --- a/client/src/cmdlfparadox.c +++ b/client/src/cmdlfparadox.c @@ -333,8 +333,9 @@ static int CmdParadoxClone(const char *Cmd) { return PM3_EINVARG; } - if (fc > 999 || cn > 99999) { - PrintAndLogEx(FAILED, "FC has a max value of 999 and CN has a max value of 99999"); + // the frame carries 8 bits of fc and 16 of cn + if (fc > 0xFF || cn > 0xFFFF) { + PrintAndLogEx(FAILED, "FC has a max value of 255 and CN has a max value of 65535"); return PM3_EINVARG; } @@ -384,7 +385,7 @@ static int CmdParadoxClone(const char *Cmd) { res = clone_t55xx_tag(blocks, ARRAYLEN(blocks)); } PrintAndLogEx(SUCCESS, "Done!"); - PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf paradox read`") " to verify"); + PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf paradox reader`") " to verify"); return res; } @@ -421,8 +422,9 @@ static int CmdParadoxSim(const char *Cmd) { return PM3_EINVARG; } - if (fc > 999 || cn > 99999) { - PrintAndLogEx(FAILED, "FC has a max value of 999 and CN has a max value of 99999"); + // the frame carries 8 bits of fc and 16 of cn + if (fc > 0xFF || cn > 0xFFFF) { + PrintAndLogEx(FAILED, "FC has a max value of 255 and CN has a max value of 65535"); return PM3_EINVARG; } if (raw_len != 0) { From 49e5b502f50b599aed0247f03d9cdce1e57b5850 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 7 Nov 2026 00:25:21 +0100 Subject: [PATCH 14/15] lf keri: refuse values the frame can't carry, print the sim id clone took negative FC and CN, and MS values above 5 and 22 bits, without a word: MS FC 40 wrote the card of FC 8. sim let ids of 32 bits or more change the fixed bits, so --id 2147483648 simulated id 0, and printed the shifted frame as Internal Id. The sim help example used --cn, the option is --id, and the clone hint named lf keri read. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmdlfkeri.c | 32 ++++++++++++++++++++++++++------ doc/commands.json | 4 ++-- tools/pm3_tests.sh | 1 + 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..2eb0d46dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 `lf keri clone` and `sim` - values the frame can't carry are refused instead of cut, `sim` prints the id and its raw, the help example and the clone hint name `--id` and `lf keri reader` (@matrix) - Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) - Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) diff --git a/client/src/cmdlfkeri.c b/client/src/cmdlfkeri.c index 4fc5cac72..996f14c89 100644 --- a/client/src/cmdlfkeri.c +++ b/client/src/cmdlfkeri.c @@ -248,8 +248,8 @@ static int CmdKeriClone(const char *Cmd) { int typeLen = sizeof(keritype) - 1; // CLIGetStrWithReturn does not guarantee string to be null-terminated CLIGetStrWithReturn(ctx, 1, keritype, &typeLen); - uint32_t fc = arg_get_int_def(ctx, 2, 0); - uint32_t cid = arg_get_int_def(ctx, 3, 0); + int fc_arg = arg_get_int_def(ctx, 2, 0); + int cn_arg = arg_get_int_def(ctx, 3, 0); bool q5 = arg_get_lit(ctx, 4); bool em = arg_get_lit(ctx, 5); CLIParserFree(ctx); @@ -259,6 +259,20 @@ static int CmdKeriClone(const char *Cmd) { return PM3_EINVARG; } + if (fc_arg < 0 || cn_arg < 0) { + PrintAndLogEx(FAILED, "FC and CN can't be negative"); + return PM3_EINVARG; + } + + // the MS scramble carries 5 bits of fc and 22 of cn + if (keritype[0] == 'm' && (fc_arg > 31 || cn_arg > 0x3FFFFF)) { + PrintAndLogEx(FAILED, "MS FC has a max value of 31 and CN has a max value of 4194303"); + return PM3_EINVARG; + } + + uint32_t fc = (uint32_t)fc_arg; + uint32_t cid = (uint32_t)cn_arg; + // Setup card data/build internal id uint32_t internalid = 0; switch (keritype[0]) { @@ -310,7 +324,7 @@ static int CmdKeriClone(const char *Cmd) { } PrintAndLogEx(SUCCESS, "Done!"); - PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf keri read`") " to verify"); + PrintAndLogEx(HINT, "Hint: Try " _YELLOW_("`lf keri reader`") " to verify"); return res; } @@ -320,7 +334,7 @@ static int CmdKeriSim(const char *Cmd) { CLIParserInit(&ctx, "lf keri sim", "Enables simulation of KERI card with internal ID.\n" "You supply a KERI card id and it will converted to a KERI internal ID.", - "lf keri sim --cn 112233" + "lf keri sim --id 112233" ); void *argtable[] = { @@ -332,6 +346,14 @@ static int CmdKeriSim(const char *Cmd) { uint64_t internalid = arg_get_u64_def(ctx, 1, 0); CLIParserFree(ctx); + // the frame carries 31 bits of internal id + if (internalid > 0x7FFFFFFF) { + PrintAndLogEx(FAILED, "Internal Id has a max value of 2147483647"); + return PM3_EINVARG; + } + + PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64) ", Raw: E0000000%08" PRIX64, internalid, internalid | 0x80000000); + internalid |= 0x80000000; internalid <<= 3; internalid += 7; @@ -343,8 +365,6 @@ static int CmdKeriSim(const char *Cmd) { bs[j++] = ((internalid >> i) & 1); } - PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id " _YELLOW_("%" PRIu64), internalid); - lf_psksim_t *payload = calloc(1, sizeof(lf_psksim_t) + sizeof(bs)); if (payload == NULL) { PrintAndLogEx(WARNING, "Failed to allocate memory"); diff --git a/doc/commands.json b/doc/commands.json index fd2b16458..e078e175f 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -13773,7 +13773,7 @@ "command": "lf keri sim", "description": "Enables simulation of KERI card with internal ID. You supply a KERI card id and it will converted to a KERI internal ID.", "notes": [ - "lf keri sim --cn 112233" + "lf keri sim --id 112233" ], "offline": false, "options": [ @@ -16812,6 +16812,6 @@ "metadata": { "commands_extracted": 936, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2026-10-23T22:15:17+00:00" + "extracted_on": "2026-11-06T23:18:49+00:00" } } diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index 675fdd4dd..b613bb90b 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -614,6 +614,7 @@ while true; do if ! CheckExecute "lf T55 keri_msid test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri_msid.pm3; lf search -1'" "KERI ID found"; then break; fi if ! CheckExecute "lf T55 keri_msid test 2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_keri_msid.pm3; lf keri demod'" \ "Descrambled MS - FC: 6 Card: 12345"; then break; fi + if ! CheckExecute "lf keri sim help example" "$CLIENTBIN -c 'lf keri sim -h'" "lf keri sim --id 112233"; then break; fi # if ! CheckExecute "lf T55 motorola test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_motorola.pm3; lf search -1'" "Indala ID found"; then break; fi if ! CheckExecute "lf T55 motorola test 2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_motorola.pm3; lf motorola demod'" \ "Motorola - fmt: 26 FC: 258 Card: 2, Raw: A0000000A0002021"; then break; fi From 43223e01925a31887eda04e12b592e179348eae2 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 7 Nov 2026 01:05:20 +0100 Subject: [PATCH 15/15] hf secc sim: code the UID size in the ATQA The sim sent ATQA 02 00 for 4, 7 and 10 byte UIDs, because the ATQA override replaces the size bits the firmware sets. The PN533 of an SCL3711 stopped after cascade level 1 and never found a 7 or 10 byte UID. The ATQA now codes the size of the UID the device simulates, 4 bytes from emulator memory when the UID is all zero, and the start message says when that happens. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmdhfsecc.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..0938a5f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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 `hf secc sim` - the ATQA codes the UID size, so readers that check it select a 7 or 10 byte UID, and a zero UID prints as taken from emulator memory (@matrix) - Fixed flashing with redirected output - the progress animation is drawn only when stdout is a terminal (@matrix) - Fixed `proxmark3 --flash`, `--dumpmem` and `--reboot-to-bootloader` exit status - a failure exits 1, a failed flash no longer ends with `All done` (@matrix) - Fixed `data rawdemod` - `--max`, `--samples` and the `--p2` clock no longer wrap above 255, `--fs` refuses values above 255 (@matrix) diff --git a/client/src/cmdhfsecc.c b/client/src/cmdhfsecc.c index ae1ebda62..195ec6a44 100644 --- a/client/src/cmdhfsecc.c +++ b/client/src/cmdhfsecc.c @@ -475,6 +475,11 @@ static int CmdHFHIDConfigSim(const char *Cmd) { char uid_str[2 * sizeof(uid) + 1]; strncpy(uid_str, sprint_hex_inrow(uid, uidlen), sizeof(uid_str) - 1); uid_str[sizeof(uid_str) - 1] = '\0'; + // an all-zero UID makes the device take a 4-byte UID from emulator memory + bool uid_from_emul = (memcmp(uid, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", sizeof(uid)) == 0); + if (uid_from_emul) { + snprintf(uid_str, sizeof(uid_str), "from emulator memory"); + } PrintAndLogEx(INFO, "HID Config Card sim:" " UID " _YELLOW_("%s") " AID " _YELLOW_("%s") @@ -490,7 +495,8 @@ static int CmdHFHIDConfigSim(const char *Cmd) { payload.tagtype = 4; // ISO14443-4 base type; ATQA/SAK/ATS overridden by ARM payload.flags = flags; payload.exitAfter = exitAfterNReads; - payload.atqa[0] = 0x02; // HID Config Card ATQA high byte + // HID Config Card ATQA high byte, b8 b7 code the UID size (ISO/IEC 14443-3) + payload.atqa[0] = 0x02 | ((uid_from_emul || uidlen == 4) ? 0x00 : ((uidlen == 7) ? 0x40 : 0x80)); payload.atqa[1] = 0x00; // HID Config Card ATQA low byte payload.sak = 0x38; // HID Config Card SAK payload.ats_len = (uint8_t)ats_len;