diff --git a/armsrc/appmain.c b/armsrc/appmain.c index c28d1448c..8e4b1933b 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1066,7 +1066,7 @@ static void PacketReceived(PacketCommandNG *packet) { // SniffMifare(packet->oldarg[0]); // break; case CMD_MIFARE_SETMOD: - MifareSetMod(packet->oldarg[0], packet->data.asBytes); + MifareSetMod(packet->data.asBytes); break; //mifare desfire case CMD_MIFARE_DESFIRE_READBL: diff --git a/armsrc/apps.h b/armsrc/apps.h index e7d600b8c..045dc907b 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -163,7 +163,7 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1); void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); // Work with "magic Chinese" card void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); void MifareCIdent(); // is "magic chinese" card? -void MifareSetMod(uint8_t mod, uint8_t *key); +void MifareSetMod(uint8_t *datain); void MifareUSetPwd(uint8_t arg0, uint8_t *datain); void OnSuccessMagic(); void OnErrorMagic(uint8_t reason); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 0ce2a1554..43b06593b 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1999,11 +1999,13 @@ void OnErrorMagic(uint8_t reason) { OnSuccessMagic(); } -void MifareSetMod(uint8_t mod, uint8_t *key) { - uint64_t ui64Key = bytes_to_num(key, 6); +void MifareSetMod(uint8_t *datain) { + + uint8_t mod = datain[0]; + uint64_t ui64Key = bytes_to_num(datain + 1, 6); // variables - uint8_t isOK = 0; + uint16_t isOK = PM3_EFATAL; uint8_t uid[10] = {0}; uint32_t cuid = 0; struct Crypto1State mpcs = {0, 0}; @@ -2042,14 +2044,15 @@ void MifareSetMod(uint8_t mod, uint8_t *key) { break; } - isOK = 1; + isOK = PM3_SUCCESS; break; } crypto1_destroy(pcs); LED_B_ON(); - reply_old(CMD_ACK, isOK, 0, 0, 0, 0); + reply_ng(CMD_MIFARE_SETMOD, isOK, NULL, 0); + LED_B_OFF(); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index d39581ea2..4a39109c3 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -3205,19 +3205,25 @@ static int CmdHf14AMfSetMod(const char *Cmd) { return 1; } + uint8_t data[7]; + data[0] = mod; + memcpy(data+1, key, 6); + clearCommandBuffer(); - SendCommandOLD(CMD_MIFARE_SETMOD, mod, 0, 0, key, 6); + SendCommandNG(CMD_MIFARE_SETMOD, data, sizeof(data)); PacketResponseNG resp; - if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { - uint8_t ok = resp.oldarg[0] & 0xff; - PrintAndLogEx(SUCCESS, "isOk:%02x", ok); - if (!ok) - PrintAndLogEx(FAILED, "Failed."); + if (WaitForResponseTimeout(CMD_MIFARE_SETMOD, &resp, 1500)) { + + if (resp.status == PM3_SUCCESS) + PrintAndLogEx(SUCCESS, "Success"); + else + PrintAndLogEx(FAILED, "Failed"); + } else { PrintAndLogEx(WARNING, "Command execute timeout"); } - return 0; + return PM3_SUCCESS; } // Mifare NACK bug detection diff --git a/client/mifare/mifarehost.c b/client/mifare/mifarehost.c index f0184cd72..d1ae6a595 100644 --- a/client/mifare/mifarehost.c +++ b/client/mifare/mifarehost.c @@ -912,26 +912,8 @@ int detect_classic_nackbug(bool verbose) { if (verbose) PrintAndLogEx(SUCCESS, "press pm3-button on the Proxmark3 device to abort both Proxmark3 and client.\n"); - // for nice animation - bool term = !isatty(STDIN_FILENO); -#if defined(__linux__) || (__APPLE__) - char star[] = {'-', '\\', '|', '/'}; - uint8_t staridx = 0; -#endif - while (true) { - - if (term) { - printf("."); - } else { - printf( -#if defined(__linux__) || (__APPLE__) - _GREEN_("\e[s%c\e[u"), star[(staridx++ % 4) ] -#else - "." -#endif - ); - } + printf("."); fflush(stdout); if (ukbhit()) { int gc = getchar();