Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfc: Attempt to detect MFP 2k in MFC mode #4053

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/nfc/protocols/mf_classic/mf_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ static const MfClassicFeatures mf_classic_features[MfClassicTypeNum] = {
.full_name = "Mifare Classic 4K",
.type_name = "4K",
},
[MfClassicTypePlus2k] =
{
// TODO: need to validate whether 17 or 18 sectors are accessible
.sectors_total = 17,
.blocks_total = 544,
.full_name = "Mifare Plus 2K",
.type_name = "Plus 2K",
},
};

const NfcDeviceBase nfc_device_mf_classic = {
Expand Down
1 change: 1 addition & 0 deletions lib/nfc/protocols/mf_classic/mf_classic.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef enum {
MfClassicTypeMini,
MfClassicType1k,
MfClassicType4k,
MfClassicTypePlus2k,

MfClassicTypeNum,
} MfClassicType;
Expand Down
12 changes: 12 additions & 0 deletions lib/nfc/protocols/mf_classic/mf_classic_poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ NfcCommand mf_classic_poller_handler_detect_type(MfClassicPoller* instance) {
instance->state = MfClassicPollerStateStart;
instance->current_type_check = MfClassicType4k;
FURI_LOG_D(TAG, "4K detected");
} else {
instance->current_type_check = MfClassicTypePlus2k;
}
} else if(instance->current_type_check == MfClassicTypePlus2k) {
// Second-last block in sector 16, which may exist if said sector is not in SL3 mode
MfClassicError error =
mf_classic_poller_get_nt(instance, 66, MfClassicKeyTypeA, NULL, false);
if(error == MfClassicErrorNone) {
instance->data->type = MfClassicTypePlus2k;
instance->state = MfClassicPollerStateStart;
instance->current_type_check = MfClassicType4k;
FURI_LOG_D(TAG, "Plus 2K detected");
} else {
instance->current_type_check = MfClassicType1k;
}
Expand Down