100 Commits
Author SHA1 Message Date
Iceman 1bd629931a Merge pull request #3774 from innocentbystanderproxmark/minor-PM5-documentation-updates
Getting Started Guide updates
2026-11-10 13:30:25 +08:00
Iceman 589856f2e6 Merge branch 'master' into minor-PM5-documentation-updates
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-10 13:30:09 +08:00
iceman1001 3a3842ed61 style 2026-11-10 12:22:55 +07:00
iceman1001andClaude Opus 5.5 dc96e3babe hw bwm name: help says 1-15 chars, matching the enforced limit
Client and firmware both cap the name at BWM_BLE_NAME_MAX_LEN (15); the
help said 1-31. Also fix the define's comment: the ESP buffer is 32, the
real bound is the BLE advertisement (17 chars).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:17:06 +07:00
iceman1001andClaude Opus 5.5 ecf0e7b3f5 hw bwm wifi: report why the join failed instead of "joined but no IP"
The bring-up always printed "joined but no IP after DHCP wait" when no
address came, even when the ESP said the join itself failed (e.g. result=1
err=201: network not found). Print by join result, with a readable name
for the common WiFi reason codes. Initialise the result buffer so a short
reply can't print garbage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:17:06 +07:00
iceman1001andClaude Opus 5.5 509579d854 hf mfu pwdgen: read the tag by default, --uid offline, --mfg for Philips
Without options the UID and the Philips MFG string are now read from the
tag, `-r` is gone. `--uid` is the offline path, and the new `--mfg` gives
the Philips toothbrush algo its MFG string offline, which used to need
the tag on the antenna. Help shows a working Philips sample taken from
the generator self test vector, also run by pm3_tests.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:15:52 +07:00
iceman1001andClaude Opus 5.5 1eae2e2d34 hf mf view: clear the RKF TCAS padding before comparing instances
rkf_tcas_t has a padding byte before mac (offset 31). rkf_read_tcas()
set every field but left that byte, and both the TCAS instance check
in hf mf view and its selftest compare the two instances with memcmp.
The result depended on stack contents: the Makefile client passed, the
CMake client failed "tcas instances equal". Since 6fbe96e18 the CI
greps the aggregate Transit selftest line, so every cmake test job
(ubuntu, macos, wsl, proxspace) failed.

Zero the whole struct in rkf_read_tcas().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:06:53 +07:00
Iceman 3203a2018d Merge pull request #3773 from innocentbystanderproxmark/add-references-to-proxmark-guis
Adding a links to a bunch of proxmark (3/5) GUIs
2026-11-10 12:57:37 +08:00
iceman1001andClaude Opus 5.5 645f04f545 hw bwm upgrade: print the upload progress in place
The upload used its own printf "\rProgress: [n%]" line, without the
client prefix, spinner or emoji. Print it with PrintAndLogEx(INPLACE),
in the same format as the spiffs upload, and drop the unused helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:29:52 +07:00
iceman1001andClaude Opus 5.5 f5e3af6472 hw fpga config: print the transfer progress in place
The progress line was printed once per chunk, about 55 lines for a PM5
bitstream. Print it in place and end the line once the transfer is done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:26:18 +07:00
iceman1001andClaude Opus 5.5 63d3f09726 hf mf info: two stage transit identification
Probing every identifying key of every transit sector, A and B, took up to
12 key check calls / 44 authentications, most of the time being the 50 ms
field power up per call.

Stage 1 now checks one signature per parser, key A only, one call per
sector (sectors 0, 4, 7, 8). Signatures are A or A/B keys, so key A holds
one of them on a real card. Only when a signature matches does stage 2
check that parser's remaining keys. Sector 0 is skipped when info already
found its key A.

Foreign card: 3-4 calls instead of 8-12, roughly 0.3 s instead of 0.7-1.2 s.
The probe lives in parsetransit.c behind a key check callback, the self
tests drive it with a dump and pin the call counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:23:50 +07:00
iceman1001andClaude Opus 5.5 f777b91a09 PM5: ship the FPGA image built from the repo sources
client/resources/PM5_FPGA_fix_loedge_bug.bin was a Gowin IDE build
posted in #3449 on 2026-08-15, before the FPGA sources were opened in
#3697. Its lo_edge_detect fix (adc_clk = pck0) has been in the sources
since 7666e8444, so the shipped binary only lagged behind them and
could not be checked against anything in the tree.

Add `make -C fpga fpga_pm5_release`, which builds fpga_pm5.bin and
copies it with its sha512 to client/resources. It stays out of `all`
so a local test build does not replace the shipped image by accident.
Point update_fpga.cmd and update_fpga_and_bwm.cmd at fpga_pm5.bin and
document the build in Getting_Started_With_PM5.md.

