Makefile.defs hardening sets -D_FORTIFY_SOURCE=3. Under clang, glibc's
stdio2.h then defines fprintf as a macro, so the stdout hook in
deps/reveng/config.h redefined it and -Werror stopped the build in
bmpbit.c, cli.c, model.c, poly.c, preset.c and src/cmdcrc.c. Undefine
fprintf, fputs and puts before hooking them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hf gp info also tries the OpenPlatform card manager AID
A000000003000000 before falling back to the default applet. That
fallback now warns and is titled "Default applet" instead of
"Security Domain".
hf gp aids returns PM3_ESOFT when the card accepts any SELECT, instead
of PM3_SUCCESS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- SW1 SW2 colouring wrote past line[] / sw_escapes[] for responses over
648 bytes. It is now limited to the rows actually printed (324 bytes),
like the CRC marker.
- The session opens on the ATS, not on RATS, so an ATS whose TL byte
looks like an I-block PCB is no longer decoded as an APDU response.
If no ATS was captured, the next reader frame opens the session.
- A command is decoded as an APDU only if Lc / Le matches the INF
length (ISO 7816-4 cases 1-4, short and extended). A response is
decoded only when it answers such a command. This keeps native
DESFire and similar I-blocks from being labelled as APDUs or coloured
as status words.
- `trace list -t 7816` and `-t fmcos` reset the 14a-4 session state
at the start, like the other 14a listings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Next attempt must fit in 2.5 s, judged by the longest attempt so far.
Client waits 5 s for info/dump.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New `hf gp` command family. Every subcommand works without keys and
never sends INITIALIZE UPDATE / EXTERNAL AUTHENTICATE, so no card
retry counter is used. All take -w for the contact interface, -a to
log APDUs and -v for verbose output.
hf gp info
Selects the ISD, or the default applet when A000000151000000 is
absent, and reads:
- Card Recognition Data, decoding the GP version, SCP and Java Card
version from their OIDs
- CPLC, with the fabricator name and BCD dates decoded
- the Key Information Template (KVN, key id, type, length, with
SCP02 / SCP03 key sets marked)
- IIN, CIN and the SCP sequence counter
GET DATA retries with CLA 00 on cards that reject CLA 80.
hf gp crs
GET STATUS on the Contactless Registry Service (GPC_SPE_025 3.11),
following 6310 to fetch more data. Lists each applet's AID,
lifecycle, contactless activation state, display data, URL, group
and CREL members. --aid filters on a full or partial AID.
hf gp aids
Finds applet AIDs by partial SELECT (P2=00, first occurrence):
- finds the shortest prefix the card accepts
- tries aidlist.json prefixes and every registered RID A0 00 00 0x xx
(--quick skips the RID sweep)
- extends each hit one byte at a time to the full AID
- --prefix limits the search to one subtree
Cards whose default applet accepts any SELECT are detected and
refused. The walk is capped at 200000 APDUs and can be stopped with
<Enter>. Without partial selection it falls back to the full
aidlist.json AIDs.
aidlist.json gains the GP ISD, CRS and ARA-M AIDs, plus USIM, ISIM,
CSIM, UnionPay, and ICCOA so found AIDs get named. The CCC digital key entry gets a description.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inside an ISO14443-4 session, now decodes I-blocks
as APDUs instead of passing them to the plain 14a annotator.
- A session opens on RATS and closes on WUPA, REQA, HLTA, S(DESELECT)
or a new trace. Only I-blocks with a valid CRC_A are decoded.
- Commands are named by INS (SELECT FILE, GET CHALLENGE, ...), or shown
as 'APDU CLA xx INS yy'. The first block of a chain is marked
'(chained)'. Continuation blocks are skipped.
- CID and NAD bytes are skipped. CLA FF and INS 6x / 9x are rejected
as not being APDUs.
- Responses show the status word text only for errors. 9000 and 61xx
stay quiet.
- The reader's S(DESELECT) is labelled.
- With colours on, SW1 SW2 of a response APDU are shown in cyan.
annotateIso14443aLastHasSW() tells cmdtrace when the last frame had a
status word.
The ISO7816 INS name switch moves into iso7816_ins_name(), shared by
annotateIso14443a() and annotateIso7816(). The output of
does not change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clone and sim encoded only 7 BCD digits of the CN and the last two
digits of the year, which the demod maps to 1961-2060, so
--cn 12345678 wrote card 2345678 and --year 1950 the year 2050.
Both values were also cut to 32 and 16 bits first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Implemented passive mode for COTAG sim:
- load modulation with an fc/2 subcarrier locked to the reader carrier.
- This mode is now a default as it has several advantages:
- phase coherent response,
- can detect reader field drop mid frame "transmission" and restart
immediately -- important with some readers that may drop field
early and send reactivation shortly afterwards expecting the
tag to respond there as well.
- "active tx mode" is now via CLI toggle --active: it may give better range,
but may not work with all readers.
- Improved COTAG activation sequence detection for a wider range of COTAG
readers that may vary slightly in activation sequence timings (thresholds
for the rise-to-rise mode).
ASKDemod_ext() was called with maxErr 0. The error is most often the
cut first bit of the read, outside every frame. cmdlfgallagher.c passes
100 in the same call since dfb7eaf06, and a frame still has to pass
both checksums.
A 0xBB0314FF first block, which getnoralsyBits() notes as seen, no
longer gets the unknown bits warning. The example in the comment is
such a card, its hex column said BB0214FF.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page check covers the Hitag 2, S and µ `wrbl`, the data check S and
µ. `htu rdbl -c` stops at the 55 blocks the reply holds, `hts -m` above
3 is refused, `ta -h` shows its help and argument errors free the
parser.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Annotators, `trace extract`, `-x` and `-c` stay inside the frame, the
trace and the row buffer, `-t ht2` inside the Hitag 2 state, and frame
lengths are 16 bit wide. Topaz, FeliCa and five byte ISO14443-A frames
get the right CRC check, Topaz and iCLASS traces tell their ISO14443-A
and ISO15693 frames apart, and the SEOS, 14b, DESFire and Hitag µ
labels are corrected. Six make check expectations on the repository
traces cover the fixes.
Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
demod splits the starting digit from the reserved bits, writes the
animal code as CCC NNNNNNNNNNNN, knows all 249 ISO 3166-1 countries
and shows Bio-Thermo only for the chips' exact trailer. clone and sim
refuse values the frame can't carry, sim sends the data block flag for
--extended 000000 and stops with Enter, reader also tries 125 kHz.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lf destron sim only printed "To be implemented". It now sends the
frame that lf destron clone writes, FSK2 RF/50 as in the clone's T5577
config. Both take 5 bytes of 00-7F: clone wrote a byte above 7F
without its top bit and padded a short uid with FF of bad parity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012e7xUDfDUXJQU7SWV3ULS1
The sum of y2, y4, y7, y8, y10, y11, y14 and y16 comes from a 2014
forum post that says "I believe", and with fc bit 6 added it still
missed one of the seven genuine Indala cards now on record (FC 20 CN
9045). The same post gives Keri 26-bit W as the same calculation with
"11" and "00", and five such cards are on record. Adding fc bits x1,
x2, x3, x5, x6 and x7 fits all twelve. With these card number bits and
"01" for an even sum, no other fc set does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three more genuine cards came to light in the repository traces. The
checksum over the card number bits alone matched three of the five,
with fc bit 6 in the sum it matches all five.
Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
PR #2453 computed the parity bits over stream positions and PR #2947
inverted the checksum, so --fc/--cn clones did not match the genuine
cards on record, from issue #2939 and the DangerousThings forum. Both
carry the 26-bit Wiegand parity of getIndalaBits4041x and the checksum
from before #2947, and the encoder now reproduces them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>