@@ -315,7 +315,7 @@ uint32_t mifare_nested_worker_predict_delay(
315
315
uint32_t nt1 , nt2 , i = 0 , previous = 0 , prng_delay = 0 , zero_prng_value = 65565 , repeat = 0 ;
316
316
317
317
if (tries > 10 ) {
318
- return 2 ; // To many tries, fallback to hardnested
318
+ return 2 ; // Too many tries, fallback to hardnested
319
319
}
320
320
321
321
// This part of attack is my attempt to implement it on Flipper.
@@ -618,13 +618,9 @@ bool mifare_nested_worker_check_initial_keys(
618
618
}
619
619
}
620
620
}
621
-
622
- if (sector == sector_count - 1 && key_block == 0 ) {
623
- return false;
624
- }
625
621
}
626
622
627
- return true ;
623
+ return * key_block ;
628
624
}
629
625
630
626
void mifare_nested_worker_collect_nonces_static (MifareNestedWorker * mifare_nested_worker ) {
@@ -686,7 +682,7 @@ void mifare_nested_worker_collect_nonces_static(MifareNestedWorker* mifare_neste
686
682
}
687
683
688
684
FURI_LOG_I (
689
- TAG , "Using %c key for block %lu: %06llX " , !found_key_type ? 'A' : 'B' , key_block , key );
685
+ TAG , "Using %c key for block %lu: %012llX " , !found_key_type ? 'A' : 'B' , key_block , key );
690
686
691
687
nonces -> tries = 1 ;
692
688
@@ -783,6 +779,8 @@ void mifare_nested_worker_collect_nonces_hard(MifareNestedWorker* mifare_nested_
783
779
uint32_t found_key_type = 0 ;
784
780
uint32_t key_block = 0 ;
785
781
uint32_t sector_count = 0 ;
782
+ uint32_t cuid = 0 ;
783
+ furi_hal_nfc_activate_nfca (200 , & cuid );
786
784
787
785
FURI_LOG_I (TAG , "Running hardnested attack" );
788
786
FuriString * tag_info = furi_string_alloc_printf ("Tag UID: " );
@@ -829,7 +827,7 @@ void mifare_nested_worker_collect_nonces_hard(MifareNestedWorker* mifare_nested_
829
827
}
830
828
831
829
FURI_LOG_I (
832
- TAG , "Using %c key for block %lu: %06llX " , !found_key_type ? 'A' : 'B' , key_block , key );
830
+ TAG , "Using %c key for block %lu: %012llX " , !found_key_type ? 'A' : 'B' , key_block , key );
833
831
834
832
FuriHalNfcTxRxContext tx_rx = {};
835
833
nonces -> tries = 1 ;
@@ -880,17 +878,16 @@ void mifare_nested_worker_collect_nonces_hard(MifareNestedWorker* mifare_nested_
880
878
FSAM_READ_WRITE ,
881
879
FSOM_CREATE_ALWAYS );
882
880
883
- FuriString * cuid = furi_string_alloc_printf ("CUID: " );
884
- mifare_nested_worker_write_uid_string (& data , cuid );
885
881
FuriString * header = furi_string_alloc_printf (
886
- "Filetype: Flipper Nested Nonces File\nVersion: %s\nNote: you will need desktop app to recover keys: %s\n%s \n" ,
882
+ "Filetype: Flipper Nested Nonces File\nVersion: %s\nNote: you will need desktop app to recover keys: %s\nKey %c cuid 0x%08lx sec %u \n" ,
887
883
NESTED_NONCE_FORMAT_VERSION ,
888
884
NESTED_RECOVER_KEYS_GITHUB_LINK ,
889
- furi_string_get_cstr (cuid ));
885
+ !key_type ? 'A' : 'B' ,
886
+ cuid ,
887
+ sector );
890
888
891
889
stream_write_string (file_stream , header );
892
890
furi_string_free (header );
893
- furi_string_free (cuid );
894
891
895
892
while (!info -> collected &&
896
893
mifare_nested_worker -> state == MifareNestedWorkerStateCollecting ) {
@@ -1037,7 +1034,7 @@ void mifare_nested_worker_collect_nonces(MifareNestedWorker* mifare_nested_worke
1037
1034
}
1038
1035
1039
1036
FURI_LOG_I (
1040
- TAG , "Using %c key for block %lu: %06llX " , !found_key_type ? 'A' : 'B' , key_block , key );
1037
+ TAG , "Using %c key for block %lu: %012llX " , !found_key_type ? 'A' : 'B' , key_block , key );
1041
1038
1042
1039
while (mifare_nested_worker -> state == MifareNestedWorkerStateCollecting ) {
1043
1040
FuriHalNfcTxRxContext tx_rx = {};
@@ -1278,7 +1275,7 @@ bool* mifare_nested_worker_check_keys_exists(
1278
1275
1279
1276
for (uint32_t i = 0 ; i < key_count ; i ++ ) {
1280
1277
old_keys [i ] = false;
1281
- key_strings [i ] = furi_string_alloc_printf ("%06llX \n" , keys [i ]);
1278
+ key_strings [i ] = furi_string_alloc_printf ("%012llX \n" , keys [i ]);
1282
1279
}
1283
1280
1284
1281
while (mifare_nested_worker -> state == MifareNestedWorkerStateValidating ) {
@@ -1467,7 +1464,8 @@ void mifare_nested_worker_check_keys(MifareNestedWorker* mifare_nested_worker) {
1467
1464
}
1468
1465
1469
1466
if (result == NestedCheckKeyValid ) {
1470
- FURI_LOG_I (TAG , "Found valid %c key for sector %u: %06llX" , key_type , sector , key );
1467
+ FURI_LOG_I (
1468
+ TAG , "Found valid %c key for sector %u: %012llX" , key_type , sector , key );
1471
1469
bool exists = false;
1472
1470
1473
1471
for (uint8_t i = 0 ; i < keys_count ; i ++ ) {
@@ -1525,7 +1523,7 @@ void mifare_nested_worker_check_keys(MifareNestedWorker* mifare_nested_worker) {
1525
1523
for (uint8_t i = 0 ; i < keys_count ; i ++ ) {
1526
1524
if (keys [i ] == (uint64_t )-1 ) continue ;
1527
1525
1528
- FuriString * key_string = furi_string_alloc_printf ("%06llX \n" , keys [i ]);
1526
+ FuriString * key_string = furi_string_alloc_printf ("%012llX \n" , keys [i ]);
1529
1527
1530
1528
mifare_nested_worker_write_key (storage , key_string );
1531
1529
FURI_LOG_I (TAG , "Added new key: %s" , furi_string_get_cstr (key_string ));
0 commit comments