mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
This commit is contained in:
+46
-46
@@ -626,7 +626,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
#ifdef WITH_LF
|
||||
case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
||||
AcquireRawAdcSamples125k(c->arg[0]);
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
break;
|
||||
case CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
||||
ModThenAcquireRawAdcSamples125k(c->arg[0],c->arg[1],c->arg[2],c->d.asBytes);
|
||||
@@ -638,7 +638,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
CmdHIDsimTAG(c->arg[0], c->arg[1], 1); // Simulate HID tag by ID
|
||||
break;
|
||||
case CMD_HID_CLONE_TAG: // Clone HID tag by ID to T55x7
|
||||
CopyHIDtoT55x7(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
CopyHIDtoT55x7(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_EM410X_WRITE_TAG:
|
||||
WriteEM410x(c->arg[0], c->arg[1], c->arg[2]);
|
||||
@@ -663,26 +663,26 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
case CMD_INDALA_CLONE_TAG_L: // Clone Indala 224-bit tag by UID to T55x7
|
||||
CopyIndala224toT55x7(c->d.asDwords[0], c->d.asDwords[1], c->d.asDwords[2], c->d.asDwords[3], c->d.asDwords[4], c->d.asDwords[5], c->d.asDwords[6]);
|
||||
break;
|
||||
case CMD_T55XX_READ_BLOCK:
|
||||
T55xxReadBlock(c->arg[1], c->arg[2],c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_T55XX_WRITE_BLOCK:
|
||||
T55xxWriteBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_T55XX_READ_TRACE: // Clone HID tag by ID to T55x7
|
||||
T55xxReadTrace();
|
||||
break;
|
||||
case CMD_PCF7931_READ: // Read PCF7931 tag
|
||||
ReadPCF7931();
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
// UsbSendPacket((uint8_t*)&ack, sizeof(ack));
|
||||
break;
|
||||
case CMD_EM4X_READ_WORD:
|
||||
EM4xReadWord(c->arg[1], c->arg[2],c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_EM4X_WRITE_WORD:
|
||||
EM4xWriteWord(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_T55XX_READ_BLOCK:
|
||||
T55xxReadBlock(c->arg[1], c->arg[2],c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_T55XX_WRITE_BLOCK:
|
||||
T55xxWriteBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_T55XX_READ_TRACE: // Clone HID tag by ID to T55x7
|
||||
T55xxReadTrace();
|
||||
break;
|
||||
case CMD_PCF7931_READ: // Read PCF7931 tag
|
||||
ReadPCF7931();
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
// UsbSendPacket((uint8_t*)&ack, sizeof(ack));
|
||||
break;
|
||||
case CMD_EM4X_READ_WORD:
|
||||
EM4xReadWord(c->arg[1], c->arg[2],c->d.asBytes[0]);
|
||||
break;
|
||||
case CMD_EM4X_WRITE_WORD:
|
||||
EM4xWriteWord(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes[0]);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef WITH_HITAG
|
||||
@@ -772,7 +772,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
break;
|
||||
|
||||
case CMD_READER_MIFARE:
|
||||
ReaderMifare(c);
|
||||
ReaderMifare(c->arg[0]);
|
||||
break;
|
||||
case CMD_MIFARE_READBL:
|
||||
MifareReadBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
|
||||
@@ -863,7 +863,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
LED_D_OFF(); // LED D indicates field ON or OFF
|
||||
break;
|
||||
|
||||
case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: {
|
||||
case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K:
|
||||
// UsbCommand n;
|
||||
// if(c->cmd == CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K) {
|
||||
// n.cmd = CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K;
|
||||
@@ -877,24 +877,24 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
// UsbSendPacket((uint8_t *)&n, sizeof(n));
|
||||
// LED_B_OFF();
|
||||
|
||||
LED_B_ON();
|
||||
for(size_t i=0; i<c->arg[1]; i += USB_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((c->arg[1] - i),USB_CMD_DATA_SIZE);
|
||||
cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K,i,len,0,((byte_t*)BigBuf)+c->arg[0]+i,len);
|
||||
}
|
||||
// Trigger a finish downloading signal with an ACK frame
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
LED_B_ON();
|
||||
for(size_t i=0; i<c->arg[1]; i += USB_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((c->arg[1] - i),USB_CMD_DATA_SIZE);
|
||||
cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K,i,len,0,((byte_t*)BigBuf)+c->arg[0]+i,len);
|
||||
}
|
||||
// Trigger a finish downloading signal with an ACK frame
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
LED_B_OFF();
|
||||
} break;
|
||||
break;
|
||||
|
||||
case CMD_DOWNLOADED_SIM_SAMPLES_125K: {
|
||||
uint8_t *b = (uint8_t *)BigBuf;
|
||||
memcpy(b+c->arg[0], c->d.asBytes, 48);
|
||||
//Dbprintf("copied 48 bytes to %i",b+c->arg[0]);
|
||||
// UsbSendPacket((uint8_t*)&ack, sizeof(ack));
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
} break;
|
||||
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
break;
|
||||
}
|
||||
case CMD_READ_MEM:
|
||||
ReadMem(c->arg[0]);
|
||||
break;
|
||||
@@ -926,35 +926,35 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
#endif
|
||||
case CMD_SETUP_WRITE:
|
||||
case CMD_FINISH_WRITE:
|
||||
case CMD_HARDWARE_RESET: {
|
||||
usb_disable();
|
||||
case CMD_HARDWARE_RESET:
|
||||
usb_disable();
|
||||
SpinDelay(1000);
|
||||
SpinDelay(1000);
|
||||
AT91C_BASE_RSTC->RSTC_RCR = RST_CONTROL_KEY | AT91C_RSTC_PROCRST;
|
||||
for(;;) {
|
||||
// We're going to reset, and the bootrom will take control.
|
||||
}
|
||||
} break;
|
||||
break;
|
||||
|
||||
case CMD_START_FLASH: {
|
||||
case CMD_START_FLASH:
|
||||
if(common_area.flags.bootrom_present) {
|
||||
common_area.command = COMMON_AREA_COMMAND_ENTER_FLASH_MODE;
|
||||
}
|
||||
usb_disable();
|
||||
usb_disable();
|
||||
AT91C_BASE_RSTC->RSTC_RCR = RST_CONTROL_KEY | AT91C_RSTC_PROCRST;
|
||||
for(;;);
|
||||
} break;
|
||||
break;
|
||||
|
||||
case CMD_DEVICE_INFO: {
|
||||
uint32_t dev_info = DEVICE_INFO_FLAG_OSIMAGE_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_OS;
|
||||
if(common_area.flags.bootrom_present) dev_info |= DEVICE_INFO_FLAG_BOOTROM_PRESENT;
|
||||
// UsbSendPacket((uint8_t*)&c, sizeof(c));
|
||||
cmd_send(CMD_DEVICE_INFO,dev_info,0,0,0,0);
|
||||
} break;
|
||||
|
||||
default: {
|
||||
cmd_send(CMD_DEVICE_INFO,dev_info,0,0,0,0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Dbprintf("%s: 0x%04x","unknown command:",c->cmd);
|
||||
} break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ void RAMFUNC SniffMifare(uint8_t param);
|
||||
void EPA_PACE_Collect_Nonce(UsbCommand * c);
|
||||
|
||||
// mifarecmd.h
|
||||
void ReaderMifare(UsbCommand *c);
|
||||
void ReaderMifare(bool first_try);
|
||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
|
||||
void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
|
||||
+239
-327
File diff suppressed because it is too large
Load Diff
+8
-10
@@ -28,7 +28,7 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
// variables
|
||||
byte_t isOK = 0;
|
||||
byte_t dataoutbuf[16];
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
uint32_t cuid;
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
@@ -109,7 +109,7 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
// variables
|
||||
byte_t isOK = 0;
|
||||
byte_t dataoutbuf[16 * 4];
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
uint32_t cuid;
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
@@ -208,7 +208,7 @@ void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
|
||||
// variables
|
||||
byte_t isOK = 0;
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
uint32_t cuid;
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
@@ -298,7 +298,7 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
||||
// variables
|
||||
int rtr, i, j, m, len;
|
||||
int davg, dmin, dmax;
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
uint32_t cuid, nt1, nt2, nttmp, nttest, par, ks1;
|
||||
uint8_t par_array[4];
|
||||
nestedVector nvector[NES_MAX_INFO + 1][11];
|
||||
@@ -493,7 +493,6 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
||||
}
|
||||
|
||||
LED_B_ON();
|
||||
SpinDelay(100);
|
||||
cmd_send(CMD_ACK,0,ncount,targetBlockNo + (targetKeyType * 0x100),buf,48);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
@@ -507,7 +506,6 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
||||
// memset(ack.d.asBytes, 0x00, sizeof(ack.d.asBytes));
|
||||
|
||||
LED_B_ON();
|
||||
SpinDelay(300);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||
LED_B_OFF();
|
||||
@@ -536,7 +534,7 @@ void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
// variables
|
||||
int i;
|
||||
byte_t isOK = 0;
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
uint32_t cuid;
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
@@ -649,7 +647,7 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
|
||||
// variables
|
||||
byte_t dataoutbuf[16];
|
||||
byte_t dataoutbuf2[16];
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
|
||||
// clear trace
|
||||
iso14a_clear_trace();
|
||||
@@ -761,11 +759,11 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
|
||||
|
||||
// variables
|
||||
byte_t isOK = 0;
|
||||
uint8_t uid[8];
|
||||
uint8_t uid[10];
|
||||
uint8_t d_block[18];
|
||||
uint32_t cuid;
|
||||
|
||||
memset(uid, 0x00, 8);
|
||||
memset(uid, 0x00, 10);
|
||||
uint8_t* receivedAnswer = mifare_get_bigbufptr();
|
||||
|
||||
if (workFlags & 0x08) {
|
||||
|
||||
+59
-2
@@ -294,11 +294,11 @@ void StartCountUS()
|
||||
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS; // timer disable
|
||||
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_XC1; // from timer 0
|
||||
|
||||
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN;
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN;
|
||||
AT91C_BASE_TCB->TCB_BCR = 1;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t RAMFUNC GetCountUS(){
|
||||
return (AT91C_BASE_TC1->TC_CV * 0x8000) + ((AT91C_BASE_TC0->TC_CV / 15) * 10);
|
||||
@@ -314,3 +314,60 @@ uint32_t RAMFUNC GetDeltaCountUS(){
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Mifare timer. Uses ssp_clk from FPGA
|
||||
// -------------------------------------------------------------------------
|
||||
void StartCountMifare()
|
||||
{
|
||||
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_TC0) | (1 << AT91C_ID_TC1) | (1 << AT91C_ID_TC2); // Enable Clock to all timers
|
||||
AT91C_BASE_TCB->TCB_BMR = AT91C_TCB_TC0XC0S_TIOA1 // XC0 Clock = TIOA1
|
||||
| AT91C_TCB_TC1XC1S_NONE // XC1 Clock = none
|
||||
| AT91C_TCB_TC2XC2S_TIOA0; // XC2 Clock = TIOA0
|
||||
|
||||
// configure TC1 to create a short pulse on TIOA1 when a rising edge on TIOB1 (= ssp_clk from FPGA) occurs:
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS; // disable TC1
|
||||
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV1_CLOCK // TC1 Clock = MCK(48MHz)/2 = 24MHz
|
||||
| AT91C_TC_CPCSTOP // Stop clock on RC compare
|
||||
| AT91C_TC_EEVTEDG_RISING // Trigger on rising edge of Event
|
||||
| AT91C_TC_EEVT_TIOB // Event-Source: TIOB1 (= ssc_clk from FPGA = 13,56MHz / 16)
|
||||
| AT91C_TC_ENETRG // Enable external trigger event
|
||||
| AT91C_TC_WAVESEL_UP // Upmode without automatic trigger on RC compare
|
||||
| AT91C_TC_WAVE // Waveform Mode
|
||||
| AT91C_TC_AEEVT_SET // Set TIOA1 on external event
|
||||
| AT91C_TC_ACPC_CLEAR; // Clear TIOA1 on RC Compare
|
||||
AT91C_BASE_TC1->TC_RC = 0x04; // RC Compare value = 0x04
|
||||
|
||||
// use TC0 to count TIOA1 pulses
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS; // disable TC0
|
||||
AT91C_BASE_TC0->TC_CMR = AT91C_TC_CLKS_XC0 // TC0 clock = XC0 clock = TIOA1
|
||||
| AT91C_TC_WAVE // Waveform Mode
|
||||
| AT91C_TC_WAVESEL_UP // just count
|
||||
| AT91C_TC_ACPA_CLEAR // Clear TIOA0 on RA Compare
|
||||
| AT91C_TC_ACPC_SET; // Set TIOA0 on RC Compare
|
||||
AT91C_BASE_TC0->TC_RA = 1; // RA Compare value = 1; pulse width to TC2
|
||||
AT91C_BASE_TC0->TC_RC = 0; // RC Compare value = 0; increment TC2 on overflow
|
||||
|
||||
// use TC2 to count TIOA0 pulses (giving us a 32bit counter (TC0/TC2) clocked by ssp_clk)
|
||||
AT91C_BASE_TC2->TC_CCR = AT91C_TC_CLKDIS; // disable TC2
|
||||
AT91C_BASE_TC2->TC_CMR = AT91C_TC_CLKS_XC2 // TC2 clock = XC2 clock = TIOA0
|
||||
| AT91C_TC_WAVE // Waveform Mode
|
||||
| AT91C_TC_WAVESEL_UP; // just count
|
||||
|
||||
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKEN; // enable TC0
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN; // enable TC1
|
||||
AT91C_BASE_TC2->TC_CCR = AT91C_TC_CLKEN; // enable TC2
|
||||
AT91C_BASE_TCB->TCB_BCR = 1; // assert Sync (set all timers to 0 on next active clock edge)
|
||||
}
|
||||
|
||||
|
||||
uint32_t RAMFUNC GetCountMifare(){
|
||||
uint32_t tmp_count;
|
||||
tmp_count = (AT91C_BASE_TC2->TC_CV << 16) | AT91C_BASE_TC0->TC_CV;
|
||||
if ((tmp_count & 0xffff) == 0) { //small chance that we may have missed an increment in TC2
|
||||
return (AT91C_BASE_TC2->TC_CV << 16);
|
||||
}
|
||||
else {
|
||||
return tmp_count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,7 @@ void StartCountUS();
|
||||
uint32_t RAMFUNC GetCountUS();
|
||||
uint32_t RAMFUNC GetDeltaCountUS();
|
||||
|
||||
void StartCountMifare();
|
||||
uint32_t RAMFUNC GetCountMifare();
|
||||
|
||||
#endif
|
||||
|
||||
+16
-19
@@ -15,18 +15,20 @@ static int CmdHelp(const char *Cmd);
|
||||
int CmdHF14AMifare(const char *Cmd)
|
||||
{
|
||||
uint32_t uid = 0;
|
||||
uint32_t nt = 0;
|
||||
uint32_t nt = 0, nr = 0;
|
||||
uint64_t par_list = 0, ks_list = 0, r_key = 0;
|
||||
uint8_t isOK = 0;
|
||||
uint8_t keyBlock[8] = {0};
|
||||
|
||||
if (param_getchar(Cmd, 0) && param_gethex(Cmd, 0, keyBlock, 8)) {
|
||||
PrintAndLog("Nt must include 8 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
UsbCommand c = {CMD_READER_MIFARE, {true, 0, 0}};
|
||||
|
||||
// message
|
||||
printf("-------------------------------------------------------------------------\n");
|
||||
printf("Executing command. Expected execution time: 25sec on average :-)\n");
|
||||
printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");
|
||||
printf("-------------------------------------------------------------------------\n");
|
||||
|
||||
|
||||
UsbCommand c = {CMD_READER_MIFARE, {(uint32_t)bytes_to_num(keyBlock, 4), 0, 0}};
|
||||
start:
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
@@ -34,15 +36,10 @@ start:
|
||||
//flush queue
|
||||
while (ukbhit()) getchar();
|
||||
|
||||
// message
|
||||
printf("-------------------------------------------------------------------------\n");
|
||||
printf("Executing command. It may take up to 30 min.\n");
|
||||
printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");
|
||||
printf("-------------------------------------------------------------------------\n");
|
||||
|
||||
// wait cycle
|
||||
while (true) {
|
||||
//printf(".");
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
if (ukbhit()) {
|
||||
getchar();
|
||||
@@ -51,27 +48,26 @@ start:
|
||||
}
|
||||
|
||||
UsbCommand resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,2000)) {
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
|
||||
isOK = resp.arg[0] & 0xff;
|
||||
|
||||
uid = (uint32_t)bytes_to_num(resp.d.asBytes + 0, 4);
|
||||
nt = (uint32_t)bytes_to_num(resp.d.asBytes + 4, 4);
|
||||
par_list = bytes_to_num(resp.d.asBytes + 8, 8);
|
||||
ks_list = bytes_to_num(resp.d.asBytes + 16, 8);
|
||||
|
||||
nr = bytes_to_num(resp.d.asBytes + 24, 4);
|
||||
printf("\n\n");
|
||||
PrintAndLog("isOk:%02x", isOK);
|
||||
if (!isOK) PrintAndLog("Proxmark can't get statistic info. Execution aborted.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
// error
|
||||
if (isOK != 1) return 1;
|
||||
|
||||
// execute original function from util nonce2key
|
||||
if (nonce2key(uid, nt, par_list, ks_list, &r_key))
|
||||
if (nonce2key(uid, nt, nr, par_list, ks_list, &r_key))
|
||||
{
|
||||
isOK = 2;
|
||||
PrintAndLog("Key not found (lfsr_common_prefix list is null). Nt=%08x", nt);
|
||||
@@ -86,8 +82,9 @@ start:
|
||||
PrintAndLog("Found valid key:%012"llx, r_key);
|
||||
else
|
||||
{
|
||||
if (isOK != 2) PrintAndLog("Found invalid key. ( Nt=%08x ,Trying use it to run again...", nt);
|
||||
c.arg[0] = nt;
|
||||
if (isOK != 2) PrintAndLog("Found invalid key. ");
|
||||
PrintAndLog("Failing is expected to happen in 25%% of all cases. Trying again with a different reader nonce...");
|
||||
c.arg[0] = false;
|
||||
goto start;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
#include "nonce2key.h"
|
||||
#include "ui.h"
|
||||
|
||||
int nonce2key(uint32_t uid, uint32_t nt, uint64_t par_info, uint64_t ks_info, uint64_t * key) {
|
||||
int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info, uint64_t ks_info, uint64_t * key) {
|
||||
struct Crypto1State *state, *state_s;
|
||||
uint32_t pos, nr, rr, nr_diff;//, ks1, ks2;
|
||||
uint32_t pos, rr, nr_diff;//, ks1, ks2;
|
||||
byte_t bt, i, ks3x[8], par[8][8];
|
||||
uint64_t key_recovered;
|
||||
nr = rr = 0;
|
||||
rr = 0;
|
||||
|
||||
// Reset the last three significant bits of the reader nonce
|
||||
nr &= 0xffffff1f;
|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
#include "crapto1.h"
|
||||
#include "common.h"
|
||||
|
||||
int nonce2key(uint32_t uid, uint32_t nt, uint64_t par_info, uint64_t ks_info, uint64_t * key);
|
||||
int nonce2key(uint32_t uid, uint32_t nt, uint32_t nr, uint64_t par_info, uint64_t ks_info, uint64_t * key);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user