]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
Merge pull request #102 from marshmellow42/master
[proxmark3-svn] / client / cmdhfmf.c
index 5f2e8dec33bf1ccef336000204d1cf0d258c299c..aa3b66dc64b960f2bf855b62257f904b26196a4e 100644 (file)
@@ -547,7 +547,7 @@ int CmdHF14AMfNested(const char *Cmd)
        uint8_t trgKeyType = 0;\r
        uint8_t SectorsCnt = 0;\r
        uint8_t key[6] = {0, 0, 0, 0, 0, 0};\r
-       uint8_t keyBlock[13*6];\r
+       uint8_t keyBlock[14*6];\r
        uint64_t key64 = 0;\r
        bool transferToEml = false;\r
        \r
@@ -1202,7 +1202,7 @@ int CmdHF14AMfELoad(const char *Cmd)
        \r
        if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;\r
 \r
-       fnameptr += len;\r
+       fnameptr += len-4;\r
 \r
        sprintf(fnameptr, ".eml"); \r
        \r
@@ -1311,7 +1311,7 @@ int CmdHF14AMfESave(const char *Cmd)
                for (j = 0; j < 7; j++, fnameptr += 2)\r
                        sprintf(fnameptr, "%02X", buf[j]); \r
        } else {\r
-               fnameptr += len;\r
+               fnameptr += len-4;\r
        }\r
 \r
        // add file extension\r
@@ -1499,16 +1499,16 @@ int CmdHF14AMfCSetUID(const char *Cmd)
 \r
 int CmdHF14AMfCSetBlk(const char *Cmd)\r
 {\r
-       uint8_t uid[8] = {0x00};\r
        uint8_t memBlock[16] = {0x00};\r
        uint8_t blockNo = 0;\r
+       bool wipeCard = FALSE;\r
        int res;\r
 \r
        if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
-               PrintAndLog("Usage:  hf mf csetblk <block number> <block data (32 hex symbols)>");\r
+               PrintAndLog("Usage:  hf mf csetblk <block number> <block data (32 hex symbols)> [w]");\r
                PrintAndLog("sample:  hf mf csetblk 1 01020304050607080910111213141516");\r
-               PrintAndLog("Set block data for magic Chinese card (only works with!!!)");\r
-               PrintAndLog("If you want wipe card then add 'w' into command line. \n");\r
+               PrintAndLog("Set block data for magic Chinese card (only works with such cards)");\r
+               PrintAndLog("If you also want wipe the card then add 'w' at the end of the command line");\r
                return 0;\r
        }       \r
 \r
@@ -1519,14 +1519,15 @@ int CmdHF14AMfCSetBlk(const char *Cmd)
                return 1;\r
        }\r
 \r
+       char ctmp = param_getchar(Cmd, 2);\r
+       wipeCard = (ctmp == 'w' || ctmp == 'W');\r
        PrintAndLog("--block number:%2d data:%s", blockNo, sprint_hex(memBlock, 16));\r
 \r
-       res = mfCSetBlock(blockNo, memBlock, uid, 0, CSETBLOCK_SINGLE_OPER);\r
+       res = mfCSetBlock(blockNo, memBlock, NULL, wipeCard, CSETBLOCK_SINGLE_OPER);\r
        if (res) {\r
-                       PrintAndLog("Can't write block. error=%d", res);\r
-                       return 1;\r
-               }\r
-       \r
+               PrintAndLog("Can't write block. error=%d", res);\r
+               return 1;\r
+       }\r
        return 0;\r
 }\r
 \r
@@ -1574,7 +1575,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
                if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;\r
 \r
                memcpy(filename, Cmd, len);\r
-               fnameptr += len;\r
+               fnameptr += len-4;\r
 \r
                sprintf(fnameptr, ".eml"); \r
        \r
@@ -1591,6 +1592,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
                        memset(buf, 0, sizeof(buf));\r
                        \r
                        if (fgets(buf, sizeof(buf), f) == NULL) {\r
+                               fclose(f);\r
                                PrintAndLog("File reading error.");\r
                                return 2;\r
                        }\r
@@ -1599,6 +1601,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
                                if(strlen(buf) && feof(f))\r
                                        break;\r
                                PrintAndLog("File content error. Block data must include 32 HEX symbols");\r
+                               fclose(f);\r
                                return 2;\r
                        }\r
                        for (i = 0; i < 32; i += 2)\r
@@ -1637,7 +1640,7 @@ int CmdHF14AMfCGetBlk(const char *Cmd) {
        if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
                PrintAndLog("Usage:  hf mf cgetblk <block number>");\r
                PrintAndLog("sample:  hf mf cgetblk 1");\r
-               PrintAndLog("Get block data from magic Chinese card (only works with!!!)\n");\r
+               PrintAndLog("Get block data from magic Chinese card (only works with such cards)\n");\r
                return 0;\r
        }       \r
 \r
@@ -1664,7 +1667,7 @@ int CmdHF14AMfCGetSc(const char *Cmd) {
        if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
                PrintAndLog("Usage:  hf mf cgetsc <sector number>");\r
                PrintAndLog("sample:  hf mf cgetsc 0");\r
-               PrintAndLog("Get sector data from magic Chinese card (only works with!!!)\n");\r
+               PrintAndLog("Get sector data from magic Chinese card (only works with such cards)\n");\r
                return 0;\r
        }       \r
 \r
Impressum, Datenschutz