Commit Graph
14511 Commits
Author SHA1 Message Date
iceman1001andClaude Opus 5.5 00a759b0c7 trace load: keep the current trace when loading a file fails
The trace buffer was cleared before the load, so a missing or empty
file lost the trace already loaded. Loading straight into gs_trace also
left it dangling when loadFile_safe() freed it on a short read, to be
freed again by the next clear or load. Load into a local buffer and
swap it in on success.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:51:04 +07:00
iceman1001andClaude Opus 5.5 2c60f882f8 trace: handle traces larger than 64 KiB
A PM5 BigBuf is several hundred KiB, so its traces outgrow the 16 bit
trace length and record positions. The device already reports the
length as 32 bit in download_done_t.extra, but download_trace_ex() kept
it in a uint16_t and cut it modulo 65536, as `trace load` did for files.

Make the client side trace length and every record position 32 bit, and
drop the 64 KiB refusal from d36d821c5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:48:37 +07:00
iceman1001andClaude Opus 5.5 d36d821c5e trace: refuse traces over 64 KiB instead of truncating their length
The trace buffer length and all record positions are 16 bit. `trace
load` and the spiffs import (ImportTraceBuffer took a uint16_t, its
caller passes a uint32_t) cut a longer length modulo 65536, eg a 70005
byte file loaded as 4469 bytes. Report it and keep the buffer empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:45:47 +07:00
iceman1001andClaude Opus 5.5 58b8330aa1 trace extract: check the DESFire ISO/AES reply length before skipping it
Same order as the native branch. No change in output, the reply is a
tag frame the next pass ignores anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:43:42 +07:00
iceman1001andClaude Opus 5.5 587fd0b4ef trace extract: tell iCLASS SELECT and CHECK from other reader frames
They were matched on the low nibble of the first byte only. A 14a CL2
SELECT, 95 70 UID BCC CRC, is 9 bytes like a CHECK and was printed as
its MACs, and a MIFARE AUTH B, 61 .., was taken as a SELECT and ate the
frame after it.

A SELECT now needs CSN[8] and a reply with a valid iCLASS CRC, which is
only skipped when it matched. A CHECK carries no CRC, so a frame with a
valid CRC_A is not one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:42:04 +07:00
iceman1001andClaude Opus 5.5 e5ee5098c8 trace extract: reset the UID and epurse at the start of each run
They are static and were never cleared, so an iCLASS CHECK in a trace
without a SELECT gave an `hf iclass lookup` line with the CSN and epurse
of a trace extracted earlier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:39:56 +07:00
iceman1001andClaude Opus 5.5 bbb438df71 trace list/extract: stop when the trace download fails
Both ignored the result of download_trace(). After a timeout they went
on with whatever the client side trace buffer held, ie an older trace,
under a fresh "Recorded activity" line. Offline they printed the failed
upload error and then listed the buffer anyway.

Download only when a device is present and return its error, offline
uses the trace buffer like `trace save` does. The "removing parameter
-1" hint is only given when -1 was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:37:33 +07:00
iceman1001andClaude Opus 5.5 42bb5a0387 trace extract: only look for DESFire auth in ISO14443-4 I-blocks
Any reader frame with the top two bits clear was searched for an auth
command at its first two INF bytes. A MIFARE Ultralight READBLOCK(10),
30 0A CRC, was reported as a native DESFire auth with the CRC byte as
key number and page data as challenge (traces/hf_14a_mfuc.trace), and
so was a native SelectApplication of an AID starting with 0A.

