- if (strlen(Cmd)<3) {
- PrintAndLog("Usage: hf 14 mfwrbl <block number> <key A/B> <key (12 hex symbols)> <block data (32 hex symbols)>");
- PrintAndLog(" sample: hf 14a mfwrbl 0 A FFFFFFFFFFFF 000102030405060708090A0B0C0D0E0F");
- return 0;
- }
-
- blockNo = param_get8(Cmd, 0);
- cmdp = param_getchar(Cmd, 1);
- if (cmdp == 0x00) {
- PrintAndLog("Key type must be A or B");
- return 1;
- }
- if (cmdp != 'A' && cmdp != 'a') keyType = 1;
- if (param_gethex(Cmd, 2, key, 12)) {
- PrintAndLog("Key must include 12 HEX symbols");
- return 1;
- }
- if (param_gethex(Cmd, 3, bldata, 32)) {
- PrintAndLog("Block data must include 32 HEX symbols");
- return 1;
- }
- PrintAndLog("--block no:%02x key type:%02x key:%s", blockNo, keyType, sprint_hex(key, 6));
- PrintAndLog("--data: %s", sprint_hex(bldata, 16));
-
- UsbCommand c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}};
- memcpy(c.d.asBytes, key, 6);
- memcpy(c.d.asBytes + 10, bldata, 16);
- SendCommand(&c);
- UsbCommand * resp = WaitForResponseTimeout(CMD_ACK, 1500);
-
- if (resp != NULL) {
- uint8_t isOK = resp->arg[0] & 0xff;
-
- PrintAndLog("isOk:%02x", isOK);
- } else {
- PrintAndLog("Command execute timeout");
- }
-
- return 0;
-}
-
-int CmdHF14AMfRdBl(const char *Cmd)
-{
- uint8_t blockNo = 0;
- uint8_t keyType = 0;
- uint8_t key[6] = {0, 0, 0, 0, 0, 0};
-
- char cmdp = 0x00;
-
-
- if (strlen(Cmd)<3) {
- PrintAndLog("Usage: hf 14 mfrdbl <block number> <key A/B> <key (12 hex symbols)>");
- PrintAndLog(" sample: hf 14a mfrdbl 0 A FFFFFFFFFFFF ");
- return 0;
- }
-
- blockNo = param_get8(Cmd, 0);
- cmdp = param_getchar(Cmd, 1);
- if (cmdp == 0x00) {
- PrintAndLog("Key type must be A or B");
- return 1;
- }
- if (cmdp != 'A' && cmdp != 'a') keyType = 1;
- if (param_gethex(Cmd, 2, key, 12)) {
- PrintAndLog("Key must include 12 HEX symbols");
- return 1;
- }
- PrintAndLog("--block no:%02x key type:%02x key:%s ", blockNo, keyType, sprint_hex(key, 6));
-
- UsbCommand c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}};
- memcpy(c.d.asBytes, key, 6);
- SendCommand(&c);
- UsbCommand * resp = WaitForResponseTimeout(CMD_ACK, 1500);
-
- if (resp != NULL) {
- uint8_t isOK = resp->arg[0] & 0xff;
- uint8_t * data = resp->d.asBytes;
-
- if (isOK)
- PrintAndLog("isOk:%02x data:%s", isOK, sprint_hex(data, 16));
- else
- PrintAndLog("isOk:%02x", isOK);
- } else {
- PrintAndLog("Command execute timeout");
- }
-
- return 0;
-}
-
-int CmdHF14AMfRdSc(const char *Cmd)
-{
- int i;
- uint8_t sectorNo = 0;
- uint8_t keyType = 0;
- uint8_t key[6] = {0, 0, 0, 0, 0, 0};
-
- uint8_t isOK = 0;
- uint8_t * data = NULL;
-
- char cmdp = 0x00;
-
- if (strlen(Cmd)<3) {
- PrintAndLog("Usage: hf 14 mfrdsc <sector number> <key A/B> <key (12 hex symbols)>");
- PrintAndLog(" sample: hf 14a mfrdsc 0 A FFFFFFFFFFFF ");