public static MifareUltralightModel Parse(byte[] data)
 {
     return(new MifareUltralightModel()
     {
         Created = "ChameleonMiniGUI",
         Card = new MifareUltralightCardInfo()
         {
             Version = MifareClassicModel.ByteArrayToString(data.Take(8)),
             TBO_0 = MifareClassicModel.ByteArrayToString(data.Skip(8).Take(2)),
             Tearing = MifareClassicModel.ByteArrayToString(data.Skip(10).Take(3)),
             Pack = MifareClassicModel.ByteArrayToString(data.Skip(13).Take(2)),
             TBO_1 = MifareClassicModel.ByteArrayToString(data.Skip(15).Take(1)),
             Signature = MifareClassicModel.ByteArrayToString(data.Skip(16).Take(32)),
             Counter = null
         },
         Blocks = MifareClassicModel.ToNestedByteArray(data.Skip(48).ToArray(), 4)
     });
 }
 public MifareClassicCardInfo(MifareClassicModel mfc)
 {
     Mifare = mfc;
 }
Exemple #3
0
        public static MifareUltralightModel Parse(byte[] data)
        {
            bool isNewHeaderFormat = HasUltralightNewHeader(data);
            bool isOldHeaderFormat = !isNewHeaderFormat && HasUltralightHeader(data);

            if (isNewHeaderFormat)
            {
                // parse new dump format
                return(new MifareUltralightModel()
                {
                    Created = "ChameleonMiniGUI",
                    Card = new MifareUltralightCardInfo()
                    {
                        Version = MifareClassicModel.ByteArrayToString(data.Take(8)),
                        TBO_0 = MifareClassicModel.ByteArrayToString(data.Skip(8).Take(2)),
                        Tearing0 = MifareClassicModel.ByteArrayToString(data.Skip(44 + 3).Take(1)),
                        Tearing1 = MifareClassicModel.ByteArrayToString(data.Skip(44 + 7).Take(1)),
                        Tearing2 = MifareClassicModel.ByteArrayToString(data.Skip(44 + 11).Take(1)),
                        TBO_1 = MifareClassicModel.ByteArrayToString(data.Skip(10).Take(1)),
                        Signature = MifareClassicModel.ByteArrayToString(data.Skip(12).Take(32)),
                        Counter0 = MifareClassicModel.ByteArrayToString(data.Skip(44 + 0).Take(3)),
                        Counter1 = MifareClassicModel.ByteArrayToString(data.Skip(44 + 4).Take(3)),
                        Counter2 = MifareClassicModel.ByteArrayToString(data.Skip(44 + 8).Take(3))
                    },
                    Blocks = MifareClassicModel.ToNestedByteArray(data.Skip(MifareUltralightCardInfo.NewPrefixLength).ToArray(), 4)
                });
            }
            else if (isOldHeaderFormat)
            {
                // parse old dump format
                return(new MifareUltralightModel()
                {
                    Created = "ChameleonMiniGUI",
                    Card = new MifareUltralightCardInfo()
                    {
                        Version = MifareClassicModel.ByteArrayToString(data.Take(8)),
                        TBO_0 = MifareClassicModel.ByteArrayToString(data.Skip(8).Take(2)),
                        Tearing0 = MifareClassicModel.ByteArrayToString(data.Skip(10).Take(1)),
                        Tearing1 = MifareClassicModel.ByteArrayToString(data.Skip(10).Take(1)),
                        Tearing2 = MifareClassicModel.ByteArrayToString(data.Skip(10).Take(1)),
                        TBO_1 = MifareClassicModel.ByteArrayToString(data.Skip(15).Take(1)),
                        Signature = MifareClassicModel.ByteArrayToString(data.Skip(16).Take(32)),
                        Counter0 = "000000",
                        Counter1 = "000000",
                        Counter2 = "000000"
                    },
                    Blocks = MifareClassicModel.ToNestedByteArray(data.Skip(MifareUltralightCardInfo.PrefixLength).ToArray(), 4)
                });
            }
            else
            {
                return(new MifareUltralightModel()
                {
                    Created = "ChameleonMiniGUI",
                    Card = new MifareUltralightCardInfo()
                    {
                        Version = null,
                        TBO_0 = null,
                        Tearing0 = null,
                        Tearing1 = null,
                        Tearing2 = null,
                        TBO_1 = null,
                        Signature = null,
                        Counter0 = null,
                        Counter1 = null,
                        Counter2 = null
                    },
                    Blocks = MifareClassicModel.ToNestedByteArray(data.ToArray(), 4)
                });
            };
        }
 public MifareClassicSectorKey(MifareClassicModel mfc, int sector)
 {
     this.mfc          = mfc;
     this.SectorNumber = sector;
 }