X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/0675f200e6d52728457664e5e127af2496af9bdd..f5c5499ab80d650e549a006e75ce30922d5fa144:/client/cmdhfmf.c diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 9928cb1b..8c91e84c 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -1255,6 +1255,40 @@ int CmdHF14AMfCSetUID(const char *Cmd) int CmdHF14AMfCSetBlk(const char *Cmd) { + uint8_t uid[8]; + uint8_t memBlock[16]; + uint8_t blockNo = 0; + int res; + memset(memBlock, 0x00, sizeof(memBlock)); + + if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') { + PrintAndLog("Usage: hf mf csetblk "); + PrintAndLog("sample: hf mf csetblk 1 01020304050607080910111213141516"); + PrintAndLog("Set block data for magic Chinese card (only works with!!!)"); + PrintAndLog("If you want wipe card then add 'w' into command line. \n"); + return 0; + } + + blockNo = param_get8(Cmd, 0); + if (blockNo >= 32 * 4 + 8 * 16) { + PrintAndLog("Block number must be in [0..255] as in MIFARE classic."); + return 1; + } + + if (param_gethex(Cmd, 1, memBlock, 32)) { + PrintAndLog("block data must include 32 HEX symbols"); + return 1; + } + + PrintAndLog("--block number:%02x data:%s", blockNo, sprint_hex(memBlock, 16)); + + res = mfCSetBlock(blockNo, memBlock, uid, 0); + if (res) { + PrintAndLog("Can't write block. error=%d", res); + return 1; + } + + PrintAndLog("UID:%s", sprint_hex(uid, 4)); return 0; } @@ -1284,7 +1318,7 @@ static command_t CommandTable[] = {"ecfill", CmdHF14AMfECFill, 0, "Fill simulator memory with help of keys from simulator"}, {"ekeyprn", CmdHF14AMfEKeyPrn, 0, "Print keys from simulator memory"}, {"csetuid", CmdHF14AMfCSetUID, 0, "Set UID for magic Chinese card"}, - {"csetblk", CmdHF14AMfCSetBlk, 0, "(n/a)Write block into magic Chinese card"}, + {"csetblk", CmdHF14AMfCSetBlk, 0, "Write block into magic Chinese card"}, {"cload", CmdHF14AMfCLoad, 0, "(n/a)Load dump into magic Chinese card"}, {NULL, NULL, 0, NULL} };