Require an I-block PCB, take the command after CLA 90 only when the
frame is wrapped, and the key number before the CRC. long_jmp now
follows the framing instead of guessing it from the frame length.
The switch loses one indent level, see git diff -w.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:35:37 +07:00
iceman1001andClaude Opus 5.5 1f8e21dda7 trace extract: tell 2TDEA from 3TDEA by the challenge length
The ISO auth branch took a tag reply longer than 20 bytes as 3TDEA. A
native 3TDEA reply is 20 bytes, so it was shown as 2TDEA with half the
challenge. Use what is left after the framing, SW and CRC instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:30:13 +07:00
iceman1001andClaude Opus 5.5 26bd949bcd hf gp: fix macOS link error, unaligned pointer in packed sAPDU_t
The OP card manager SELECT built its sAPDU_t from a static AID, so
clang emitted a constant template with an absolute pointer at offset 5
of the PACKED struct. Apple ld rejects it:
  ld: pointer not aligned in 'l___const.gp_info.op'+0x5 (cmdhfgp.o)
Keep the AID on the stack, like the other sAPDU_t users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:30:01 +07:00
iceman1001andClaude Opus 5.5 c9d5bdd7ea trace extract: find the DESFire auth challenge after PCB, CID and NAD
The tag challenge of the DES, ISO and AES auth branches was read from
frame + 1. In native framing that is the AF status byte, and with a CID
it is the CID byte, so the challenge came out shifted by one, eg
traces/hf_mfdes_sniff.trace gave 000675359294E7CD instead of
0675359294E7CDA1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:28:34 +07:00
iceman1001andClaude Opus 5.5 f885a22d59 trace extract: print the full AES auth challenges
The MFDES AES auth branch printed 8 of the 16 RndB bytes and 16 of the
32 reader bytes, and accepted a 9 byte tag reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:23:25 +07:00
iceman1001andClaude Opus 5.5 1f543f3ced em4x50: reply deadline for read / info retries
The retry check estimated the next attempt from the longest one so far.
That does not bound it:
- get_pulse_length() waits up to 4 bit periods
- one find_double_listen_window() can take about 3.2 s with no signal
- a login + read attempt can take over 6 s
- setup before tstart was not counted

A slow attempt after fast failures could end after the client gave up,
leaving the late reply queued for the next command.

