public static string Attack(byte[] bytes) { var show_all = ""; if (bytes == null || !bytes.Any()) { return($"No data found on device{Environment.NewLine}"); } UInt64 canary = ToUInt64(bytes, MyKey.DoNotDecryptCanaryOffset); if (canary != MyKey.DoNotDecryptCanary) { // Decrypt data, with key 123321, length 208 DecryptData(bytes, 123321, 208); } // validate CRC is ok. (length 210, since two last bytes is crc) if (!Crc.CheckCrc14443(Crc.CRC16_14443_A, bytes, 210)) { return($"Data failed CRC check{Environment.NewLine}"); } /* * Data layout * first 16byte is Sector0, Block0 * * then comes items of 16bytes length * 0 auth cmd (0x60 or 0x61) * 1 blocknumber (0 - 0x7F) * 2,3 crc 2bytes * 4,5,6,7 NT * 8,9,10,11 NR * 12,13,14,15 AR */ var uid = ToUInt32(bytes, 0); var myKeys = new List <MyKey>(); // Copy nonce - data into object and list for (int i = 0; i < 12; i++) { var mykey = new MyKey { UID = uid, KeyType = bytes[(i + 1) * 16], Block = bytes[(i + 1) * 16 + 1], nt0 = ToUInt32(bytes, (i + 1) * 16 + 4), nr0 = ToUInt32(bytes, (i + 1) * 16 + 8), ar0 = ToUInt32(bytes, (i + 1) * 16 + 12) }; mykey.Sector = ToSector(mykey.Block); // skip sectors with 0xFF if (mykey.Sector != 0xFF) { myKeys.Add(mykey); } } var my_cmp = new KeyComparer(); myKeys.Sort(my_cmp); show_all = KeyWorker(myKeys); return(show_all); }