at v192 3.3 kB view raw
1diff --git a/src/mfoc.c b/src/mfoc.c 2index 0cb917d..195de68 100644 3--- a/src/mfoc.c 4+++ b/src/mfoc.c 5@@ -93,8 +93,8 @@ int main(int argc, char *const argv[]) 6 {0x58, 0x7e, 0xe5, 0xf9, 0x35, 0x0f}, 7 {0xa0, 0x47, 0x8c, 0xc3, 0x90, 0x91}, 8 {0x53, 0x3c, 0xb6, 0xc7, 0x23, 0xf6}, 9- {0x8f, 0xd0, 0xa4, 0xf2, 0x56, 0xe9} 10- 11+ {0x8f, 0xd0, 0xa4, 0xf2, 0x56, 0xe9}, 12+ {0xb4, 0xc1, 0x32, 0x43, 0x9e, 0xef} 13 }; 14 15 mftag t; 16@@ -219,12 +219,31 @@ int main(int argc, char *const argv[]) 17 goto error; 18 } 19 20- // Save tag's block size (b4K) 21- t.b4K = (t.nt.nti.nai.abtAtqa[1] == 0x02); 22 t.authuid = (uint32_t) bytes_to_num(t.nt.nti.nai.abtUid + t.nt.nti.nai.szUidLen - 4, 4); 23 24- t.num_blocks = (t.b4K) ? 0xff : 0x3f; 25- t.num_sectors = t.b4K ? NR_TRAILERS_4k : NR_TRAILERS_1k; 26+ // Get Mifare Classic type from SAK 27+ // see http://www.nxp.com/documents/application_note/AN10833.pdf Section 3.2 28+ switch (t.nt.nti.nai.btSak) 29+ { 30+ case 0x08: 31+ printf("Found Mifare Classic 1k tag\n"); 32+ t.num_sectors = NR_TRAILERS_1k; 33+ t.num_blocks = NR_BLOCKS_1k; 34+ break; 35+ case 0x09: 36+ printf("Found Mifare Classic Mini tag\n"); 37+ t.num_sectors = NR_TRAILERS_MINI; 38+ t.num_blocks = NR_BLOCKS_MINI; 39+ break; 40+ case 0x18: 41+ printf("Found Mifare Classic 4k tag\n"); 42+ t.num_sectors = NR_TRAILERS_4k; 43+ t.num_blocks = NR_BLOCKS_4k; 44+ break; 45+ defaul: 46+ ERR("Cannot determine card type from SAK"); 47+ goto error; 48+ } 49 50 t.sectors = (void *) calloc(t.num_sectors, sizeof(sector)); 51 if (t.sectors == NULL) { 52@@ -564,7 +583,7 @@ void usage(FILE *stream, int errno) 53 fprintf(stream, " k try the specified key in addition to the default keys\n"); 54 // fprintf(stream, " D number of distance probes, default is 20\n"); 55 // fprintf(stream, " S number of sets with keystreams, default is 5\n"); 56- fprintf(stream, " P number of probes per sector, instead of default of 20\n"); 57+ fprintf(stream, " P number of probes per sector, instead of default of 150\n"); 58 fprintf(stream, " T nonce tolerance half-range, instead of default of 20\n (i.e., 40 for the total range, in both directions)\n"); 59 // fprintf(stream, " s specify the list of sectors to crack, for example -s 0,1,3,5\n"); 60 fprintf(stream, " O file in which the card contents will be written (REQUIRED)\n"); 61diff --git a/src/mfoc.h b/src/mfoc.h 62index b411670..532e834 100644 63--- a/src/mfoc.h 64+++ b/src/mfoc.h 65@@ -2,11 +2,21 @@ 66 #define TRY_KEYS 50 67 68 // Number of trailers == number of sectors 69-// 16x64b = 16 70+// Mifare Classic 1k 16x64b = 16 71 #define NR_TRAILERS_1k (16) 72-// 32x64b + 8*256b = 40 73+// Mifare Classic Mini 74+#define NR_TRAILERS_MINI (5) 75+// Mifare Classic 4k 32x64b + 8*256b = 40 76 #define NR_TRAILERS_4k (40) 77 78+// Number of blocks 79+// Mifare Classic 1k 80+#define NR_BLOCKS_1k 0x3f 81+// Mifare Classic Mini 82+#define NR_BLOCKS_MINI 0x13 83+// Mifare Classic 4k 84+#define NR_BLOCKS_4k 0xff 85+ 86 #define MAX_FRAME_LEN 264 87 88 // Used for counting nonce distances, explore [nd-value, nd+value] 89@@ -46,7 +56,6 @@ typedef struct { 90 uint8_t num_sectors; 91 uint8_t num_blocks; 92 uint32_t authuid; 93- bool b4K; 94 } mftag; 95 96 typedef struct {