The image was built with oss-cad-suite 2026-10-11, the release pinned
in fpga-pm5.yml. A clean rebuild gives the same bytes, IDCODE is
0x1100381B, and all clocks meet timing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:18:13 +07:00
iceman1001andClaude Opus 5.5 0357f68358 transit identification: changelog entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:06:06 +07:00
iceman1001andClaude Opus 5.5 3342ce5034 hf 14a info: possible T-Mobilitat from the ATS
The T-Mobilitat historical bytes tag is all info has without reading the
application list, so the line says "Possible" and hints `hf mfdes info`,
which confirms it by AID and prints the card number. No card exchange
added; `hf search` gets it through the same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:59 +07:00
iceman1001andClaude Opus 5.5 3e988eb1c3 hf calypso info: print the transit identifier line
Same "Transit.......... <name> ( <region> )" line as the other info
commands, from the ticketing environment before the records are read.
No hint, info already runs the full decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:59 +07:00
iceman1001andClaude Opus 5.5 a0f7229467 hf 14b info: identify Intertic tickets
Only on 512 bit SRx / ST25TB tags, where Intertic tickets live. The
whole tag is 16 blocks plus the system block, so info reads all 17 and
runs the ST25TB transit parsers on them, the same data `hf 14b dump`
decodes. Detection is a layout check, so the line says "Possible".
4K tags are left alone. Hints `hf 14b dump`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:59 +07:00
iceman1001andClaude Opus 5.5 5aa74846d0 hf felica info: identify transit cards
Names Japan IC (system 0003), Octopus (8008) and Shenzhen Tong (8005)
from the system codes info already discovers, no extra card exchange.
Hints `hf felica dump`, which reads the public services and decodes
balance and history. `hf felica reader` only polls for the IDm and is
left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:59 +07:00
iceman1001andClaude Opus 5.5 856d6e5223 hf mfu info: identify transit tickets
The fingerprint read now covers at least pages 0..15, two more page
reads inside the same READCARD exchange and no extra round trip. That is
all the Troika Ultralight, TRT and Ventra parsers use, so a match is
decoded in full right there. Their detection is a layout check, so the
line says "Possible". Hints `hf mfu dump`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:59 +07:00
iceman1001andClaude Opus 5.5 b109a22023 hf mf info: transit fingerprint
Identifies MIFARE Classic transit cards by their sector keys and MAD
block 1. Keys info already found for sectors 0 and 1 are reused. Every
other sector a parser identifies by (0, 1, 4, 5, 7, 8 today) gets one
`mf_check_keys` exchange per key type carrying only that sector's
candidate keys, and no key B check once key A is known. Worst case is
12 exchanges and about 45 authentications, typically fewer. Block 1 is
read with the sector 0 key info found, for Nextfare and Zolotaya Korona.
Prints "Transit.........." in the Fingerprint section and hints
`hf mf autopwn`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:59 +07:00
iceman1001andClaude Opus 5.5 6c6ccb0998 hf mfdes info: identify transit cards
Names the card system from the AID list info already reads (Clipper,
ITSO, myki, nol, Opal, T-Mobilitat with its ATS), then reads the free
files the matching parser decodes card number and balance from and runs
the parser on that partial image, like the HRT parser already does here.
Adds one select plus a settings and a read exchange per summary file,
only on an identified card. Hints `hf mfdes dump --no-auth` for the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:48 +07:00
iceman1001andClaude Opus 5.5 a0a3d52d52 transit parsers: identify API for info commands
Each card system can now be named from the partial data an info command
already has: sector keys and MAD block 1 for MIFARE Classic, the
application list and ATS for DESFire, system codes for FeliCa, and the
same data a dump has for Ultralight, ST25TB and Calypso.

Dispatch rows gain a display name, region, decode hint and identify
entry. Detection is shared, not duplicated: the MFC key checks become
key sets matched against either a dump or the keys an info probe found,
the DESFire checks run over an application list built from the dump.
transit_mfdes_summary_files() lists the free files a parser decodes card
number and balance from. Every identify path has a positive and a
negative selftest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:05:47 +07:00
iceman1001andClaude Opus 5.5 4c4a719686 PM5: skip the RSSI ADC re-init when the channel is unchanged
EmGetCmdTimeout() calls AdcSetupRssiChannel() before every listen. On
AT32 that resets the ADC, waits for ready, runs both calibration phases
and a blocking 640.5 cycle vref conversion, all before Uart14aInit and
before the SSC is read. The single byte SPI4 buffer overruns meanwhile,
so a reader frame sent close to the minimum FDT loses its start. Hardware
paced frames like the MIFARE auth nR/aR hit this; host paced activation
frames do not. The Miller decoder then syncs mid frame and logs short
fragments with parity errors.

