X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/8556b852ed769280d1b63054ab1bd08fa19b746a..0675f200e6d52728457664e5e127af2496af9bdd:/client/mifarehost.c diff --git a/client/mifarehost.c b/client/mifarehost.c index f52fb602..529c248d 100644 --- a/client/mifarehost.c +++ b/client/mifarehost.c @@ -10,6 +10,7 @@ #include #include +#include #include "mifarehost.h" @@ -215,3 +216,27 @@ int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount) { return 0; } +int mfCSetUID(uint8_t *uid, uint8_t *oldUID, int wantWipe) { + uint8_t isOK = 0; + 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 + + UsbCommand c = {CMD_MIFARE_EML_CSETBLOCK, {wantWipe, 1, 0}}; + memcpy(c.d.asBytes, block0, 16); + SendCommand(&c); + + UsbCommand * resp = WaitForResponseTimeout(CMD_ACK, 1500); + + if (resp != NULL) { + isOK = resp->arg[0] & 0xff; + PrintAndLog("isOk:%02x", isOK); + memcpy(oldUID, resp->d.asBytes, 4); + if (!isOK) return 2; + } else { + PrintAndLog("Command execute timeout"); + return 1; + } + return 0; +}