1061 Commits
Author SHA1 Message Date
Iceman 653edf1f9c Merge branch 'master' into fix/lf-hid-demod-frame-length
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-23 06:23:02 +09:00
Iceman 2c30606f9e Merge branch 'master' into fix/3678-hitag-ttf-and-t55xx-p1-false-positive
Signed-off-by: Iceman <iceman@iuse.se>
2026-11-23 04:38:38 +09:00
Matthew CarrollandClaude Opus 5.5 4e429c0e89 lf hid demod: decode only a frame whose preambles are 96 or 192 bits apart
A long format (over 37 bits) is sent as a 192-bit frame, a short one as 96.
Extra bits ahead of a preamble decoded as a frame shifted by those bits. If a
preamble pair is the wrong length or not Manchester, try the next pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 09:23:14 -07:00
iceman1001andClaude Opus 5 c154f730c3 crapto1: much faster MIFARE Classic key recovery
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>
2026-11-13 12:20:04 +07:00
iceman1001andClaude Opus 5.5 89b873c281 Baud rates in kbps/Mbps
"BWM link baud....... 1500000 bps", "Bootloader BWM link at 921600 baud"
and "PM3 UART serial baudrate: 921600" now read 1.5 Mbps / 921.6 kbps.

sprint_bitrate() next to sprint_bytes() in common/commonutil.c: decimal
units, as line rates go ("9600 bps", "921.6 kbps", "1.5 Mbps").

Built PM5 (OS + bootrom), RDV4 with FLASH, client gcc; clang shows no
warnings on the changed files. Checked on PM5 over USB and WiFi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 15:55:31 +07:00
iceman1001andClaude Opus 5.5 f1d42086c2 hw status, mem info: transfer speed and memory size in KB/MB
"Transfer Speed PM3 -> Client... 1111313 bytes/s" and
"Memory size... 2048 Kb ( 32 pages * 64k )" (Kb is kilobit) now read
"1.06 MB/s" and "2.00 MB ( 32 pages * 64 KB )".

sprint_bytes() in common/commonutil.c formats a byte count in binary
units ("512 bytes", "136.7 KB", "1.07 MB") for the firmware (armsrc
printf.h sprintf) and the client alike.

Built PM5 (OS + bootrom), RDV4 with FLASH, client gcc; clang shows no
new warnings. Checked on PM5: USB 1.04 MB/s, WiFi 137.5 KB/s, 2.00 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 15:52:06 +07:00
Mykhailo ShevchukandClaude Opus 5 ba544d684d Fix EM410x decode reading past the end of the demod buffer
Em410xDecode() overloaded *size four ways: the caller's buffer length on
entry, then the preamble repeat period written back by preambleSearch(),
then a format selector, then the decoded length on exit. The value
reaching removeEm410xParity() as the format selector was therefore not
the buffer length, yet that function derived its read length from it and
read blen bits with no bounds check - up to 110 bits from an arbitrary
start index. A demod buffer whose preamble sits near the end is read out
of bounds.

Give each role its own name - buflen, period, fmt - and bound the reads
in removeEm410xParity() on buflen, which is now passed separately. The
*size write on exit is unchanged, so external callers see the same
contract.

The sledge-of-0x05 scan keeps its original window: it is bounded on the
repeat period, not on the buffer, rearranged only to avoid the unsigned
underflow in `x < *size - sizeof(fives)`. Widening it to the whole buffer
would let stray noise select the 80 bit format and silently fail an
otherwise good read.

Verified with a guard-page harness placing a 70 bit array against a
PAGE_NOACCESS boundary with the preamble at index 7: the previous code
faults with 0xC0000005, this returns -6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-11-11 18:09:31 +02: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 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
iceman1001 2e2598bca9 style 2026-09-27 21:15:18 +02:00
Philippe Teuwen e2acee8a85 Revert "Release v4.23346 - Frosty Lemon"
This reverts commit dc0110c29d.
2026-09-18 00:22:18 +02:00
Philippe Teuwen dc0110c29d Release v4.23346 - Frosty Lemon 2026-09-18 00:22:18 +02:00
Philippe Teuwen 634edd11fd make style 2026-09-16 19:00:50 +02:00
Matthew CarrollandClaude Opus 5 907f21b8cb lf psk demod: do not accept a phase shift from the lead-in
The emitted bit is the running phase, so a shift accepted before the tag answers
toggles curPhase once too often and the rest of the word comes back complemented.