Keep the full setup for the first call or a channel change. Otherwise
clear a stale conversion flag and restart the conversion. A dropped ADC
(RDY clear) still takes the full path. RDV4 is unaffected.

Reported in #3768.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:56:37 +07:00
iceman1001andClaude Opus 5.5 b077bf263d HID SAM: Seader style downgrades, hf mf sam, hf mfdes sam, wiegand downgrade
Bring the SAM commands to parity with Seader's (bettse/seader, GPLv3)
read and save options:

- hf mf sam: MIFARE Classic SE via CMD_HF_SAM_MFC
- hf mfdes sam: DESFire EV1/EV2 via CMD_HF_SAM_SEOS, as Seader drives it
- --dg legacy|sr|prox|mfc and --save on hf iclass / seos / mf / mfdes sam
- wiegand downgrade: the same outputs offline, from a saved credential
  or PACS bits, plus --selftest

Outputs follow seader_credential.c:
- legacy / sr: 20 block iCLASS dump, Seader's config, epurse, Kd from the
  HID standard key, block 6 03030303 0003E014 (A3 for SR, PACS left
  unencrypted), PACS in block 7, SR SIO in blocks 10-17. A CSN read from
  iCLASS is kept, anything else gets Seader's fake CSN 7AF53113FEFF12E0.
- mfc: 1K dump with Seader's block 0, MAD, HID sector 1 keys and PACS in
  block 5, the layout hf mf encodehid writes.
- prox: lf hid clone --bin, and -w H10301 for 26 bits as Seader does.
- --save: a "hid credential" JSON with PACS, bits, UID, SIO, media type.

The PACS parsing hf iclass sam and hf seos sam each had a copy of moves
to hidsio.c; hf seos sam is now the shared ISO14443-A command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:23:51 +07:00
iceman1001andClaude Opus 5.5 fb193860e8 wiegand: share the sentinel right-aligned PACS packing
HID stores PACS bits behind a sentinel bit, right aligned, both in iCLASS
block 7 and in MIFARE Classic block 5. Move hf mf encodehid's packing
into wiegand_pack_sentinel_bytes() so the SAM downgrades reuse it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:23:39 +07:00
iceman1001andClaude Opus 5.5 0fdbdbdadd HID SAM: read MIFARE Classic SE through CMD_HF_SAM_MFC
sam_mfc.c was empty and CMD_HF_SAM_MFC was a no-op. Implement the relay
the way Seader's plugin_hf_mfc_transmit does it. The SAM runs Crypto1
itself and tags each nfcSend with a format:

- 00 C0 00: plain bytes, CRC already included, parity generated
- 00 00 40 / 24 / 44: air order bit stream carrying the SAM's own parity

Answers to the latter go back in the same bit form, len + len / 8 + 1
bytes like Seader. Unlike Seader, every byte gets its real parity bit;
Seader leaves bytes 8 and on at zero. A silent card is reported to the
SAM as rfStatus 00 20, an unknown format as 00 04, Seader's codes, and
the conversation continues.

Card detected follows Seader for MIFARE Classic: protocol, CSN and SAK,
no ATQA. The card is selected without RATS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:23:39 +07:00
iceman1001andClaude Opus 5.5 d2e077ded9 HID SAM: return CSN / UID and the plaintext SIO with the PACS
Seader keeps the SIO it sees on the air while the SAM reads a card, which
is what lets it write an iCLASS SR downgrade. Do the same:

- iCLASS: READ / READ4 answers from block 6 on are kept; the SIO is the
  lowest captured block holding a SEQUENCE whose DER length is covered by
  contiguous captured blocks (so a legacy block 7 that happens to start
  with 0x30 is not taken for it).
- DESFire: the ReadData of file 0x0F Seader keys on, plus 91 AF
  continuations (Seader only keeps the first frame).

A new request flag (bit 7 for CMD_HF_SAM_PICOPASS, bit 2 for
CMD_HF_SAM_SEOS) asks for a sam_ext_reply_hdr_t ahead of the SAM
response. It is only sent for a plain PACS request, so -d, --info and
--break replies are unchanged. The capture lives in .bss and the reply
is built in BigBuf to keep the RDV4 stack untouched.

Also from Seader: a DESFire EV2 answers the Seos select with a 6F 22 85 20
FCI. Hide it from the SAM as 6A 82 and add Le to the DESFire select.

