Commit Graph
494 Commits
Author SHA1 Message Date
Antiklesys 0ffe244a6b Fix for circular buffer error during hf iclass sim
Issue origin:
Commit 6b7665ed5 "Added live fc/cn update to hf iclass tagsim" added a data_available() poll inside the per-byte DMA loop of GetIso15693CommandFromReader so the ARM could drop out of RF-listen and process live emulator updates.

Before that commit, that tight loop had no USB poll at all — only gotFrame / BUTTON_PRESS / WDT_HIT. Verified via git show 6b7665ed5^:armsrc/iso15693.c.

Why it shows up on sim -t 3/6/7: those are the FULL sim modes that share do_iclass_simulation. Between reader commands the decoder sits in STATE_READER_UNSYNCD, so the gated poll at iso15693.c:1570-1575 fires every byte (reading UDP peripheral registers). With DMA filling at ~1 byte / ~19 µs, the added USB register reads plus jitter occasionally push the CPU past the 90% lag threshold → behindBy 461 with DMA_BUFFER_SIZE=512.

Commit fb8f94fa2 narrowed the gate to UNSYNCD to stop mid-frame exits, but the per-byte poll itself is still what's new on that path.

Fix:

New mode constant in include/iclass_cmd.h:

#define ICLASS_SIM_MODE_FULL_LIVE  8  // FULL + allow USB interrupt for live emul updates
Treat it identically to ICLASS_SIM_MODE_FULL everywhere except for the poll gate.

Add a flag param to GetIso15693CommandFromReader — e.g. bool allow_usb_interrupt in iso15693.c:1495 and iso15693.h:42. Wrap the poll:

if (allow_usb_interrupt &&
    (dr->state == STATE_READER_UNSYNCD ||
     dr->state == STATE_READER_AWAIT_1ST_FALLING_EDGE_OF_SOF) &&
     data_available()) { ... }
Pass true only for live mode in do_iclass_simulation iclass.c:502:

bool live = (simulationMode == ICLASS_SIM_MODE_FULL_LIVE);
len = GetIso15693CommandFromReader(receivedCmd, MAX_FRAME_SIZE, &reader_eof_time, live);
The len == -2 drain block stays but becomes dead code for non-live modes (never returns -2).

Client side: cmdhficlass.c:1687 (CmdHFiClassTagSim) sends ICLASS_SIM_MODE_FULL_LIVE. CmdHFiClassSim -t 3/6/7 keeps sending ICLASS_SIM_MODE_FULL / _GLITCH / _GLITCH_KEY.

Other callers (iso15693.c:2270, iclass.c:1121 = reader-attack sim) pass false.

Result:

hf iclass sim -t 3/6/7 → byte-inner loop is back to its pre-tagsim shape → no blow-buffer abort.
hf iclass tagsim → keeps live update ability; still has the overhead, but that's the trade-off the feature needs.
2026-04-17 03:00:14 +08:00
Antiklesys d92c9e06e9 Update cmdhficlass.c 2026-04-15 11:18:47 +08:00
Antiklesys 8d6e474a75 hf iclass legbrute speed improvements #1
Imported updates from legbrute hashcat modules to speed up hf iclass legbrute

1. Bitslicing — biggest win (~32×)
Kernel stores each cipher register (l, r, b, t) as 32 parallel 1-bit lanes in u32s (m64000_a3-pure.cl:147-201, bs_iclass_tick) and computes 32 MACs per tick. The CPU doMAC_brute does 1 at a time. A 64-bit bitslice port would give ~64× per core; AVX2 gets 256×. This is the single largest speedup lever.

2. Early-reject after 8 output ticks
In m64000_sxx (m64000_a3-pure.cl:534-535) the kernel breaks out as soon as the first MAC byte can't match. doMAC_brute always produces the full 32 output bits before memcmp. Comparing byte-by-byte as bits are produced saves ~3× on the output phase since 255/256 keys fail after byte 0.

3. Pre-expanded y_ccnr bit array
Kernel expands the 96 input bits into a flat array once (m64000_a3-pure.cl:239-247) and reuses it for every candidate. suc_bytes in cipher.c:181 re-does b >>= 1 shifts for every key. Pre-expanding lets the inner loop be branch-free and vectorizable.

