`hf gp aids` found A0000003820013000101 and A0000003820017000101 on two
physical HID reader configuration cards and could not name either.
They sit in the same HID Global range as the Reader Manager admin card
AIDs already listed (A00000038200xx000101).
Added as "HID configuration card", type configuration. No Sources entry:
these come from physical cards, not from the Reader Manager app the
neighbouring entries cite.
Verified A0000003820017000101 on its card: `hf gp aids` now prints
"HID configuration card | HID Global". A0000003820013000101 is taken from
a scan of the other card. JSON valid, tools/check_json_uniq.py passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding out which files an NTAG 424 has meant running getfs once per
file number and reading past "91 F0 Specified file number does not
exist" for the gaps. The card can't be asked: it answers GetFileIDs
with 91 1C, command not supported.
`--fileno` is now optional. Without it getfs asks GetFileSettings for
file numbers 0-31, prints the settings of every file that exists the
same way as for a single file, and ends with "Found 3 files: 1, 2, 3".
"No such file" is the expected answer for most numbers and stays quiet;
any other status is reported against its file number. A number the
card never answered is not taken to mean there is no file there: the
list then says it is incomplete and the command returns PM3_EPARTIAL.
The probe uses its own exchange rather than ntag424_get_file_settings(),
since ntag424_exchange_apdu() reports every unexpected status as an
error and returns PM3_ESOFT both for a card error and for no response.
Behaviour change: `hf ntag424 getfs` without arguments lists all files
instead of failing on the missing `--fileno`. `--fileno N` is unchanged.
Tested on an NTAG 424 DNA: files 1, 2 and 3 found in 0.59 s, settings
identical to querying each file on its own, file 2's SDM block included;
`--fileno 3` and `--fileno 4` behave as before. The incomplete-list path
was not exercised on hardware. Builds clean with gcc and clang.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After two failed reads of a block the dump loop ends, but the table was
still printed for every block the tag reports, from a buffer that is
zero where nothing was read, the command returned PM3_SUCCESS, and
without --ns that table was saved as the dump. A card with genuine zero
blocks makes the difference impossible to see. On a PM5 before 05c21a33b
every dump of an EM4233 read block 0, failed on block 1 and printed all
52 rows.
A dump that stops early now prints only the blocks it read, says
"Dump incomplete, read X of Y blocks, not saved", saves nothing and
returns PM3_EPARTIAL.
The tag answering 0x0F/0x10 is different: that is the existing end of
memory heuristic, used when SYSINFO gave no size and 128 blocks were
assumed. The block count now becomes what the tag actually holds, so
the dump stays complete and no rows past the real end are shown.
Behaviour change: an interrupted dump exits PM3_EPARTIAL instead of 0
and writes no file. A complete dump is unchanged.
Tested on a PM5 with an EM4233 (52 blocks), the pre-05c21a33b firmware
serving as a source of genuine read failures:
- fixed firmware, 1-of-4 and 1-of-256: 20/20 complete, exit 0
- failing firmware, 1-of-4: 15/15 "read 2..14 of 52 blocks, not saved",
only those rows printed, exit PM3_EPARTIAL; without --ns no file
- the end of memory path was not reached: this tag reports its size in
SYSINFO
Builds clean with gcc and clang.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mfu_auth_chk() compared the chunk result with 2, which neither the
device nor the client returns, so Enter or a timeout during a chunk
went on with every remaining chunk and pass, and the check returned
success. With no chunk run the speed line printed "-nan", and the
progress line stayed one chunk behind, ending at 111/113 (98.2 %)
with all 113 keys tested.
Enter or a timeout in a chunk now ends the check and turns the field
off, a timeout is returned, the speed is printed only when time was
measured and the progress line counts the keys tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
brute did not check Enter between chunks and compared the chunk
result with 2, what a chunk timeout returned before PM3_ETIMEOUT, so
Enter or a timeout during a chunk went on with the next chunk. The
keys/s print divided by the whole seconds of a stage, by zero for a
stage under 1 s. --emu did not check the trailer read, --dump named
the key file from a UID read at the end and lost the keys when the
card was gone, and a failed save returned success.
Enter, or a timeout in a chunk, now ends the command and turns the
field off, the speed is printed only when at least 1 s has passed,
the trailer read is checked, the key file is named when the command
starts and a failed save is returned.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fchk compared the chunk result with 2, what a chunk timeout returned
before PM3_ETIMEOUT, so a chunk timeout or Enter during a chunk went
on with the next chunk. --emu did not check the trailer read, --dump
named the key file from a UID read at the end and lost the keys when
the card was gone, a failed save returned success, and --blk ignored
--emu and --dump.
Enter or a timeout in a chunk now ends the check and turns the field
off, the trailer read is checked, the key file is named when the
command starts, a failed save is returned and --blk goes on to --emu
and --dump.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`hf mfp chk` could print a key table with most sectors missing and exit
0. One PM3_ERFTRANS from MifareAuth4() - the exchange failing, not the
card refusing the key - made plus_key_check() drop the field and return,
abandoning every sector after it, and CmdHFMFPChk() ignored that return.
On a PM5 before 05c21a33b this found 0 or 1 of 15 AES keys on a card that
has all of them.
Only PM3_ERFTRANS leaves a key without a verdict: PM3_EWRONGANSWER is the
card refusing it. Such a key is now counted as untested, the field is
reset and the search continues with the next one. After 3 unanswered keys
in a row the key slot is given up and the rest of the list is counted for
it, so a card that has gone away cannot hold the sweep up. When anything
went untested the command says so and returns PM3_EPARTIAL, as
`hf mfdes chk` does.
Behaviour change: an incomplete search exits PM3_EPARTIAL instead of 0,
and the progress line no longer stops at the first `E`.
Tested on a MIFARE Plus EV1 in SL1, `hf mfp chk -s 0 -e 31 -f
mfp_default_keys`:
- clean link: 15 keys, exit 0, no warning, as before
- six transport failures forced across different slots: 15 keys,
"6 candidates got no verdict", exit PM3_EPARTIAL (was: sweep aborted)
- one key slot forced dead: given up after 3, 26 + 32 = 58 untested
keys counted over the two key lists, 15 keys found, exit PM3_EPARTIAL
The forcing was a temporary build, not part of this change.
Builds clean with gcc and clang.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PM5 HF reader lost frames in both directions, the RDV4 did not. Same
card, client and firmware source: `hf mf hardnested` nonce acquisition
logged ~330 Auth1/Auth2/select errors per run on the PM5 and none on the
RDV4, which is the error flood `hf mf autopwn` shows.
The 14443-A reader moves one SSC word per Manchester bit, one every
9.4 us, and the AT32 SPI that carries them from the FPGA holds a single
word. The reader loops poll it. usbd_core_init() unmasks the OTG start
of frame interrupt, which fires every millisecond and has an empty
handler in the CDC class, and whenever it landed mid frame the loop
missed its bit-time. On receive that is an SPI overrun, and the overrun
path in FPGA_SSC_RX_Ready() discards the buffered word as well, so every
hit cost two bits: failing reads showed card replies exactly 256 carrier
cycles (two bit-times) shorter than good ones. The AT91 polls USB, so
nothing can preempt these loops on an RDV4.
Masking SOF after usbd_init() leaves the OTG interrupt for actual
transfers. Nothing in pm3 uses SOF and USB throughput is unchanged
(8 readings each way, mean 665 vs 669 KB/s). The bootrom does no HF work
and is left as it was.
Measured on the PM5 with BWM V5, before -> after:
- MFC authenticated read: 48/60 -> 60/60
- hardnested nonce acquisition: ~330 errors/run -> 0, SPI overruns -> 0
- hf mfp chk -s 0 -e 31: 0-1 of 15 keys -> 15/15, with the client from
before 7772aa92b as well
- hf mfdes chk: 58-80 14443-4 retransmissions/run -> 1-7, 12 s -> 6 s
- hf mfdes auth -c native, client before 7772aa92b: 13/30 failed -> 0/30
A handful of 14443-4 retransmissions per DESFire run remain with no SPI
overrun behind them; that card couples poorly at its position on this
antenna.
7772aa92b and the ISO-4 recovery in eab887680 stay: they are spec fixes
for any lossy link. They were also compensating for this, which is why
those paths already looked better before the cause was found.
Diagnosed by counting SPI receive overruns and by masking interrupts
across the reader loops, which took the errors to zero; masking only the
SOF interrupt does the same without touching protocol code.
Builds: PM5 and PM3RDV4 clean (file is AT32 only).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
autopwn took the emulator memory clear, the key transfer and the dump
fill as good whatever happened, read each trailer back from the block
numbered like its sector and returned success when the key file or
the dump could not be saved. A failed hardnested or static nested
attack, or a MIFARE Plus that needed hardnested, threw away the keys
already found. The dump was named by reading the card again and lost
without it, a Mini was saved with 64 blocks, Enter during a dictionary
chunk did not end the dictionary, the keys added to -k could be
written past its buffer, and the key file name and the dictionary
leaked.
Each step is now checked and its failure returned, a failed attack
keeps the found keys and the files are named from the UID read at the
start. pm3_save_mf_dump() returns the result of the save.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"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>
"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>
Release asset from RfidResearchGroup/Proxmark5_BWM_esp32 tag V5
(built Nov 12 2026 08:31:33, ESP-IDF v5.5.2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PM5 <-> ESP UART at 921600 capped pm3 over WiFi and BLE at ~90 KB/s.
Once the ESP accepted per-host forwarding (its fw drains the RX FIFO at
half full, which 1.5 Mbaud needs, and falls back to 921600 on its own
when a host talks slower), the PM5 negotiates BWM_UART_BAUD_FAST
(1500000). Then it asks for tagging again, as the baud set cleared it.
Older ESP fw: stays at 921600.
The ESP keeps its baud across our reset while the bootrom only knows
921600/460800, so CMD_HARDWARE_RESET and CMD_START_FLASH step the link
back to BWM_UART_BAUD_TARGET first (bwm_fwd_prepare_reset).
APB1 is 144 MHz active, 24 MHz idle: dividers 96 and 16, exact.
PM5 + BWM fw at 1.5 Mbaud: WiFi 136-143 KB/s, BLE 64-111 KB/s, USB
unchanged; 0 UART errors; bootloader entry finds the BWM at 921600,
also with the step-down removed (ESP fallback). Built PM5 and RDV4.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bwm_read_ng() gave up after 10 * (3000000 / BWM_UART_BAUD) idle passes
plus USART_SLOW_LINK's 50000, but USART_SLOW_LINK is defined nowhere:
60 passes, a few microseconds. WiFi gets away with it, a frame arrives
in one piece. BLE delivers one write (MTU-3 = 253 bytes) per connection
event, so a 2048-byte command spans ~9 events and the read gave up
after the first: PM3_EIO on the PM5, the rest parsed as junk frames,
hw ping -l 2048 over BLE timed out in most sessions.
It now gives up after BWM_RX_GAP_MS (500 ms) without a new byte.
receive_ng() only calls it once a frame has started, so an idle link
never waits.
PM5 over BLE: hw ping -l 2048 20/20 (304-385 ms), was failing in most
sessions; WiFi and USB unchanged. Not built for RDV4 (BWM only).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uart_receive() returns early through the wakeup pipe when a command is
queued (5c38ce0a1), but the BLE branch went straight into ble_recv(),
whose select() only watched the ATT socket. A queued command waited for
the whole RX timeout (200 ms) before the comm thread sent it, and at
connect even longer: a 32-byte hw ping over BLE took 250-600 ms.
ble_recv() now also watches the wakeup pipe, under the same rule as
uart_receive(): only while no byte of the frame is in hand.
PM5 over BLE (Intel AX201, MTU 256): hw ping 74-128 ms, was 510-600 ms.
USB and WiFi unchanged. gcc and clang.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The BWM carries two hosts on one link, a BLE central and a WiFi (TCP)
client. The ESP merged their data into one DATA_FORWARD stream and the
PM5 into one FIFO, and every reply went to both endpoints: two sessions
corrupted each other's frames, and a passive BLE client got copies of a
WiFi session (and the ESP's BLE buffers with them: heap low 7.5 KB).
Like USB/FPC on an RDV4 with a Blueshark, each command now records where
it came from and its replies go back there:
- bwm_frame.c: one input FIFO per endpoint; DATA_FORWARD_FROM (8093)
[ep][data] fills that endpoint's FIFO, untagged DATA_FORWARD the BLE
one. Acks for SEND_FORWARD_DATA_TO (5001) count like 5000's.
- bwm_forward.c: receive_ng() reads a whole frame from one endpoint and
latches it for the reply; replies go out as SEND_FORWARD_DATA_TO.
The main loop asks the ESP for tagged mode (SET_FORWARD_TAGGED 5002):
retried while the ESP boots, given up when it answers CMD_ERROR (older
fw, untagged as before), asked again after the ESP lost it (untagged
data arrives) or when a client connects after giving up.
- The bootrom keeps the single untagged stream.
The OS FIFOs grow from 2048 to 4096 bytes: a 2048-byte command over the
BWM is 2060 bytes framed and never fit, `hw ping -l 2048` over WiFi
timed out.
hw status at debug level adds the forward routing, the ESP uptime, its
UART RX error counters and per-task free stack
(APP_CMD_GET_SYS_RUNTIME_STATS).
PM5 + ESP fw with per-host forwarding: phone on BLE (nRF Connect) and 40
pm3 sessions over WiFi at once, 89.5 KB/s each, every ping intact, BLE
pings answered over BLE only, no WiFi reply seen on BLE. With the old
ESP (V4): routing stays "every host", sessions and 2048-byte pings OK.
Built PM5 (OS + bootrom) and RDV4; bootrom not flashed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`hf mfp chk` could report a near empty key table on a card whose keys are
all there, and DESFire in the native command set could fail an
authentication with the right key. Two ISO/IEC 14443-4 problems, both in
`ExchangeRAW14a()`, which MIFARE Plus and the DESFire native command set
both sit on.
The block number was toggled where the I-block is built, not once the
PICC had answered it. 7.5.3 toggles on a completed exchange, so every
exchange that did not complete left the client one step ahead of the
card, and from there every following command carried a block number the
card read as a retransmission. Nothing but a reselect recovered it, so a
single lost frame spoiled the rest of the sequence. That is what turned a
frame loss of a few percent into a 43% authentication failure rate on a
link that drops frames.
The second one is that a lost answer ended the exchange. 7.5.6 calls that
a transmission error and gives the PCD R(NAK) to ask the PICC for its
last block again; an R(ACK) carrying the other block number back means
the PICC never got ours, so the block goes out once more. `iso14_apdu()`
got this in eab887680 and the raw path had nothing, which is why the same
card behaves so differently through the two transports. Bounded at two
tries. A silent device is left alone: waiting again there only stacks up
another full timeout.
Measured on a PM5 whose HF link drops frames, same card and position
throughout. 30 authentications with the correct AES key via
`hf mfdes auth -c native`: 13 failed before, 6 with the block number
fixed, 0 with both. `hf mfdes auth -c niso` was already at 0 and stays
there. `hf mfp chk -s 0 -e 31` found 0, 1 and 1 of 15 AES keys on three
runs before and 15 on five runs after - it takes longer because it now
finishes the search instead of abandoning it.
Behaviour change: commands on these paths retry a lost frame, so one that
used to fail fast can now take up to two extra exchanges. A wrong key is
still a wrong key - verified that all-FF reports AUTHENTICATION_ERROR and
not the no-answer code - and a channel the card does not implement still
fails on the first frame, so neither is mistaken for something to retry.
Not addressed here, both known and separate:
- `hf mfp chk` abandons every remaining sector on one PM3_ERFTRANS and
its caller drops that return, so the key table comes out short with a
success exit code. Same conflation as #3787.
- the 14443a reader transmit in armsrc/iso14443a.c hands the frame to the
FPGA and returns without waiting for it to go out, unlike iso14443b.c
and iso15693.c. Adding the wait measurably cuts the frame loss but
wants a regression pass of its own.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The options were read one position further on in the argument table:
--1k selected a Mini, --emu a 4K with no transfer, --dump the
transfer, and --1k with --emu was refused. With --emu the command
ignored the results of the transfer and of FastDumpWithEcFill() and
returned success. It now reads positions 1-6 and handles both results
as hf mf fchk does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mf_dark_side() checks the candidates in chunks, but filled a chunk with
candidate i * max_keys + j while i already counts keys. From the second
chunk on it tested the wrong candidates and read past the end of the
list. It now takes candidate i + j, as mf_static_nested() does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mf_nested() put the same key candidate in every slot of a chunk, so
with two or more candidates the right key was never tested.
MifareNested() looked for the target nonce only at the average
calibration distance +-2, while some cards spread wider, and then took
a wrong nonce. It now also searches the measured range. The single
sector mode retries a run without a key, as autopwn does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MifareChkKeys() retried a failed selection forever and checked neither
the button nor USB, so a card that stopped answering kept the device
in the loop until a power cycle. It now replies PM3_ECARDEXCHANGE
after 11 failed selections in a row and PM3_EOPABORTED on the button
or a new command. The first key is retried too and select result 3
counts as a failure. hf mf staticnested, the static nested step of
hf mf autopwn and hf mf sen stop on PM3_ECARDEXCHANGE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes#3787.
`hf mfdes chk` could print "No keys found", exit 0, and miss keys that
are on the card. Two conflated results caused it.
DesfireAuthenticate() returned 7 both when the PICC answered the 2nd
auth frame with AUTHENTICATION_ERROR, a real wrong key, and when the
exchange got no answer at all. Every card error collapses to
PM3_EAPDU_FAIL in the send layer, so the code could not tell them
apart. The dictionary loop read "no answer" as a confirmed wrong key:
no retry, no resync, candidate counted as tested. A lost 2nd frame
also left the PICC waiting for it with a 14443-4 block number no
longer matching ours, so the next candidate drew 91CA and was lost too.
AuthCheckDesfire() reported every failed SelectApplication as "AID
does not exist", so a lost SELECT response skipped a whole
application. On a DESFire EV1 here that dropped the one application
holding the keys in 2 of 5 runs.
respcode stays 0xFF when no status byte arrives, and that is the
discriminator both places now use. A candidate the PICC gave no
verdict on is retried after a reselect; what still cannot be covered
is counted and reported, so `hf mfdes chk` prints "Search was not
exhaustive" and returns PM3_EPARTIAL instead of success. `hf mfdes
detect` had the same conflation.
The auth result codes are named in desfirecore.h now instead of bare
integers. Naming the `res < 7` bound showed it also matched
PM3_SUCCESS, so a found key triggered a field drop and reselect, and
was lost entirely if that reselect failed. Codes 1 and 7 no longer
carry a transmit failure, so their strings say what they mean: a wrong
key reported "Sending auth response (2nd frame) failed" before.
iso14_apdu() gains the ISO/IEC 14443-4 7.5.6 PCD error recovery it
never had. A lost or damaged answer is a transmission error, not a
dead link: R(NAK) asks the PICC to send its last block again, and an
R(ACK) back means it never got ours, so the block is repeated. Two
rounds. The CRC is checked before the block number is toggled now, so
a damaged frame can no longer desync the link, and `hw status` reports
how often a frame had to be asked for again and how often that did
not help.
Also fixed on the way: a -3 return from the WTX loop left the extended
timeout in place for the next exchange, and a negative iso14_apdu()
return was assigned into a uint16_t length, making reply_ng() send a
PM3_EOVFLOW frame.
Tested on hardware with a DESFire EV1 against both platforms. PM5
before: 3 of 5 runs found the keys. PM5 after: 23 of 24, the one miss
a 14443-3 activation failure before any APDU. RDV4: 6 of 6 before,
10 of 10 after. The counter shows why they differ, same card and
client: RDV4 needed 0 retransmissions in ~5000 exchanges, the PM5
0 to 80 per ~500 depending on the run, always in the reader to card
direction. The recovery hides that, it does not fix it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The device side of the MIFARE reader commands freed the BigBuf with
BigBuf_free(), and many also cleared it with BigBuf_Clear_ext().
BigBuf_free() drops the emulator memory, so the next emulator access
allocates a new zeroed one, and BigBuf_Clear_ext() zeroes it. A dump
loaded with `hf mf eload` was gone after `hf mf rdbl`, `hf mf fchk`,
`hf 14a info` and other reader commands. These routines now use
BigBuf_free_keep_EM() and BigBuf_Clear_keep_EM(), as the simulators
do.
Not fixed, because there is no RDV4 here to test them: the four
BigBuf_free() calls under WITH_FLASH. On a device with flash memory
the flash dictionary check (`--mem`) and MifareChkKeys_file() still
drop the emulator memory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>