sam_set_card_detected_seos() moves to sam_common.c as
sam_set_card_detected_iso14a() so the MIFARE Classic path can share it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:23:39 +07:00
iceman1001andClaude Opus 5.5 6100a46f12 commonutil: pack / unpack ISO14443-A air order bits with parity
A HID SAM driving MIFARE Classic hands over Crypto1 frames as one bit
stream: each byte's 8 data bits LSB first followed by its parity bit.
These convert between that stream and the bytes plus parity array the
PM3 reader and trace code use. Shared so the client can self test them.

Cross checked against a port of Seader's plugin_hf_mfc_transmit for
frames up to 8 bytes (its limit) and for 4 and 18 byte answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:23:39 +07:00
iceman1001andClaude Opus 5.5 8d2a419319 transit parsers: changelog entry, align command table entries
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:17:26 +07:00
iceman1001andClaude Opus 5.5 6fbe96e181 pm3_tests: run the transit parser self tests
One check per technology, each greps the aggregate Transit selftest line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:05:13 +07:00
iceman1001andClaude Opus 5.5 070972f47e transit parsers: Calypso card systems
Run from hf calypso info. parsecalypso.c is a table driven EN 1545 walker
(fixed fields, presence bitmaps, repeated containers) after Metrodroid's
En1545Parser, shared by the network parsers:

  Navigo (Paris, 250901)          Metrodroid transit/intercode
  Intercode, other 250xxx         Metrodroid transit/intercode
  Opus (Montreal, 124001)         Metrodroid transit/opus
  Rav-Kav (Israel, 376xxx)        Metrodroid transit/ravkav

hf calypso info additionally hands over the ICC record, so Intercode and
Opus print the card number as issued, reads the second contracts file
(SFI 06) after a full first one, and reads the per contract counters at
SFI 0A..0D, where Rav-Kav keeps its stored value.

Holder data is deliberately not decoded. Self tests are synthetic,
neither Metrodroid nor Metroflip ships real record hex for these.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:05:13 +07:00
iceman1001andClaude Opus 5.5 8b2f4f9cf6 transit parsers: FeliCa and ST25TB card systems
FeliCa parsers run from hf felica dump over the services it read without
authentication:

  Japan IC (Suica, PASMO, ICOCA, ...)  Metrodroid transit/suica
                                       issuer named from its service codes
  Octopus, Shenzhen Tong               Metrodroid transit/octopus

The dump adapter now keeps locked services in the list, without blocks,
since the Japan IC issuer naming depends on them.

ST25TB parser, run from hf 14b view / dump on SRT512:

  Intertic (French networks)           pyscripts/intertic.py, Metroflip

Self tests: Metrodroid SuicaTest service sets and OctopusTest balances,
synthetic history blocks and Intertic tickets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:05:13 +07:00
iceman1001andClaude Opus 5.5 b2335fcc90 transit parsers: DESFire and Ultralight card systems
DESFire parsers run from hf mfdes view / dump and are detected by AID.
They decode the free-read files; `hf mfdes dump --no-auth` is what reads
those, and a parser says so when a file it needs is missing. Locked
balance/trip files (myki, nol, T-Mobilitat) need operator keys and are
only named.

  Clipper (SF Bay)      Metrodroid, Flipper clipper.c
  Opal (Sydney)         Metrodroid
  myki (Melbourne)      Metrodroid, card number only
  ITSO (UK)             Flipper itso.c
  nol (Dubai)           Metrodroid, Metroflip
  T-Mobilitat           Metroflip, number from ATS historical bytes

Ultralight parsers run from hf mfu view / dump:

  TRT                   Flipper trt.c
  Ventra (Chicago)      Flipper ventra.c, Metrodroid Nextfare UL

Self tests: Metrodroid ClipperTest, MykiTest, OpalTest plus the real
opal-transit-litter dump matched against Metrodroid's parsed output;
synthetic for the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:05:13 +07:00
iceman1001andClaude Opus 5.5 4fcd3c274e transit parsers: MIFARE Classic card systems
Run from hf mf view / dump / autopwn on the full dump. Detection is by
sector keys plus a data signature, as Metrodroid and Flipper do it, so
a dump needs the real keys in its trailers.

  Bip! (Santiago)            Metrodroid ChileBip, Flipper bip.c
  CharlieCard (Boston)       Metrodroid, Flipper charliecard.c
  Kazan                      Metrodroid, Flipper kazan.c
  Metromoney (Tbilisi)       Metrodroid, Flipper metromoney.c
  Nextfare: Go card (Brisbane), TAP (LA), Go-To (Minneapolis)
                             Metrodroid Nextfare/SeqGo/LaxTap/MspGoto
  Podorozhnik / Plantain     Metrodroid, Flipper plantain.c
  RENFE Suma 10              Metroflip renfe_sum10.c, partial
  SmartRider (Perth), MyWay  Metrodroid
  Troika, MFC and Ultralight Metrodroid, Flipper troika.c
  Umarsh                     Metrodroid, Flipper umarsh.c
  Zolotaya Korona            Metrodroid

