Esempio n. 1
0
        public void TestLongPacket()
        {
            Input.Seek(12, SeekOrigin.Begin);

            Header h = new Header(Input);

            LongPacket lp = new LongPacket(h, Input);

            Assert.IsTrue(lp.IsComplete);
            Assert.AreEqual(46, lp.Data.Length);

            byte[] testData = new byte[] {0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20};

            for (int i = 0; i < 10; ++i)
            {
                Assert.AreEqual(testData[i], lp.Data[i]);
            }
        }
Esempio n. 2
0
        void Run()
        {
            IMessage msg;
            Header h;
            while (true)
            {
                h = new Header(_infile);

                msg = null;
                if (h.IsSystemMessage)
                {
                    msg = MessageFactory.CreateMessage(h.SystemType, h.Datum);
                    UpdateEventType(msg);
                }
                else
                {
                    msg = MessageFactory.CreateMessage(h.CarType, _evtType);
                }

                try
                {
                    Packet p = msg.CreatePacketType(h, _infile, null);

                    msg.Deserialise(h, p);

                    //Console.WriteLine(msg);
                }
                catch (NullReferenceException)
                {
                    //Console.WriteLine("*" + msg);
                    break;
                }
            }

            if( msg is F1.Messages.System.Notice )
            {
                LongPacket packet = new LongPacket(h, _infile);

                Test((byte[])packet.Data.Clone(), StringUtils.StringToASCIIBytes(_rawMessage));
                Crack(packet.Data, StringUtils.StringToASCIIBytes(_rawMessage));
            }
            else
            {
                Console.WriteLine("Notice is not the first encrypted packet.");
            }
        }