]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
CHG: change the shields..
[proxmark3-svn] / client / cmdhfmf.c
index af96543d58be2284bcdf35e09d768d4dcaaff63a..7cc07e96f62e485c330c77ce6f359184261f80ca 100644 (file)
@@ -94,12 +94,14 @@ int usage_hf14_hardnested(void){
        PrintAndLog("      w    acquire nonces and write them to binary file nonces.bin");\r
        PrintAndLog("      s    slower acquisition (required by some non standard cards)");\r
        PrintAndLog("      r    read nonces.bin and start attack");\r
        PrintAndLog("      w    acquire nonces and write them to binary file nonces.bin");\r
        PrintAndLog("      s    slower acquisition (required by some non standard cards)");\r
        PrintAndLog("      r    read nonces.bin and start attack");\r
+       PrintAndLog("      t    tests?");\r
        PrintAndLog(" ");\r
        PrintAndLog("samples:");\r
        PrintAndLog("      hf mf hardnested 0 A FFFFFFFFFFFF 4 A");\r
        PrintAndLog("      hf mf hardnested 0 A FFFFFFFFFFFF 4 A w");\r
        PrintAndLog("      hf mf hardnested 0 A FFFFFFFFFFFF 4 A w s");\r
        PrintAndLog("      hf mf hardnested r");\r
        PrintAndLog(" ");\r
        PrintAndLog("samples:");\r
        PrintAndLog("      hf mf hardnested 0 A FFFFFFFFFFFF 4 A");\r
        PrintAndLog("      hf mf hardnested 0 A FFFFFFFFFFFF 4 A w");\r
        PrintAndLog("      hf mf hardnested 0 A FFFFFFFFFFFF 4 A w s");\r
        PrintAndLog("      hf mf hardnested r");\r
+       PrintAndLog("      hf mf hardnested r a0a1a2a3a4a5");\r
        PrintAndLog(" ");\r
        PrintAndLog("Add the known target key to check if it is present in the remaining key space:");\r
        PrintAndLog("      sample5: hf mf hardnested 0 A A0A1A2A3A4A5 4 A FFFFFFFFFFFF");\r
        PrintAndLog(" ");\r
        PrintAndLog("Add the known target key to check if it is present in the remaining key space:");\r
        PrintAndLog("      sample5: hf mf hardnested 0 A A0A1A2A3A4A5 4 A FFFFFFFFFFFF");\r
@@ -218,8 +220,7 @@ END:
        return 0;\r
 }\r
 \r
        return 0;\r
 }\r
 \r
-int CmdHF14AMfWrBl(const char *Cmd)\r
-{\r
+int CmdHF14AMfWrBl(const char *Cmd) {\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
@@ -268,8 +269,7 @@ int CmdHF14AMfWrBl(const char *Cmd)
        return 0;\r
 }\r
 \r
        return 0;\r
 }\r
 \r
-int CmdHF14AMfRdBl(const char *Cmd)\r
-{\r
+int CmdHF14AMfRdBl(const char *Cmd) {\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
@@ -317,8 +317,7 @@ int CmdHF14AMfRdBl(const char *Cmd)
   return 0;\r
 }\r
 \r
   return 0;\r
 }\r
 \r
-int CmdHF14AMfRdSc(const char *Cmd)\r
-{\r
+int CmdHF14AMfRdSc(const char *Cmd) {\r
        int i;\r
        uint8_t sectorNo = 0;\r
        uint8_t keyType = 0;\r
        int i;\r
        uint8_t sectorNo = 0;\r
        uint8_t keyType = 0;\r
@@ -375,8 +374,7 @@ int CmdHF14AMfRdSc(const char *Cmd)
   return 0;\r
 }\r
 \r
   return 0;\r
 }\r
 \r
