]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
making USB CDC branch
[proxmark3-svn] / client / cmdhfmf.c
index c27ba56cbf184b05deaea598adc77c229c703744..dff5db37e08e526687e816480e66880082ae2ca0 100644 (file)
@@ -71,17 +71,22 @@ start:
        if (isOK != 1) return 1;\r
        \r
        // execute original function from util nonce2key\r
-       if (nonce2key(uid, nt, par_list, ks_list, &r_key)) return 2;\r
-       printf("------------------------------------------------------------------\n");\r
-       PrintAndLog("Key found:%012llx \n", r_key);\r
+       if (nonce2key(uid, nt, par_list, ks_list, &r_key))\r
+       {\r
+               isOK = 2;\r
+               PrintAndLog("Key not found (lfsr_common_prefix list is null). Nt=%08x", nt);    \r
+       } else {\r
+               printf("------------------------------------------------------------------\n");\r
+               PrintAndLog("Key found:%012llx \n", r_key);\r
 \r
-       num_to_bytes(r_key, 6, keyBlock);\r
-       isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key);\r
+               num_to_bytes(r_key, 6, keyBlock);\r
+               isOK = mfCheckKeys(0, 0, 1, keyBlock, &r_key);\r
+       }\r
        if (!isOK) \r
                PrintAndLog("Found valid key:%012llx", r_key);\r
        else\r
        {\r
-               PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt); \r
+               if (isOK != 2) PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt);  \r
                c.arg[0] = nt;\r
                goto start;\r
        }\r
@@ -984,10 +989,6 @@ int CmdHF14AMfEGet(const char *Cmd)
        }       \r
        \r
        blockNo = param_get8(Cmd, 0);\r
-       if (blockNo >= 32 * 4 + 8 * 16) {\r
-               PrintAndLog("Block number must be in [0..255] as in MIFARE classic.");\r
-               return 1;\r
-       }\r
 \r
        PrintAndLog(" ");\r
        if (!mfEmlGetMem(data, blockNo, 3)) {\r
@@ -1028,10 +1029,6 @@ int CmdHF14AMfESet(const char *Cmd)
        }       \r
        \r
        blockNo = param_get8(Cmd, 0);\r
-       if (blockNo >= 32 * 4 + 8 * 16) {\r
-               PrintAndLog("Block number must be in [0..255] as in MIFARE classic.");\r
-               return 1;\r
-       }\r
        \r
        if (param_gethex(Cmd, 1, memBlock, 32)) {\r
                PrintAndLog("block data must include 32 HEX symbols");\r
@@ -1269,10 +1266,6 @@ int CmdHF14AMfCSetBlk(const char *Cmd)
        }       \r
 \r
        blockNo = param_get8(Cmd, 0);\r
-       if (blockNo >= 32 * 4 + 8 * 16) {\r
-               PrintAndLog("Block number must be in [0..255] as in MIFARE classic.");\r
-               return 1;\r
-       }\r
 \r
        if (param_gethex(Cmd, 1, memBlock, 32)) {\r
                PrintAndLog("block data must include 32 HEX symbols");\r
@@ -1400,10 +1393,6 @@ int CmdHF14AMfCGetBlk(const char *Cmd) {
        }       \r
 \r
        blockNo = param_get8(Cmd, 0);\r
-       if (blockNo >= 32 * 4 + 8 * 16) {\r
-               PrintAndLog("Block number must be in [0..255] as in MIFARE classic.");\r
-               return 1;\r
-       }\r
 \r
        PrintAndLog("--block number:%02x ", blockNo);\r
 \r
@@ -1543,9 +1532,9 @@ int CmdHF14AMfCSave(const char *Cmd) {
 \r
 int CmdHF14AMfSniff(const char *Cmd){\r
        // params\r
-       bool wantLogToFile = 1;\r
-       bool wantDecrypt = 1;\r
-       bool wantSaveToEml = 0;\r
+       bool wantLogToFile = 0;\r
+       bool wantDecrypt = 0;\r
+       //bool wantSaveToEml = 0; TODO\r
        bool wantSaveToEmlFile = 0;\r
 \r
        //var \r
@@ -1558,6 +1547,7 @@ int CmdHF14AMfSniff(const char *Cmd){
        uint8_t atqa[2];\r
        uint8_t sak;\r
        bool isTag;\r
+       uint32_t parity;\r
        uint8_t buf[3000];\r
        uint8_t * bufPtr = buf;\r
        memset(buf, 0x00, 3000);\r
@@ -1578,7 +1568,7 @@ int CmdHF14AMfSniff(const char *Cmd){
                char ctmp = param_getchar(Cmd, i);\r
                if (ctmp == 'l' || ctmp == 'L') wantLogToFile = true;\r
                if (ctmp == 'd' || ctmp == 'D') wantDecrypt = true;\r
-               if (ctmp == 'e' || ctmp == 'E') wantSaveToEml = true;\r
+               //if (ctmp == 'e' || ctmp == 'E') wantSaveToEml = true; TODO\r
                if (ctmp == 'f' || ctmp == 'F') wantSaveToEmlFile = true;\r
        }\r
        \r
@@ -1625,7 +1615,9 @@ int CmdHF14AMfSniff(const char *Cmd){
                                num = 0;\r
                                while (bufPtr - buf + 9 < blockLen) {\r
                                  isTag = bufPtr[3] & 0x80 ? true:false;\r
-                                       bufPtr += 8;\r
+                                       bufPtr += 4;\r
+                                       parity = *((uint32_t *)(bufPtr));\r
+                                       bufPtr += 4;\r
                                        len = bufPtr[0];\r
                                        bufPtr++;\r
                                        if ((len == 14) && (bufPtr[0] = 0xff) && (bufPtr[1] = 0xff)) {\r
@@ -1642,7 +1634,7 @@ int CmdHF14AMfSniff(const char *Cmd){
                                        } else {\r
                                                PrintAndLog("%s(%d):%s", isTag ? "TAG":"RDR", num, sprint_hex(bufPtr, len));\r
                                                if (wantLogToFile) AddLogHex(logHexFileName, isTag ? "TAG: ":"RDR: ", bufPtr, len);\r
-                                               if (wantDecrypt) mfTraceDecode(bufPtr, len, wantSaveToEmlFile);\r
+                                               if (wantDecrypt) mfTraceDecode(bufPtr, len, parity, wantSaveToEmlFile);\r
                                        }\r
                                        bufPtr += len;\r
                                        num++;\r
Impressum, Datenschutz