mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
Chg 'hf 14a info' - static/fixed nonce detection
This commit is contained in:
parent
07b3b6ed4e
commit
a6a48f0e6d
6 changed files with 86 additions and 0 deletions
|
@ -1251,6 +1251,10 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
MifareU_Otp_Tearoff();
|
||||
break;
|
||||
}
|
||||
case CMD_HF_MIFARE_STATIC_NONCE: {
|
||||
MifareHasStaticNonce();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_NFCBARCODE
|
||||
|
|
|
@ -2057,6 +2057,57 @@ OUT:
|
|||
BigBuf_Clear_ext(false);
|
||||
}
|
||||
|
||||
void MifareHasStaticNonce() {
|
||||
|
||||
// variables
|
||||
int retval = PM3_SUCCESS, len;
|
||||
|
||||
uint32_t nt = 0 ;
|
||||
uint8_t rec[1] = {0x00};
|
||||
uint8_t recpar[1] = {0x00};
|
||||
uint8_t *uid = BigBuf_malloc(10);
|
||||
uint8_t data[1] = {0x00};
|
||||
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
pcs = &mpcs;
|
||||
iso14a_card_select_t card_info;
|
||||
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!iso14443a_select_card(uid, &card_info, NULL, true, 0, true)) {
|
||||
retval = PM3_ESOFT;
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
// Transmit MIFARE_CLASSIC_AUTH
|
||||
len = mifare_sendcmd_short(pcs, false, 0x60, 0, rec, recpar, NULL);
|
||||
if (len != 4) {
|
||||
retval = PM3_ESOFT;
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
// Save the tag nonce (nt)
|
||||
if (nt == bytes_to_num(rec, 4)) {
|
||||
data[0]++;
|
||||
}
|
||||
|
||||
nt = bytes_to_num(rec, 4);
|
||||
|
||||
CHK_TIMEOUT();
|
||||
}
|
||||
|
||||
OUT:
|
||||
reply_ng(CMD_HF_MIFARE_STATIC_NONCE, retval, data, sizeof(data));
|
||||
// turns off
|
||||
OnSuccessMagic();
|
||||
BigBuf_free();
|
||||
BigBuf_Clear_ext(false);
|
||||
|
||||
crypto1_deinit(pcs);
|
||||
}
|
||||
|
||||
void OnSuccessMagic() {
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
|
|
@ -39,6 +39,7 @@ int MifareECardLoadExt(uint8_t numSectors, uint8_t keyType);
|
|||
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 MifareHasStaticNonce(); // Has the tag a static nonce?
|
||||
|
||||
void MifareSetMod(uint8_t *datain);
|
||||
void MifareUSetPwd(uint8_t arg0, uint8_t *datain);
|
||||
|
|
|
@ -1132,6 +1132,34 @@ int detect_classic_nackbug(bool verbose) {
|
|||
}
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
/* Detect Mifare Classic Static / Fixed nonce
|
||||
detects special magic cards that has a static / fixed nonce
|
||||
returns:
|
||||
0 = has normal nonce
|
||||
1 = has static/fixed nonce
|
||||
2 = cmd failed
|
||||
*/
|
||||
int detect_classic_static_nonce(void) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFARE_STATIC_NONCE, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_HF_MIFARE_STATIC_NONCE, &resp, 500)) {
|
||||
|
||||
if (resp.status == PM3_ESOFT)
|
||||
return 2;
|
||||
|
||||
if (resp.data.asBytes[0] == 0)
|
||||
return 0;
|
||||
|
||||
if (resp.data.asBytes[0] != 0)
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* try to see if card responses to "chinese magic backdoor" commands. */
|
||||
void detect_classic_magic(void) {
|
||||
|
||||
|
|
|
@ -90,5 +90,6 @@ int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data,
|
|||
int detect_classic_prng(void);
|
||||
int detect_classic_nackbug(bool verbose);
|
||||
void detect_classic_magic(void);
|
||||
int detect_classic_static_nonce(void);
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool isEncrypted);
|
||||
#endif
|
||||
|
|
|
@ -507,6 +507,7 @@ typedef struct {
|
|||
#define CMD_HF_DESFIRE_COMMAND 0x072e
|
||||
|
||||
#define CMD_HF_MIFARE_NACK_DETECT 0x0730
|
||||
#define CMD_HF_MIFARE_STATIC_NONCE 0x0731
|
||||
|
||||
// MFU OTP TearOff
|
||||
#define CMD_HF_MFU_OTP_TEAROFF 0x0740
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue