X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/345fb24aaa0ba6586c3ac2b4835eefdebcaf3314..6ce0e5386a5dd4ce8eb171437e2b62ca55a328ea:/client/cmdhfmfu.c diff --git a/client/cmdhfmfu.c b/client/cmdhfmfu.c index ce345789..884ed3ff 100644 --- a/client/cmdhfmfu.c +++ b/client/cmdhfmfu.c @@ -23,26 +23,6 @@ #define MAX_NTAG_215 0x86 #define MAX_NTAG_216 0xe6 -typedef enum TAGTYPE_UL { - UNKNOWN = 0x0000, - UL = 0x0001, - UL_C = 0x0002, - UL_EV1_48 = 0x0004, - UL_EV1_128 = 0x0008, - NTAG = 0x0010, - NTAG_213 = 0x0020, - NTAG_215 = 0x0040, - NTAG_216 = 0x0080, - MY_D = 0x0100, - MY_D_NFC = 0x0200, - MY_D_MOVE = 0x0400, - MY_D_MOVE_NFC = 0x0800, - MAGIC = 0x1000, - UL_MAGIC = UL | MAGIC, - UL_C_MAGIC = UL_C | MAGIC, - UL_ERROR = 0xFFFF, -} TagTypeUL_t; - #define KEYS_3DES_COUNT 7 uint8_t default_3des_keys[KEYS_3DES_COUNT][16] = { { 0x42,0x52,0x45,0x41,0x4b,0x4d,0x45,0x49,0x46,0x59,0x4f,0x55,0x43,0x41,0x4e,0x21 },// 3des std key @@ -96,9 +76,10 @@ char* getUlev1CardSizeStr( uint8_t fsize ){ static char buf[40]; char *retStr = buf; + memset(buf, 0, sizeof(buf)); - uint8_t usize = 1 << ((fsize >>1) + 1); - uint8_t lsize = 1 << (fsize >>1); + uint16_t usize = 1 << ((fsize >>1) + 1); + uint16_t lsize = 1 << (fsize >>1); // is LSB set? if ( fsize & 1 ) @@ -258,7 +239,7 @@ static int ul_print_default( uint8_t *data){ uid[6] = data[7]; PrintAndLog(" UID : %s ", sprint_hex(uid, 7)); - PrintAndLog(" UID[0] : %02x, Manufacturer: %s", uid[0], getTagInfo(uid[0]) ); + PrintAndLog(" UID[0] : %02X, Manufacturer: %s", uid[0], getTagInfo(uid[0]) ); if ( uid[0] == 0x05 ) { uint8_t chip = (data[8] & 0xC7); // 11000111 mask, bit 3,4,5 RFU switch (chip){ @@ -270,19 +251,20 @@ static int ul_print_default( uint8_t *data){ // CT (cascade tag byte) 0x88 xor SN0 xor SN1 xor SN2 int crc0 = 0x88 ^ data[0] ^ data[1] ^data[2]; if ( data[3] == crc0 ) - PrintAndLog(" BCC0 : 0x%02X - Ok", data[3]); + PrintAndLog(" BCC0 : %02X - Ok", data[3]); else - PrintAndLog(" BCC0 : 0x%02X - crc should be %02x", data[3], crc0); + PrintAndLog(" BCC0 : %02X - crc should be %02X", data[3], crc0); int crc1 = data[4] ^ data[5] ^ data[6] ^data[7]; if ( data[8] == crc1 ) - PrintAndLog(" BCC1 : 0x%02X - Ok", data[8]); + PrintAndLog(" BCC1 : %02X - Ok", data[8]); else - PrintAndLog(" BCC1 : 0x%02X - crc should be 0x%02X", data[8], crc1 ); + PrintAndLog(" BCC1 : %02X - crc should be %02X", data[8], crc1 ); - PrintAndLog(" Internal : 0x%02X - %s default", data[9], (data[9]==0x48)?"":"not" ); + PrintAndLog(" Internal : %02X - %s default", data[9], (data[9]==0x48)?"":"not" ); PrintAndLog(" Lock : %s - %s", sprint_hex(data+10, 2),printBits( 2, data+10) ); PrintAndLog("OneTimePad : %s ", sprint_hex(data + 12, 4)); + PrintAndLog(""); return 0; } @@ -312,31 +294,35 @@ static int ntag_print_CC(uint8_t *data) { return 0; } -static int ul_print_type(uint16_t tagtype){ +int ul_print_type(uint16_t tagtype, uint8_t spaces){ + char spc[11] = " "; + spc[10]=0x00; + char *spacer = spc + (10-spaces); + if ( tagtype & UL ) - PrintAndLog(" TYPE : MIFARE Ultralight (MF0ICU1) %s [%x]", (tagtype & MAGIC)?"":"", tagtype); + PrintAndLog("%sTYPE : MIFARE Ultralight (MF0ICU1) %s [%x]", spacer, (tagtype & MAGIC)?"":"", tagtype); else if ( tagtype & UL_C) - PrintAndLog(" TYPE : MIFARE Ultralight C (MF0ULC) %s [%x]", (tagtype & MAGIC)?"":"", tagtype ); + PrintAndLog("%sTYPE : MIFARE Ultralight C (MF0ULC) %s [%x]", spacer, (tagtype & MAGIC)?"":"", tagtype ); else if ( tagtype & UL_EV1_48) - PrintAndLog(" TYPE : MIFARE Ultralight EV1 48bytes (MF0UL1101)"); + PrintAndLog("%sTYPE : MIFARE Ultralight EV1 48bytes (MF0UL1101)", spacer); else if ( tagtype & UL_EV1_128) - PrintAndLog(" TYPE : MIFARE Ultralight EV1 128bytes (MF0UL2101)"); + PrintAndLog("%sTYPE : MIFARE Ultralight EV1 128bytes (MF0UL2101)", spacer); else if ( tagtype & NTAG_213 ) - PrintAndLog(" TYPE : MIFARE NTAG 213 144bytes (NT2H1311G0DU)"); + PrintAndLog("%sTYPE : MIFARE NTAG 213 144bytes (NT2H1311G0DU)", spacer); else if ( tagtype & NTAG_215 ) - PrintAndLog(" TYPE : MIFARE NTAG 215 504bytes (NT2H1511G0DU)"); + PrintAndLog("%sTYPE : MIFARE NTAG 215 504bytes (NT2H1511G0DU)", spacer); else if ( tagtype & NTAG_216 ) - PrintAndLog(" TYPE : MIFARE NTAG 216 888bytes (NT2H1611G0DU)"); + PrintAndLog("%sTYPE : MIFARE NTAG 216 888bytes (NT2H1611G0DU)", spacer); else if ( tagtype & MY_D ) - PrintAndLog(" TYPE : INFINEON my-d\x99"); + PrintAndLog("%sTYPE : INFINEON my-d\x99", spacer); else if ( tagtype & MY_D_NFC ) - PrintAndLog(" TYPE : INFINEON my-d\x99 NFC"); + PrintAndLog("%sTYPE : INFINEON my-d\x99 NFC", spacer); else if ( tagtype & MY_D_MOVE ) - PrintAndLog(" TYPE : INFINEON my-d\x99 move"); + PrintAndLog("%sTYPE : INFINEON my-d\x99 move", spacer); else if ( tagtype & MY_D_MOVE_NFC ) - PrintAndLog(" TYPE : INFINEON my-d\x99 move NFC"); + PrintAndLog("%sTYPE : INFINEON my-d\x99 move NFC", spacer); else - PrintAndLog(" TYPE : Unknown %04x",tagtype); + PrintAndLog("%sTYPE : Unknown %04x", spacer, tagtype); return 0; } @@ -499,7 +485,7 @@ uint16_t GetHF14AMfU_Type(void){ } // Ultralight - ATQA / SAK if ( card.atqa[1] != 0x00 || card.atqa[0] != 0x44 || card.sak != 0x00 ) { - PrintAndLog("Tag is not Ultralight | NTAG | MY-D [ATQA: %02X %02x SAK: %02X]\n", card.atqa[1], card.atqa[0], card.sak); + PrintAndLog("Tag is not Ultralight | NTAG | MY-D [ATQA: %02X %02X SAK: %02X]\n", card.atqa[1], card.atqa[0], card.sak); ul_switch_off_field(); return UL_ERROR; } @@ -577,7 +563,7 @@ int CmdHF14AMfUInfo(const char *Cmd){ PrintAndLog("\n--- Tag Information ---------"); PrintAndLog("-------------------------------------------------------------"); - ul_print_type(tagtype); + ul_print_type(tagtype, 6); status = ul_select(&card); if ( status < 1 ){ @@ -884,6 +870,7 @@ int CmdHF14AMfUDump(const char *Cmd){ case 's': swapEndian = true; cmdp++; + break; default: PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp)); errors = true;