mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07: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]);
|
// SniffMifare(packet->oldarg[0]);
|
||||||
// break;
|
// break;
|
||||||
case CMD_MIFARE_SETMOD:
|
case CMD_MIFARE_SETMOD:
|
||||||
MifareSetMod(packet->oldarg[0], packet->data.asBytes);
|
MifareSetMod(packet->data.asBytes);
|
||||||
break;
|
break;
|
||||||
//mifare desfire
|
//mifare desfire
|
||||||
case CMD_MIFARE_DESFIRE_READBL:
|
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 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 MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain);
|
||||||
void MifareCIdent(); // is "magic chinese" card?
|
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 MifareUSetPwd(uint8_t arg0, uint8_t *datain);
|
||||||
void OnSuccessMagic();
|
void OnSuccessMagic();
|
||||||
void OnErrorMagic(uint8_t reason);
|
void OnErrorMagic(uint8_t reason);
|
||||||
|
|
|
@ -1999,11 +1999,13 @@ void OnErrorMagic(uint8_t reason) {
|
||||||
OnSuccessMagic();
|
OnSuccessMagic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MifareSetMod(uint8_t mod, uint8_t *key) {
|
void MifareSetMod(uint8_t *datain) {
|
||||||
uint64_t ui64Key = bytes_to_num(key, 6);
|
|
||||||
|
uint8_t mod = datain[0];
|
||||||
|
uint64_t ui64Key = bytes_to_num(datain + 1, 6);
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
uint8_t isOK = 0;
|
uint16_t isOK = PM3_EFATAL;
|
||||||
uint8_t uid[10] = {0};
|
uint8_t uid[10] = {0};
|
||||||
uint32_t cuid = 0;
|
uint32_t cuid = 0;
|
||||||
struct Crypto1State mpcs = {0, 0};
|
struct Crypto1State mpcs = {0, 0};
|
||||||
|
@ -2042,14 +2044,15 @@ void MifareSetMod(uint8_t mod, uint8_t *key) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
isOK = 1;
|
isOK = PM3_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
crypto1_destroy(pcs);
|
crypto1_destroy(pcs);
|
||||||
|
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
reply_old(CMD_ACK, isOK, 0, 0, 0, 0);
|
reply_ng(CMD_MIFARE_SETMOD, isOK, NULL, 0);
|
||||||
|
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
|
|
@ -3205,19 +3205,25 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t data[7];
|
||||||
|
data[0] = mod;
|
||||||
|
memcpy(data+1, key, 6);
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_MIFARE_SETMOD, mod, 0, 0, key, 6);
|
SendCommandNG(CMD_MIFARE_SETMOD, data, sizeof(data));
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
if (WaitForResponseTimeout(CMD_MIFARE_SETMOD, &resp, 1500)) {
|
||||||
uint8_t ok = resp.oldarg[0] & 0xff;
|
|
||||||
PrintAndLogEx(SUCCESS, "isOk:%02x", ok);
|
if (resp.status == PM3_SUCCESS)
|
||||||
if (!ok)
|
PrintAndLogEx(SUCCESS, "Success");
|
||||||
PrintAndLogEx(FAILED, "Failed.");
|
else
|
||||||
|
PrintAndLogEx(FAILED, "Failed");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||||
}
|
}
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mifare NACK bug detection
|
// Mifare NACK bug detection
|
||||||
|
|
|
@ -912,26 +912,8 @@ int detect_classic_nackbug(bool verbose) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PrintAndLogEx(SUCCESS, "press pm3-button on the Proxmark3 device to abort both Proxmark3 and client.\n");
|
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) {
|
while (true) {
|
||||||
|
printf(".");
|
||||||
if (term) {
|
|
||||||
printf(".");
|
|
||||||
} else {
|
|
||||||
printf(
|
|
||||||
#if defined(__linux__) || (__APPLE__)
|
|
||||||
_GREEN_("\e[s%c\e[u"), star[(staridx++ % 4) ]
|
|
||||||
#else
|
|
||||||
"."
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
}
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (ukbhit()) {
|
if (ukbhit()) {
|
||||||
int gc = getchar();
|
int gc = getchar();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue