Skip to content

Commit

Permalink
revert gen2(not ready for release yet)
Browse files Browse the repository at this point in the history
will be reverted until found issues (dict attack, wipe) are fixed
and apply only latest gen4 changes by Leptopt1los
  • Loading branch information
xMasterX committed Mar 23, 2024
1 parent 6f19c6d commit 2a30138
Show file tree
Hide file tree
Showing 48 changed files with 608 additions and 3,527 deletions.
Binary file removed base_pack/nfc_magic/assets/DolphinSuccess_91x55.png
Binary file not shown.
Binary file not shown.
57 changes: 29 additions & 28 deletions base_pack/nfc_magic/lib/magic/nfc_magic_scanner.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "nfc_magic_scanner.h"

#include "core/check.h"
#include "protocols/gen1a/gen1a_poller.h"
#include "protocols/gen2/gen2_poller.h"
#include "protocols/gen4/gen4.h"
#include "protocols/gen4/gen4_poller.h"
#include <nfc/nfc_poller.h>

Expand All @@ -18,7 +19,8 @@ struct NfcMagicScanner {
NfcMagicScannerSessionState session_state;
NfcMagicProtocol current_protocol;

uint32_t gen4_password;
Gen4Password gen4_password;
Gen4* gen4_data;
bool magic_protocol_detected;

NfcMagicScannerCallback callback;
Expand All @@ -43,17 +45,19 @@ NfcMagicScanner* nfc_magic_scanner_alloc(Nfc* nfc) {

NfcMagicScanner* instance = malloc(sizeof(NfcMagicScanner));
instance->nfc = nfc;
instance->gen4_data = gen4_alloc();

return instance;
}

void nfc_magic_scanner_free(NfcMagicScanner* instance) {
furi_assert(instance);

gen4_free(instance->gen4_data);
free(instance);
}

void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, uint32_t password) {
void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, Gen4Password password) {
furi_assert(instance);

instance->gen4_password = password;
Expand All @@ -66,33 +70,24 @@ static int32_t nfc_magic_scanner_worker(void* context) {
furi_assert(instance->session_state == NfcMagicScannerSessionStateActive);

while(instance->session_state == NfcMagicScannerSessionStateActive) {
do {
if(instance->current_protocol == NfcMagicProtocolGen1) {
instance->magic_protocol_detected = gen1a_poller_detect(instance->nfc);
if(instance->magic_protocol_detected) {
break;
}
} else if(instance->current_protocol == NfcMagicProtocolGen4) {
Gen4PollerError error = gen4_poller_detect(instance->nfc, instance->gen4_password);
if(instance->current_protocol == NfcMagicProtocolGen1) {
instance->magic_protocol_detected = gen1a_poller_detect(instance->nfc);
} else if(instance->current_protocol == NfcMagicProtocolGen4) {
gen4_reset(instance->gen4_data);
Gen4 gen4_data;
Gen4PollerError error =
gen4_poller_detect(instance->nfc, instance->gen4_password, &gen4_data);
if(error == Gen4PollerErrorProtocol) {
NfcMagicScannerEvent event = {
.type = NfcMagicScannerEventTypeDetectedNotMagic,
};
instance->callback(event, instance->context);
break;
} else {
instance->magic_protocol_detected = (error == Gen4PollerErrorNone);
if(instance->magic_protocol_detected) {
break;
}
} else if(instance->current_protocol == NfcMagicProtocolGen2) {
Gen2PollerError error = gen2_poller_detect(instance->nfc);
instance->magic_protocol_detected = (error == Gen2PollerErrorNone);
if(instance->magic_protocol_detected) {
break;
}
} else if(instance->current_protocol == NfcMagicProtocolClassic) {
NfcPoller* poller = nfc_poller_alloc(instance->nfc, NfcProtocolMfClassic);
instance->magic_protocol_detected = nfc_poller_detect(poller);
nfc_poller_free(poller);
if(instance->magic_protocol_detected) {
break;
}
gen4_copy(instance->gen4_data, &gen4_data);
}
} while(false);
}

if(instance->magic_protocol_detected) {
NfcMagicScannerEvent event = {
Expand Down Expand Up @@ -162,3 +157,9 @@ void nfc_magic_scanner_stop(NfcMagicScanner* instance) {
instance->callback = NULL;
instance->context = NULL;
}

Gen4* nfc_magic_scanner_get_gen4_data(NfcMagicScanner* instance) {
furi_assert(instance);

return instance->gen4_data;
}
5 changes: 4 additions & 1 deletion base_pack/nfc_magic/lib/magic/nfc_magic_scanner.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "protocols/gen4/gen4.h"
#include <nfc/nfc.h>
#include "protocols/nfc_magic_protocols.h"

Expand Down Expand Up @@ -30,7 +31,7 @@ NfcMagicScanner* nfc_magic_scanner_alloc(Nfc* nfc);

void nfc_magic_scanner_free(NfcMagicScanner* instance);

void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, uint32_t password);
void nfc_magic_scanner_set_gen4_password(NfcMagicScanner* instance, Gen4Password password);

void nfc_magic_scanner_start(
NfcMagicScanner* instance,
Expand All @@ -39,6 +40,8 @@ void nfc_magic_scanner_start(

void nfc_magic_scanner_stop(NfcMagicScanner* instance);

Gen4* nfc_magic_scanner_get_gen4_data(NfcMagicScanner* instance);

#ifdef __cplusplus
}
#endif
178 changes: 0 additions & 178 deletions base_pack/nfc_magic/lib/magic/protocols/gen2/crypto1.c

This file was deleted.

45 changes: 0 additions & 45 deletions base_pack/nfc_magic/lib/magic/protocols/gen2/crypto1.h

This file was deleted.

Loading

0 comments on commit 2a30138

Please sign in to comment.