+int CmdHF14AMfCWipe(const char *Cmd)\r
+{\r
+ int res, gen = 0;\r
+ int numBlocks = 16 * 4;\r
+ bool wipeCard = false;\r
+ bool fillCard = false;\r
+ \r
+ if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
+ PrintAndLog("Usage: hf mf cwipe [card size] [w] [f]");\r
+ PrintAndLog("sample: hf mf cwipe 1 w f");\r
+ PrintAndLog("[card size]: 0 = 320 bytes (Mifare Mini), 1 = 1K (default), 2 = 2K, 4 = 4K");\r
+ PrintAndLog("w - Wipe magic Chinese card (only works with gen:1a cards)");\r
+ PrintAndLog("f - Fill the card with default data and keys (works with gen:1a and gen:1b cards only)");\r
+ return 0;\r
+ }\r
+\r
+ gen = mfCIdentify();\r
+ if ((gen != 1) && (gen != 2)) \r
+ return 1;\r
+ \r
+ numBlocks = ParamCardSizeBlocks(param_getchar(Cmd, 0));\r
+\r
+ char cmdp = 0;\r
+ while(param_getchar(Cmd, cmdp) != 0x00){\r
+ switch(param_getchar(Cmd, cmdp)) {\r
+ case 'w':\r
+ case 'W':\r
+ wipeCard = 1;\r
+ break;\r
+ case 'f':\r
+ case 'F':\r
+ fillCard = 1;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ cmdp++;\r
+ }\r
+\r
+ if (!wipeCard && !fillCard) \r
+ wipeCard = true;\r
+\r
+ PrintAndLog("--blocks count:%2d wipe:%c fill:%c", numBlocks, (wipeCard)?'y':'n', (fillCard)?'y':'n');\r
+\r
+ if (gen == 2) {\r
+ /* generation 1b magic card */\r
+ if (wipeCard) {\r
+ PrintAndLog("WARNING: can't wipe magic card 1b generation");\r
+ }\r
+ res = mfCWipe(numBlocks, true, false, fillCard); \r
+ } else {\r
+ /* generation 1a magic card by default */\r
+ res = mfCWipe(numBlocks, false, wipeCard, fillCard); \r
+ }\r
+\r
+ if (res) {\r
+ PrintAndLog("Can't wipe. error=%d", res);\r
+ return 1;\r
+ }\r
+ PrintAndLog("OK");\r
+ return 0;\r
+}\r
+\r