mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
Refactor enums to avoid redefinition
This commit is contained in:
@@ -97,9 +97,9 @@ typedef struct {
|
|||||||
bool is_key_attack;
|
bool is_key_attack;
|
||||||
uint8_t key_attack_current_sector;
|
uint8_t key_attack_current_sector;
|
||||||
bool is_card_present;
|
bool is_card_present;
|
||||||
uint8_t nested_phase;
|
MfClassicNestedPhase nested_phase;
|
||||||
uint8_t prng_type;
|
MfClassicPrngType prng_type;
|
||||||
uint8_t backdoor;
|
MfClassicBackdoor backdoor;
|
||||||
uint16_t nested_target_key;
|
uint16_t nested_target_key;
|
||||||
uint16_t msb_count;
|
uint16_t msb_count;
|
||||||
bool enhanced_dict;
|
bool enhanced_dict;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <bit_lib/bit_lib.h>
|
#include <bit_lib/bit_lib.h>
|
||||||
#include <dolphin/dolphin.h>
|
#include <dolphin/dolphin.h>
|
||||||
#include <lib/nfc/protocols/mf_classic/mf_classic_poller.h>
|
|
||||||
|
|
||||||
#define TAG "NfcMfClassicDictAttack"
|
#define TAG "NfcMfClassicDictAttack"
|
||||||
|
|
||||||
|
|||||||
@@ -316,21 +316,21 @@ void dict_attack_reset_key_attack(DictAttack* instance) {
|
|||||||
instance->view, DictAttackViewModel * model, { model->is_key_attack = false; }, true);
|
instance->view, DictAttackViewModel * model, { model->is_key_attack = false; }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dict_attack_set_nested_phase(DictAttack* instance, uint8_t nested_phase) {
|
void dict_attack_set_nested_phase(DictAttack* instance, MfClassicNestedPhase nested_phase) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
instance->view, DictAttackViewModel * model, { model->nested_phase = nested_phase; }, true);
|
instance->view, DictAttackViewModel * model, { model->nested_phase = nested_phase; }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dict_attack_set_prng_type(DictAttack* instance, uint8_t prng_type) {
|
void dict_attack_set_prng_type(DictAttack* instance, MfClassicPrngType prng_type) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
instance->view, DictAttackViewModel * model, { model->prng_type = prng_type; }, true);
|
instance->view, DictAttackViewModel * model, { model->prng_type = prng_type; }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dict_attack_set_backdoor(DictAttack* instance, uint8_t backdoor) {
|
void dict_attack_set_backdoor(DictAttack* instance, MfClassicBackdoor backdoor) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
with_view_model(
|
with_view_model(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
#include <lib/nfc/protocols/mf_classic/mf_classic_poller.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -9,32 +10,6 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct DictAttack DictAttack;
|
typedef struct DictAttack DictAttack;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MfClassicNestedPhaseNone,
|
|
||||||
MfClassicNestedPhaseAnalyzePRNG,
|
|
||||||
MfClassicNestedPhaseDictAttack,
|
|
||||||
MfClassicNestedPhaseDictAttackResume,
|
|
||||||
MfClassicNestedPhaseCalibrate,
|
|
||||||
MfClassicNestedPhaseRecalibrate,
|
|
||||||
MfClassicNestedPhaseCollectNtEnc,
|
|
||||||
MfClassicNestedPhaseFinished,
|
|
||||||
} MfClassicNestedPhase;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MfClassicPrngTypeUnknown, // Tag not yet tested
|
|
||||||
MfClassicPrngTypeNoTag, // No tag detected during test
|
|
||||||
MfClassicPrngTypeWeak, // Weak PRNG, standard Nested
|
|
||||||
MfClassicPrngTypeHard, // Hard PRNG, Hardnested
|
|
||||||
} MfClassicPrngType;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MfClassicBackdoorUnknown, // Tag not yet tested
|
|
||||||
MfClassicBackdoorNone, // No observed backdoor
|
|
||||||
MfClassicBackdoorAuth1, // Tag responds to v1 auth backdoor
|
|
||||||
MfClassicBackdoorAuth2, // Tag responds to v2 auth backdoor
|
|
||||||
MfClassicBackdoorAuth3, // Tag responds to v3 auth backdoor (static encrypted nonce)
|
|
||||||
} MfClassicBackdoor;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DictAttackEventSkipPressed,
|
DictAttackEventSkipPressed,
|
||||||
} DictAttackEvent;
|
} DictAttackEvent;
|
||||||
@@ -71,11 +46,11 @@ void dict_attack_set_key_attack(DictAttack* instance, uint8_t sector);
|
|||||||
|
|
||||||
void dict_attack_reset_key_attack(DictAttack* instance);
|
void dict_attack_reset_key_attack(DictAttack* instance);
|
||||||
|
|
||||||
void dict_attack_set_nested_phase(DictAttack* instance, uint8_t nested_phase);
|
void dict_attack_set_nested_phase(DictAttack* instance, MfClassicNestedPhase nested_phase);
|
||||||
|
|
||||||
void dict_attack_set_prng_type(DictAttack* instance, uint8_t prng_type);
|
void dict_attack_set_prng_type(DictAttack* instance, MfClassicPrngType prng_type);
|
||||||
|
|
||||||
void dict_attack_set_backdoor(DictAttack* instance, uint8_t backdoor);
|
void dict_attack_set_backdoor(DictAttack* instance, MfClassicBackdoor backdoor);
|
||||||
|
|
||||||
void dict_attack_set_nested_target_key(DictAttack* instance, uint16_t target_key);
|
void dict_attack_set_nested_target_key(DictAttack* instance, uint16_t target_key);
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,41 @@ typedef enum {
|
|||||||
MfClassicPollerModeDictAttackEnhanced, /**< Poller enhanced dictionary attack mode. */
|
MfClassicPollerModeDictAttackEnhanced, /**< Poller enhanced dictionary attack mode. */
|
||||||
} MfClassicPollerMode;
|
} MfClassicPollerMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MfClassic poller nested attack phase.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
MfClassicNestedPhaseNone,
|
||||||
|
MfClassicNestedPhaseAnalyzePRNG,
|
||||||
|
MfClassicNestedPhaseDictAttack,
|
||||||
|
MfClassicNestedPhaseDictAttackResume,
|
||||||
|
MfClassicNestedPhaseCalibrate,
|
||||||
|
MfClassicNestedPhaseRecalibrate,
|
||||||
|
MfClassicNestedPhaseCollectNtEnc,
|
||||||
|
MfClassicNestedPhaseFinished,
|
||||||
|
} MfClassicNestedPhase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MfClassic pseudorandom number generator (PRNG) type.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
MfClassicPrngTypeUnknown, // Tag not yet tested
|
||||||
|
MfClassicPrngTypeNoTag, // No tag detected during test
|
||||||
|
MfClassicPrngTypeWeak, // Weak PRNG, standard Nested
|
||||||
|
MfClassicPrngTypeHard, // Hard PRNG, Hardnested
|
||||||
|
} MfClassicPrngType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MfClassic authentication backdoor type.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
MfClassicBackdoorUnknown, // Tag not yet tested
|
||||||
|
MfClassicBackdoorNone, // No observed backdoor
|
||||||
|
MfClassicBackdoorAuth1, // Tag responds to v1 auth backdoor
|
||||||
|
MfClassicBackdoorAuth2, // Tag responds to v2 auth backdoor (sometimes static encrypted)
|
||||||
|
MfClassicBackdoorAuth3, // Tag responds to v3 auth backdoor (static encrypted nonce)
|
||||||
|
} MfClassicBackdoor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MfClassic poller request mode event data.
|
* @brief MfClassic poller request mode event data.
|
||||||
*
|
*
|
||||||
@@ -78,9 +113,9 @@ typedef struct {
|
|||||||
uint8_t sectors_read; /**< Number of sectors read. */
|
uint8_t sectors_read; /**< Number of sectors read. */
|
||||||
uint8_t keys_found; /**< Number of keys found. */
|
uint8_t keys_found; /**< Number of keys found. */
|
||||||
uint8_t current_sector; /**< Current sector number. */
|
uint8_t current_sector; /**< Current sector number. */
|
||||||
uint8_t nested_phase; /**< Nested attack phase. */
|
MfClassicNestedPhase nested_phase; /**< Nested attack phase. */
|
||||||
uint8_t prng_type; /**< PRNG (weak or hard). */
|
MfClassicPrngType prng_type; /**< PRNG (weak or hard). */
|
||||||
uint8_t backdoor; /**< Backdoor type. */
|
MfClassicBackdoor backdoor; /**< Backdoor type. */
|
||||||
uint16_t nested_target_key; /**< Target key for nested attack. */
|
uint16_t nested_target_key; /**< Target key for nested attack. */
|
||||||
uint16_t
|
uint16_t
|
||||||
msb_count; /**< Number of unique most significant bytes seen during Hardnested attack. */
|
msb_count; /**< Number of unique most significant bytes seen during Hardnested attack. */
|
||||||
|
|||||||
@@ -48,32 +48,6 @@ typedef enum {
|
|||||||
MfClassicCardStateLost,
|
MfClassicCardStateLost,
|
||||||
} MfClassicCardState;
|
} MfClassicCardState;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MfClassicNestedPhaseNone,
|
|
||||||
MfClassicNestedPhaseAnalyzePRNG,
|
|
||||||
MfClassicNestedPhaseDictAttack,
|
|
||||||
MfClassicNestedPhaseDictAttackResume,
|
|
||||||
MfClassicNestedPhaseCalibrate,
|
|
||||||
MfClassicNestedPhaseRecalibrate,
|
|
||||||
MfClassicNestedPhaseCollectNtEnc,
|
|
||||||
MfClassicNestedPhaseFinished,
|
|
||||||
} MfClassicNestedPhase;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MfClassicPrngTypeUnknown, // Tag not yet tested
|
|
||||||
MfClassicPrngTypeNoTag, // No tag detected during test
|
|
||||||
MfClassicPrngTypeWeak, // Weak PRNG, standard Nested
|
|
||||||
MfClassicPrngTypeHard, // Hard PRNG, Hardnested
|
|
||||||
} MfClassicPrngType;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
MfClassicBackdoorUnknown, // Tag not yet tested
|
|
||||||
MfClassicBackdoorNone, // No observed backdoor
|
|
||||||
MfClassicBackdoorAuth1, // Tag responds to v1 auth backdoor
|
|
||||||
MfClassicBackdoorAuth2, // Tag responds to v2 auth backdoor
|
|
||||||
MfClassicBackdoorAuth3, // Tag responds to v3 auth backdoor (static encrypted nonce)
|
|
||||||
} MfClassicBackdoor;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MfClassicKey key;
|
MfClassicKey key;
|
||||||
MfClassicBackdoor type;
|
MfClassicBackdoor type;
|
||||||
|
|||||||
Reference in New Issue
Block a user