- {0x4A,0xF8,0x4B,0x19}, // PACK 0xE5,0xBE -- italian bus (sniffed)
- {0x33,0x6B,0xA1,0x19}, // PACK 0x9c,0x2d -- italian bus (sniffed)
- {0xFF,0x90,0x6C,0xB2}, // PACK 0x12,0x9e -- italian bus (sniffed)
- {0x05,0x22,0xE6,0xB4}, // PACK 0x80,0x80 -- Amiiboo (sniffed) pikachu-b UID:
- {0x7E,0x22,0xE6,0xB4}, // PACK 0x80,0x80 -- AMiiboo (sniffed)
- {0x02,0xE1,0xEE,0x36}, // PACK 0x80,0x80 -- AMiiboo (sniffed) sonic UID: 04d257 7ae33e8027
- {0x32,0x0C,0x16,0x17}, // PACK 0x80,0x80 -- AMiiboo (sniffed)
-};
+};
+
+#define MAX_UL_TYPES 18
+uint32_t UL_TYPES_ARRAY[MAX_UL_TYPES] = {
+ UNKNOWN, UL, UL_C,
+ UL_EV1_48, UL_EV1_128, NTAG,
+ NTAG_203, NTAG_210, NTAG_212,
+ NTAG_213, NTAG_215, NTAG_216,
+ MY_D, MY_D_NFC, MY_D_MOVE,
+ MY_D_MOVE_NFC, MY_D_MOVE_LEAN, FUDAN_UL};
+
+uint8_t UL_MEMORY_ARRAY[MAX_UL_TYPES] = {
+ MAX_UL_BLOCKS, MAX_UL_BLOCKS, MAX_ULC_BLOCKS,
+ MAX_ULEV1a_BLOCKS, MAX_ULEV1b_BLOCKS, MAX_NTAG_203,
+ MAX_NTAG_203, MAX_NTAG_210, MAX_NTAG_212,
+ MAX_NTAG_213, MAX_NTAG_215, MAX_NTAG_216,
+ MAX_UL_BLOCKS, MAX_MY_D_NFC, MAX_MY_D_MOVE,
+ MAX_MY_D_MOVE, MAX_MY_D_MOVE_LEAN, MAX_UL_BLOCKS};
+
+// Certain pwd generation algo nickname A.
+uint32_t ul_ev1_pwdgenA(uint8_t* uid) {
+
+ uint8_t pos = (uid[3] ^ uid[4] ^ uid[5] ^ uid[6]) % 32;
+
+ uint32_t xortable[] = {
+ 0x4f2711c1, 0x07D7BB83, 0x9636EF07, 0xB5F4460E, 0xF271141C, 0x7D7BB038, 0x636EF871, 0x5F4468E3,
+ 0x271149C7, 0xD7BB0B8F, 0x36EF8F1E, 0xF446863D, 0x7114947A, 0x7BB0B0F5, 0x6EF8F9EB, 0x44686BD7,
+ 0x11494fAF, 0xBB0B075F, 0xEF8F96BE, 0x4686B57C, 0x1494F2F9, 0xB0B07DF3, 0xF8F963E6, 0x686B5FCC,
+ 0x494F2799, 0x0B07D733, 0x8F963667, 0x86B5F4CE, 0x94F2719C, 0xB07D7B38, 0xF9636E70, 0x6B5F44E0
+ };
+
+ uint8_t entry[] = {0x00,0x00,0x00,0x00};
+ uint8_t pwd[] = {0x00,0x00,0x00,0x00};
+
+ num_to_bytes( xortable[pos], 4, entry);
+
+ pwd[0] = entry[0] ^ uid[1] ^ uid[2] ^ uid[3];
+ pwd[1] = entry[1] ^ uid[0] ^ uid[2] ^ uid[4];
+ pwd[2] = entry[2] ^ uid[0] ^ uid[1] ^ uid[5];
+ pwd[3] = entry[3] ^ uid[6];
+
+ return (uint32_t)bytes_to_num(pwd, 4);
+}
+
+// Certain pwd generation algo nickname B. (very simple)
+uint32_t ul_ev1_pwdgenB(uint8_t* uid) {
+
+ uint8_t pwd[] = {0x00,0x00,0x00,0x00};
+
+ pwd[0] = uid[1] ^ uid[3] ^ 0xAA;
+ pwd[1] = uid[2] ^ uid[4] ^ 0x55;
+ pwd[2] = uid[3] ^ uid[5] ^ 0xAA;
+ pwd[3] = uid[4] ^ uid[6] ^ 0x55;
+ return (uint32_t)bytes_to_num(pwd, 4);
+}
+
+// Certain pwd generation algo nickname C.
+uint32_t ul_ev1_pwdgenC(uint8_t* uid){
+ uint32_t pwd = 0;
+ uint8_t base[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x28,
+ 0x63, 0x29, 0x20, 0x43, 0x6f, 0x70, 0x79, 0x72,
+ 0x69, 0x67, 0x68, 0x74, 0x20, 0x4c, 0x45, 0x47,
+ 0x4f, 0x20, 0x32, 0x30, 0x31, 0x34, 0xaa, 0xaa
+ };
+
+ memcpy(base, uid, 7);
+
+ for (int i = 0; i < 32; i += 4) {
+ uint32_t b = *(uint32_t *)(base + i);
+ pwd = b + ROTR(pwd, 25) + ROTR(pwd, 10) - pwd;
+ }
+ return BSWAP_32(pwd);
+}
+
+void ul_ev1_pwdgen_selftest(){