added mfCWipe and CmdHF14AMfCWipe functions

This commit is contained in:
merlokk 2017-09-19 18:57:48 +03:00
commit 0957f6690f
4 changed files with 58 additions and 0 deletions

View file

@ -1867,6 +1867,58 @@ int CmdHF14AMfCSetUID(const char *Cmd)
return 0;
}
int ParamGetCardSize(const char c) {
int numSectors = 16;
switch (c) {
case '0' : numSectors = 5; break;
case '2' : numSectors = 32; break;
case '4' : numSectors = 40; break;
default: numSectors = 16;
}
return numSectors;
}
int CmdHF14AMfCWipe(const char *Cmd)
{
int res, gen = 0;
char ctmp;
int numSectors = 16;
bool wipeCard = false;
bool setCard = false;
if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {
PrintAndLog("Usage: hf mf cwipe <card size> [w]");
PrintAndLog("sample: hf mf cwipe 1 w s");
PrintAndLog("w - Wipe for magic Chinese card (only works with such cards)");
PrintAndLog("p - Put default data to the card ");
return 0;
}
gen = mfCIdentify();
char cardSize = param_getchar(Cmd, 1);
numSectors = ParamGetCardSize(cardSize);
ctmp = param_getchar(Cmd, 2);
wipeCard = (ctmp == 'w' || ctmp == 'W');
setCard = (ctmp == 'p' || ctmp == 'P');
PrintAndLog("--sectors count:%2d ", numSectors);
if (gen == 2) {
/* generation 1b magic card */
res = mfCWipe(numSectors, wipeCard, setCard); // wipeCard, CSETBLOCK_SINGLE_OPER | CSETBLOCK_MAGIC_1B
} else {
/* generation 1a magic card by default */
res = mfCWipe(numSectors, wipeCard, setCard); // wipeCard, CSETBLOCK_SINGLE_OPER
}
if (res) {
PrintAndLog("Can't wipe. error=%d", res);
return 1;
}
return 0;
}
int CmdHF14AMfCSetBlk(const char *Cmd)
{
uint8_t memBlock[16] = {0x00};

View file

@ -34,6 +34,7 @@ extern int CmdHF14AMfELoad(const char* cmd);
extern int CmdHF14AMfESave(const char* cmd);
extern int CmdHF14AMfECFill(const char* cmd);
extern int CmdHF14AMfEKeyPrn(const char* cmd);
extern int CmdHF14AMfCWipe(const char* cmd);
extern int CmdHF14AMfCSetUID(const char* cmd);
extern int CmdHF14AMfCSetBlk(const char* cmd);
extern int CmdHF14AMfCGetBlk(const char* cmd);

View file

@ -452,6 +452,10 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, bool wantWipe, uin
return 0;
}
int mfCWipe(uint8_t numSectors, bool wantWipe, bool wantSet) {
return 0;
}
int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, bool wantWipe, bool wantFill) {
uint8_t oldblock0[16] = {0x00};
uint8_t block0[16] = {0x00};

View file

@ -33,6 +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(uint8_t numSectors, bool wantWipe, bool wantSet);
extern int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, bool wantWipe, bool wantFill);
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);