From c2f83fc314e6a69fdf71a07ce97405b8e48e358d Mon Sep 17 00:00:00 2001 From: Mykhailo Shevchuk Date: Thu, 5 Nov 2026 16:05:13 +0200 Subject: [PATCH 1/5] hf mf supercard - UID write on super card generation 2 The gen2 branch refused `-u` with "Not supported on this card". These cards do take a UID write: a five command knock, the new UID one byte per command (always seven commands, zero padded), then a HLTA which commits it. The card answers the halt instead of staying silent, and without it everything before is discarded when the field drops - which is why the sequence is absent from the vendor app, whose HLTA is emitted by the Android NFC stack on teardown. The new UID must match the card's current UID length, the parts are physically 4b or 7b. Outcome is decided by re-selecting and comparing the UID, not by the status byte. Verified on a 4 byte card. The 7 byte path is inferred from the sequence always carrying seven UID bytes and is untested. A refused -r / -u now returns an error instead of PM3_SUCCESS. Co-Authored-By: Claude Opus 5 --- CHANGELOG.md | 2 + client/src/cmdhfmf.c | 202 +++++++++++++++++++++++++++++++++++++-- doc/commands.json | 4 +- doc/magic_cards_notes.md | 36 +++++++ 4 files changed, 235 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1d1f1b6..078a2c3d9 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] +- Added `hf mf supercard -u` - UID change on super card generation 2 (@mishamyte) +- Changed `hf mf supercard` - a refused `-r`/`-u` now exits non-zero instead of reporting success (@mishamyte) - 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/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 0638d888c..2a9cf55cd 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -8105,6 +8105,177 @@ static int mfc_supercard_gen2_recovery(uint8_t items, uint8_t tracedata[FURUI_MA return PM3_SUCCESS; } +// super card generation 2, UID write +#define SUPER_GEN2_UID_LEN 7 // UID bytes sent, zero padded +#define SUPER_GEN2_ACK 0x11 // command accepted +#define SUPER_GEN2_COMMITTED 0x22 // halt answer + +// select a super card. Clears the trace when the field is kept, so a later `hf 14a list` holds only the write +static int mfc_supercard_select(bool keep_field_on, iso14a_card_select_t *card) { + + uint32_t flags = ISO14A_CONNECT | ISO14A_NO_RATS; + if (keep_field_on) { + flags |= ISO14A_NO_DISCONNECT | ISO14A_CLEARTRACE; + } + + clearCommandBuffer(); + SendIso14aReader(flags, NULL, 0); + + PacketResponseNG resp; + uint16_t len = 0; + uint8_t sel = 0; + if (WaitForIso14aReply(&resp, 1500, &len, &sel) == false) { + return PM3_ETIMEOUT; + } + + if (sel == 0) { + return PM3_ECARDEXCHANGE; + } + + if (len < sizeof(iso14a_card_select_t)) { + PrintAndLogEx(FAILED, "Short select answer, %u bytes. Client and firmware out of sync?", len); + return PM3_ELENGTH; + } + + memcpy(card, resp.data.asBytes, sizeof(iso14a_card_select_t)); + + if (card->uidlen == 0) { + return PM3_ECARDEXCHANGE; + } + return PM3_SUCCESS; +} + +// one frame of the gen2 UID write. PM3_ECARDEXCHANGE when the card stayed silent, +// PM3_EWRONGANSWER when it answered and refused +static int mfc_supercard_gen2_frame(uint8_t cmd, uint8_t arg, uint8_t status) { + + uint8_t data[2] = {cmd, arg}; + uint32_t flags = ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT; + + clearCommandBuffer(); + SendIso14aReader(flags, data, sizeof(data)); + + PacketResponseNG resp; + uint16_t len = 0; + if (WaitForIso14aReply(&resp, 1500, &len, NULL) == false) { + return PM3_ETIMEOUT; + } + + PrintAndLogEx(DEBUG, "%02X %02X >>> %s", cmd, arg, sprint_hex_inrow(resp.data.asBytes, len)); + + // the device reports a silent card as a zero length answer, not as a timeout + if (len == 0) { + return PM3_ECARDEXCHANGE; + } + + // 18 byte answer on the wire, 16 byte payload plus CRC. Only the payload is required + if (len < 16) { + PrintAndLogEx(FAILED, "Short answer... %s", sprint_hex_inrow(resp.data.asBytes, len)); + return PM3_ELENGTH; + } + + if (resp.data.asBytes[0] != status || resp.data.asBytes[1] != arg) { + PrintAndLogEx(FAILED, "Card answered... %s, expected status %02X arg %02X", + sprint_hex_inrow(resp.data.asBytes, len), status, arg); + return PM3_EWRONGANSWER; + } + return PM3_SUCCESS; +} + +// change UID on a super card generation 2. Knock, UID one byte per command, +// then HLTA, which commits - without it the card discards the write on field drop +static int mfc_supercard_gen2_set_uid(const uint8_t *uid, uint8_t uidlen) { + + static const uint8_t knock[] = {0xF3, 0x2A, 0xBD, 0xEF, 0x01}; + + iso14a_card_select_t old_card = {0}; + + int res = mfc_supercard_select(true, &old_card); + if (res != PM3_SUCCESS) { + if (res == PM3_ETIMEOUT) { + PrintAndLogEx(FAILED, "Device did not answer the select command"); + } else { + PrintAndLogEx(FAILED, "Failed to select card, is it on the antenna?"); + } + DropField(); + return res; + } + + // these parts are physically 4 or 7 byte, the length is not changeable + if (old_card.uidlen != uidlen) { + PrintAndLogEx(FAILED, "Card UID is " _YELLOW_("%u") " bytes, new UID is " _YELLOW_("%u") " bytes", old_card.uidlen, uidlen); + DropField(); + return PM3_EINVARG; + } + + for (uint8_t i = 0; i < ARRAYLEN(knock); i++) { + res = mfc_supercard_gen2_frame(0x30, knock[i], SUPER_GEN2_ACK); + if (res != PM3_SUCCESS) { + if (res == PM3_ECARDEXCHANGE) { + PrintAndLogEx(FAILED, "Card stopped answering at knock command " _YELLOW_("%u") " of %zu", i + 1, ARRAYLEN(knock)); + } else { + PrintAndLogEx(FAILED, "Card rejected knock command " _YELLOW_("%u") " of %zu", i + 1, ARRAYLEN(knock)); + PrintAndLogEx(HINT, "Hint: Are you sure your card is a super card generation 2?"); + } + DropField(); + return res; + } + } + + uint8_t new_uid[SUPER_GEN2_UID_LEN] = {0}; + memcpy(new_uid, uid, uidlen); + + for (uint8_t i = 0; i < SUPER_GEN2_UID_LEN; i++) { + res = mfc_supercard_gen2_frame(0x30, new_uid[i], SUPER_GEN2_ACK); + if (res != PM3_SUCCESS) { + if (res == PM3_ECARDEXCHANGE) { + PrintAndLogEx(FAILED, "Card stopped answering at UID byte " _YELLOW_("%u") " of %u, the write is incomplete", i + 1, SUPER_GEN2_UID_LEN); + PrintAndLogEx(HINT, "Hint: hold the card still on the antenna and run the command again"); + } else { + PrintAndLogEx(FAILED, "Card rejected UID byte " _YELLOW_("%u") " of %u", i + 1, SUPER_GEN2_UID_LEN); + } + DropField(); + return res; + } + } + + // not fatal, the UID read back below decides the outcome + int res_halt = mfc_supercard_gen2_frame(0x50, 0x00, SUPER_GEN2_COMMITTED); + if (res_halt != PM3_SUCCESS) { + PrintAndLogEx(WARNING, "Card did not acknowledge the commit (%d), verifying anyway", res_halt); + } + + DropField(); + + iso14a_card_select_t new_card = {0}; + res = PM3_ETIMEOUT; + + // card is writing, it ignores the first activation attempts + for (uint8_t i = 0; i < 4 && res != PM3_SUCCESS; i++) { + msleep(150); + res = mfc_supercard_select(false, &new_card); + PrintAndLogEx(DEBUG, "verify activation %u... %d", i + 1, res); + } + + if (res != PM3_SUCCESS) { + PrintAndLogEx(FAILED, "Card did not answer after the commit, can't verify the new UID"); + PrintAndLogEx(WARNING, "The write may still have succeeded, the card ignores activation while writing"); + PrintAndLogEx(HINT, "Hint: keep the card on the antenna and run `hf 14a info`"); + return PM3_EPARTIAL; + } + + if (new_card.uidlen != uidlen || memcmp(new_card.uid, uid, uidlen) != 0) { + PrintAndLogEx(FAILED, "Super card UID change [ " _RED_("fail") " ]"); + PrintAndLogEx(INFO, "Card UID... %s", sprint_hex(new_card.uid, new_card.uidlen)); + return PM3_ESOFT; + } + + PrintAndLogEx(SUCCESS, "Old UID... %s", sprint_hex(old_card.uid, old_card.uidlen)); + PrintAndLogEx(SUCCESS, "New UID... %s", sprint_hex(new_card.uid, new_card.uidlen)); + PrintAndLogEx(SUCCESS, "Super card UID change ( " _GREEN_("ok") " )"); + return PM3_SUCCESS; +} + static int CmdHf14AMfSuperCard(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf mf supercard", @@ -8116,13 +8287,13 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { void *argtable[] = { arg_param_begin, arg_lit0("r", "reset", "Reset card"), - arg_str0("u", "uid", "", "New UID (4 hex bytes)"), + arg_str0("u", "uid", "", "New UID (4 hex bytes, or 7 on generation 2)"), arg_lit0(NULL, "furui", "Furui detection card"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); bool reset_card = arg_get_lit(ctx, 1); - uint8_t uid[4]; + uint8_t uid[7] = {0}; int uidlen = 0; int res = CLIParamHexToBuf(arg_get_str(ctx, 2), uid, sizeof(uid), &uidlen); bool is_furui = arg_get_lit(ctx, 3); @@ -8130,8 +8301,13 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { CLIParserFree(ctx); // sanity checks - if (res || (!res && uidlen && uidlen != sizeof(uid))) { - PrintAndLogEx(ERR, "UID must include 4 hex bytes"); + if (res) { + PrintAndLogEx(ERR, "UID must be 4 or 7 hex bytes"); + return PM3_EINVARG; + } + + if (uidlen && uidlen != 4 && uidlen != 7) { + PrintAndLogEx(ERR, "UID must be 4 or 7 hex bytes. Got %d", uidlen); return PM3_EINVARG; } @@ -8143,7 +8319,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { // no reset on super card FURUI if (uidlen || reset_card) { PrintAndLogEx(FAILED, "Not supported on this card"); - return PM3_SUCCESS; + return PM3_ENOTIMPL; } // read 8 traces @@ -8211,9 +8387,14 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { if (i == SUPER_MAX_TRACES) { // no reset on super card generation 2. - if (uidlen || reset_card) { + if (reset_card) { PrintAndLogEx(FAILED, "Not supported on this card"); - return PM3_SUCCESS; + return PM3_ENOTIMPL; + } + + // change UID on a super card generation 2 + if (uidlen) { + return mfc_supercard_gen2_set_uid(uid, uidlen); } // recover key from collected traces @@ -8231,6 +8412,13 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { // change UID on a super card generation 1 if (uidlen) { + + // generation 1 is 4 byte UID only + if (uidlen != 4) { + PrintAndLogEx(FAILED, "Super card generation 1 UID must be 4 hex bytes"); + return PM3_EINVARG; + } + keep_field_on = false; uint8_t response[6]; int resplen = 0; diff --git a/doc/commands.json b/doc/commands.json index fd2b16458..4d6374d0d 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -7102,7 +7102,7 @@ "options": [ "-h, --help This help", "-r, --reset Reset card", - "-u, --uid New UID (4 hex bytes)", + "-u, --uid New UID (4 hex bytes, or 7 on generation 2)", "--furui Furui detection card" ], "usage": "hf mf supercard [-hr] [-u ] [--furui]" @@ -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-05T11:51:27+00:00" } } diff --git a/doc/magic_cards_notes.md b/doc/magic_cards_notes.md index 76dbe9e55..de9039cb9 100644 --- a/doc/magic_cards_notes.md +++ b/doc/magic_cards_notes.md @@ -1698,6 +1698,39 @@ CF CE <1b block number> // Backdoor read 16b block CF FE <4b new_password> // Change password ``` +UID write without the Gen4 backdoor, all frames raw ISO14443-A with CRC, in one field session +after a normal anticollision + select: + +``` +30 F3 // knock, 5 commands +30 2A +30 BD +30 EF +30 01 +30 // new UID, one byte per command +30 // always 7 commands, zero padded for a 4b UID +... +50 00 // HLTA, commits the write +``` + +Every command is answered with 16 bytes plus CRC: status byte, the echoed argument, the CRC of +the command frame the reader sent, then 12 bytes constant for the session. Status is `11` while +accepting commands and `22` on the halt. + +``` +Rdr |30 5D 62 21| +Tag |11 5D 62 21 6000720F 8CB1A65B E3553815|+crc +Rdr |50 00 57 CD| +Tag |22 00 57 CD 6000720F 8CB1A65B E3553815|+crc +``` + +The halt is the commit. A compliant tag stays silent on HLTA, this one answers, and without it +the card discards everything above when the field drops. Afterwards the card is busy writing: +the next WUPA gets no answer and the one after that returns the new UID, so allow ~150ms and +more than one activation attempt. + +The UID length can't be changed, the parts are physically 4b or 7b. + ### MIFARE Classic Super Furui ^[Top](#top) @@ -1764,6 +1797,9 @@ hf mf info [usb] pm3 --> hf mf supercard --furui ... + +[usb] pm3 --> hf mf supercard -u 11223344 +... ``` # MIFARE Ultralight From 59ec032d03c580fdf409e7696d2e7e6a211abb92 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 6 Nov 2026 22:43:09 +0100 Subject: [PATCH 2/5] hf thinfilm sim: let a second simulation wait for its own end Enter leaves a simulation running on the device, by design. The next hf thinfilm sim stopped it, took the PM3_EOPABORTED reply left behind for its own and printed "Done!" at once. A ping round trip before starting drops that reply. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + client/src/cmdhfthinfilm.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bedd944..178e7e5c0 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 thinfilm sim` - a second simulation in the same client no longer ends at once with `Done!` (@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/cmdhfthinfilm.c b/client/src/cmdhfthinfilm.c index 54e4699a2..141b1d67e 100644 --- a/client/src/cmdhfthinfilm.c +++ b/client/src/cmdhfthinfilm.c @@ -179,9 +179,17 @@ int CmdHfThinFilmSim(const char *Cmd) { data[data_len++] = b1; } + // end a simulation still running from an earlier call and drop its reply + PacketResponseNG resp; + clearCommandBuffer(); + SendCommandNG(CMD_PING, NULL, 0); + if (WaitForResponseTimeout(CMD_PING, &resp, 3000) == false) { + PrintAndLogEx(WARNING, "command execution time out"); + return PM3_ETIMEOUT; + } + clearCommandBuffer(); SendCommandNG(CMD_HF_THINFILM_SIMULATE, (uint8_t *)&data, data_len); - PacketResponseNG resp; PrintAndLogEx(SUCCESS, "press " _GREEN_("pm3 button") " to abort simulation"); int ret; From 579bafa1619abd01dfd2528a7dc0b87ded86a25b Mon Sep 17 00:00:00 2001 From: Ryan4n6 <131580830+Ryan4n6@users.noreply.github.com> Date: Tue, 3 Nov 2026 03:04:17 -0500 Subject: [PATCH 3/5] feat(hf mfu): add weak-PRNG backstop for Ultralight C fingerprint The existing mfulc_fingerprint() detects known counterfeit families (Lab401 DW, Feiju FJ8010, USCUID-UL v1/v2, Giantec GT23SC4489, Hospitality) by their deterministic command and CRC tells, returning early on a match. This commit adds a generic weak-PRNG catch-all for clones that evade those fixed profiles. mfulc_prng_test() runs on the genuine-looking fallthrough, right before the "likely MF0ICU2" verdict. It collects RndB nonces via repeated 1A00 auth starts and flags a duplicate: - Genuine NXP draws RndB from a hardware TRNG (2^64 space), so it never repeats across a realistic batch. - Giantec/USCUID use a 16-bit LFSR whose wakeup-timing seed concentrates the observed pool to roughly 2^6.5, so a duplicate appears within 12 authentications. A single collision is proof of a weak PRNG. This backstop catches weak-RNG clones, including future variants the profile table does not know. MFULC_PRNG_SAMPLES (40) and MFULC_PRNG_CLEAR (39) are tunable. Tested on genuine NXP MF0ULC (UID 04 1C BE 92 E7 7A 80): 40 unique nonces, no collision, verdict "consistent with a genuine TRNG". Ref: "BREAKMEIFYOUCAN!", eprint.iacr.org/2026/100, Section 11. Co-Authored-By: Claude Opus 4.5 Claude-Session: https://claude.ai/code/session_012e7xUDfDUXJQU7SWV3ULS1 --- client/src/cmdhfmfu.c | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 9255a3a21..9fe55a0ff 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2028,6 +2028,79 @@ int mfu_get_version_uid(uint8_t *version, uint8_t *uid) { return PM3_SUCCESS; } +// Statistical PRNG check (generic weak-RNG backstop). +// Genuine NXP ULC draws RndB from a hardware TRNG (2^64 space), so it never +// repeats across a realistic batch. The common counterfeits (Giantec +// GT23SC4489, USCUID-UL) use a 16-bit LFSR whose wakeup-timing seed +// concentrates the observed RndB pool to ~2^6.5, so a duplicate appears within +// ~12 authentications. A single collision is therefore proof of a weak PRNG. +// This runs only on the genuine-looking fallthrough below (the known +// counterfeit profiles return earlier), so it is the catch-all for weak-RNG +// clones that match none of those profiles, including future variants. +// Ref: "BREAKMEIFYOUCAN!", eprint.iacr.org/2026/100, Section 11. +#define MFULC_PRNG_SAMPLES 40 +#define MFULC_PRNG_CLEAR 39 // no collision by here => an LFSR pool would have, >99.99% + +static int mfulc_prng_test(uint32_t samples) { + if (samples < 2) { + samples = 2; + } + if (samples > 64) { + samples = 64; + } + + uint8_t rndb[64][8]; + uint32_t got = 0; + + for (uint32_t i = 0; i < samples; i++) { + iso14a_card_select_t card; + if (ul_select(&card) == false) { + continue; + } + uint8_t nonce[11] = {0x00}; + int rl = ulc_requestAuthentication(nonce, sizeof(nonce)); + DropField(); + // response is AF || ek(RndB)[8] || CRC[2]; compare the 8-byte ek(RndB) + if (rl < 9 || nonce[0] != 0xAF) { + continue; + } + memcpy(rndb[got], &nonce[1], 8); + got++; + } + + if (got < 2) { + PrintAndLogEx(INFO, "PRNG......... could not collect nonces (got %u)", got); + return PM3_ESOFT; + } + + uint32_t first_dup = 0; + uint32_t dups = 0; + for (uint32_t i = 0; i < got; i++) { + for (uint32_t j = 0; j < i; j++) { + if (memcmp(rndb[i], rndb[j], 8) == 0) { + if (first_dup == 0) { + first_dup = i + 1; // 1-based draw index + } + dups++; + break; + } + } + } + + if (dups > 0) { + PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("weak") ": repeated RndB (%u dup in %u, first at draw %u)", dups, got, first_dup); + PrintAndLogEx(INFO, " genuine NXP uses a TRNG and never repeats: counterfeit (LFSR) tell"); + return PM3_SUCCESS; + } + + if (got >= MFULC_PRNG_CLEAR) { + PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces, consistent with a genuine TRNG", got); + } else { + PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces (need >= %u for high confidence)", got, (uint32_t)MFULC_PRNG_CLEAR); + } + return PM3_SUCCESS; +} + static int mfulc_fingerprint(void) { iso14a_card_select_t card; PacketResponseNG resp; @@ -2139,6 +2212,9 @@ static int mfulc_fingerprint(void) { } } } + // No known counterfeit profile matched; run the generic weak-PRNG + // backstop before concluding the card is genuine. + mfulc_prng_test(MFULC_PRNG_SAMPLES); PrintAndLogEx(INFO, "likely MF0ICU2"); DropField(); return PM3_SUCCESS; From 0839f3b7083d5639226e50c554ad3f07a29b378d Mon Sep 17 00:00:00 2001 From: Ryan Massfeller Date: Sat, 7 Nov 2026 02:35:38 -0500 Subject: [PATCH 4/5] fix(mfulc): trim verbose comments per review - Remove wall-of-text comment block (moved to PR description) - Simplify output: "Genuine" vs "Weak" per Iceman's feedback - Remove explanatory INFO line Co-Authored-By: Claude Opus 4.5 --- client/src/cmdhfmfu.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 9fe55a0ff..35c885384 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2028,18 +2028,9 @@ int mfu_get_version_uid(uint8_t *version, uint8_t *uid) { return PM3_SUCCESS; } -// Statistical PRNG check (generic weak-RNG backstop). -// Genuine NXP ULC draws RndB from a hardware TRNG (2^64 space), so it never -// repeats across a realistic batch. The common counterfeits (Giantec -// GT23SC4489, USCUID-UL) use a 16-bit LFSR whose wakeup-timing seed -// concentrates the observed RndB pool to ~2^6.5, so a duplicate appears within -// ~12 authentications. A single collision is therefore proof of a weak PRNG. -// This runs only on the genuine-looking fallthrough below (the known -// counterfeit profiles return earlier), so it is the catch-all for weak-RNG -// clones that match none of those profiles, including future variants. -// Ref: "BREAKMEIFYOUCAN!", eprint.iacr.org/2026/100, Section 11. +// Weak-PRNG backstop: RndB collision => counterfeit LFSR #define MFULC_PRNG_SAMPLES 40 -#define MFULC_PRNG_CLEAR 39 // no collision by here => an LFSR pool would have, >99.99% +#define MFULC_PRNG_CLEAR 39 static int mfulc_prng_test(uint32_t samples) { if (samples < 2) { @@ -2088,15 +2079,14 @@ static int mfulc_prng_test(uint32_t samples) { } if (dups > 0) { - PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("weak") ": repeated RndB (%u dup in %u, first at draw %u)", dups, got, first_dup); - PrintAndLogEx(INFO, " genuine NXP uses a TRNG and never repeats: counterfeit (LFSR) tell"); + PrintAndLogEx(SUCCESS, "PRNG......... " _RED_("Weak") " (RndB collision at %u)", first_dup); return PM3_SUCCESS; } if (got >= MFULC_PRNG_CLEAR) { - PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces, consistent with a genuine TRNG", got); + PrintAndLogEx(SUCCESS, "PRNG......... " _GREEN_("Genuine")); } else { - PrintAndLogEx(INFO, "PRNG......... no RndB collision in %u nonces (need >= %u for high confidence)", got, (uint32_t)MFULC_PRNG_CLEAR); + PrintAndLogEx(INFO, "PRNG......... inconclusive (%u/%u nonces)", got, (uint32_t)MFULC_PRNG_CLEAR); } return PM3_SUCCESS; } @@ -2212,8 +2202,7 @@ static int mfulc_fingerprint(void) { } } } - // No known counterfeit profile matched; run the generic weak-PRNG - // backstop before concluding the card is genuine. + // weak-PRNG backstop mfulc_prng_test(MFULC_PRNG_SAMPLES); PrintAndLogEx(INFO, "likely MF0ICU2"); DropField(); From 9616c8e45c1c28b84c1d2cf750cfdd6c28183a7a Mon Sep 17 00:00:00 2001 From: Ryan Massfeller Date: Sat, 7 Nov 2026 02:44:43 -0500 Subject: [PATCH 5/5] docs: add CHANGELOG entry for ULC PRNG backstop Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e51139e63..6a7ad6bbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - 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 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) +- Added `hf mfu info` weak-PRNG backstop - detects counterfeit ULC via RndB collision (@Ryan4n6) - 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)