]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
fix hf search (#908)
[proxmark3-svn] / client / cmdhfmf.c
index 9ecf99fbe831c1b51061921f25188e153e409e7e..22e6efac643716b1536d9f95844733c91d6a3830 100644 (file)
@@ -707,17 +707,17 @@ int CmdHF14AMfNested(const char *Cmd)
        if (cmdp == 'o') { // ------------------------------------  one sector working\r
                PrintAndLog("--target block no:%3d, target key type:%c ", trgBlockNo, trgKeyType?'B':'A');\r
                int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true);\r
        if (cmdp == 'o') { // ------------------------------------  one sector working\r
                PrintAndLog("--target block no:%3d, target key type:%c ", trgBlockNo, trgKeyType?'B':'A');\r
                int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true);\r
-               if (isOK) {\r
+               if (isOK < 0) {\r
                        switch (isOK) {\r
                                case -1 : PrintAndLog("Error: No response from Proxmark.\n"); break;\r
                                case -2 : PrintAndLog("Button pressed. Aborted.\n"); break;\r
                                case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break;\r
                        switch (isOK) {\r
                                case -1 : PrintAndLog("Error: No response from Proxmark.\n"); break;\r
                                case -2 : PrintAndLog("Button pressed. Aborted.\n"); break;\r
                                case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break;\r
-                               default : PrintAndLog("Unknown Error.\n");\r
+                               default : PrintAndLog("Unknown Error (%d)\n", isOK);\r
                        }\r
                        return 2;\r
                }\r
                key64 = bytes_to_num(keyBlock, 6);\r
                        }\r
                        return 2;\r
                }\r
                key64 = bytes_to_num(keyBlock, 6);\r
-               if (key64) {\r
+               if (!isOK) {\r
                        PrintAndLog("Found valid key:%012" PRIx64, key64);\r
 \r
                        // transfer key to the emulator\r
                        PrintAndLog("Found valid key:%012" PRIx64, key64);\r
 \r
                        // transfer key to the emulator\r
@@ -792,12 +792,12 @@ int CmdHF14AMfNested(const char *Cmd)
                                        if (e_sector[sectorNo].foundKey[trgKeyType]) continue;\r
                                        PrintAndLog("-----------------------------------------------");\r
                                        int16_t isOK = mfnested(blockNo, keyType, key, FirstBlockOfSector(sectorNo), trgKeyType, keyBlock, calibrate);\r
                                        if (e_sector[sectorNo].foundKey[trgKeyType]) continue;\r
                                        PrintAndLog("-----------------------------------------------");\r
                                        int16_t isOK = mfnested(blockNo, keyType, key, FirstBlockOfSector(sectorNo), trgKeyType, keyBlock, calibrate);\r
-                                       if(isOK) {\r
+                                       if(isOK < 0) {\r
                                                switch (isOK) {\r
                                                        case -1 : PrintAndLog("Error: No response from Proxmark.\n"); break;\r
                                                        case -2 : PrintAndLog("Button pressed. Aborted.\n"); break;\r
                                                        case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break;\r
                                                switch (isOK) {\r
                                                        case -1 : PrintAndLog("Error: No response from Proxmark.\n"); break;\r
                                                        case -2 : PrintAndLog("Button pressed. Aborted.\n"); break;\r
                                                        case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break;\r
-                                                       default : PrintAndLog("Unknown Error.\n");\r
+                                                       default : PrintAndLog("Unknown Error (%d)\n", isOK);\r
                                                }\r
                                                free(e_sector);\r
                                                return 2;\r
                                                }\r
                                                free(e_sector);\r
                                                return 2;\r
@@ -808,7 +808,7 @@ int CmdHF14AMfNested(const char *Cmd)
                                        iterations++;\r
 \r
                                        key64 = bytes_to_num(keyBlock, 6);\r
                                        iterations++;\r
 \r
                                        key64 = bytes_to_num(keyBlock, 6);\r
-                                       if (key64) {\r
+                                       if (!isOK) {\r
                                                PrintAndLog("Found valid key:%012" PRIx64, key64);\r
                                                e_sector[sectorNo].foundKey[trgKeyType] = 1;\r
                                                e_sector[sectorNo].Key[trgKeyType] = key64;\r
                                                PrintAndLog("Found valid key:%012" PRIx64, key64);\r
                                                e_sector[sectorNo].foundKey[trgKeyType] = 1;\r
                                                e_sector[sectorNo].Key[trgKeyType] = key64;\r
@@ -2060,7 +2060,7 @@ int CmdHF14AMfEKeyPrn(const char *Cmd)
                                PrintAndLog("error get block %d", FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1);\r
                                break;\r
                        }\r
                                PrintAndLog("error get block %d", FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1);\r
                                break;\r
                        }\r
-                       fwrite(data+6, 1, 6, fkeys);\r
+                       fwrite(data, 1, 6, fkeys);\r
                }\r
                for(i = 0; i < numSectors; i++) {\r
                        if (mfEmlGetMem(data, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1)) {\r
                }\r
                for(i = 0; i < numSectors; i++) {\r
                        if (mfEmlGetMem(data, FirstBlockOfSector(i) + NumBlocksPerSector(i) - 1, 1)) {\r
Impressum, Datenschutz