mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 06:54:19 +00:00
NFC: MF Classic parsers read() fix (dictionary attack skip) (#3355)
* NFC: MF Classic lib: MfClassicErrorPartialRead added * unnecessary imports removed * MfClassicError refactor by @gornekich Co-authored-by: gornekich <n.gorbadey@gmail.com> --------- Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
parent
e6f078eeb7
commit
ed34dfa1c6
7 changed files with 18 additions and 20 deletions
|
@ -60,7 +60,7 @@ static bool aime_read(Nfc* nfc, NfcDevice* device) {
|
|||
}
|
||||
|
||||
error = mf_classic_poller_sync_read(nfc, &keys, data);
|
||||
if(error != MfClassicErrorNone) {
|
||||
if(error == MfClassicErrorNotPresent) {
|
||||
FURI_LOG_W(TAG, "Failed to read data");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ static bool hid_read(Nfc* nfc, NfcDevice* device) {
|
|||
}
|
||||
|
||||
error = mf_classic_poller_sync_read(nfc, &keys, data);
|
||||
if(error != MfClassicErrorNone) {
|
||||
if(error == MfClassicErrorNotPresent) {
|
||||
FURI_LOG_W(TAG, "Failed to read data");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -135,14 +135,14 @@ static bool plantain_read(Nfc* nfc, NfcDevice* device) {
|
|||
}
|
||||
|
||||
error = mf_classic_poller_sync_read(nfc, &keys, data);
|
||||
if(error != MfClassicErrorNone) {
|
||||
if(error != MfClassicErrorNotPresent) {
|
||||
FURI_LOG_W(TAG, "Failed to read data");
|
||||
break;
|
||||
}
|
||||
|
||||
nfc_device_set_data(device, NfcProtocolMfClassic, data);
|
||||
|
||||
is_read = true;
|
||||
is_read = (error == MfClassicErrorNone);
|
||||
} while(false);
|
||||
|
||||
mf_classic_free(data);
|
||||
|
|
|
@ -137,14 +137,14 @@ static bool troika_read(Nfc* nfc, NfcDevice* device) {
|
|||
}
|
||||
|
||||
error = mf_classic_poller_sync_read(nfc, &keys, data);
|
||||
if(error != MfClassicErrorNone) {
|
||||
if(error == MfClassicErrorNotPresent) {
|
||||
FURI_LOG_W(TAG, "Failed to read data");
|
||||
break;
|
||||
}
|
||||
|
||||
nfc_device_set_data(device, NfcProtocolMfClassic, data);
|
||||
|
||||
is_read = true;
|
||||
is_read = (error == MfClassicErrorNone);
|
||||
} while(false);
|
||||
|
||||
mf_classic_free(data);
|
||||
|
|
|
@ -85,14 +85,14 @@ static bool two_cities_read(Nfc* nfc, NfcDevice* device) {
|
|||
}
|
||||
|
||||
error = mf_classic_poller_sync_read(nfc, &keys, data);
|
||||
if(error != MfClassicErrorNone) {
|
||||
if(error != MfClassicErrorNotPresent) {
|
||||
FURI_LOG_W(TAG, "Failed to read data");
|
||||
break;
|
||||
}
|
||||
|
||||
nfc_device_set_data(device, NfcProtocolMfClassic, data);
|
||||
|
||||
is_read = true;
|
||||
is_read = (error == MfClassicErrorNone);
|
||||
} while(false);
|
||||
|
||||
mf_classic_free(data);
|
||||
|
|
|
@ -39,6 +39,7 @@ typedef enum {
|
|||
MfClassicErrorNotPresent,
|
||||
MfClassicErrorProtocol,
|
||||
MfClassicErrorAuth,
|
||||
MfClassicErrorPartialRead,
|
||||
MfClassicErrorTimeout,
|
||||
} MfClassicError;
|
||||
|
||||
|
|
|
@ -475,19 +475,16 @@ MfClassicError
|
|||
|
||||
nfc_poller_stop(poller);
|
||||
|
||||
if(poller_context.error != MfClassicErrorNone) {
|
||||
error = poller_context.error;
|
||||
} else {
|
||||
const MfClassicData* mfc_data = nfc_poller_get_data(poller);
|
||||
uint8_t sectors_read = 0;
|
||||
uint8_t keys_found = 0;
|
||||
const MfClassicData* mfc_data = nfc_poller_get_data(poller);
|
||||
uint8_t sectors_read = 0;
|
||||
uint8_t keys_found = 0;
|
||||
|
||||
mf_classic_get_read_sectors_and_keys(mfc_data, §ors_read, &keys_found);
|
||||
if((sectors_read > 0) || (keys_found > 0)) {
|
||||
mf_classic_copy(data, mfc_data);
|
||||
} else {
|
||||
error = MfClassicErrorNotPresent;
|
||||
}
|
||||
mf_classic_get_read_sectors_and_keys(mfc_data, §ors_read, &keys_found);
|
||||
if((sectors_read == 0) && (keys_found == 0)) {
|
||||
error = MfClassicErrorNotPresent;
|
||||
} else {
|
||||
mf_classic_copy(data, mfc_data);
|
||||
error = mf_classic_is_card_read(mfc_data) ? MfClassicErrorNone : MfClassicErrorPartialRead;
|
||||
}
|
||||
|
||||
nfc_poller_free(poller);
|
||||
|
|
Loading…
Reference in a new issue