-uint8_t FirstBlockOfSector(uint8_t sectorNo)\r
-{\r
+uint8_t FirstBlockOfSector(uint8_t sectorNo) {\r
        if (sectorNo < 32) {\r
                return sectorNo * 4;\r
        } else {\r
        if (sectorNo < 32) {\r
                return sectorNo * 4;\r
        } else {\r
@@ -384,8 +382,7 @@ uint8_t FirstBlockOfSector(uint8_t sectorNo)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
-uint8_t NumBlocksPerSector(uint8_t sectorNo)\r
-{\r
+uint8_t NumBlocksPerSector(uint8_t sectorNo) {\r
        if (sectorNo < 32) {\r
                return 4;\r
        } else {\r
        if (sectorNo < 32) {\r
                return 4;\r
        } else {\r
@@ -942,7 +939,7 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
        \r
        char ctmp;\r
        ctmp = param_getchar(Cmd, 0);\r
        \r
        char ctmp;\r
        ctmp = param_getchar(Cmd, 0);\r
-       if (ctmp != 'H' && ctmp != 'h' ) return usage_hf14_hardnested();\r
+       if (ctmp == 'H' || ctmp == 'h' ) return usage_hf14_hardnested();\r
        if (ctmp != 'R' && ctmp != 'r' && ctmp != 'T' && ctmp != 't' && strlen(Cmd) < 20) return usage_hf14_hardnested();\r
        \r
        bool know_target_key = false;\r
        if (ctmp != 'R' && ctmp != 'r' && ctmp != 'T' && ctmp != 't' && strlen(Cmd) < 20) return usage_hf14_hardnested();\r
        \r
        bool know_target_key = false;\r
@@ -1008,9 +1005,9 @@ int CmdHF14AMfNestedHard(const char *Cmd) {
                        trgBlockNo, \r
                        trgKeyType?'B':'A', \r
                        trgkey[0], trgkey[1], trgkey[2], trgkey[3], trgkey[4], trgkey[5],\r
                        trgBlockNo, \r
                        trgKeyType?'B':'A', \r
                        trgkey[0], trgkey[1], trgkey[2], trgkey[3], trgkey[4], trgkey[5],\r
-                       know_target_key?"":" (not set)",\r
-                       nonce_file_write?"write":nonce_file_read?"read":"none",\r
-                       slow?"Yes":"No",\r
+                       know_target_key ? "" : " (not set)",\r
+                       nonce_file_write ? "write": nonce_file_read ? "read" : "none",\r
+                       slow ? "Yes" : "No",\r
                        tests);\r
 \r
        int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key?trgkey:NULL, nonce_file_read, nonce_file_write, slow, tests);\r
                        tests);\r
 \r
        int16_t isOK = mfnestedhard(blockNo, keyType, key, trgBlockNo, trgKeyType, know_target_key?trgkey:NULL, nonce_file_read, nonce_file_write, slow, tests);\r
@@ -1204,6 +1201,8 @@ int CmdHF14AMfChk(const char *Cmd) {
        \r
        // time\r
        clock_t t1 = clock();\r
        \r
        // time\r
        clock_t t1 = clock();\r
+       time_t start, end;\r
+       time(&start);\r
        \r
        // check keys.\r
        for (trgKeyType = !keyType;  trgKeyType < 2;  (keyType==2) ? (++trgKeyType) : (trgKeyType=2) ) {\r
        \r
        // check keys.\r
        for (trgKeyType = !keyType;  trgKeyType < 2;  (keyType==2) ? (++trgKeyType) : (trgKeyType=2) ) {\r
@@ -1231,12 +1230,14 @@ int CmdHF14AMfChk(const char *Cmd) {
                }\r
        }\r
        t1 = clock() - t1;\r
                }\r
        }\r
        t1 = clock() - t1;\r
+       time(&end);\r
+       unsigned long elapsed_time = difftime(end, start);      \r
        if ( t1 > 0 )\r
        if ( t1 > 0 )\r
-               printf("\nTime in checkkeys: %.0f ticks\n", (float)t1);\r
+               PrintAndLog("\nTime in checkkeys: %.0f ticks %u seconds\n", (float)t1, elapsed_time);\r
 \r
 \r
+               \r
        // 20160116 If Sector A is found, but not Sector B,  try just reading it of the tag?\r
        if ( keyType != 1 ) {\r
        // 20160116 If Sector A is found, but not Sector B,  try just reading it of the tag?\r
        if ( keyType != 1 ) {\r
-               \r
                PrintAndLog("testing to read key B...");\r
                for (i = 0; i < SectorsCnt; i++) {\r
                        // KEY A  but not KEY B\r
                PrintAndLog("testing to read key B...");\r
                for (i = 0; i < SectorsCnt; i++) {\r
                        // KEY A  but not KEY B\r
Impressum, Datenschutz