X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/31b6e9af2beb26d7e78ab5f085f79fbb350e8f90..f5c5499ab80d650e549a006e75ce30922d5fa144:/client/mifarehost.c diff --git a/client/mifarehost.c b/client/mifarehost.c index 394d2471..2ce0b5e2 100644 --- a/client/mifarehost.c +++ b/client/mifarehost.c @@ -216,3 +216,32 @@ int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount) { return 0; } +int mfCSetUID(uint8_t *uid, uint8_t *oldUID, int wantWipe) { + uint8_t block0[16]; + memset(block0, 0, 16); + memcpy(block0, uid, 4); + block0[4] = block0[0]^block0[1]^block0[2]^block0[3]; // Mifare UID BCC + + return mfCSetBlock(0, block0, oldUID, wantWipe); +} + +int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, int wantWipe) { + uint8_t isOK = 0; + + UsbCommand c = {CMD_MIFARE_EML_CSETBLOCK, {wantWipe, 1, blockNo}}; + memcpy(c.d.asBytes, data, 16); + SendCommand(&c); + + UsbCommand * resp = WaitForResponseTimeout(CMD_ACK, 1500); + + if (resp != NULL) { + isOK = resp->arg[0] & 0xff; + PrintAndLog("isOk:%02x", isOK); + memcpy(uid, resp->d.asBytes, 4); + if (!isOK) return 2; + } else { + PrintAndLog("Command execute timeout"); + return 1; + } + return 0; +}