X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/53d5dc643f592124676b4290c8f81e6039e9abc7..e1778858ddc53a6a82e8ee24f02e6b673687f69a:/armsrc/mifareutil.c diff --git a/armsrc/mifareutil.c b/armsrc/mifareutil.c index 4795a7ec..1dd62951 100644 --- a/armsrc/mifareutil.c +++ b/armsrc/mifareutil.c @@ -121,7 +121,10 @@ int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockN // "random" reader nonce: //byte_t nr[4] = {0x55, 0x41, 0x49, 0x92}; - byte_t nr[4] = {0x01, 0x01, 0x01, 0x01}; + fast_prand(); + byte_t nr[4]; + num_to_bytes(prand(), 4, nr); + //byte_t nr[4] = {0x01, 0x01, 0x01, 0x01}; uint32_t nt, ntpp; // Supplied tag nonce @@ -154,7 +157,7 @@ int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockN // some statistic if (!ntptr && (MF_DBGLEVEL >= 3)) - Dbprintf("auth uid: %08x nt: %08x", uid, nt); + Dbprintf("auth uid: %08x | nr: %08x | nt: %08x", uid, nr, nt); // save Nt if (ntptr) @@ -564,23 +567,19 @@ int emlSetValBl(uint32_t blReg, uint8_t blBlock, int blockNum) { uint64_t emlGetKey(int sectorNum, int keyType) { uint8_t key[6] = {0x00}; uint8_t* emCARD = BigBuf_get_EM_addr(); - memcpy(key, emCARD + 16 * (FirstBlockOfSector(sectorNum) + NumBlocksPerSector(sectorNum) - 1) + keyType * 10, 6); return bytes_to_num(key, 6); } void emlClearMem(void) { - int b; - const uint8_t trailer[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; const uint8_t uid[] = {0xe6, 0x84, 0x87, 0xf3, 0x16, 0x88, 0x04, 0x00, 0x46, 0x8e, 0x45, 0x55, 0x4d, 0x70, 0x41, 0x04}; uint8_t* emCARD = BigBuf_get_EM_addr(); - memset(emCARD, 0, CARD_MEMORY_SIZE); // fill sectors trailer data - for(b = 3; b < 256; b<127?(b+=4):(b+=16)) - emlSetMem((uint8_t *)trailer, b , 1); + for(uint16_t b = 3; b < 256; ((b < 127) ? (b += 4) : (b += 16))) + emlSetMem((uint8_t *)trailer, b, 1); // uid emlSetMem((uint8_t *)uid, 0, 1);