The release matrix built PM3GENERIC and PM3RDV4 only, so every release went
out without PM5 ever being compiled, even though AGENTS.md asks for both and
PM5 has build options no other platform has.
Adds three firmware builds, covering every PLATFORM_EXTRAS token Makefile.hal
accepts for PM5 plus its own standalone mode and size switch: a bare build on
a flash-backed standalone, BWM with GDB_GATEWAY, and NO_LOWBATT_SHUTDOWN plus
NO_LOWBATT_BEEP with SKIP_CEP=1 and no standalone. BTADDON and FPC_USART_DEV
are rejected on PM5, which also rules out HF_CARDHOPPER and HF_REBLAY, so
there is no line for those. SMARTCARD is left out too: the token is accepted
but PM5 does not compile i2c.
Adds a cmake client build as well. That one passes PLATFORM to cmake, not to
make, because client/CMakeLists.txt reads it at configure time to set
-DDEFAULT_PM5; passed to make it would be ignored and the build would not be
a PM5 client at all.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Nested and static nested recovery ran lfsr_recovery32 once per nonce and
intersected two ~2^16 candidate lists. The cipher state is linear while the
nonce is fed in, so the states for one nonce are those for the other xored
with a known difference. Checking both keystreams inside a single recovery
leaves about one candidate instead of two large lists.
lfsr_recovery32_dual() does that: it skips the early bit times where the
difference prunes little (start chosen per call from an exact per bit match
probability, falling back to 0 on overflow), scans the first pass 64 states
at a time through a bit packed filter table, extends the tables branch free
in cache sized chunks, and replaces the 512 scattered sort buckets with one
contiguous counting sort.
lfsr_recovery32() is rebuilt on the same machinery, so hf mf sen, mfkey32,
mfkey64 and the nested tools all gain. It stays single threaded because
nested_util.c already calls it from four threads. recover() takes the second
keystream as optional extra state; the plain path is unchanged.
Both return the same key sets as before, verified against the old code under
ASan/UBSan over random and degenerate nonce pairs.
nested per key: ~390 ms -> ~4 ms
lfsr_recovery32 per call: ~270 ms -> ~165 ms
peak RSS, single nonce: 47.6 MB -> 27.6 MB
tools/mfc/protocol links pthread now, as the other two mfc tool dirs do.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
With iclass the script answers the SAM's e-purse UPDATE in place of
the card. It sent the second half of the new value, then 87 02 and two
bytes of the first half. A card answers the two halves swapped.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The script had no path for a HID MIFARE Classic credential, where the
SAM runs Crypto1 itself and sends frames with its own parity bits. A
HID DESFire credential was read only under the seos name.
mfc relays as hf mf sam does: select without RATS, UID and SAK to the
SAM, then each frame as plain bytes or as the SAM's bit stream with
ISO14A_NO_PARITY, and a timeout status when the card is silent.
desfire takes the seos relay.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
DetectST only runs on ask, and each fsk hit set its ST flag to false. An
fsk hit now reports ST if its block 0 word has the ST bit set and a copy
of the word sits 33 to 36 bits before or after it.
On a buffer of 92 bits or more, test() starts its scan at bit 28 and
often picks the second copy of block 0. On a short capture the copy
after that word may not fit, so the check also looks behind it. If
neither side has room for a copy, the ST bit decides. A Q5 word still
reports no ST.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASKDemod_ext sets its ST flag if DetectST cut terminators out, and never
clears it. The four ask attempts that call it preset the flag to true,
so every hit from them reported ST. Each of those hits now starts from
false and reports ST only if DetectST cut terminators out of that
demodulation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each trace is the buffer 'lf t55xx detect --r0' leaves after reading block 0
of a T5577. info -1 decodes block 0 with the configuration detect found. A
test fails on a wrong polarity, a wrong offset or no answer.
detect -1 can't tell that a loaded buffer holds a block read, so
t55xx_fallback_try follows its strict fsk pass with a non-strict one.
The non-strict pass finds the fsk2a ST word even without the stride fix.
The fsk2a ST test therefore can't catch a fault in the strict pass's
stride check. Only a live detect can.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same setup as before: a T5577 written as Indala PSK1 RF/32, 24 mm off a
Proxmark3 Easy antenna, 4096 samples. The tracker fails on it and the fc/2
fallback reads it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two of the five tests failed on master. gallagher_decode_creds()
descrambled the caller's buffer in place, so test_known_vector_creds()
compared the encoding with its own input after the decode had changed
it. gallagher_construct_credential() never set csn_len, so test_MES()
encoded with an uninitialised CSN length and got 9C24CC5C instead of
4F36B74E, the formats/mes.md vector. The command printed no overall
result and make check did not run it, so no automated run showed the
failures.
gallagher_decode_creds() now decodes a copy, the constructor sets
csn_len, GallagherTest() prints "Tests ( ok )" or "Tests ( fail )" as
DesfireTest() does, and pm3_tests.sh runs hf gallagher test with the
other hf self-tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decode the five tag traces in traces/cotag that had no test (active
1558 / 385816, passive 2402442, Bewator 1576805 / 1576807) by card
number, and run lf search on an active and a passive trace.
The 3361, HD500 and TWN4 activation sequence traces carry no tag, so
lf cotag demod must fail on them and lf search must find nothing. That
guards the demod against reporting a card number from reader noise.
lf_cotag_reader_HD500_with_tag.pm3 is left out: lf cotag demod cannot
decode the tag inside that reader capture yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The demod raw id came from the 0x56 preamble and reserved zero bits
since f28da2da6 (2017), 0x40c00080 for every tag, and the magic search
stopped at 0xFE.
sim ignored --magic, sent mode 0 when -m was omitted, used -1 as "no
--cn", cut ids above 32 bits, turned modes above 15 into 1 and
accepted conflicting options.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
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>
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>
brew's "openssl" alias follows the newest major (now openssl@4), so
`brew --prefix openssl` returns a prefix that isn't installed on setups
with only openssl@3, and the build fails with evp.h / des.h not found.
Probe the candidate kegs and use the first that actually has the headers.
Co-Authored-By: Claude Opus 4.8 <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>
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>
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>
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>
mfulc_des_brute added the Homebrew openssl@3.6 include directory, which
the macOS runners no longer have, and -Wmissing-include-dirs under
-Werror stopped the build. It now uses brew --prefix openssl, as #3734
did for mfd_aes_brute.
Since MSYS2 filesystem 2026.10.18 /etc/profile runs post-install
scripts on the first start only, so ProxSpace never installed its
packages and the build found no arm-none-eabi-gcc. The workflow now
runs ProxSpace's setup script when setup\installed is missing.
The third mfulc_des_brute test in pm3_tests.sh is now labelled 3/3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hardcoded openssl@3.6 include path fails macOS CI when that formula
is absent. Ask brew for the installed OpenSSL prefix and use it for
both headers and libraries.
Built all three mfd_aes_brute tools with Clang and GCC 16 against
OpenSSL 3 and 4 on macOS. Existing linker deprecation warnings remain.
Read SBS before TIME/DATE to latch a coherent snapshot in synchronous
ERTC mode. A rollover between the previous calendar and subsecond reads
could move the tick count backwards and cause false receive timeouts.
Preserve millisecond conversion and shared delta-helper semantics.
Add actual-source rollover, conversion and register-locking coverage.
Leave acquisition limits and RF timing unchanged.
Co-Authored-By: OpenAI coding assistant <noreply@openai.com>
Signed-off-by: nip <182409448+nip-was-here@users.noreply.github.com>
At fc/2 the subcarrier is a one-sample alternation and pskRawDemod_ext finds
wave tops one sample at a time, unfiltered. On a weak tag, sample noise erases
tops; a wave then reads as four samples and counts as a phase shift, and the
bit stream fills with errors although every bit is still in the trace. A T5577
Indala at 22 mm gave the wrong card on 14 of 50 lf search reads.
PSKDemod keeps the tracker's result whenever it is clean, so nothing changes
where master already works. Otherwise, for fc/2, it tries the existing coherent
receiver pm3_psk_demod (now with an optional per-symbol magnitude output) and
keeps that only if it scores well above what level-step leakage can produce,
its bits aren't doubled or constant, and no symbol is weak. The receiver's
output is differential, so one bad decision would flip every later bit: a weak
symbol refuses the trace rather than risk a wrong card (absolute decisions with
weak symbols left to maxErr were tried and gave wrong IDs on dropouts). With no
usable clock from the caller, candidate clocks are tried largest first. Polarity is voted from the
raw level over each phase reversal, the cue pskFindFirstPhaseShift reads at the
first one. Client only; firmware is unchanged.
Base vs this change, same captures:
- T5577 Indala, live lf search: 22 mm 3 right / 14 wrong -> 50 / 0; 24 mm
0 / 2 -> 50 / 0; 26 mm and 0-20 mm unchanged
- lf t55xx dump, live: 22 and 24 mm blocks 0-2 and page 1 correct 5/5 where
master reads nothing; unchanged where master reads
- emulated Indala (Chameleon Ultra, clock drifting against the reader):
lf search right / wrong 56 / 130 -> 91 / 95 of 200; every one of the 95 is
master's own wrong ID on the same capture
- 27 PSK traces in traces/, weakened with Gaussian noise: correct 341 -> 636 of
810, wrong IDs 83 -> 21; with recorded Proxmark noise 367 -> 553 of 648,
33 -> 27. No lost reads and no new wrong IDs in either
- traces/lf_*.pm3 (99): lf search -1 and -1 -c output identical; 1,581
non-PSK probes: lf search and lf t55xx detect identical
- 200 empty-field captures: no decode, either build
tools/pm3_tests.sh: a weak 24 mm Indala trace must read its ID (fails on
master), and a synthetic NRZ with an fc/2 ripple must not decode as a tag
(the level-step leakage the score check rejects).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add bidirectional conversion between DFC v4 credentials and mfdes v1 JSON, with documentation and round-trip coverage. Include H10301 FC69 CN420 factory and field fixtures and an external HID reader test target.
Co-Authored-By: GPT-Daybreak Blue <noreply@openai.com>
PLATFORM=PM3ULTIMATE has not built since c0ecb1c62 (2026-04-14), which
fixed a real heap overflow by changing one character:
- if (total_size > num_infiles * FPGA_CONFIG_SIZE) {
+ if (total_size >= num_infiles * FPGA_CONFIG_SIZE) {
The old '>' checked after the fact, so a round could start with the
buffer already full and write num_infiles * FPGA_INTERLEAVE_SIZE bytes
past the end. But '>=' answers the wrong question: a buffer that is
exactly full is not an error, it is the expected end state for a
platform whose bitstreams are sized to FPGA_CONFIG_SIZE.
Two things had to change.
all_feof() tested the EOF flag, and C only sets that once a read has
already run off the end -- consuming the last byte of a file leaves it
clear. A file whose length is an exact multiple of FPGA_INTERLEAVE_SIZE
therefore still looked unfinished after its final whole chunk, and the
interleave loop ran one more round of pure zero padding. It now peeks a
byte with fgetc/ungetc instead, so a file read to its last byte counts
as finished right away.
PM3ULTIMATE is the only platform this reaches:
fpga_pm3_ult_felica.bit 69984 = 243 * 288 exactly
fpga_pm3_ult_hf_15.bit 69983
fpga_pm3_ult_hf.bit 69980
fpga_pm3_ult_lf.bit 69980
243 rounds * 4 files * 288 = 279936, which is exactly
4 * FPGA_CONFIG_SIZE for 2s50vq144. Round 244 was padding only, and '>='
killed it there. Stock PM3's largest bitstream is 42172, not a chunk
multiple, so its last round trips feof naturally and it never gets that
far -- which is why this went unnoticed, nothing in CI builds ULTIMATE.
The guard now asks whether the next round fits, which is the condition
it was always meant to express and is strictly stronger than the
original '>':
if (total_size + (num_infiles * FPGA_INTERLEAVE_SIZE) > num_infiles * FPGA_CONFIG_SIZE)
Verified: PM3ULTIMATE compresses 279936 bytes to 40195 and all four
bitstreams decompress back byte-exact. Output is byte-identical to
before for stock 2s30vq100 (169344 -> 106628), for icopyx XC3
(72864 -> 27292) and for the '-s' .data section path. fullimage builds
for PM3ULTIMATE, PM3RDV4, PM3GENERIC and PM5.
Note FPGA_CONFIG_SIZE is now exactly the size of the largest ULTIMATE
bitstream. Regenerate that one byte larger and the guard fires again,
correctly; bump the constant by one interleave step rather than touching
the guard.
Co-Authored-By: Claude Opus 5 (1M context)
zlib_decompress() walks its output in whole FPGA_INTERLEAVE_SIZE chunks:
for (long k = 0; k < *outsize / (FPGA_INTERLEAVE_SIZE * num_outfiles); k++)
so a stream that is not a whole number of chunks loses its trailing partial one.
With two or more inputs the read loop zero-pads each stream past EOF and the
total lands on a boundary, but the padding was guarded by 'num_infiles > 1', so
the single input case was left ragged. 42172 bytes of fpga_pm3_hf.bit is 146.43
chunks, and -d handed back 39788 - a clean looking prefix, short by 2384 bytes,
22 of them real bitstream data.
Gate the padding on single_block instead. It must not be 'always pad': -s is the
.data section, and start.c's uncompress_data_section() sizes the decompression
with __data_end__ - __data_start__. Rounding .data from 14944 up to 14976 makes
LZ4_decompress_safe() return an error, and that path is the LED panic loop, so
the firmware would never reach AppMain().
1 bitstream 42172 in -> 42336 packed, -d round trip byte identical,
archive 28730 -> 28731
4 bitstreams archive byte identical to 43fe6c3eb, round trip exact
-s .data byte identical to 43fe6c3eb on the same input, unpadded
The 164 padding bytes never reach the FPGA: DownloadFPGA() shifts out only
bitstream_length bytes, taken from the .bit 'e' section header.
Also simulated the ARM decoder over the new archive - LZ4_decompress_safe_continue()
block by block into a FPGA_RING_BUFFER_BYTES buffer - 3 blocks of 16384/16384/9568,
none over the ring buffer.
Co-Authored-By: Claude Opus 5 (1M context)