From 472800e8471e49bedaa947418ed787039317cfff Mon Sep 17 00:00:00 2001 From: merlokk Date: Wed, 20 Sep 2017 18:40:56 +0300 Subject: [PATCH] added gen1b flag to hf mf cwipe command --- armsrc/mifarecmd.c | 13 +++++++++---- client/cmdhfmf.c | 4 ++-- client/mifarehost.c | 5 +++-- client/mifarehost.h | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 166910e9..4bdf48bf 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1185,10 +1185,15 @@ void MifareCWipe(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){ // var byte_t isOK = 0; uint32_t numBlocks = arg0; - uint8_t needWipe = arg1; - uint8_t needFill = arg2; - bool gen1b = FALSE; - + // cmdParams: + // bit 0 - wipe gen1a + // bit 1 - fill card with default data + // bit 2 - gen1a = 0, gen1b = 1 + uint8_t cmdParams = arg1; + bool needWipe = cmdParams & 0x01; + bool needFill = cmdParams & 0x02; + bool gen1b = cmdParams & 0x04; + uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE]; uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE]; diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 759cf0b5..b3af9120 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -1914,10 +1914,10 @@ int CmdHF14AMfCWipe(const char *Cmd) if (wipeCard) { PrintAndLog("WARNING: can't wipe magic card 1b generation"); } - res = mfCWipe(numBlocks, false, fillCard); + res = mfCWipe(numBlocks, true, false, fillCard); } else { /* generation 1a magic card by default */ - res = mfCWipe(numBlocks, wipeCard, fillCard); + res = mfCWipe(numBlocks, false, wipeCard, fillCard); } if (res) { diff --git a/client/mifarehost.c b/client/mifarehost.c index 061f9ba2..8a840d47 100644 --- a/client/mifarehost.c +++ b/client/mifarehost.c @@ -452,9 +452,10 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, bool wantWipe, uin return 0; } -int mfCWipe(uint32_t numSectors, bool wantWipe, bool wantFill) { +int mfCWipe(uint32_t numSectors, bool gen1b, bool wantWipe, bool wantFill) { uint8_t isOK = 0; - UsbCommand c = {CMD_MIFARE_CWIPE, {numSectors, wantWipe, wantFill}}; + uint8_t cmdParams = wantWipe + wantFill * 0x02 + gen1b * 0x04; + UsbCommand c = {CMD_MIFARE_CWIPE, {numSectors, cmdParams, 0}}; SendCommand(&c); UsbCommand resp; diff --git a/client/mifarehost.h b/client/mifarehost.h index 9e00e141..34793a29 100644 --- a/client/mifarehost.h +++ b/client/mifarehost.h @@ -33,7 +33,7 @@ extern int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint extern int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount); extern int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount); -extern int mfCWipe(uint32_t numSectors, bool wantWipe, bool wantFill); +extern int mfCWipe(uint32_t numSectors, bool gen1b, bool wantWipe, bool wantFill); extern int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID); extern int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, bool wantWipe, uint8_t params); extern int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);