+static int ul_print_version(uint8_t *data){
+ PrintAndLog("VERSION COMMAND: %s", sprint_hex(data, 8) );
+ PrintAndLog(" Vendor ID : 0x%02X, Manufacturer: %s", data[1], getTagInfo(data[1]));
+ PrintAndLog(" Product type : %s" , getProductTypeStr(data[2]));
+ PrintAndLog("Product subtype : 0x%02X %s" , data[3], (data[3]==1) ?"17 pF":"50pF");
+ PrintAndLog(" Major version : 0x%02X" , data[4]);
+ PrintAndLog(" Minor version : 0x%02X" , data[5]);
+ PrintAndLog(" Size : %s", getUlev1CardSizeStr(data[6]));
+ PrintAndLog(" Protocol type : 0x%02X" , data[7]);
+ return 0;
+}
+
+static int ul_print_type(uint16_t tagtype){
+ if ( tagtype & UL )
+ PrintAndLog(" TYPE : MIFARE Ultralight (MF0ICU1) %s", (tagtype & MAGIC)?"<magic>":"");
+ else if ( tagtype & UL_C)
+ PrintAndLog(" TYPE : MIFARE Ultralight C (MF0ULC) %s", (tagtype & MAGIC)?"<magic>":"" );
+ else if ( tagtype & UL_EV1_48)
+ PrintAndLog(" TYPE : MIFARE Ultralight EV1 48bytes (MF0UL1101)");
+ else if ( tagtype & UL_EV1_128)
+ PrintAndLog(" TYPE : MIFARE Ultralight EV1 128bytes (MF0UL2101");
+ else if ( tagtype & NTAG_213 )
+ PrintAndLog(" TYPE : MIFARE NTAG 213 144bytes (NT2H1311G0DU)");
+ else if ( tagtype & NTAG_215 )
+ PrintAndLog(" TYPE : MIFARE NTAG 215 504bytes (NT2H1511G0DU)");
+ else if ( tagtype & NTAG_216 )
+ PrintAndLog(" TYPE : MIFARE NTAG 216 888bytes (NT2H1611G0DU)");
+ else
+ PrintAndLog(" TYPE : Unknown %x",tagtype);
+ return 0;
+}
+
+uint16_t GetHF14AMfU_Type(void){
+
+ TagTypeUL_t tagtype = UNKNOWN;
+ iso14a_card_select_t card;
+ uint8_t version[10] = {0x00};
+ uint8_t nonce1[11] = {0x00};
+ uint8_t nonce2[11] = {0x00};
+ int status = 0;
+ int len;
+
+ status = ul_select(&card);
+ if ( status < 1 ){
+ PrintAndLog("Error: couldn't select");
+ return UL_ERROR;
+ }
+
+ // Ultralight - ATQA / SAK
+ if ( card.atqa[1] != 0x00 && card.atqa[0] != 0x44 && card.sak != 0x00 ) {
+ ul_switch_off_field();
+ return UL_ERROR;
+ }
+
+ len = ulev1_getVersion(version);
+
+ switch (len) {
+ case -1:
+ tagtype = (UL | UL_C);
+ break;
+ case 0x0A: {
+
+ if ( version[2] == 0x03 && version[6] == 0x0B )
+ tagtype = UL_EV1_48;
+ else if ( version[2] == 0x03 && version[6] != 0x0B )
+ tagtype = UL_EV1_128;
+ else if ( version[2] == 0x04 && version[6] == 0x0F )
+ tagtype = NTAG_213;
+ else if ( version[2] == 0x04 && version[6] != 0x11 )
+ tagtype = NTAG_215;
+ else if ( version[2] == 0x04 && version[6] == 0x13 )
+ tagtype = NTAG_216;
+ else if ( version[2] == 0x04 )
+ tagtype = NTAG;
+
+ break;
+ }
+ case 0x01:{
+ tagtype = UL_C;
+ break;
+ }
+ case 0x00: {
+ tagtype = UL;
+ break;
+ }
+ default :{
+ tagtype = UNKNOWN;
+ break;
+ }
+ }
+
+ if ((tagtype & ( UL_C | UL ))) {
+ // Magic UL-C, by observation,
+ // it seems to have a static nonce response to 0x1A command.
+ status = ul_select(&card);
+ status = ulc_requestAuthentication(0, nonce1);
+ if ( status > 0 ) {
+ status = ulc_requestAuthentication(0, nonce2);
+
+ if ( !memcmp(nonce1, nonce2, 11)) {
+ tagtype = UL_C_MAGIC;
+ }
+ else
+ tagtype = UL_C;
+
+ } else {
+ tagtype = UL;
+ }
+ }
+
+ //PrintAndLog("ICE %d", tagtype);
+ //Magic Ultralight test here. It takes present UID, and tries to write it back.
+ if ( (tagtype & UL) ){
+ // read 3des key or PWD,
+ // if response bytes == all zeros its a NORMAL tag.
+ //return UL_MAGIC;
+ }
+
+ ul_switch_off_field();
+ return tagtype;
+}
+
+int CmdHF14AMfUInfo(const char *Cmd){
+
+ uint8_t datatemp[7] = {0x00};
+ uint8_t data[16] = {0x00};
+ iso14a_card_select_t card;
+ uint8_t *key;
+ int status;
+
+ PrintAndLog("\n-- Tag Information ---------");
+ PrintAndLog("-------------------------------------------------------------");
+
+ TagTypeUL_t tagtype = GetHF14AMfU_Type();
+ if (tagtype == UL_ERROR) return -1;
+
+ ul_print_type(tagtype);
+
+ status = ul_select(&card);
+ if ( status < 1 ){
+ PrintAndLog("Error: couldn't select");
+ ul_switch_off_field();
+ return status;
+ }
+
+ // read pages 0,1,2,4 (should read 4pages)
+ status = ul_read(0, data);
+ if ( status == -1 ){
+ PrintAndLog("Error: tag didn't answer to READ");
+ ul_switch_off_field();
+ return status;
+ }
+