read and info now set a deadline after setup, 1 s before the client
timeout. The listen window, ACK and word decode loops stop at the
deadline, as do the retries. With no deadline set (write, brute, sim,
...) they behave as before. The client waits 5 s for read, as it
already did for info / dump.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:19:44 +07:00
iceman1001 6cdccfb2df fix -fPIC issues 2026-11-09 14:02:52 +07:00
iceman1001andClaude Opus 5.5 340819e430 reveng: build with clang and _FORTIFY_SOURCE
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>
2026-11-09 14:01:51 +07:00
iceman1001 648cbf159c make style 2026-11-09 12:32:20 +07:00
iceman1001 e3ec14f437 hf gp aids: use the GP RID as --prefix example 2026-11-09 11:56:28 +07:00
iceman1001andClaude Opus 5.5 e05c479ad6 hf gp: label the default applet, fail when every SELECT is accepted
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>
2026-11-09 11:48:04 +07:00
iceman1001andClaude Opus 5.5 ff59b0bd33 trace list: fix 14a-4 APDU decode bounds and false positives
- 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>
2026-11-09 11:48:04 +07:00
iceman1001andClaude Opus 5.5 62f9fa8414 em4x50: only retry a read if it can still end in time
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>
2026-11-09 11:44:12 +07:00
Christian HerrmannandClaude Opus 5.5 4004a454de hf gp: add GlobalPlatform info, crs and aids commands
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>
2026-11-09 11:11:09 +07:00
Christian HerrmannandClaude Opus 5.5 f6ca733601 trace list: annotate ISO14443-4 APDUs and highlight SW1 SW2
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>
2026-11-09 10:35:22 +07:00
Iceman 74aded1d28 Merge pull request #3727 from kormax/aidlist-more-mobile-aid-values
Add more mobile AID values to 'aidlist.json'
2026-11-09 11:09:12 +08:00
Iceman 58ce7278e4 Merge branch 'master' into cotag_sim_passive
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-09 10:47:45 +08:00
Gabriele GristinaandClaude Opus 5.5 5fb4d6b250 lf noralsy: refuse CN above 9999999 and years outside 1961-2060
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>
2026-11-08 17:47:43 +01:00
towelbyte 93631d06d7 lf cotag sim: COTAG simulation improvements
- 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).
2026-11-08 13:10:45 +01:00
Iceman 699e528db9 Merge branch 'master' into fix-trace-list
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-08 15:39:37 +08:00
Iceman 43890115f5 Merge branch 'master' into fix-indala-fc-cn
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-08 11:16:43 +08:00
Iceman d6eb6bb1d0 Merge branch 'master' into fix-hitag-commands
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-08 11:14:04 +08:00
Gabriele GristinaandClaude Opus 5.5 a70f0adec8 lf noralsy demod: stop losing reads to one demod error, accept BB0314FF
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>
2026-11-08 03:55:51 +01:00
Gabriele GristinaandClaude Opus 5.5 96ad2981bd lf hitag: refuse bad pages and data, fix eview, Paxton and LCK1 output
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>
2026-11-08 02:08:02 +01:00
Iceman 46a5a7209f Merge branch 'master' into fix-destron-sim
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-08 08:22:37 +08:00
Gabriele GristinaandClaude Mythos 5.1 c6dc5ef1bb trace list/extract: frame bounds, CRC checks and annotation fixes
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>
2026-11-08 01:18:04 +01:00
Iceman 6f3c6759d9 Merge branch 'master' into fix-fdxb-iso
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-08 08:02:48 +08:00
Iceman 15811614a6 Merge branch 'master' into fix-destron-sim
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-08 07:58:25 +08:00
tpglitch b15152662c fix: payload for in Lua script 2026-11-07 17:03:01 -06:00
Gabriele Gristina eea78faeeb Merge remote-tracking branch 'origin/master' into fix-indala-fc-cn
# Conflicts:
#	CHANGELOG.md
2026-11-07 22:18:56 +01:00
Gabriele GristinaandClaude Opus 5.5 745c78d29e lf fdxb: ISO 11784 fields, Bio-Thermo clone/sim, sim and reader fixes
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>
2026-11-07 22:07:54 +01:00
Gabriele GristinaandClaude Opus 5.5 5bc67a0d1c lf destron: implement sim, refuse uids the frame can't carry
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>
2026-11-07 20:01:51 +01:00
Iceman 22e9e59b27 Merge branch 'master' into fix-thinfilm-sim-restart
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-07 16:52:28 +08:00
Ryan MassfellerandClaude Opus 4.5 0839f3b708 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 <noreply@anthropic.com>
2026-11-07 02:48:57 -05:00
Ryan4n6andClaude Opus 4.5 579bafa161 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012e7xUDfDUXJQU7SWV3ULS1
2026-11-07 02:48:57 -05:00
Iceman 4b5eadd32b Merge branch 'master' into feat/supercard-gen2-uid-write
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-07 09:46:11 +08:00
Gabriele Gristina f5372c4d9f Merge branch 'master' of https://github.com/RfidResearchGroup/proxmark3 into fix-indala-fc-cn 2026-11-07 02:45:35 +01:00
Gabriele Gristina 6a365952c0 Merge branch 'master' of https://github.com/RfidResearchGroup/proxmark3 into fix-indala-fc-cn 2026-11-07 02:42:12 +01:00
Iceman 0bb60083d8 Merge branch 'master' into fix-wiegand-formats
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-07 09:41:56 +08:00
Gabriele GristinaandClaude Opus 5.5 6c1545cb5f lf indala: --fc/--cn checksum fitted to twelve genuine cards
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>
2026-11-07 02:39:31 +01:00
Iceman 724e0b438c Merge branch 'master' into fix-secc-atqa
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-07 09:39:03 +08:00
Iceman fc3a14f8f5 Merge branch 'master' into fix-keri-limits
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-07 09:36:27 +08:00
Iceman 19fbb76ded Merge branch 'master' into fix-paradox-limits
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-07 09:33:48 +08:00