mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Merge branch 'master' of https://github.com/iceman1001/proxmark3
This commit is contained in:
commit
e8bf76a83f
3 changed files with 34 additions and 28 deletions
|
@ -707,12 +707,14 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
clock_t t2 = clock() - t1;
|
clock_t t2 = clock() - t1;
|
||||||
if ( t2 > 0 )
|
if ( t2 > 0 )
|
||||||
PrintAndLog("Time to check 6 known keys: %.0f ticks %4.2f sec", (float)t2, ((float)t2)/CLOCKS_PER_SEC);
|
PrintAndLog("Time to check 6 known keys: %.0f ticks %4.2f sec", (float)t2, ((float)t2)/CLOCKS_PER_SEC);
|
||||||
|
|
||||||
|
PrintAndLog("enter nested...");
|
||||||
|
|
||||||
// nested sectors
|
// nested sectors
|
||||||
iterations = 0;
|
iterations = 0;
|
||||||
PrintAndLog("enter nested...");
|
PrintAndLog("enter nested...");
|
||||||
bool calibrate = true;
|
bool calibrate = true;
|
||||||
|
|
||||||
for (i = 0; i < NESTED_SECTOR_RETRY; i++) {
|
for (i = 0; i < NESTED_SECTOR_RETRY; i++) {
|
||||||
for (uint8_t sectorNo = 0; sectorNo < SectorsCnt; ++sectorNo) {
|
for (uint8_t sectorNo = 0; sectorNo < SectorsCnt; ++sectorNo) {
|
||||||
for (trgKeyType = 0; trgKeyType < 2; ++trgKeyType) {
|
for (trgKeyType = 0; trgKeyType < 2; ++trgKeyType) {
|
||||||
|
@ -742,6 +744,10 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t1 = clock() - t1;
|
||||||
|
if ( t1 > 0 )
|
||||||
|
PrintAndLog("Time in nested: %.0f ticks %4.2f sec (%4.2f sec per key)\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/iterations/CLOCKS_PER_SEC);
|
||||||
|
|
||||||
// 20160116 If Sector A is found, but not Sector B, try just reading it of the tag?
|
// 20160116 If Sector A is found, but not Sector B, try just reading it of the tag?
|
||||||
PrintAndLog("trying to read key B...");
|
PrintAndLog("trying to read key B...");
|
||||||
|
@ -768,15 +774,12 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
key64 = bytes_to_num(data+10, 6);
|
key64 = bytes_to_num(data+10, 6);
|
||||||
if (key64) {
|
if (key64) {
|
||||||
PrintAndLog("Data:%s", sprint_hex(data+10, 6));
|
PrintAndLog("Data:%s", sprint_hex(data+10, 6));
|
||||||
e_sector[i].foundKey[1] = 1;
|
e_sector[i].foundKey[1] = TRUE;
|
||||||
e_sector[i].Key[1] = key64;
|
e_sector[i].Key[1] = key64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t1 = clock() - t1;
|
|
||||||
if ( t1 > 0 )
|
|
||||||
PrintAndLog("Time in nested: %.0f ticks %4.2f sec (%4.2f sec per key)\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/iterations/CLOCKS_PER_SEC);
|
|
||||||
|
|
||||||
//print them
|
//print them
|
||||||
printKeyTable( SectorsCnt, e_sector );
|
printKeyTable( SectorsCnt, e_sector );
|
||||||
|
@ -1047,7 +1050,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
}
|
}
|
||||||
keyBlock = p;
|
keyBlock = p;
|
||||||
}
|
}
|
||||||
PrintAndLog("check key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,
|
PrintAndLog("key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,
|
||||||
(keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],
|
(keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],
|
||||||
(keyBlock + 6*keycnt)[3], (keyBlock + 6*keycnt)[4], (keyBlock + 6*keycnt)[5], 6);
|
(keyBlock + 6*keycnt)[3], (keyBlock + 6*keycnt)[4], (keyBlock + 6*keycnt)[5], 6);
|
||||||
keycnt++;
|
keycnt++;
|
||||||
|
@ -1087,7 +1090,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
}
|
}
|
||||||
memset(keyBlock + 6 * keycnt, 0, 6);
|
memset(keyBlock + 6 * keycnt, 0, 6);
|
||||||
num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);
|
num_to_bytes(strtoll(buf, NULL, 16), 6, keyBlock + 6*keycnt);
|
||||||
PrintAndLog("check custom key[%2d] %012"llx, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));
|
PrintAndLog("check key[%2d] %012"llx, keycnt, bytes_to_num(keyBlock + 6*keycnt, 6));
|
||||||
keycnt++;
|
keycnt++;
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
}
|
}
|
||||||
|
@ -1104,7 +1107,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
if (keycnt == 0) {
|
if (keycnt == 0) {
|
||||||
PrintAndLog("No key specified, trying default keys");
|
PrintAndLog("No key specified, trying default keys");
|
||||||
for (;keycnt < defaultKeysSize; keycnt++)
|
for (;keycnt < defaultKeysSize; keycnt++)
|
||||||
PrintAndLog("check default key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,
|
PrintAndLog("key[%2d] %02x%02x%02x%02x%02x%02x", keycnt,
|
||||||
(keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],
|
(keyBlock + 6*keycnt)[0],(keyBlock + 6*keycnt)[1], (keyBlock + 6*keycnt)[2],
|
||||||
(keyBlock + 6*keycnt)[3], (keyBlock + 6*keycnt)[4], (keyBlock + 6*keycnt)[5], 6);
|
(keyBlock + 6*keycnt)[3], (keyBlock + 6*keycnt)[4], (keyBlock + 6*keycnt)[5], 6);
|
||||||
}
|
}
|
||||||
|
@ -1117,19 +1120,20 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t trgKeyType = 0;
|
uint8_t trgKeyType = 0;
|
||||||
|
uint32_t max_keys = keycnt > (USB_CMD_DATA_SIZE/6) ? (USB_CMD_DATA_SIZE/6) : keycnt;
|
||||||
|
|
||||||
// time
|
// time
|
||||||
clock_t t1 = clock();
|
clock_t t1 = clock();
|
||||||
|
|
||||||
// check keys.
|
// check keys.
|
||||||
for (trgKeyType = 0; trgKeyType < 2; ++trgKeyType) {
|
for (trgKeyType = 0; trgKeyType < 2; ++trgKeyType) {
|
||||||
|
|
||||||
int b = blockNo;
|
int b = blockNo;
|
||||||
for (int i = 0; i < SectorsCnt; ++i) {
|
for (int i = 0; i < SectorsCnt; ++i) {
|
||||||
|
|
||||||
// skip already found keys.
|
// skip already found keys.
|
||||||
if (e_sector[i].foundKey[trgKeyType]) continue;
|
if (e_sector[i].foundKey[trgKeyType]) continue;
|
||||||
|
|
||||||
uint32_t max_keys = keycnt > (USB_CMD_DATA_SIZE/6) ? (USB_CMD_DATA_SIZE/6) : keycnt;
|
|
||||||
|
|
||||||
for (uint32_t c = 0; c < keycnt; c += max_keys) {
|
for (uint32_t c = 0; c < keycnt; c += max_keys) {
|
||||||
|
|
||||||
|
@ -1137,7 +1141,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
|
|
||||||
res = mfCheckKeys(b, trgKeyType, true, size, &keyBlock[6*c], &key64);
|
res = mfCheckKeys(b, trgKeyType, true, size, &keyBlock[6*c], &key64);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
PrintAndLog("Sector:%3d Block:%3d, key type: %C -- Found key [%012"llx"]", i, b, trgKeyType ? 'B':'A', key64);
|
//PrintAndLog("Sector:%3d Block:%3d, key type: %C -- Found key [%012"llx"]", i, b, trgKeyType ? 'B':'A', key64);
|
||||||
|
|
||||||
e_sector[i].Key[trgKeyType] = key64;
|
e_sector[i].Key[trgKeyType] = key64;
|
||||||
e_sector[i].foundKey[trgKeyType] = TRUE;
|
e_sector[i].foundKey[trgKeyType] = TRUE;
|
||||||
|
@ -1150,6 +1154,11 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
b < 127 ? ( b +=4 ) : ( b += 16 );
|
b < 127 ? ( b +=4 ) : ( b += 16 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t1 = clock() - t1;
|
||||||
|
if ( t1 > 0 )
|
||||||
|
printf("Time in checkkeys: %.0f ticks %1.2f sec (%1.2f sec per key)\n\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/keycnt/CLOCKS_PER_SEC);
|
||||||
|
|
||||||
// 20160116 If Sector A is found, but not Sector B, try just reading it of the tag?
|
// 20160116 If Sector A is found, but not Sector B, try just reading it of the tag?
|
||||||
PrintAndLog("testing to read B...");
|
PrintAndLog("testing to read B...");
|
||||||
for (i = 0; i < SectorsCnt; i++) {
|
for (i = 0; i < SectorsCnt; i++) {
|
||||||
|
@ -1180,10 +1189,7 @@ int CmdHF14AMfChk(const char *Cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t1 = clock() - t1;
|
|
||||||
if ( t1 > 0 )
|
|
||||||
printf("Time in checkkeys: %.0f ticks %1.2f sec (%1.2f sec per key)\n\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/keycnt/CLOCKS_PER_SEC);
|
|
||||||
|
|
||||||
//print them
|
//print them
|
||||||
printKeyTable( SectorsCnt, e_sector );
|
printKeyTable( SectorsCnt, e_sector );
|
||||||
|
|
|
@ -686,8 +686,8 @@ static void Check_for_FilterFlipProperties(void)
|
||||||
|
|
||||||
static void simulate_MFplus_RNG(uint32_t test_cuid, uint64_t test_key, uint32_t *nt_enc, uint8_t *par_enc)
|
static void simulate_MFplus_RNG(uint32_t test_cuid, uint64_t test_key, uint32_t *nt_enc, uint8_t *par_enc)
|
||||||
{
|
{
|
||||||
struct Crypto1State sim_cs;
|
struct Crypto1State sim_cs = {0, 0};
|
||||||
sim_cs.odd = sim_cs.even = 0;
|
// sim_cs.odd = sim_cs.even = 0;
|
||||||
|
|
||||||
// init cryptostate with key:
|
// init cryptostate with key:
|
||||||
for(int8_t i = 47; i > 0; i -= 2) {
|
for(int8_t i = 47; i > 0; i -= 2) {
|
||||||
|
|
|
@ -120,6 +120,7 @@ int getCommand(UsbCommand* response)
|
||||||
//Pick out the next unread command
|
//Pick out the next unread command
|
||||||
UsbCommand* last_unread = &cmdBuffer[cmd_tail];
|
UsbCommand* last_unread = &cmdBuffer[cmd_tail];
|
||||||
memcpy(response, last_unread, sizeof(UsbCommand));
|
memcpy(response, last_unread, sizeof(UsbCommand));
|
||||||
|
|
||||||
//Increment tail - this is a circular buffer, so modulo buffer size
|
//Increment tail - this is a circular buffer, so modulo buffer size
|
||||||
cmd_tail = (cmd_tail +1 ) % CMD_BUFFER_SIZE;
|
cmd_tail = (cmd_tail +1 ) % CMD_BUFFER_SIZE;
|
||||||
|
|
||||||
|
@ -146,10 +147,10 @@ bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeou
|
||||||
for ( size_t dm_seconds = 0; dm_seconds < ms_timeout/10; dm_seconds++ ) {
|
for ( size_t dm_seconds = 0; dm_seconds < ms_timeout/10; dm_seconds++ ) {
|
||||||
|
|
||||||
while( getCommand(response) ) {
|
while( getCommand(response) ) {
|
||||||
if(response->cmd == cmd){
|
if(response->cmd == cmd)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msleep(10); // XXX ugh
|
msleep(10); // XXX ugh
|
||||||
if (dm_seconds == 200) { // Two seconds elapsed
|
if (dm_seconds == 200) { // Two seconds elapsed
|
||||||
PrintAndLog("Waiting for a response from the proxmark...");
|
PrintAndLog("Waiting for a response from the proxmark...");
|
||||||
|
@ -188,20 +189,19 @@ void UsbCommandReceived(UsbCommand *UC)
|
||||||
return;
|
return;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case CMD_DEBUG_PRINT_INTEGERS: {
|
case CMD_DEBUG_PRINT_INTEGERS:
|
||||||
PrintAndLog("#db# %08x, %08x, %08x \r\n", UC->arg[0], UC->arg[1], UC->arg[2]);
|
PrintAndLog("#db# %08x, %08x, %08x", UC->arg[0], UC->arg[1], UC->arg[2]);
|
||||||
return;
|
break;
|
||||||
} break;
|
|
||||||
|
|
||||||
case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K: {
|
case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K:
|
||||||
memcpy(sample_buf+(UC->arg[0]),UC->d.asBytes,UC->arg[1]);
|
memcpy( sample_buf + (UC->arg[0]), UC->d.asBytes, UC->arg[1]);
|
||||||
return;
|
break;
|
||||||
} break;
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
storeCommand(UC);
|
storeCommand(UC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue