Loading...
Searching...
No Matches
mf_classic_poller.h
1#pragma once
2
3#include "mf_classic.h"
4#include <lib/nfc/protocols/iso14443_3a/iso14443_3a_poller.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
13typedef struct MfClassicPoller MfClassicPoller;
14
18typedef enum {
19 MfClassicPollerEventTypeRequestMode,
21 MfClassicPollerEventTypeRequestReadSector,
23 MfClassicPollerEventTypeRequestSectorTrailer,
24 MfClassicPollerEventTypeRequestWriteBlock,
26 MfClassicPollerEventTypeRequestKey,
27 MfClassicPollerEventTypeNextSector,
28 MfClassicPollerEventTypeDataUpdate,
29 MfClassicPollerEventTypeFoundKeyA,
30 MfClassicPollerEventTypeFoundKeyB,
31 MfClassicPollerEventTypeKeyAttackStart,
32 MfClassicPollerEventTypeKeyAttackStop,
33 MfClassicPollerEventTypeKeyAttackNextSector,
35 MfClassicPollerEventTypeCardDetected,
36 MfClassicPollerEventTypeCardLost,
37 MfClassicPollerEventTypeSuccess,
38 MfClassicPollerEventTypeFail,
39} MfClassicPollerEventType;
40
44typedef enum {
45 MfClassicPollerModeRead,
46 MfClassicPollerModeWrite,
47 MfClassicPollerModeDictAttackStandard,
48 MfClassicPollerModeDictAttackEnhanced,
49} MfClassicPollerMode;
50
54typedef enum {
55 MfClassicNestedPhaseNone,
56 MfClassicNestedPhaseAnalyzePRNG,
57 MfClassicNestedPhaseDictAttack,
58 MfClassicNestedPhaseDictAttackVerify,
59 MfClassicNestedPhaseDictAttackResume,
60 MfClassicNestedPhaseCalibrate,
61 MfClassicNestedPhaseRecalibrate,
62 MfClassicNestedPhaseCollectNtEnc,
63 MfClassicNestedPhaseFinished,
64} MfClassicNestedPhase;
65
69typedef enum {
70 MfClassicPrngTypeUnknown, // Tag not yet tested
71 MfClassicPrngTypeNoTag, // No tag detected during test
72 MfClassicPrngTypeWeak, // Weak PRNG, standard Nested
73 MfClassicPrngTypeHard, // Hard PRNG, Hardnested
74} MfClassicPrngType;
75
79typedef enum {
80 MfClassicBackdoorUnknown, // Tag not yet tested
81 MfClassicBackdoorNone, // No observed backdoor
82 MfClassicBackdoorAuth1, // Tag responds to v1 auth backdoor
83 MfClassicBackdoorAuth2, // Tag responds to v2 auth backdoor (sometimes static encrypted)
84 MfClassicBackdoorAuth3, // Tag responds to v3 auth backdoor (static encrypted nonce)
85} MfClassicBackdoor;
86
92typedef struct {
93 MfClassicPollerMode mode;
96
106
113typedef struct {
114 uint8_t sectors_read;
115 uint8_t keys_found;
117 MfClassicNestedPhase nested_phase;
118 MfClassicPrngType prng_type;
119 MfClassicBackdoor backdoor;
121 uint16_t
124
134
146
157
168
178
194
200typedef struct {
201 MfClassicPollerEventType type;
204
219MfClassicError mf_classic_poller_get_nt(
220 MfClassicPoller* instance,
221 uint8_t block_num,
222 MfClassicKeyType key_type,
223 MfClassicNt* nt,
224 bool backdoor_auth);
225
240MfClassicError mf_classic_poller_get_nt_nested(
241 MfClassicPoller* instance,
242 uint8_t block_num,
243 MfClassicKeyType key_type,
244 MfClassicNt* nt,
245 bool backdoor_auth);
246
263MfClassicError mf_classic_poller_auth(
264 MfClassicPoller* instance,
265 uint8_t block_num,
266 MfClassicKey* key,
267 MfClassicKeyType key_type,
269 bool backdoor_auth);
270
287MfClassicError mf_classic_poller_auth_nested(
288 MfClassicPoller* instance,
289 uint8_t block_num,
290 MfClassicKey* key,
291 MfClassicKeyType key_type,
293 bool backdoor_auth,
294 bool early_ret);
295
306MfClassicError mf_classic_poller_halt(MfClassicPoller* instance);
307
318MfClassicError mf_classic_poller_read_block(
319 MfClassicPoller* instance,
320 uint8_t block_num,
321 MfClassicBlock* data);
322
333MfClassicError mf_classic_poller_write_block(
334 MfClassicPoller* instance,
335 uint8_t block_num,
336 MfClassicBlock* data);
337
352MfClassicError mf_classic_poller_value_cmd(
353 MfClassicPoller* instance,
354 uint8_t block_num,
355 MfClassicValueCommand cmd,
356 int32_t data);
357
369MfClassicError mf_classic_poller_value_transfer(MfClassicPoller* instance, uint8_t block_num);
370
385MfClassicError mf_classic_poller_send_standard_frame(
386 MfClassicPoller* instance,
387 const BitBuffer* tx_buffer,
388 BitBuffer* rx_buffer,
389 uint32_t fwt_fc);
390
405MfClassicError mf_classic_poller_send_frame(
406 MfClassicPoller* instance,
407 const BitBuffer* tx_buffer,
408 BitBuffer* rx_buffer,
409 uint32_t fwt_fc);
410
428MfClassicError mf_classic_poller_send_custom_parity_frame(
429 MfClassicPoller* instance,
430 const BitBuffer* tx_buffer,
431 BitBuffer* rx_buffer,
432 uint32_t fwt_fc);
433
448MfClassicError mf_classic_poller_send_encrypted_frame(
449 MfClassicPoller* instance,
450 const BitBuffer* tx_buffer,
451 BitBuffer* rx_buffer,
452 uint32_t fwt_fc);
453
454#ifdef __cplusplus
455}
456#endif
Definition bit_buffer.c:7
Definition mf_classic.h:111
Definition mf_classic.h:78
Definition mf_classic.h:137
Definition mf_classic.h:87
Definition mf_classic.h:95
MfClassic poller next sector event data.
Definition mf_classic_poller.h:103
uint8_t current_sector
Current sector number.
Definition mf_classic_poller.h:104
MfClassic poller key request event data.
Definition mf_classic_poller.h:130
bool key_provided
Flag indicating if key is provided.
Definition mf_classic_poller.h:132
MfClassicKey key
Key to be used by poller.
Definition mf_classic_poller.h:131
MfClassic poller read sector request event data.
Definition mf_classic_poller.h:140
MfClassicKeyType key_type
Key type to be used by poller.
Definition mf_classic_poller.h:143
bool key_provided
Flag indicating if key is provided.
Definition mf_classic_poller.h:144
uint8_t sector_num
Sector number to be read.
Definition mf_classic_poller.h:141
MfClassicKey key
Key to be used by poller.
Definition mf_classic_poller.h:142
MfClassic poller request mode event data.
Definition mf_classic_poller.h:92
const MfClassicData * data
Data to be used by poller.
Definition mf_classic_poller.h:94
MfClassicPollerMode mode
Mode to be used by poller.
Definition mf_classic_poller.h:93
MfClassic poller sector trailer request event data.
Definition mf_classic_poller.h:152
bool sector_trailer_provided
Flag indicating if sector trailer is provided.
Definition mf_classic_poller.h:155
uint8_t sector_num
Sector number to be read.
Definition mf_classic_poller.h:153
MfClassicBlock sector_trailer
Sector trailer to be used by poller.
Definition mf_classic_poller.h:154
MfClassic poller update event data.
Definition mf_classic_poller.h:113
uint8_t keys_found
Number of keys found.
Definition mf_classic_poller.h:115
uint8_t current_sector
Current sector number.
Definition mf_classic_poller.h:116
MfClassicPrngType prng_type
PRNG (weak or hard).
Definition mf_classic_poller.h:118
uint16_t nested_target_key
Target key for nested attack.
Definition mf_classic_poller.h:120
MfClassicNestedPhase nested_phase
Nested attack phase.
Definition mf_classic_poller.h:117
uint8_t sectors_read
Number of sectors read.
Definition mf_classic_poller.h:114
uint16_t msb_count
Number of unique most significant bytes seen during Hardnested attack.
Definition mf_classic_poller.h:122
MfClassicBackdoor backdoor
Backdoor type.
Definition mf_classic_poller.h:119
MfClassic poller write block request event data.
Definition mf_classic_poller.h:163
bool write_block_provided
Flag indicating if block is provided.
Definition mf_classic_poller.h:166
MfClassicBlock write_block
Block to be written.
Definition mf_classic_poller.h:165
uint8_t block_num
Block number to be written.
Definition mf_classic_poller.h:164
MfClassic poller event.
Definition mf_classic_poller.h:200
MfClassicPollerEventData * data
Pointer to event specific data.
Definition mf_classic_poller.h:202
MfClassicPollerEventType type
Event type.
Definition mf_classic_poller.h:201
MfClassic poller key attack event data.
Definition mf_classic_poller.h:175
uint8_t current_sector
Current sector number.
Definition mf_classic_poller.h:176
Definition mf_classic_poller_i.h:175
MfClassic poller event data.
Definition mf_classic_poller.h:182
MfClassicError error
Error code on MfClassicPollerEventTypeFail event.
Definition mf_classic_poller.h:183
MfClassicPollerEventDataUpdate data_update
Data update context.
Definition mf_classic_poller.h:187
MfClassicPollerEventDataSectorTrailerRequest sec_tr_data
Sector trailer request context.
Definition mf_classic_poller.h:191
MfClassicPollerEventKeyAttackData key_attack_data
Key attack context.
Definition mf_classic_poller.h:190
MfClassicPollerEventDataDictAttackNextSector next_sector_data
Next sector context.
Definition mf_classic_poller.h:185
MfClassicPollerEventDataWriteBlockRequest write_block_data
Write block request context.
Definition mf_classic_poller.h:192
MfClassicPollerEventDataReadSectorRequest read_sector_request_data
Read sector request context.
Definition mf_classic_poller.h:189
MfClassicPollerEventDataKeyRequest key_request_data
Key request context.
Definition mf_classic_poller.h:186
MfClassicPollerEventDataRequestMode poller_mode
Poller mode context.
Definition mf_classic_poller.h:184