]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
added: readed blocks (password mode) into tag.sectors[]. 'lf hitag sim' simulates...
[proxmark3-svn] / client / cmdhfmf.c
index 98006d4165c2bef9c630f285110d5496e0b6c6eb..f3f243c440f94ab60a9aa4efb226c8e2c0e9b08f 100644 (file)
@@ -984,10 +984,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 +1024,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 +1261,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 +1388,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
@@ -1542,6 +1526,13 @@ int CmdHF14AMfCSave(const char *Cmd) {
 }\r
 \r
 int CmdHF14AMfSniff(const char *Cmd){\r
+       // params\r
+       bool wantLogToFile = 0;\r
+       bool wantDecrypt = 0;\r
+       //bool wantSaveToEml = 0; TODO\r
+       bool wantSaveToEmlFile = 0;\r
+\r
+       //var \r
        int res = 0;\r
        int len = 0;\r
        int blockLen = 0;\r
@@ -1551,16 +1542,31 @@ 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
        \r
        if (param_getchar(Cmd, 0) == 'h') {\r
-               PrintAndLog("Usage:  hf mf sniff ");\r
-               PrintAndLog("        sample: hf mf sniff ");\r
+               PrintAndLog("It continuously get data from the field and saves it to: log, emulator, emulator file.");\r
+               PrintAndLog("You can specify:");\r
+               PrintAndLog("    l - save encrypted sequence to logfile `uid.log`");\r
+               PrintAndLog("    d - decrypt sequence and put it to log file `uid.log`");\r
+               PrintAndLog(" n/a   e - decrypt sequence, collect read and write commands and save the result of the sequence to emulator memory");\r
+               PrintAndLog("    r - decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`");\r
+               PrintAndLog("Usage:  hf mf sniff [l][d][e][r]");\r
+               PrintAndLog("  sample: hf mf sniff l d e");\r
                return 0;\r
        }       \r
        \r
+       for (int i = 0; i < 4; i++) {\r
+               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; TODO\r
+               if (ctmp == 'f' || ctmp == 'F') wantSaveToEmlFile = true;\r
+       }\r
+       \r
        printf("-------------------------------------------------------------------------\n");\r
        printf("Executing command. \n");\r
        printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");\r
@@ -1604,16 +1610,26 @@ 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
                                                memcpy(uid, bufPtr + 2, 7);\r
                                                memcpy(atqa, bufPtr + 2 + 7, 2);\r
                                                sak = bufPtr[11];\r
+                                               \r
                                                PrintAndLog("tag select uid:%s atqa:%02x %02x sak:0x%02x", sprint_hex(uid, 7), atqa[0], atqa[1], sak);\r
+                                               if (wantLogToFile) {\r
+                                                       FillFileNameByUID(logHexFileName, uid, ".log", 7);\r
+                                                       AddLogCurrentDT(logHexFileName);\r
+                                               }                                               \r
+                                               if (wantDecrypt) mfTraceInit(uid, atqa, sak, wantSaveToEmlFile);\r
                                        } 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, parity, wantSaveToEmlFile);\r
                                        }\r
                                        bufPtr += len;\r
                                        num++;\r
Impressum, Datenschutz