pskFindFirstPhaseShift judged its first measured length, but waveStart starts as
wherever the caller began looking - that length is part of a wave, not a wave,
and any gap beating fc was taken as a shift. Baseline on the first peak instead.
pskRawDemod_ext separately trusted a shift under one bit period in; the clock is
known by then, so look again from a bit period in.

Both are needed - dropping either leaves one of the tags measured inverting on
most reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 14:57:15 -07:00
Matthew CarrollandClaude Opus 5 e206d748a2 lf fsk demod: do not fabricate a bit from a leading run
aggregate_bits sized each run of like waves in bits and then forced a zero to
one. That is right mid-stream, where a run rounding to nothing would drop a bit
the tag did send. On the leading run it is wrong: a single subcarrier wave is
about fchigh samples against a bit period of clk, so it rounds to no bits and
was made into one anyway - a bit the tag never sent, shifting every bit after it
and dragging startIdx back by most of a bit period.

Skip a leading run that rounds to nothing and let the next transition be first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 14:57:14 -07:00
Matthew CarrollandClaude Opus 5 1ebcf225f1 lf nrz demod: start the bitstream at the first edge
The samples before the first level change were counted as bits, and where no
edge arrives inside ten clocks the long-run flush fired first and invented ten
of them out of the quiet lead-in. The count sat on a rounding boundary, so one
sample of jitter in that edge added or dropped a leading bit and rotated the
rest of the word - while startIdx, derived from the same count, held i % clk and
could name no sample.

A level change can only fall on a bit boundary, so start there and report it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 14:57:11 -07:00
iceman1001 ace5d63ff9 hitag2: fix simulation against genuine readers, add restore, fix info
Simulation now completes the full exchange with a genuine Paxton reader in
password mode, and crypto mode read/write passes Proxmark-to-Proxmark.

Firmware:
- SOF was one bit period short. The lead-in that compensated for the lost
  head half bit was removed and nothing replaced it, so readers rejected
  every answer with a second START_AUTH. Default is now 6.
- The edge-detect threshold was latched before being measured, so the value
  chosen depended on whether the Proxmark was in a field when sim started.
  It is now measured on field entry and re-armed when the reader leaves.
- The percentile walk latched on run-scoped variables, so one attempt made
  outside a field poisoned every later one.
- Field loss was detected from TIMESTAMP, which is free-running MCU time and
  never stalls. Detect it from receive silence instead.
- Frames of a length the protocol does not have no longer reach the state
  machine; our own modulation tail was resetting the session and breaking
  every write.
- A dropped edge merges two or three reader bit periods into one gap. Those
  bits were discarded; they are now recovered by decomposition, which is what
  made crypto mode work (AUTH decode 15% -> 100%).
- Threshold selection is limited to 20 and 32 and settles in under 25 ms.

Client:
- lf hitag info printed a hardcoded 0x06 and reported 'Password mode' for
  every tag. It now reads page 3, takes -k (4 bytes password, 6 bytes
  crypto), and says so when the config cannot be read.
- lf hitag restore: writes a dump back in dependency order - user pages,
  then key material, then config last - validates the config byte, and
  prints the credential the tag will require afterwards.
- lf hitag crack2 now reports why it failed instead of a bare 'fail'.
- trace list: bit count moved to its own column, relative mode shows a
  Frame Delay Time row rather than renaming Start/End, --frame and -r
  rejected together.
2026-09-04 13:20:29 +02:00
dxl 3ea93dfc85 Add the xyield macro function to yield the CPU. 2026-09-02 00:02:14 +08:00
dxl af9f16d880 Fixed unintended global export in commonutil.c, thx nieldk. 2026-08-19 12:04:32 +02:00
dxl 9cdda9aa62 Reuse the logic for checking version information. 2026-08-19 12:04:32 +02:00
iceman1001 2c6e607110 style 2026-07-15 16:39:15 +02:00
iceman1001 bf082caab7 fix coverity #910690 2026-07-03 11:22:38 +02:00
towelbyte 2e35b95a7c Fix: Replace VLAs with heap alloc in lfdemod signal helpers
Using "data load" on very large trace files (e.g. dumps with 700k samples,
such as COTAG dumps) was causing crashes on some platforms due to stack overflow
since VLA temporary buffers were used.