Two Cities cards match both Troika and Podorozhnik, each printing its own
half. Self tests use the Metrodroid vectors where they exist (Troika UL
asset, Nextfare, a SmartRider timestamp) and synthetic dumps otherwise.
parsetransitmfc.h holds the shared sector/key accessors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:05:13 +07:00
iceman1001andClaude Opus 5.5 ea599c4a71 transit parsers: shared helpers and per technology dispatch
Adds parsers/parsetransit.{c,h}: MSB/LSB bit readers and writers, date,
datetime and money formatting, one print style for every card system,
and a dispatcher per technology that runs each registered parser whose
detection matches. The tables start empty, card systems follow.

Hook points, each run on data the command already has:
  hf mf view / hf mf dump / hf mf autopwn   -> transit_mfc_parse
  hf mfdes view / hf mfdes dump             -> transit_mfdes_parse
  hf mfu view / hf mfu dump                 -> transit_mfu_parse
  hf 14b view / dump (SRx)                  -> transit_st25tb_parse
  hf felica dump                            -> transit_felica_parse
  hf calypso info                           -> transit_calypso_parse

hf calypso info now also reads the contract list, counters, contracts
and events by SFI for the Calypso parsers. Self tests hang off the same
commands via --selftest; hf mfu view gains that flag, hf felica dump and
hf calypso info gain it and become always available so it runs offline,
with an explicit device check for the real path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:05:13 +07:00
iceman1001andClaude Opus 5.5 a9a5b1ac51 hf 15 implant: read NTAG 5 link + TMP112/TMP117/TMP119 temperature implants
New client command for VivoKey Thermo / Temptress style implants. The
NTAG 5 link (NTP5332) is used as I2C master: energy harvesting is enabled
through the EH_CONFIG_REG session register (AN12365), the TI sensor is
driven with WRITE I2C / READ I2C / READ SRAM and the I2C master status
register is polled for completion and NAKs. Sensors at 0x48-0x4B are
probed and identified by the TMP117/TMP119 device id register, a one-shot
conversion is triggered and the result printed in C and F.

Pure client side, uses CMD_HF_ISO15693_COMMAND with the field kept on.
Offline self test for the conversions is hooked into pm3_tests.sh, and
hf 15 info hints at the command for NTAG 5 tags.

Not tested on hardware, no implant available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:59:50 +07:00
iceman1001andClaude Opus 5.5 8b9b152dbf hf goodisplay: write images to Goodisplay NFC e-paper tags
New `hf goodisplay load` for the NFC-D1 tags GDEY0154D67, GDEY0213B74,
GDEY029T94 and GDEY037T03. They use a Fudan FM1280 talking ISO14443-4
with proprietary CLA F0 APDUs (config F0 DB/DA, image F0 D2 in 250 byte
chained blocks, refresh F0 D4), unlike the raw 14a CD xx frames of
Waveshare tags, hence a separate command family. Protocol and init
sequence from the Flipper Zero NFC Eink app (GPLv3, RebornedBrain).

Image load/crop/dither, save and 1bpp packing move from cmdhfwaveshare.c
into imgutils.c so both commands share them. Waveshare output is
unchanged.

hf 14a info hints at hf waveshare for its known UIDs (now incl. FSTN11m)
and at hf goodisplay for a SAK 28 ATS 0B 78 33 A0 02 90 <UID> 00 tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:57:02 +07:00
iceman1001andClaude Opus 5.5 8186415226 hf waveshare load: fix 2.7" height and partial last byte packing
The 2.7" panel is 176x264: the send loop pushes 48 x 121 = 5808 bytes,
so with 276 rows the bottom 12 rows of the image were silently dropped.

