mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-07 16:48:15 +08:00
chg: hf mf setmod - uses NG
This commit is contained in:
parent
41acc98d87
commit
65ff4f0e92
5 changed files with 24 additions and 33 deletions
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue