]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
changed -elf to -eabi in install-gnuarm4.sh ARMLIB suggestion
[proxmark3-svn] / client / cmdhfmf.c
index 2d1c76d50e15ea91a2e8a518740fa02ac24a7417..8c91e84cb9f3015510841735467a514a27bffae4 100644 (file)
@@ -712,7 +712,7 @@ int CmdHF14AMfChk(const char *Cmd)
 {\r
        FILE * f;\r
        char filename[256]={0};\r
-       uint8_t buf[13];\r
+       char buf[13];\r
        uint8_t *keyBlock = NULL, *p;\r
        uint8_t stKeyBlock = 20;\r
        \r
@@ -1218,6 +1218,85 @@ int CmdHF14AMfEKeyPrn(const char *Cmd)
        return 0;\r
 }\r
 \r
+int CmdHF14AMfCSetUID(const char *Cmd)\r
+{\r
+       uint8_t wipeCard = 0;\r
+       uint8_t uid[8];\r
+       uint8_t oldUid[8];\r
+       int res;\r
+\r
+       if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
+               PrintAndLog("Usage:  hf mf csetuid <UID 8 hex symbols> <w>");\r
+               PrintAndLog("sample:  hf mf csetuid 01020304 w");\r
+               PrintAndLog("Set UID for magic Chinese card (only works with!!!)");\r
+               PrintAndLog("If you want wipe card then add 'w' into command line. \n");\r
+               return 0;\r
+       }       \r
+\r
+       if (param_getchar(Cmd, 0) && param_gethex(Cmd, 0, uid, 8)) {\r
+               PrintAndLog("UID must include 8 HEX symbols");\r
+               return 1;\r
+       }\r
+\r
+       char ctmp = param_getchar(Cmd, 1);\r
+       if (ctmp == 'w' || ctmp == 'W') wipeCard = 1;\r
+       \r
+       PrintAndLog("--wipe card:%02x uid:%s", wipeCard, sprint_hex(uid, 4));\r
+\r
+       res = mfCSetUID(uid, oldUid, wipeCard);\r
+       if (res) {\r
+                       PrintAndLog("Can't set UID. error=%d", res);\r
+                       return 1;\r
+               }\r
+       \r
+       PrintAndLog("old UID:%s", sprint_hex(oldUid, 4));\r
+       return 0;\r
+}\r
+\r
+int CmdHF14AMfCSetBlk(const char *Cmd)\r
+{\r
+       uint8_t uid[8];\r
+       uint8_t memBlock[16];\r
+       uint8_t blockNo = 0;\r
+       int res;\r
+       memset(memBlock, 0x00, sizeof(memBlock));\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("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
+               return 0;\r
+       }       \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
+               return 1;\r
+       }\r
+\r
+       PrintAndLog("--block number:%02x data:%s", blockNo, sprint_hex(memBlock, 16));\r
+\r
+       res = mfCSetBlock(blockNo, memBlock, uid, 0);\r
+       if (res) {\r
+                       PrintAndLog("Can't write block. error=%d", res);\r
+                       return 1;\r
+               }\r
+       \r
+       PrintAndLog("UID:%s", sprint_hex(uid, 4));\r
+       return 0;\r
+}\r
+\r
+int CmdHF14AMfCLoad(const char *Cmd)\r
+{\r
+       return 0;\r
+}\r
+\r
 static command_t CommandTable[] =\r
 {\r
   {"help",             CmdHelp,                                1, "This help"},\r
@@ -1238,6 +1317,9 @@ static command_t CommandTable[] =
   {"esave",            CmdHF14AMfESave,                0, "Save to file emul dump"},\r
   {"ecfill",   CmdHF14AMfECFill,               0, "Fill simulator memory with help of keys from simulator"},\r
   {"ekeyprn",  CmdHF14AMfEKeyPrn,      0, "Print keys from simulator memory"},\r
+  {"csetuid",  CmdHF14AMfCSetUID,      0, "Set UID for magic Chinese card"},\r
+  {"csetblk",  CmdHF14AMfCSetBlk,      0, "Write block into magic Chinese card"},\r
+  {"cload",            CmdHF14AMfCLoad,                0, "(n/a)Load dump into magic Chinese card"},\r
   {NULL, NULL, 0, NULL}\r
 };\r
 \r
Impressum, Datenschutz