[FL-1396] Mifare Classic read (#1034)
* rfal: add new data exchange function * core: add FURI_BIT to common defines * furi_hal_nfc: add data exchange with custom patiry bits * lib: extend nfc common API * assets: add mf classic dictionary * lib: introduce mifare classic library * nfc: add dictionary reader helper * nfc worker: add worker events, add mifare classic read * nfc: rework scenes with worker events * nfc: add read mifare classic GUI * nfc device: add mifare classic save * nfc: add dictionary open fail scene * nfc: mention resources * stream: fix stream read line * subghz: rework file read with fixed stream_read_line * furi_hal_nfc: decrease communication timeout * nfc: rework keys load from dictionary with file_stream * nfc: add read mifare classic suggestion * nfc: fix mifare classic read view * nfc: fix index size * nfc: add switch to no dictionary found scene * nfc: add mifare classic load * nfc: improve read mifare classic design * mifare_classic: add proxmark3 mention * nfc: format sources * nfc: fix typos, add documentation
This commit is contained in:
@@ -8,4 +8,5 @@ enum NfcCustomEvent {
|
||||
NfcCustomEventWorkerExit,
|
||||
NfcCustomEventByteInputDone,
|
||||
NfcCustomEventTextInputDone,
|
||||
NfcCustomEventDictAttackDone,
|
||||
};
|
53
applications/nfc/helpers/nfc_mf_classic_dict.c
Normal file
53
applications/nfc/helpers/nfc_mf_classic_dict.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "nfc_mf_classic_dict.h"
|
||||
|
||||
#include <flipper_format/flipper_format.h>
|
||||
#include <lib/toolbox/args.h>
|
||||
|
||||
#define NFC_MF_CLASSIC_DICT_PATH "/ext/nfc/assets/mf_classic_dict.nfc"
|
||||
|
||||
#define NFC_MF_CLASSIC_KEY_LEN (13)
|
||||
|
||||
bool nfc_mf_classic_dict_check_presence(Storage* storage) {
|
||||
furi_assert(storage);
|
||||
return storage_common_stat(storage, NFC_MF_CLASSIC_DICT_PATH, NULL) == FSE_OK;
|
||||
}
|
||||
|
||||
bool nfc_mf_classic_dict_open_file(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
return file_stream_open(stream, NFC_MF_CLASSIC_DICT_PATH, FSAM_READ, FSOM_OPEN_EXISTING);
|
||||
}
|
||||
|
||||
void nfc_mf_classic_dict_close_file(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
file_stream_close(stream);
|
||||
}
|
||||
|
||||
bool nfc_mf_classic_dict_get_next_key(Stream* stream, uint64_t* key) {
|
||||
furi_assert(stream);
|
||||
furi_assert(key);
|
||||
uint8_t key_byte_tmp = 0;
|
||||
string_t next_line;
|
||||
string_init(next_line);
|
||||
*key = 0;
|
||||
|
||||
bool next_key_read = false;
|
||||
while(!next_key_read) {
|
||||
if(stream_read_line(stream, next_line)) break;
|
||||
if(string_get_char(next_line, 0) == '#') continue;
|
||||
if(string_size(next_line) != NFC_MF_CLASSIC_KEY_LEN) continue;
|
||||
for(uint8_t i = 0; i < 12; i += 2) {
|
||||
args_char_to_hex(
|
||||
string_get_char(next_line, i), string_get_char(next_line, i + 1), &key_byte_tmp);
|
||||
*key |= (uint64_t)key_byte_tmp << 8 * (5 - i / 2);
|
||||
}
|
||||
next_key_read = true;
|
||||
}
|
||||
|
||||
string_clear(next_line);
|
||||
return next_key_read;
|
||||
}
|
||||
|
||||
void nfc_mf_classic_dict_reset(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
stream_rewind(stream);
|
||||
}
|
15
applications/nfc/helpers/nfc_mf_classic_dict.h
Normal file
15
applications/nfc/helpers/nfc_mf_classic_dict.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <storage/storage.h>
|
||||
#include <lib/toolbox/stream/file_stream.h>
|
||||
|
||||
bool nfc_mf_classic_dict_check_presence(Storage* storage);
|
||||
|
||||
bool nfc_mf_classic_dict_open_file(Stream* stream);
|
||||
|
||||
void nfc_mf_classic_dict_close_file(Stream* stream);
|
||||
|
||||
bool nfc_mf_classic_dict_get_next_key(Stream* stream, uint64_t* key);
|
||||
|
||||
void nfc_mf_classic_dict_reset(Stream* stream);
|
Reference in New Issue
Block a user