Replace VLAs in computeSignalProperties() and removeSignalOffset() with
heap-allocated buffers instead.
2026-06-13 00:33:24 +02:00
Philippe Teuwen d078e8a62b make style 2026-05-21 20:54:44 +02:00
iceman1001 cbb572afad style 2026-05-11 14:36:17 +02:00
Philippe Teuwen 64f0145cb4 ARM mbedtls: prevent compilation of self_test functions
They were discarded by the linker GC as they weren't used so far, but better to make it explicit.
2026-04-28 13:00:43 +02:00
Philippe Teuwen 0f4fd96f83 ARM common/generator.c: prevent compilation of functions requiring missing mbedtls files
They were discarded by the linker GC as they weren't used so far, but better to make it explicit.
2026-04-28 13:00:43 +02:00
Philippe Teuwen e7de85a1a3 ARM LZ4: prevent compilation of functions using malloc/free
They were discarded by the linker GC as they weren't used so far, but better be safe...
2026-04-28 13:00:43 +02:00
Philippe Teuwen 961e59b5d1 Revert "Release v4.21611 - BREAKMEIFYOUCAN!"
This reverts commit aaacc75e9f.
2026-04-14 10:19:30 +02:00
Philippe Teuwen aaacc75e9f Release v4.21611 - BREAKMEIFYOUCAN! 2026-04-14 10:19:30 +02:00
Philippe Teuwen 88d20bd4f2 make style 2026-04-13 09:35:02 +02:00
iceman1001 e6db327485 text 2026-03-30 09:29:52 +07:00
iceman1001 42c8699abc simplify 2026-03-30 08:30:31 +07:00
jof Lassoff ad3885a9bb Add Vanderbilt ACT pattern-based key generation to hf mf keygen
- Implements mfc_algo_vanderbilt_one() and mfc_algo_vanderbilt_all()
- Generates keys using 'Acces' + block ID pattern (416363657300-4163636573FF)
- Supports all 40 sectors for 4K cards
- Eliminates need for 256+ keys in dictionary file
- Keys generated dynamically on-demand
2026-03-10 15:49:39 +00:00
iceman1001 338ab9c81a Revert "Release v4.21128 - Permafrost"
This reverts commit b10235b03b.
2026-02-25 16:15:01 +01:00
iceman1001 b10235b03b Release v4.21128 - Permafrost 2026-02-25 16:15:01 +01:00
Philippe Teuwen fdf3b2690a Various fixes to content GCC 16... 2026-02-07 00:51:53 +01:00
Philippe Teuwen c00e4801b7 make style 2026-02-06 13:43:41 +01:00
Aaron Tulino (Aaronjamt) 2197d9fc9f Fix ROTR conflict 2025-12-21 03:49:45 -07:00
Foxushka b380132cbb Replaced hf mf bambukeys with hf mf keygen with multiple KDFs support, use table for key output
Added Snapmaker U1 filament RFID KDF in `hf mf keygen`
2025-11-10 20:58:49 +03:00
Philippe Teuwen fd88967443 make style 2025-10-14 09:50:59 +02:00
Oleg Moiseenko 944a80d217 make style 2025-09-21 16:41:30 +03:00
iceman1001 628d8633f7 Revert "Release v4.20728 - Phrack"
This reverts commit ee9b3f4acb.
2025-09-11 20:31:08 +02:00
iceman1001 ee9b3f4acb Release v4.20728 - Phrack 2025-09-11 20:31:08 +02:00
iceman1001 2597c7576e style 2025-07-10 11:52:39 +02:00
iceman1001 a3c2d2b815 style 2025-07-08 21:15:09 +02:00
iceman1001 5de4dd68e5 text 2025-06-22 20:34:54 +02:00
iceman1001 65607fc727 added Ultralight-C simulation. hf mfu sim -t 13. Use eload first. Also added support to upload UL-C dictionaries and UL-AES to spiffs memory. A lot of textual reworked across client. Unifiy texts and a bit more color ;) 2025-06-19 17:26:20 +02:00
iceman1001 1f718683b3 Revert "Release v4.20469 - Daddy Iceman"
This reverts commit 9fa173c727.
2025-06-16 16:18:01 +02:00
iceman1001 9fa173c727 Release v4.20469 - Daddy Iceman 2025-06-16 16:18:01 +02:00