4. Widen lanes to 256/512 via AVX2/AVX-512. The bitslice code is written against a single uint64_t lane type — swapping for __m256i/__m512i (or an abstracted bs_word_t) gives 4×/8× throughput on hosts that support it, with scalar u64 fallback on ARM/older x86. NEON gives 2× for ARM.
2026-04-15 01:09:19 +08:00
Philippe Teuwen 88d20bd4f2 make style 2026-04-13 09:35:02 +02:00
Raheem Idowu b7689cd543 explictly set page = 0 in dump_req_t struct 2026-04-04 17:30:48 -04:00
Raheem Idowu 22dae554c7 hf iclass dump --page support 2026-04-04 17:15:13 -04:00
Antiklesys 51c44843c9 Removed --credit from hf iclass legrec
Option wasn't working and caused unnecessary complexity in the workflow.
2026-04-04 01:07:47 +08:00
Antiklesys b5fe39cf34 Update cmdhficlass.c
Signed-off-by: Antiklesys <syselkitna@gmail.com>
2026-04-03 12:17:34 +08:00
Antiklesys 2145bc8869 Update cmdhficlass.c 2026-04-03 12:03:59 +08:00
Antiklesys 51521fdad9 Fixed blacktears bugs 2026-04-03 12:00:56 +08:00
Antiklesys 8380c02a54 Fixed legrec grammar error and checks 2026-04-03 03:22:32 +08:00
Antiklesys 6b2e6ab1e8 Huge hf iclass legbrute performance improvements (4x)
Optimized `hf iclass legbrute` throughput: replaced recursive `suc()`/`output()` cipher functions with iterative loops, added 256-entry LUT for the `select()` function eliminating redundant bit arithmetic and halving key lookups per state step, switched successor state to in-place pointer update removing per-call struct copies, added `doMAC_brute()` with byte-wise LSB-first processing and direct output bit packing eliminating all bitstream struct overhead and output reversal calls per key candidate, and replaced per-iteration 64-bit modulo progress check with a countdown counter
2026-04-03 01:18:55 +08:00
Antiklesys 39b5153382 Improved hf iclass legbrute: fixed multithreaded
Improved `hf iclass legbrute`: fixed multithreaded key-range partitioning so threads cover non-overlapping slices of the 40-bit keyspace, added ETA display, keyboard abort with resume hint, `_Atomic` correctness for shared state, `pthread_create` error handling, and thread count capped at available CPUs .
2026-04-02 23:50:41 +08:00
iceman1001 b54c06a463 fix a missing free, and out of band reading if called with large index which was guarded at the caller before. 2026-03-29 09:39:02 +07:00
iceman1001 ee63e0bc2d improve text output in hf iclass tear 2026-03-28 12:17:59 +07:00
Antiklesys 480b58685c Added do not stabilize bits to blacktears 2026-03-28 12:34:11 +08:00
Antiklesys 7d8c9f3f6e iClass SIO Parser
Improved SIO Parsing capabilities based on @iceman1001 black hat talk
2026-03-27 20:32:41 +08:00
Antiklesys 0ac7252215 Update cmdhficlass.c 2026-03-27 11:08:16 +08:00
Antiklesys 6b7665ed59 Added live fc/cn update to hf iclass tagsim
Added live fc/cn update to `hf iclass tagsim` refreshing the csn with each update
2026-03-27 11:01:07 +08:00
Antiklesys 8bb001f2fe Update lookup --live
Updated lookup --live to stop looking in other dictionaries once the key is found
2026-03-27 10:56:32 +08:00
Antiklesys 8bff0f12b5 Added --live option to hf iclass lookup
Added `--live` option to `hf iclass lookup` command to perform a live recovery of the reader's key by simulating a tag and running the lookup command against both standard and elite dictionaries
2026-03-27 00:57:13 +08:00
Antiklesys 77613d666f Update name 2026-03-26 22:34:59 +08:00
Antiklesys 252d085e83 Added hf iclass simtag command to quickly simulate an iclass tag based on facility code and card number 2026-03-26 20:12:48 +08:00
Antiklesys 9591c0c670 Added -f parameter to hf iclass sam command to use the sam to parse a card dump 2026-03-25 18:21:44 +08:00
iceman1001 79df9c0245 fix hf iclass info - the block 7 reader failed because logic when detecting AA1 key 2026-03-23 11:42:01 +07:00
iceman1001 5c6f4d5de6 change hf iclass wrbl and hf iclass rdbl to accept the continous mode, this enables us to see tears better 2026-03-23 11:41:05 +07:00
iceman1001 55db4dc6f2 correct check if non secure mode is enabled 2026-03-20 14:34:04 +07:00
iceman1001 ba5812a775 check crypto0,1 bits if its in NON_SECURE_MODE, instead of a too strict good value of 0x2C 2026-03-20 14:30:08 +07:00
iceman1001 570fb542a0 fix logic , thanks @atk / Antiklesys 2026-03-20 14:12:55 +07:00
iceman1001 4d1304166f fix calloc handling, thanks to @antiklesys! 2026-03-20 12:30:04 +07:00
iceman1001 938060c537 use read config block as base for write data, and textual changes for nice output 2026-03-20 11:45:18 +07:00
iceman1001 367fd6f4c9 documentation 2026-03-18 18:51:14 +07:00
Antiklesys fd09895f0e Update cmdhficlass.c
Updated error description
2026-03-18 16:34:38 +08:00
Antiklesys 3f95d3cc05 Update cmdhficlass.c
Added additional personalization case
2026-03-18 16:32:31 +08:00
Antiklesys 55eb0a8d82 Update cmdhficlass.c
Fixed missing hf iclass blacktears read after @iceman1001 's update of the function from IF to SWITCH in: https://github.com/Antiklesys/proxmark3/commit/3eac1861f6baa0127855edb2323781f7f4bda8ab
2026-03-18 16:20:44 +08:00
Iceman 2e810d50de Merge pull request #3147 from Antiklesys/master
Added --raw support for hf iclass blacktears
2026-03-18 13:01:49 +07:00
iceman1001 3eac1861f6 adapted hf iclass blacktears - textually and some logic 2026-03-18 11:00:34 +07:00
Antiklesys d328601dc9 Added --raw support for hf iclass blacktears 2026-03-18 10:08:14 +08:00
Antiklesys f10d52a8a9 Update cmdhficlass.c
Updated logic to support debit key
2026-03-17 22:20:55 +08:00
Antiklesys e768a1d9ad Update cmdhficlass.c 2026-03-17 22:08:41 +08:00
Antiklesys b91ef4adaf Implemented hf iclass blacktears
Added `hf iclass blacktears` command to perform an automated tearoff of block 1 to set non-secure page mode.
2026-03-17 21:53:16 +08:00
Christian Zanon b9ddb038b7 Merge branch 'master' into hf-14b-tearoff
Signed-off-by: Christian Zanon <105173223+xNovyz@users.noreply.github.com>
2026-03-13 11:39:06 +01:00
Antiklesys 61d20368af Updated hg iclass legrec
Code cleanup removed unused variables
2026-03-13 12:23:35 +08:00
xNovyz 52676ebbd4 style: whitespace fixes 2026-03-11 22:41:21 +01:00
Antiklesys 0d2741d757 Unused variables code cleanup
Code cleanup of unused payload variables for iclass legrec
2026-03-05 21:38:16 +08:00
Antiklesys 5041fbffa7 Added --creidit option for hf iclass legrec
Added --creidit option for hf iclass legrec
2026-03-05 19:32:52 +08:00
Philippe Teuwen c00e4801b7 make style 2026-02-06 13:43:41 +01:00
Travis Weathers 61f5493f55 Fix iCLASS block 7 decoder to strip sentinel bit
When decoding iCLASS block 7 Wiegand data, the decoder was showing
incorrect bit counts (27 for 26-bit, 36 for 35-bit, etc.) because
it wasn't stripping the sentinel bit that's added during encoding.

This fix:
- Detects when binary string has sentinel bit (leading '1' making
  length one more than common formats)
- Strips the sentinel bit and recreates u96 values from corrected
  binary string
- Uses corrected length for wiegand decoding

Fixes decoding for 26-bit, 35-bit, and other formats where sentinel
bit causes incorrect format detection.
2025-12-18 14:43:15 -05:00
iceman1001 a3c2d2b815 style 2025-07-08 21:15:09 +02:00
Antiklesys 33c3988a94 Fix broken older functionality
Updated to still maintain older functionality when the macs field is passed
2025-07-05 19:26:22 +08:00