mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
remove spurious spaces & tabs at end of lines
This commit is contained in:
parent
edc19f202a
commit
60f292b18e
249 changed files with 8481 additions and 8481 deletions
|
@ -92,7 +92,7 @@ static uint16_t matrixadd ( uint8_t* bytes, uint8_t len){
|
|||
0x72 | 0111 0010
|
||||
0x5e | 0101 1110
|
||||
-----------------
|
||||
C32F 9d74
|
||||
C32F 9d74
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ static uint16_t calcSumCrumbAdd( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
sum += CRUMB(bytes[i], 4);
|
||||
sum += CRUMB(bytes[i], 6);
|
||||
}
|
||||
sum &= mask;
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
static uint16_t calcSumCrumbAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
||||
|
@ -122,7 +122,7 @@ static uint16_t calcSumNibbleAdd( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
sum += NIBBLE_LOW(bytes[i]);
|
||||
sum += NIBBLE_HIGH(bytes[i]);
|
||||
}
|
||||
sum &= mask;
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
static uint16_t calcSumNibbleAddOnes( uint8_t* bytes, uint8_t len, uint32_t mask){
|
||||
|
@ -135,7 +135,7 @@ static uint16_t calcSumCrumbXor( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
sum ^= CRUMB(bytes[i], 2);
|
||||
sum ^= CRUMB(bytes[i], 4);
|
||||
sum ^= CRUMB(bytes[i], 6);
|
||||
}
|
||||
}
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ static uint16_t calcSumByteXor( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
for (uint8_t i = 0; i < len; i++) {
|
||||
sum ^= bytes[i];
|
||||
}
|
||||
sum &= mask;
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
static uint16_t calcSumByteAdd( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
||||
|
@ -161,7 +161,7 @@ static uint16_t calcSumByteAdd( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
for (uint8_t i = 0; i < len; i++) {
|
||||
sum += bytes[i];
|
||||
}
|
||||
sum &= mask;
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
// Ones complement
|
||||
|
@ -174,7 +174,7 @@ static uint16_t calcSumByteSub( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
for (uint8_t i = 0; i < len; i++) {
|
||||
sum -= bytes[i];
|
||||
}
|
||||
sum &= mask;
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
static uint16_t calcSumByteSubOnes( uint8_t* bytes, uint8_t len, uint32_t mask){
|
||||
|
@ -186,7 +186,7 @@ static uint16_t calcSumNibbleSub( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
|||
sum -= NIBBLE_LOW(bytes[i]);
|
||||
sum -= NIBBLE_HIGH(bytes[i]);
|
||||
}
|
||||
sum &= mask;
|
||||
sum &= mask;
|
||||
return sum;
|
||||
}
|
||||
static uint16_t calcSumNibbleSubOnes( uint8_t* bytes, uint8_t len, uint32_t mask) {
|
||||
|
@ -199,7 +199,7 @@ static uint16_t calcBSDchecksum8( uint8_t* bytes, uint8_t len, uint32_t mask){
|
|||
for(uint8_t i = 0; i < len; i++){
|
||||
sum = ((sum & 0xFF) >> 1) | ((sum & 0x1) << 7); // rotate accumulator
|
||||
sum += bytes[i]; // add next byte
|
||||
sum &= 0xFF; //
|
||||
sum &= 0xFF; //
|
||||
}
|
||||
sum &= mask;
|
||||
return sum;
|
||||
|
@ -210,10 +210,10 @@ static uint16_t calcBSDchecksum4( uint8_t* bytes, uint8_t len, uint32_t mask){
|
|||
for(uint8_t i = 0; i < len; i++){
|
||||
sum = ((sum & 0xF) >> 1) | ((sum & 0x1) << 3); // rotate accumulator
|
||||
sum += NIBBLE_HIGH(bytes[i]); // add high nibble
|
||||
sum &= 0xF; //
|
||||
sum &= 0xF; //
|
||||
sum = ((sum & 0xF) >> 1) | ((sum & 0x1) << 3); // rotate accumulator
|
||||
sum += NIBBLE_LOW(bytes[i]); // add low nibble
|
||||
sum &= 0xF; //
|
||||
sum &= 0xF; //
|
||||
}
|
||||
sum &= mask;
|
||||
return sum;
|
||||
|
@ -228,10 +228,10 @@ int CmdAnalyseLfsr(const char *Cmd){
|
|||
|
||||
uint8_t iv = param_get8ex(Cmd, 0, 0, 16);
|
||||
uint8_t find = param_get8ex(Cmd, 1, 0, 16);
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "LEGIC LFSR IV 0x%02X: \n", iv);
|
||||
PrintAndLogEx(NORMAL, " bit# | lfsr | ^0x40 | 0x%02X ^ lfsr \n",find);
|
||||
|
||||
|
||||
for (uint8_t i = 0x01; i < 0x30; i += 1) {
|
||||
//period = 0;
|
||||
legic_prng_init(iv);
|
||||
|
@ -246,7 +246,7 @@ int CmdAnalyseLCR(const char *Cmd) {
|
|||
uint8_t data[50];
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) == 0|| cmdp == 'h') return usage_analyse_lcr();
|
||||
|
||||
|
||||
int len = 0;
|
||||
switch (param_gethex_to_eol(Cmd, 0, data, sizeof(data), &len)) {
|
||||
case 1:
|
||||
|
@ -267,10 +267,10 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_analyse_crc();
|
||||
|
||||
|
||||
int len = strlen(Cmd);
|
||||
if ( len & 1 ) return usage_analyse_crc();
|
||||
|
||||
|
||||
// add 1 for null terminator.
|
||||
uint8_t *data = calloc(len+1, sizeof(uint8_t));
|
||||
if ( !data ) return 1;
|
||||
|
@ -279,35 +279,35 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
free(data);
|
||||
return usage_analyse_crc();
|
||||
}
|
||||
len >>= 1;
|
||||
len >>= 1;
|
||||
|
||||
PrintAndLogEx(NORMAL, "\nTests with (%d) | %s",len, sprint_hex(data, len));
|
||||
|
||||
// 51 f5 7a d6
|
||||
|
||||
// 51 f5 7a d6
|
||||
uint8_t uid[] = {0x51, 0xf5, 0x7a, 0xd6}; //12 34 56
|
||||
init_table(CRC_LEGIC);
|
||||
uint8_t legic8 = CRC8Legic(uid, sizeof(uid));
|
||||
PrintAndLogEx(NORMAL, "Legic 16 | %X (EF6F expected) [legic8 = %02x]", crc16_legic(data, len, legic8), legic8);
|
||||
init_table(CRC_FELICA);
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %X ", crc16_xmodem(data, len));
|
||||
|
||||
PrintAndLogEx(NORMAL, "\nTests of reflection. Current methods in source code");
|
||||
|
||||
PrintAndLogEx(NORMAL, "\nTests of reflection. Current methods in source code");
|
||||
PrintAndLogEx(NORMAL, " reflect(0x3e23L,3) is %04X == 0x3e26", reflect(0x3e23L,3) );
|
||||
PrintAndLogEx(NORMAL, " reflect8(0x80) is %02X == 0x01", reflect8(0x80));
|
||||
PrintAndLogEx(NORMAL, " reflect16(0x8000) is %04X == 0x0001", reflect16(0xc6c6));
|
||||
|
||||
|
||||
uint8_t b1, b2;
|
||||
// ISO14443 crc B
|
||||
compute_crc(CRC_14443_B, data, len, &b1, &b2);
|
||||
compute_crc(CRC_14443_B, data, len, &b1, &b2);
|
||||
uint16_t crcBB_1 = b1 << 8 | b2;
|
||||
uint16_t bbb = crc(CRC_14443_B, data, len);
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc B | %04x == %04x \n", crcBB_1, bbb );
|
||||
|
||||
|
||||
|
||||
|
||||
// Test of CRC16, '123456789' string.
|
||||
//
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n\nStandard test with 31 32 33 34 35 36 37 38 39 '123456789'\n\n");
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n\nStandard test with 31 32 33 34 35 36 37 38 39 '123456789'\n\n");
|
||||
uint8_t dataStr[] = { 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39 };
|
||||
legic8 = CRC8Legic(dataStr, sizeof(dataStr));
|
||||
|
||||
|
@ -321,21 +321,21 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "CRC16 based\n\n");
|
||||
|
||||
// input from commandline
|
||||
PrintAndLogEx(NORMAL, "CCITT | %X (29B1 expected)", crc(CRC_CCITT, dataStr, sizeof(dataStr)));
|
||||
|
||||
PrintAndLogEx(NORMAL, "CCITT | %X (29B1 expected)", crc(CRC_CCITT, dataStr, sizeof(dataStr)));
|
||||
|
||||
uint8_t poll[] = {0xb2,0x4d,0x12,0x01,0x01,0x2e,0x3d,0x17,0x26,0x47,0x80, 0x95,0x00,0xf1,0x00,0x00,0x00,0x01,0x43,0x00,0xb3,0x7f};
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04X (B37F expected)", crc(CRC_FELICA, poll+2, sizeof(poll)-4));
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04X (0000 expected)", crc(CRC_FELICA, poll+2, sizeof(poll)-2));
|
||||
|
||||
|
||||
uint8_t sel_corr[] = { 0x40, 0xe1, 0xe1, 0xff, 0xfe, 0x5f, 0x02, 0x3c, 0x43, 0x01};
|
||||
PrintAndLogEx(NORMAL, "iCLASS | %04x (0143 expected)", crc(CRC_ICLASS, sel_corr, sizeof(sel_corr)-2));
|
||||
PrintAndLogEx(NORMAL, "---------------------------------------------------------------\n\n\n");
|
||||
|
||||
|
||||
// ISO14443 crc A
|
||||
compute_crc(CRC_14443_A, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcAA = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ISO14443 crc A | %04x or %04x (BF05 expected)\n", crcAA, crc(CRC_14443_A, dataStr, sizeof(dataStr)) );
|
||||
|
||||
|
||||
// ISO14443 crc B
|
||||
compute_crc(CRC_14443_B, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcBB = b1 << 8 | b2;
|
||||
|
@ -346,7 +346,7 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
uint16_t crcCC = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ISO15693 crc X25| %04x or %04x (906E expected)\n", crcCC, crc(CRC_15693, dataStr, sizeof(dataStr)) );
|
||||
|
||||
// ICLASS
|
||||
// ICLASS
|
||||
compute_crc(CRC_ICLASS, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcDD = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "ICLASS crc | %04x or %04x\n", crcDD, crc(CRC_ICLASS, dataStr, sizeof(dataStr)) );
|
||||
|
@ -355,12 +355,12 @@ int CmdAnalyseCRC(const char *Cmd) {
|
|||
compute_crc(CRC_FELICA, dataStr, sizeof(dataStr), &b1, &b2);
|
||||
uint16_t crcEE = b1 << 8 | b2;
|
||||
PrintAndLogEx(NORMAL, "FeliCa | %04x or %04x (31C3 expected)\n", crcEE, crc(CRC_FELICA, dataStr, sizeof(dataStr)));
|
||||
|
||||
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
int CmdAnalyseCHKSUM(const char *Cmd){
|
||||
|
||||
|
||||
uint8_t data[50];
|
||||
uint8_t cmdp = 0;
|
||||
uint32_t mask = 0xFFFF;
|
||||
|
@ -368,18 +368,18 @@ int CmdAnalyseCHKSUM(const char *Cmd){
|
|||
bool useHeader = false;
|
||||
int len = 0;
|
||||
memset(data, 0x0, sizeof(data));
|
||||
|
||||
|
||||
while(param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch(param_getchar(Cmd, cmdp)) {
|
||||
case 'b':
|
||||
case 'B':
|
||||
param_gethex_ex(Cmd, cmdp+1, data, &len);
|
||||
if ( len%2 ) errors = true;
|
||||
len >>= 1;
|
||||
len >>= 1;
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
case 'M':
|
||||
mask = param_get32ex(Cmd, cmdp+1, 0, 16);
|
||||
cmdp += 2;
|
||||
break;
|
||||
|
@ -399,13 +399,13 @@ int CmdAnalyseCHKSUM(const char *Cmd){
|
|||
}
|
||||
//Validations
|
||||
if (errors || cmdp == 0 ) return usage_analyse_checksum();
|
||||
|
||||
|
||||
if (useHeader) {
|
||||
PrintAndLogEx(NORMAL, " add | sub | add 1's compl | sub 1's compl | xor");
|
||||
PrintAndLogEx(NORMAL, "byte nibble crumb | byte nibble | byte nibble cumb | byte nibble | byte nibble cumb | BSD |");
|
||||
PrintAndLogEx(NORMAL, "------------------+-------------+------------------+-----------------+--------------------");
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X |\n",
|
||||
PrintAndLogEx(NORMAL, "0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X | 0x%X 0x%X 0x%X | 0x%X 0x%X |\n",
|
||||
calcSumByteAdd(data, len, mask)
|
||||
, calcSumNibbleAdd(data, len, mask)
|
||||
, calcSumCrumbAdd(data, len, mask)
|
||||
|
@ -421,7 +421,7 @@ int CmdAnalyseCHKSUM(const char *Cmd){
|
|||
, calcSumCrumbXor(data, len, mask)
|
||||
, calcBSDchecksum8(data, len, mask)
|
||||
, calcBSDchecksum4(data, len, mask)
|
||||
);
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ int CmdAnalyseDates(const char *Cmd){
|
|||
return 0;
|
||||
}
|
||||
int CmdAnalyseTEASelfTest(const char *Cmd){
|
||||
|
||||
|
||||
uint8_t v[8], v_le[8];
|
||||
memset(v, 0x00, sizeof(v));
|
||||
memset(v_le, 0x00, sizeof(v_le));
|
||||
|
@ -439,26 +439,26 @@ int CmdAnalyseTEASelfTest(const char *Cmd){
|
|||
|
||||
uint8_t cmdlen = strlen(Cmd);
|
||||
cmdlen = ( sizeof(v)<<2 < cmdlen ) ? sizeof(v)<<2 : cmdlen;
|
||||
|
||||
|
||||
if ( param_gethex(Cmd, 0, v, cmdlen) > 0 ){
|
||||
PrintAndLogEx(WARNING, "Can't read hex chars, uneven? :: %u", cmdlen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
SwapEndian64ex(v , 8, 4, v_ptr);
|
||||
|
||||
// ENCRYPTION KEY:
|
||||
|
||||
// ENCRYPTION KEY:
|
||||
uint8_t key[16] = {0x55,0xFE,0xF6,0x30,0x62,0xBF,0x0B,0xC1,0xC9,0xB3,0x7C,0x34,0x97,0x3E,0x29,0xFB };
|
||||
uint8_t keyle[16];
|
||||
uint8_t* key_ptr = keyle;
|
||||
SwapEndian64ex(key , sizeof(key), 4, key_ptr);
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "TEST LE enc| %s", sprint_hex(v_ptr, 8));
|
||||
|
||||
tea_decrypt(v_ptr, key_ptr);
|
||||
|
||||
tea_decrypt(v_ptr, key_ptr);
|
||||
PrintAndLogEx(NORMAL, "TEST LE dec | %s", sprint_hex_ascii(v_ptr, 8));
|
||||
|
||||
tea_encrypt(v_ptr, key_ptr);
|
||||
|
||||
tea_encrypt(v_ptr, key_ptr);
|
||||
tea_encrypt(v_ptr, key_ptr);
|
||||
PrintAndLogEx(NORMAL, "TEST enc2 | %s", sprint_hex_ascii(v_ptr, 8));
|
||||
|
||||
|
@ -469,14 +469,14 @@ char* pb(uint32_t b) {
|
|||
static char buf1[33] = {0};
|
||||
static char buf2[33] = {0};
|
||||
static char *s;
|
||||
|
||||
|
||||
if (s != buf1)
|
||||
s = buf1;
|
||||
else
|
||||
else
|
||||
s = buf2;
|
||||
|
||||
|
||||
memset(s, 0, sizeof(buf1));
|
||||
|
||||
|
||||
uint32_t mask = 0x80000000;
|
||||
for (uint8_t i=0; i<32;i++) {
|
||||
s[i] = (mask & b)?'1':'0';
|
||||
|
@ -491,7 +491,7 @@ int CmdAnalyseA(const char *Cmd){
|
|||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'd':
|
||||
|
@ -500,7 +500,7 @@ int CmdAnalyseA(const char *Cmd){
|
|||
if ( hexlen != sizeof(data) ) {
|
||||
PrintAndLogEx(WARNING, "Read %d bytes of %u", hexlen, sizeof(data) );
|
||||
}
|
||||
cmdp += 2;
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'h':
|
||||
return usage_analyse_a();
|
||||
|
@ -513,7 +513,7 @@ int CmdAnalyseA(const char *Cmd){
|
|||
//Validations
|
||||
if (errors || cmdp == 0 ) return usage_analyse_a();
|
||||
|
||||
|
||||
|
||||
UsbCommand c = {CMD_FPC_SEND, {0, 0, 0}};
|
||||
memcpy(c.d.asBytes, data, USB_CMD_DATA_SIZE);
|
||||
clearCommandBuffer();
|
||||
|
@ -525,16 +525,16 @@ int CmdAnalyseA(const char *Cmd){
|
|||
}
|
||||
PrintAndLogEx(NORMAL, "got ack. Status %d", resp.arg[0]);
|
||||
return 0;
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "-- " _BLUE_(its my message) "\n");
|
||||
PrintAndLogEx(NORMAL, "-- " _RED_(its my message) "\n");
|
||||
PrintAndLogEx(NORMAL, "-- " _YELLOW_(its my message) "\n");
|
||||
PrintAndLogEx(NORMAL, "-- " _GREEN_(its my message) "\n");
|
||||
|
||||
|
||||
//uint8_t syncBit = 99;
|
||||
// The start bit is one ore more Sequence Y followed by a Sequence Z (... 11111111 00x11111). We need to distinguish from
|
||||
// Sequence X followed by Sequence Y followed by Sequence Z (111100x1 11111111 00x11111)
|
||||
// we therefore look for a ...xx1111 11111111 00x11111xxxxxx... pattern
|
||||
// we therefore look for a ...xx1111 11111111 00x11111xxxxxx... pattern
|
||||
// (12 '1's followed by 2 '0's, eventually followed by another '0', followed by 5 '1's)
|
||||
# define SYNC_16BIT 0xB24D
|
||||
uint32_t shiftReg = param_get32ex(Cmd, 0, 0xb24d, 16);
|
||||
|
@ -554,7 +554,7 @@ int CmdAnalyseA(const char *Cmd){
|
|||
n1 = (n1 << 4) | (rev & (uint8_t)(~(0xFF << 4)));
|
||||
|
||||
PrintAndLogEx(NORMAL, "rev %02X | %02X %s | %02X %s |\n", rev, n0, pb(n0), n1, pb(n1) );
|
||||
|
||||
|
||||
/*
|
||||
hex(0xb24d shr 0) 0xB24D 0b1011001001001101
|
||||
hex(0xb24d shr 1) 0x5926
|
||||
|
@ -568,29 +568,29 @@ for ( int i =0; i< 16; i++) {
|
|||
if ((( shiftReg >> 7) & 0xFFFF ) == SYNC_16BIT) byte_offset = 7;
|
||||
else if ((( shiftReg >> 6) & 0xFFFF ) == SYNC_16BIT) byte_offset = 6;
|
||||
else if ((( shiftReg >> 5) & 0xFFFF ) == SYNC_16BIT) byte_offset = 5;
|
||||
else if ((( shiftReg >> 4) & 0xFFFF ) == SYNC_16BIT) byte_offset = 4;
|
||||
else if ((( shiftReg >> 4) & 0xFFFF ) == SYNC_16BIT) byte_offset = 4;
|
||||
else if ((( shiftReg >> 3) & 0xFFFF ) == SYNC_16BIT) byte_offset = 3;
|
||||
else if ((( shiftReg >> 2) & 0xFFFF ) == SYNC_16BIT) byte_offset = 2;
|
||||
else if ((( shiftReg >> 1) & 0xFFFF ) == SYNC_16BIT) byte_offset = 1;
|
||||
else if ((( shiftReg >> 0) & 0xFFFF ) == SYNC_16BIT) byte_offset = 0;
|
||||
|
||||
PrintAndLogEx(NORMAL, "Offset %u \n", byte_offset);
|
||||
if ( byte_offset != 99 )
|
||||
if ( byte_offset != 99 )
|
||||
break;
|
||||
|
||||
shiftReg >>=1;
|
||||
|
||||
shiftReg >>=1;
|
||||
}
|
||||
|
||||
uint8_t p1 = (rev & (uint8_t)(~(0xFF << byte_offset)));
|
||||
PrintAndLogEx(NORMAL, "Offset %u | leftovers %02x %s \n", byte_offset, p1, pb(p1) );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
pm3 --> da hex2bin 4db2 0100110110110010
|
||||
*/
|
||||
return 0;
|
||||
/*
|
||||
/*
|
||||
// split byte into two parts.
|
||||
uint8_t offset = 3, n0 = 0, n1 = 0;
|
||||
rev = 0xB2;
|
||||
|
@ -605,47 +605,47 @@ pm3 --> da hex2bin 4db2 0100110110110010
|
|||
//PrintAndLogEx(NORMAL, "~(0xFF >> (8-offset)) == %s |\n", pb( (uint8_t)(~(0xFF >> (8-offset))) ) );
|
||||
//PrintAndLogEx(NORMAL, " rev & xxx == %s\n\n", pb( (rev & (uint8_t)(~(0xFF << offset))) ));
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
// from A -- x bits into B and the rest into C.
|
||||
|
||||
for ( uint8_t i=0; i<8; i++){
|
||||
|
||||
for ( uint8_t i=0; i<8; i++){
|
||||
PrintAndLogEx(NORMAL, "%u | %02X %s | %02X %s |\n", i, a, pb(a), b, pb(b) );
|
||||
b = a & (a & (0xFF >> (8-i)));
|
||||
a >>=1;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
return 0;
|
||||
|
||||
// 14443-A
|
||||
uint8_t u14_c[] = {0x09, 0x78, 0x00, 0x92, 0x02, 0x54, 0x13, 0x02, 0x04, 0x2d, 0xe8 }; // atqs w crc
|
||||
// 14443-A
|
||||
uint8_t u14_c[] = {0x09, 0x78, 0x00, 0x92, 0x02, 0x54, 0x13, 0x02, 0x04, 0x2d, 0xe8 }; // atqs w crc
|
||||
uint8_t u14_w[] = {0x09, 0x78, 0x00, 0x92, 0x02, 0x54, 0x13, 0x02, 0x04, 0x2d, 0xe7 }; // atqs w crc
|
||||
PrintAndLogEx(FAILED, "14a check wrong crc | %s\n", (check_crc(CRC_14443_A, u14_w, sizeof(u14_w))) ? "YES": "NO" );
|
||||
PrintAndLogEx(FAILED, "14a check wrong crc | %s\n", (check_crc(CRC_14443_A, u14_w, sizeof(u14_w))) ? "YES": "NO" );
|
||||
PrintAndLogEx(SUCCESS, "14a check correct crc | %s\n", (check_crc(CRC_14443_A, u14_c, sizeof(u14_c))) ? "YES": "NO" );
|
||||
|
||||
|
||||
// 14443-B
|
||||
uint8_t u14b[] = {0x05,0x00,0x08,0x39,0x73};
|
||||
PrintAndLogEx(NORMAL, "14b check crc | %s\n", (check_crc(CRC_14443_B, u14b, sizeof(u14b))) ? "YES": "NO");
|
||||
PrintAndLogEx(NORMAL, "14b check crc | %s\n", (check_crc(CRC_14443_B, u14b, sizeof(u14b))) ? "YES": "NO");
|
||||
|
||||
// 15693 test
|
||||
uint8_t u15_c[] = {0x05,0x00,0x08,0x39,0x73}; // correct
|
||||
uint8_t u15_w[] = {0x05,0x00,0x08,0x39,0x72}; // wrong
|
||||
PrintAndLogEx(FAILED, "15 check wrong crc | %s\n", (check_crc(CRC_15693, u15_w, sizeof(u15_w))) ? "YES": "NO");
|
||||
PrintAndLogEx(SUCCESS, "15 check correct crc | %s\n", (check_crc(CRC_15693, u15_c, sizeof(u15_c))) ? "YES": "NO");
|
||||
PrintAndLogEx(FAILED, "15 check wrong crc | %s\n", (check_crc(CRC_15693, u15_w, sizeof(u15_w))) ? "YES": "NO");
|
||||
PrintAndLogEx(SUCCESS, "15 check correct crc | %s\n", (check_crc(CRC_15693, u15_c, sizeof(u15_c))) ? "YES": "NO");
|
||||
|
||||
// iCLASS test - wrong crc , swapped bytes.
|
||||
uint8_t iclass_w[] = { 0x40, 0xe1, 0xe1, 0xff, 0xfe, 0x5f, 0x02, 0x3c, 0x01, 0x43};
|
||||
uint8_t iclass_c[] = { 0x40, 0xe1, 0xe1, 0xff, 0xfe, 0x5f, 0x02, 0x3c, 0x43, 0x01};
|
||||
PrintAndLogEx(FAILED, "iCLASS check wrong crc | %s\n", (check_crc(CRC_ICLASS, iclass_w, sizeof(iclass_w))) ? "YES": "NO");
|
||||
PrintAndLogEx(SUCCESS, "iCLASS check correct crc | %s\n", (check_crc(CRC_ICLASS, iclass_c, sizeof(iclass_c))) ? "YES": "NO");
|
||||
|
||||
PrintAndLogEx(FAILED, "iCLASS check wrong crc | %s\n", (check_crc(CRC_ICLASS, iclass_w, sizeof(iclass_w))) ? "YES": "NO");
|
||||
PrintAndLogEx(SUCCESS, "iCLASS check correct crc | %s\n", (check_crc(CRC_ICLASS, iclass_c, sizeof(iclass_c))) ? "YES": "NO");
|
||||
|
||||
// FeliCa test
|
||||
uint8_t felica_w[] = {0x12,0x01,0x01,0x2e,0x3d,0x17,0x26,0x47,0x80, 0x95,0x00,0xf1,0x00,0x00,0x00,0x01,0x43,0x00,0xb3,0x7e};
|
||||
uint8_t felica_c[] = {0x12,0x01,0x01,0x2e,0x3d,0x17,0x26,0x47,0x80, 0x95,0x00,0xf1,0x00,0x00,0x00,0x01,0x43,0x00,0xb3,0x7f};
|
||||
PrintAndLogEx(FAILED, "FeliCa check wrong crc | %s\n", (check_crc(CRC_FELICA, felica_w, sizeof(felica_w))) ? "YES": "NO");
|
||||
PrintAndLogEx(SUCCESS, "FeliCa check correct crc | %s\n", (check_crc(CRC_FELICA, felica_c, sizeof(felica_c))) ? "YES": "NO");
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n\n");
|
||||
PrintAndLogEx(FAILED, "FeliCa check wrong crc | %s\n", (check_crc(CRC_FELICA, felica_w, sizeof(felica_w))) ? "YES": "NO");
|
||||
PrintAndLogEx(SUCCESS, "FeliCa check correct crc | %s\n", (check_crc(CRC_FELICA, felica_c, sizeof(felica_c))) ? "YES": "NO");
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n\n");
|
||||
|
||||
return 0;
|
||||
/*
|
||||
|
@ -656,7 +656,7 @@ return 0;
|
|||
star[1] = '\\';
|
||||
star[2] = '|';
|
||||
star[3] = '/';
|
||||
|
||||
|
||||
for (uint8_t k=0; k<4; k = (k+1) % 4 ) {
|
||||
PrintAndLogEx(NORMAL, "\e[s%c\e[u", star[k]);
|
||||
fflush(stdout);
|
||||
|
@ -667,19 +667,19 @@ return 0;
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//piwi
|
||||
// uid(2e086b1a) nt(230736f6) ks(0b0008000804000e) nr(000000000)
|
||||
// uid(2e086b1a) nt(230736f6) ks(0e0b0e0b090c0d02) nr(000000001)
|
||||
// uid(2e086b1a) nt(230736f6) ks(0e05060e01080b08) nr(000000002)
|
||||
//uint64_t d1[] = {0x2e086b1a, 0x230736f6, 0x0000001, 0x0e0b0e0b090c0d02};
|
||||
//uint64_t d2[] = {0x2e086b1a, 0x230736f6, 0x0000002, 0x0e05060e01080b08};
|
||||
|
||||
|
||||
// uid(17758822) nt(c0c69e59) ks(080105020705040e) nr(00000001)
|
||||
// uid(17758822) nt(c0c69e59) ks(01070a05050c0705) nr(00000002)
|
||||
//uint64_t d1[] = {0x17758822, 0xc0c69e59, 0x0000001, 0x080105020705040e};
|
||||
//uint64_t d2[] = {0x17758822, 0xc0c69e59, 0x0000002, 0x01070a05050c0705};
|
||||
|
||||
|
||||
// uid(6e442129) nt(8f699195) ks(090d0b0305020f02) nr(00000001)
|
||||
// uid(6e442129) nt(8f699195) ks(03030508030b0c0e) nr(00000002)
|
||||
// uid(6e442129) nt(8f699195) ks(02010f030c0d050d) nr(00000003)
|
||||
|
@ -687,7 +687,7 @@ return 0;
|
|||
//uint64_t d1[] = {0x6e442129, 0x8f699195, 0x0000001, 0x090d0b0305020f02};
|
||||
//uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0x00040f0f0305030e};
|
||||
|
||||
/*
|
||||
/*
|
||||
uid(3e172b29) nt(039b7bd2) ks(0c0e0f0505080800) nr(00000001)
|
||||
uid(3e172b29) nt(039b7bd2) ks(0e06090d03000b0f) nr(00000002)
|
||||
*/
|
||||
|
@ -697,7 +697,7 @@ uid(3e172b29) nt(039b7bd2) ks(0e06090d03000b0f) nr(00000002)
|
|||
// uint64_t d2[] = {0x3e172b29, 0x039b7bd2, 0x0000002, 0, 0x0e06090d03000b0f};
|
||||
uint64_t d1[] = {0x6e442129, 0x8f699195, 0x0000001, 0, 0x090d0b0305020f02};
|
||||
uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
||||
|
||||
|
||||
keycountA = nonce2key(d1[0], d1[1], d1[2], 0, d1[3], d1[4] ,&keylistA);
|
||||
keycountB = nonce2key(d2[0], d2[1], d2[2], 0, d2[3], d2[4], &keylistB);
|
||||
|
||||
|
@ -708,11 +708,11 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
switch (keycountB) {
|
||||
case 0: PrintAndLogEx(FAILED, "Key test B failed\n"); break;
|
||||
case 1: PrintAndLogEx(SUCCESS, "KEY B | %012" PRIX64 " ", keylistB[0]); break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
free(keylistA);
|
||||
free(keylistB);
|
||||
|
||||
|
||||
// qsort(keylist, keycount, sizeof(*keylist), compare_uint64);
|
||||
// keycount = intersection(last_keylist, keylist);
|
||||
|
||||
|
@ -727,7 +727,7 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
0x8211b0607367, 0xe2936b320f76, 0xaff501e84378, 0x82b31cedb21b,
|
||||
0xb725d31d4cd3, 0x3b984145b2f1, 0x3b4adb3e82ba, 0x8779075210fe
|
||||
};
|
||||
|
||||
|
||||
uint64_t keya[] = {
|
||||
0x7b5b8144a32f, 0x76b46ccc461e, 0x03c3c36ea7a2, 0x171414d31961,
|
||||
0xe2bfc7153eea, 0x48023d1d1985, 0xff7e1a410953, 0x49a3110249d3,
|
||||
|
@ -740,9 +740,9 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
0x8211b0607367, 0xe2936b320f76, 0xaff501e84378, 0x82b31cedb21b,
|
||||
0xb725d31d4cd3, 0x3b984145b2f1, 0x3b4adb3e82ba, 0x8779075210fe
|
||||
};
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
uint64_t xor[] = {
|
||||
0x0DEFED88E531, 0x7577AFA2E1BC, 0x14D7D7BDBEC3, 0xF5ABD3C6278B,
|
||||
|
@ -754,7 +754,7 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
0x6082DB527C11, 0x4D666ADA4C0E, 0x2D461D05F163, 0x3596CFF0FEC8,
|
||||
0x8CBD9258FE22, 0x00D29A7B304B, 0xBC33DC6C9244
|
||||
};
|
||||
|
||||
|
||||
|
||||
uint64_t xorA[] = {
|
||||
0x0DEFED88E531, 0x7577AFA2E1BC, 0x14D7D7BDBEC3, 0xF5ABD3C6278B,
|
||||
|
@ -769,7 +769,7 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
0x8CBD9258FE22, 0x00D29A7B304B, 0xBC33DC6C9244
|
||||
};
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
// xor key A | xor key B
|
||||
1 | 0DEFED88E531 | 2F87A1BDC230
|
||||
2 | 7577AFA2E1BC | E43F502B984C
|
||||
|
@ -795,12 +795,12 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
PrintAndLogEx(NORMAL, "%u | %012" PRIX64 " | \n", i, a);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
uint32_t id = param_get32ex(Cmd, 0, 0x93290142, 16);
|
||||
uint32_t id = param_get32ex(Cmd, 0, 0x93290142, 16);
|
||||
uint8_t uid[6] = {0};
|
||||
num_to_bytes(id,4,uid);
|
||||
|
||||
|
||||
uint8_t key_s0a[] = {
|
||||
uid[1] ^ uid[2] ^ uid[3] ^ 0x11,
|
||||
uid[1] ^ 0x72,
|
||||
|
@ -812,20 +812,20 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
|
||||
PrintAndLogEx(NORMAL, "UID | %s\n", sprint_hex(uid,4 ));
|
||||
PrintAndLogEx(NORMAL, "KEY A | %s\n", sprint_hex(key_s0a, 6));
|
||||
|
||||
|
||||
// arrays w all keys
|
||||
uint64_t foo[32] = {0};
|
||||
|
||||
|
||||
//A
|
||||
foo[0] = bytes_to_num(key_s0a, 6);
|
||||
//B
|
||||
//foo[16] = 0xcafe71411fbf;
|
||||
foo[16] = 0xeafe51411fbf;
|
||||
|
||||
for (uint8_t i=0; i<15; i++){
|
||||
|
||||
for (uint8_t i=0; i<15; i++){
|
||||
foo[i+1] = foo[i] ^ xorA[i];
|
||||
foo[i+16+1] = foo[i+16] ^ xorB[i];
|
||||
|
||||
|
||||
}
|
||||
for (uint8_t i=0; i<15; i++){
|
||||
uint64_t a = foo[i];
|
||||
|
@ -836,7 +836,7 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
a,
|
||||
( a == keya[i])?"ok":"err",
|
||||
b,
|
||||
( b == keyb[i])?"ok":"err"
|
||||
( b == keyb[i])?"ok":"err"
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
@ -846,7 +846,7 @@ uint64_t d2[] = {0x6e442129, 0x8f699195, 0x0000004, 0, 0x00040f0f0305030e};
|
|||
void generate4bNUID(uint8_t *uid, uint8_t *nuid){
|
||||
uint16_t crc;
|
||||
uint8_t b1, b2;
|
||||
|
||||
|
||||
compute_crc(CRC_14443_A, uid, 3, &b1, &b2);
|
||||
nuid[0] = (b2 & 0xE0) | 0xF;
|
||||
nuid[1] = b1;
|
||||
|
@ -858,7 +858,7 @@ void generate4bNUID(uint8_t *uid, uint8_t *nuid){
|
|||
}
|
||||
|
||||
int CmdAnalyseNuid(const char *Cmd){
|
||||
uint8_t nuid[4] = {0};
|
||||
uint8_t nuid[4] = {0};
|
||||
uint8_t uid[7] = {0};
|
||||
int len = 0;
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
|
@ -870,13 +870,13 @@ int CmdAnalyseNuid(const char *Cmd){
|
|||
if (cmdp == 't') {
|
||||
memcpy(uid, "\x04\x0d\x68\x1a\xb5\x22\x81", 7);
|
||||
generate4bNUID(uid, nuid);
|
||||
|
||||
|
||||
bool test1 = (0 == memcmp(nuid, "\x8f\x43\x0f\xef", 4));
|
||||
PrintAndLogEx(SUCCESS, "Selftest1 %s\n", test1 ? _GREEN_(OK): _RED_(Fail));
|
||||
|
||||
|
||||
memcpy(uid, "\x04\x18\x3f\x09\x32\x1b\x85", 7);
|
||||
generate4bNUID(uid, nuid);
|
||||
bool test2 = (0 == memcmp(nuid, "\x4f\x50\x5d\x7d", 4));
|
||||
bool test2 = (0 == memcmp(nuid, "\x4f\x50\x5d\x7d", 4));
|
||||
PrintAndLogEx(SUCCESS, "Selftest2 %s\n", test2 ? _GREEN_(OK) : _RED_(Fail));
|
||||
return 0;
|
||||
}
|
||||
|
@ -885,7 +885,7 @@ int CmdAnalyseNuid(const char *Cmd){
|
|||
if ( len%2 || len != 14) return usage_analyse_nuid();
|
||||
|
||||
generate4bNUID(uid, nuid);
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "UID | %s \n", sprint_hex(uid, 7));
|
||||
PrintAndLogEx(NORMAL, "NUID | %s \n", sprint_hex(nuid, 4));
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue