mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2025-03-08 17:07:19 +00:00
* 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
53 lines
1.5 KiB
C
53 lines
1.5 KiB
C
#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);
|
|
}
|