map8to1() stored a partial last byte before the final shift, leaving its
pixels right-aligned. On the 122 px wide 2.13" the last two columns were
drawn at off-panel columns 126/127. MSB-align the partial byte instead.
Byte-aligned widths are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 09:48:01 +07:00
iceman1001andClaude Opus 5.5 199cd05327 hw bwm upgrade: say "outdated" instead of "fail" for a differing BWM firmware
A mismatch is the normal case before an upgrade, not an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 08:55:41 +07:00
iceman1001andClaude Opus 5.5 39145ce3e7 PCF7931: bound the capture length instead of filling the whole BigBuf
DemodPCF7931 called DoAcquisition with sample_size 0 and no trigger, so
every capture filled all of BigBuf and only the button could stop it:
~1s on RDV4 (~32 KB), ~13s on PM5 (~405 KB). The decoder then stored
every whole block into an 8-entry stack array and copied them into
ReadPCF7931's 4-entry buffer, both unbounded - a PM5 capture holds ~190.

Capture 4.5 blocks (~0.3s on every platform), decode only the samples
taken and stop storing at the 4 blocks the caller has room for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 08:35:27 +07:00
iceman1001andClaude Opus 5.5 065a4c5eb8 hw bwm upgrade: tag the current BWM firmware ( ok / fail / n/a ) against the image
Compares the version the ESP reports with the image's app descriptor
version (esp_app_desc_t at 0x20). The ESP may report only the git hash,
so "<hash>" matches "V1-12-g<hash>". Prints "unknown ( n/a )" when the
module doesn't answer, instead of no line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 08:18:34 +07:00
iceman1001 4682bc16e2 update AGENTS.md instructions for doc/command.* files 2026-11-10 07:47:51 +07:00
iceman1001andClaude Opus 5.5 1f6b617372 ui.h: say why PrintAndLogEx is checked as gnu_printf on mingw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 07:36:35 +07:00
iceman1001andClaude Opus 5.5 4f7a1fe28b trace extract: only skip the ULC/iCLASS READCHECK reply when it is one
MFU-C AUTH and iCLASS READCHECK skipped the next record before checking
it was the tag's reply. With an unanswered command, the reader's next
frame was swallowed: a retried 1A 00 lost the whole MFU-C auth, and a
CHECK right after READCHECK was taken as the epurse, hiding the lookup.
Now the record is only consumed when it is a tag frame of the expected
shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 07:35:47 +07:00
iceman1001andClaude Opus 5.5 3515724f9a bootrom: give phase2 .data its own RW segment instead of an RWX one
.data shared the bootphase2 output section with the RAM-executed code, so
the PM5 bootrom linked with "LOAD segment with RWX permissions" (CMake
silenced it with --no-warn-rwx-segments). Put .data in .bootphase2_data
with its own PT_LOAD, placed right after .bootphase2 in RAM and flash so
the existing copy loop still covers it; asserts guard the contiguity.

