mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 02:34:48 +08:00
clean up, explain, lesser tests for buttonpress
This commit is contained in:
parent
a6a260b422
commit
7c2231974d
2 changed files with 17 additions and 10 deletions
|
@ -2821,12 +2821,12 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||||
if (checkbtn_cnt == 2000) {
|
if (checkbtn_cnt == 2000) {
|
||||||
if (BUTTON_PRESS() || data_available()) {
|
if (BUTTON_PRESS() || data_available()) {
|
||||||
isOK = -1;
|
isOK = -1;
|
||||||
return_status = PM3_EABORTED;
|
return_status = PM3_EOPABORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
checkbtn_cnt = 0;
|
checkbtn_cnt = 0;
|
||||||
}
|
}
|
||||||
checkbtn_cnt++;
|
++checkbtn_cnt;
|
||||||
|
|
||||||
// this part is from Piwi's faster nonce collecting part in Hardnested.
|
// this part is from Piwi's faster nonce collecting part in Hardnested.
|
||||||
if (!have_uid) { // need a full select cycle to get the uid first
|
if (!have_uid) { // need a full select cycle to get the uid first
|
||||||
|
@ -2885,10 +2885,11 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||||
|
|
||||||
// Receive answer. This will be a 4 Bit NACK when the 8 parity bits are OK after decoding
|
// Receive answer. This will be a 4 Bit NACK when the 8 parity bits are OK after decoding
|
||||||
int resp_res = ReaderReceive(receivedAnswer, receivedAnswerPar);
|
int resp_res = ReaderReceive(receivedAnswer, receivedAnswerPar);
|
||||||
if (resp_res == 4)
|
if (resp_res == 1)
|
||||||
received_nack = true;
|
received_nack = true;
|
||||||
else if (resp_res == 32) {
|
else if (resp_res == 4) {
|
||||||
// did we get lucky and got our dummykey to be valid?
|
// did we get lucky and got our dummykey to be valid?
|
||||||
|
// however we dont feed key w uid it the prng..
|
||||||
isOK = -6;
|
isOK = -6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3075,6 +3076,8 @@ void DetectNACKbug(void) {
|
||||||
sync_time = GetCountSspClk() & 0xfffffff8;
|
sync_time = GetCountSspClk() & 0xfffffff8;
|
||||||
|
|
||||||
LED_C_ON();
|
LED_C_ON();
|
||||||
|
uint16_t checkbtn_cnt = 0;
|
||||||
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
for (i = 1; true; ++i) {
|
for (i = 1; true; ++i) {
|
||||||
|
|
||||||
|
@ -3089,10 +3092,14 @@ void DetectNACKbug(void) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
// Test if the action was cancelled
|
// Test if the action was cancelled
|
||||||
|
if (checkbtn_cnt == 2000) {
|
||||||
if (BUTTON_PRESS() || data_available()) {
|
if (BUTTON_PRESS() || data_available()) {
|
||||||
status = PM3_EOPABORTED;
|
status = PM3_EOPABORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
checkbtn_cnt = 0;
|
||||||
|
}
|
||||||
|
++checkbtn_cnt;
|
||||||
|
|
||||||
// this part is from Piwi's faster nonce collecting part in Hardnested.
|
// this part is from Piwi's faster nonce collecting part in Hardnested.
|
||||||
if (!have_uid) { // need a full select cycle to get the uid first
|
if (!have_uid) { // need a full select cycle to get the uid first
|
||||||
|
@ -3152,10 +3159,11 @@ void DetectNACKbug(void) {
|
||||||
// Transmit reader nonce with fake par
|
// Transmit reader nonce with fake par
|
||||||
ReaderTransmitPar(mf_nr_ar, sizeof(mf_nr_ar), par, NULL);
|
ReaderTransmitPar(mf_nr_ar, sizeof(mf_nr_ar), par, NULL);
|
||||||
|
|
||||||
|
// Receive answer. This will be a 4 Bit NACK when the 8 parity bits are OK after decoding
|
||||||
if (ReaderReceive(receivedAnswer, receivedAnswerPar)) {
|
if (ReaderReceive(receivedAnswer, receivedAnswerPar)) {
|
||||||
received_nack = true;
|
received_nack = true;
|
||||||
num_nacks++;
|
num_nacks++;
|
||||||
// ALWAYS leak Detection.
|
// ALWAYS leak Detection. Well, we could be lucky and get a response nack on first try.
|
||||||
if (i == num_nacks) {
|
if (i == num_nacks) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3272,7 +3280,6 @@ void DetectNACKbug(void) {
|
||||||
num_to_bytes(i, 2, data + 2);
|
num_to_bytes(i, 2, data + 2);
|
||||||
reply_ng(CMD_HF_MIFARE_NACK_DETECT, status, data, 4);
|
reply_ng(CMD_HF_MIFARE_NACK_DETECT, status, data, 4);
|
||||||
|
|
||||||
//reply_mix(CMD_ACK, isOK, num_nacks, i, 0, 0);
|
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
hf_field_off();
|
hf_field_off();
|
||||||
set_tracing(false);
|
set_tracing(false);
|
||||||
|
|
|
@ -65,7 +65,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (WaitForResponseTimeout(CMD_HF_MIFARE_READER, &resp, 2000)) {
|
if (WaitForResponseTimeout(CMD_HF_MIFARE_READER, &resp, 2000)) {
|
||||||
if (resp.status == PM3_EABORTED) {
|
if (resp.status == PM3_EOPABORTED) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue