]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Fixes to Mifare nested function...
authorcaioxmag <caioxmag@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 1 Sep 2011 08:13:18 +0000 (08:13 +0000)
committercaioxmag <caioxmag@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Thu, 1 Sep 2011 08:13:18 +0000 (08:13 +0000)
client/cmdhfmf.c

index ed3394e5034f23545092ebcda432ea491b74189f..064aaaa5a80f5c0e65d35200fda522bd5ad623f6 100644 (file)
@@ -467,6 +467,8 @@ int CmdHF14AMfNested(const char *Cmd)
        \r
        int createDumpFile = 0;\r
        FILE *fkeys;\r
        \r
        int createDumpFile = 0;\r
        FILE *fkeys;\r
+       uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
+       uint8_t tempkey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
        \r
        char cmdp, ctmp;\r
 \r
        \r
        char cmdp, ctmp;\r
 \r
@@ -519,10 +521,12 @@ int CmdHF14AMfNested(const char *Cmd)
        }\r
 \r
        ctmp = param_getchar(Cmd, 4);\r
        }\r
 \r
        ctmp = param_getchar(Cmd, 4);\r
-       if (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
+       if              (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
+       else if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1;\r
+       \r
        ctmp = param_getchar(Cmd, 6);\r
        transferToEml |= (ctmp == 't' || ctmp == 'T');\r
        ctmp = param_getchar(Cmd, 6);\r
        transferToEml |= (ctmp == 't' || ctmp == 'T');\r
-       createDumpFile |= (ctmp == 'd' || ctmp == 'D');\r
+       transferToEml |= (ctmp == 'd' || ctmp == 'D');\r
        \r
        PrintAndLog("--block no:%02x key type:%02x key:%s etrans:%d", blockNo, keyType, sprint_hex(key, 6), transferToEml);\r
        if (cmdp == 'o')\r
        \r
        PrintAndLog("--block no:%02x key type:%02x key:%s etrans:%d", blockNo, keyType, sprint_hex(key, 6), transferToEml);\r
        if (cmdp == 'o')\r
@@ -558,8 +562,8 @@ int CmdHF14AMfNested(const char *Cmd)
                } else {\r
                        PrintAndLog("No valid key found");\r
                }\r
                } else {\r
                        PrintAndLog("No valid key found");\r
                }\r
-       } else  // ------------------------------------  multiple sectors working\r
-       {\r
+       }\r
+       else { // ------------------------------------  multiple sectors working\r
                blDiff = blockNo % 4;\r
                PrintAndLog("Block shift=%d", blDiff);\r
                e_sector = calloc(SectorsCnt, sizeof(sector));\r
                blDiff = blockNo % 4;\r
                PrintAndLog("Block shift=%d", blDiff);\r
                e_sector = calloc(SectorsCnt, sizeof(sector));\r
@@ -587,7 +591,6 @@ int CmdHF14AMfNested(const char *Cmd)
                        }\r
                } \r
                \r
                        }\r
                } \r
                \r
-               \r
                // nested sectors\r
                iterations = 0;\r
                PrintAndLog("nested...");\r
                // nested sectors\r
                iterations = 0;\r
                PrintAndLog("nested...");\r
@@ -634,17 +637,31 @@ int CmdHF14AMfNested(const char *Cmd)
                        }               \r
                }\r
                \r
                        }               \r
                }\r
                \r
+               // Create dump file\r
                if (createDumpFile) {\r
                        if ((fkeys = fopen("dumpkeys.bin","wb")) == NULL) { \r
                                PrintAndLog("Could not create file keys.bin");\r
                                free(e_sector);\r
                                return 1;\r
                        }\r
                if (createDumpFile) {\r
                        if ((fkeys = fopen("dumpkeys.bin","wb")) == NULL) { \r
                                PrintAndLog("Could not create file keys.bin");\r
                                free(e_sector);\r
                                return 1;\r
                        }\r
+                       PrintAndLog("Printing keys to bynary file dumpkeys.bin...");\r
                        for(i=0; i<16; i++) {\r
                        for(i=0; i<16; i++) {\r
-                               fwrite ( e_sector[i].Key, sizeof(e_sector[i].Key[0]), 1, fkeys );\r
+                               if (e_sector[i].foundKey[0]){\r
+                                       num_to_bytes(e_sector[i].Key[0], 6, tempkey);\r
+                                       fwrite ( tempkey, 1, 6, fkeys );\r
+                               }\r
+                               else{\r
+                                       fwrite ( &standart, 1, 6, fkeys );\r
+                               }\r
                        }\r
                        for(i=0; i<16; i++) {\r
                        }\r
                        for(i=0; i<16; i++) {\r
-                               fwrite ( e_sector[i].Key, sizeof(e_sector[i].Key[1]), 1, fkeys );\r
+                               if (e_sector[i].foundKey[1]){\r
+                                       num_to_bytes(e_sector[i].Key[1], 6, tempkey);\r
+                                       fwrite ( tempkey, 1, 6, fkeys );\r
+                               }\r
+                               else{\r
+                                       fwrite ( &standart, 1, 6, fkeys );\r
+                               }\r
                        }\r
                        fclose(fkeys);\r
                }\r
                        }\r
                        fclose(fkeys);\r
                }\r
Impressum, Datenschutz