Same image size on RDV4/PM5/PM5+BWM; code identical bar .ramfunc moving
ahead of .data, data bytes unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 07:35:47 +07:00
iceman1001andClaude Opus 5.5 5e8d208264 bootrom: don't include Standalone/Makefile.hal twice
common_arm/Makefile.hal already includes it, so a direct "make -C bootrom"
appended the standalone define twice and stopped with "You must choose only
one Standalone mode!: LF_SAMYRUN LF_SAMYRUN". Matches armsrc/Makefile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 07:35:47 +07:00
Iceman 4091326524 Merge pull request #3772 from tpglitch/fix/mingw-comp
fix(build): use GNU printf checker on MinGW
2026-11-10 08:35:36 +08:00
Iceman 12e708adb6 Merge pull request #3771 from tpglitch/fix/makefile-jobserver
fix(build): preserve jobserver for parallel builds
2026-11-10 07:37:33 +08:00
iceman1001andClaude Opus 5.5 e23ba0ec99 hf piv: print unsigned long length with %lu, not PRIu64
v is unsigned long; PRIu64 is "llu" on macOS, so clang fails the build
with the PrintAndLogEx format attribute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 23:11:57 +07:00
iceman1001andClaude Opus 5.5 d25f06d98e save_buffer8: don't read past the source on a partial last word
The 4-byte packing loop read up to 3 bytes beyond src when length was not
a multiple of 4 (ASan heap-buffer-overflow in data test_ss8). Pack byte by
byte into the zeroed backing buffer instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 23:11:57 +07:00
iceman1001andClaude Opus 5.5 a6e0cc7f30 data test_ss*: free the save state after restoring it
save_buffer8/32/S32 allocate a backing buffer that the self tests never
released. Found by cppcheck 2.22 follow-up, confirmed with LeakSanitizer
(696 bytes in 3 allocations per run of the three tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:49:12 +07:00
iceman1001andClaude Opus 5.5 3686dffe1c fix PrintAndLogEx formats that only break on 32-bit and LLP64 hosts
size_t printed with %lu/%ld/PRIu64 and uint64_t with %lu are correct on
64-bit Linux/macOS only; with the new format attribute they fail -Werror
builds on 32-bit hosts (RPi, 32-bit Windows), and %lu for uint64_t also on
64-bit Windows. unsigned long printed with PRIu64 likewise.
Found by a 32-bit (arm-none-eabi) syntax-only pass over the client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:41:40 +07:00
iceman1001andClaude Opus 5.5 cc50ed6b72 client: check PrintAndLogEx format strings at compile time
Add a printf format attribute to PrintAndLogEx so gcc/clang flag
argument/specifier mismatches (previous commit fixed the 34 existing ones).
On mingw use __MINGW_PRINTF_FORMAT, matching the GNU printf selected by
_ISOC99_SOURCE rather than ms_printf.

PrintAndLogEx(x, "") is the established way to print an empty line, so
-Wno-format-zero-length is added to every build that compiles callers:
client Makefile, client CMake, experimental_lib, and cliparser (Makefile
and cmake).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:35:57 +07:00
iceman1001andClaude Opus 5.5 3deae3d904 fix PrintAndLogEx format string mismatches
Found by building with a printf format attribute on PrintAndLogEx.

User visible:
- hw version: GENERIC device/firmware name was passed as an unused arg
  and never printed
- hf saflok selftest: PRIx32 lacked '%', printed a literal 'x'
- hf mfp: key index value was never printed
- hf waveshare: output filename was never printed

Also: size_t/int64_t/uint64_t specifiers (%zu, PRId64, PRIX64), int
macros printed with %zu, ' ' flag on %u, unused arg in flash_prepare,
and non-literal strings passed as the format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:20:15 +07:00
iceman1001andClaude Opus 5.5 fb8a354249 hf seos: drop duplicated nested plaintext_adf check
Found by cppcheck 2.22 (identicalInnerCondition). No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:11:23 +07:00
iceman1001andClaude Opus 5.5 bd5c5e7004 check calloc results in data test_ss* and hf mf hardnested candidates
The save-state self tests and add_more_candidates() dereferenced calloc
results without a NULL check. Follow each file's existing OOM handling.
Found by cppcheck 2.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:11:11 +07:00
iceman1001andClaude Opus 5.5 3123340d5f parity: mask table index in non-GNUC fallbacks
The 16/32-bit parity fallbacks folded x but indexed g_odd_byte_parity[256]
with the unmasked value, reading out of bounds. Only reachable with a
compiler that does not define __GNUC__. Found by cppcheck 2.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 18:05:12 +07:00
iceman1001andClaude Opus 5.5 00ae94312c data test_ss*: print size_t with %zu instead of %llu
%llu reads a 64-bit argument for a size_t, which is only correct on LP64
hosts; 32-bit builds (e.g. RPi Zero, 32-bit Windows) print garbage.
Found by cppcheck 2.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 17:59:44 +07:00
iceman1001andClaude Opus 5.5 1e9033c83a hf seos: fix ADF compare leaking two strdup copies
The decrypted/selected ADF strings were strdup'd and uppercased for the
compare, but never freed on either return path and used without NULL check.
Use strcasecmp on the originals instead. Found by cppcheck 2.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 17:58:22 +07:00
iceman1001andClaude Opus 5.5 47df440998 fix wrong NULL check after allocating executable directory
set_my_executable_path() checked my_executable_path instead of the freshly
allocated my_executable_directory, so a failed calloc led to strncpy on NULL.
Found by cppcheck 2.22.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 17:55:50 +07:00
iceman1001andClaude Opus 5.5 e51bf90b63 trace list: show a negative Start / End instead of wrapping it
The Start and End columns were unsigned differences to the first frame,
so a frame stamped before it or after the timer restarted showed as
about 4294967296, eg -281 in traces/lf_hitag_crypto_dump.trace and
-29708 in traces/hf_14b_cryptorf_select.trace. Same as the frame delay
time in d11643c8f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:37:09 +07:00
iceman1001andClaude Opus 5.5 634fc7d457 trace list: accept -c given twice
Most `xx list` aliases pass "<protocol> -c", so adding -c yourself, eg
`hf 14a list -c`, gave "extraneous option -c". Allow up to two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:16:59 +07:00
iceman1001andClaude Opus 5.5 f7d86c4b60 trace extract: keep the iCLASS CSN apart from the 14a UID
Both lived in extract_uid, so a 14a anticollision after an iCLASS SELECT
overwrote the CSN and its CHECK gave no lookup line. Also take CL2 only
after a CL1 with the cascade tag, and CL3 after such a CL2, instead of
printing a UID made of whatever the buffer held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:13:45 +07:00
iceman1001andClaude Opus 5.5 63dc6a8d7d trace extract: find the DESFire EV2 auth challenge in any framing
extractChall_ev2() only took a 21 byte tag reply, ie wrapped framing
without CID, so a native EV2 First / Non First auth, or one with a CID,
printed no challenge. Locate it like the AES branch does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:11:37 +07:00
iceman1001andClaude Opus 5.5 81a9807c39 fileutils: clear *pdata after freeing it on a load error
loadFile_safeEx, loadFile_TXTsafe, loadFileEML_safe and loadFileMCT_safe
freed *pdata on a short read or a failed realloc but left the caller's
pointer set, so a caller keeping it freed it again. Same as
loadFileDICTIONARY_safe_ex already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 15:05:52 +07:00
iceman1001andClaude Opus 5.5 d11643c8f2 trace list: show a negative frame delay time instead of wrapping it
The -r and --frame delay was an unsigned difference, so a frame starting
before the end of the previous one, or after the timer restarted, eg
between the sessions of traces/hf_14b_xerox_info.trace or the frames of
traces/lf_HitagS256_dump.trace, showed as about 4294967296 instead of
-83024 or -117.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:59:13 +07:00
iceman1001andClaude Opus 5.5 fcd66c39e8 trace list: same column header with -r
With -r the Data header said "' denotes short bytes", but short bytes
are marked (n), and in both modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:58:17 +07:00
iceman1001andClaude Opus 5.5 bd47a48d50 trace save: return the download and file errors
It returned PM3_SUCCESS when the trace download or writing the file
failed, so scripts carried on as if the trace was saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:55:58 +07:00
iceman1001andClaude Opus 5.5 b9863f3156 trace list: don't truncate the arguments of the xx list aliases
CmdTraceListAlias() built "-t <protocol> <args>" in a 128 byte buffer,
so a longer command line was cut silently, eg `hf mf list -f` with a
long dictionary path tried to load a truncated file name and fell back
to the default keys. Allocate the buffer to fit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:54:40 +07:00
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
Iceman 9b9503f4ff Merge pull request #3767 from TomHarkness/fix/macos-openssl-brew-prefix
tools: find brew OpenSSL via installed keg, not the alias
2026-11-09 13:38:58 +08: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
iceman1001 de3c55fcd7 fix my old work stuff... 2026-11-09 11:41:28 +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
Christian HerrmannandClaude Opus 5.5 4c9be69148 PM5: zero-init TMR2 input config in StartCountSspClk
StartCountSspClk() declared its tmr_input_config_type on the stack
without initialising it and never set input_filter_value.
tmr_input_channel_init() copies that field into TMR2 CM1.C2DF, so the
digital input filter on the ssp_clk pin took whatever low nibble was
left on the stack, and could change from call to call depending on
the caller's stack contents.

TMR2 is clocked by that filtered input (C2DF2, external clock mode A),
so the filter decides which ssp_clk edges get counted. With fDTS at
288 MHz, filter values around 13 need ~556 ns of stable input against
a ~590 ns ssp_clk half period (fc/16 in 14a reader modes). Edges are
then dropped some of the time, and 14-15 drop every edge. In sniffer
mode (fc/8) values from about 10 already break. Lost ticks delay
frame timing derived from GetCountSspClk() (ReaderTransmit timing,
sync_time loops) by a varying amount. This shows up as random nonce
distance jitter and slow distance calibration in hf mf nested/autopwn
on PM5.

Zero-initialise the struct so the filter is off (C2DF = 0), matching
StartLoEdgeCapture() in the same file.

Reported by @adrian-stepien in #3709.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:28:17 +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 ebd33229e3 Merge pull request #3742 from abou28/em4x50-liw-sync-fix-pr
em4x50: sync RM on the second listen window
2026-11-09 11:07:21 +08:00
Iceman a87e8cb014 Merge branch 'master' into em4x50-liw-sync-fix-pr
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-09 10:50:17 +08:00
Iceman 19bbcedf6b Merge pull request #3761 from towelbyte/cotag_sim_passive
`lf cotag sim` - add and default to passive mode, improve field drop and activation sequence detection
2026-11-09 10:49:32 +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
Iceman ecef4e89ca Merge branch 'master' into em4x50-liw-sync-fix-pr
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-09 10:47:06 +08:00
Iceman 299be31710 Merge pull request #3766 from matrix/fix-noralsy-limits
lf noralsy: refuse CN above 9999999 and years outside 1961-2060
2026-11-09 10:17:53 +08:00