Exemplo n.º 1
0
        public bool ProcessClientData()
        {
            switch (State)
            {
            case -1:
                //Garbage. Drop it.
                GetClientData(ClientBuffer.Length);
                return(false);

            case 0:
                if (ClientBuffer.Length < 128)
                {
                    // garbage from a running game session. we ignore it.
                    //If we open a hex File we handle it diffrent ;)
                    if (OpenFileMode == false)
                    {
                        GetClientData(ClientBuffer.Length);
                    }
                    return(false);
                }

                SecSession.ClientKey1 = GetClientData(128);
                return(true);

            case 1:
                if (ClientBuffer.Length < 128)
                {
                    return(false);
                }

                SecSession.ClientKey2 = GetClientData(128);
                return(true);
            }

            if (ClientBuffer.Length < 4)
            {
                return(false);
            }

            int length = BitConverter.ToUInt16(ClientBuffer, 0);

            if (ClientBuffer.Length < length)
            {
                return(false);
            }

            ushort opCode     = BitConverter.ToUInt16(ClientBuffer, 2);
            string opcodename = PacketTranslator.GetOpcodeName(MainWindow, opCode);

            Packet_old tmpPacket = new Packet_old(false, opCode, opcodename, GetClientData(length), false);

            string itemText = string.Format("[C] {0} [{1}]"
                                            , tmpPacket.Name
                                            , tmpPacket.Data.Length
                                            );

            MainWindow.AppendPacket(Colors.WhiteSmoke, itemText, tmpPacket);

            return(false);
        }
Exemplo n.º 2
0
 private void messageReceived(Message message)
 {
     try
     {
         //Message does not contain our length, add it to see the full packet
         byte[] data = new byte[message.Data.Count];
         Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2);
         data[0] = (byte)(((short)message.Data.Count) & 255);
         data[1] = (byte)(((short)message.Data.Count) >> 8);
         if (message.Direction == MessageDirection.ClientToServer)
         {
             Packet_old tmpPacket = new Packet_old(Direction.CS, message.OpCode, data, false);
             mainWindow.pp.AppendPacket(tmpPacket);
         }
         else
         {
             Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false);
             mainWindow.pp.AppendPacket(tmpPacket);
         }
     }
     catch (Exception ex)
     {
         mainWindow.SetText("device_OnPacketArrival failure. \n Message:" + ex);
     }
 }
Exemplo n.º 3
0
        private void messageReceived(Message message)
        {
            try
            {
                //Message does not contain our length, add it to see the full packet
                byte[] data = new byte[message.Data.Count];
                Array.Copy(message.Data.Array, 0, data, 2, message.Data.Count - 2);
                data[0] = (byte) (((short) message.Data.Count) & 255);
                data[1] = (byte)(((short)message.Data.Count) >> 8);
                if (message.Direction == MessageDirection.ClientToServer)
                {
                    Packet_old tmpPacket = new Packet_old(Direction.CS, message.OpCode, data, false);
                    mainWindow.pp.AppendPacket(tmpPacket);
                }
                else
                {
                    Packet_old tmpPacket = new Packet_old(Direction.SC, message.OpCode, data, false);
                    mainWindow.pp.AppendPacket(tmpPacket);
                }
            }
            catch (Exception ex)
            {

                mainWindow.SetText("device_OnPacketArrival failure. \n Message:" + ex);
            }
        }
        public void ProcessServerData()
        {
            int length = ServerPackets.NextPacketLength();
            if (length == 0) throw new Exception("Server data reader is broken....");

            byte[] data = ServerPackets.GetBytes(length);
            ushort opCode = BitConverter.ToUInt16(data, 2);
            Packet_old tmpPacket = new Packet_old(Direction.SC, opCode, data, false);
            //Debug.Print(DateTime.Now.ToLongTimeString() + " " + tmpPacket.OpName);

            MainWindow.AppendPacket(tmpPacket);
        }
Exemplo n.º 5
0
        public bool ShowPacket(Packet_old packet)
        {
            if (!showAny) return false;
            if (packet.Dir == Direction.CS && !showCS) return false;
            if (packet.Dir == Direction.SC && !showSC) return false;

            if (showOnlyOpcodes.Count > 0)
            {
                return showOnlyOpcodes.Contains(packet.OpCode);
            }
            else
            {
                return !ignoreOpcodes.Contains(packet.OpCode);
            }
        }
Exemplo n.º 6
0
        public void ProcessClientData()
        {
            int length = ClientPackets.NextPacketLength();

            if (length == 0)
            {
                throw new Exception("Client data reader is broken....");
            }

            byte[]     data      = ClientPackets.GetBytes(length);
            ushort     opCode    = BitConverter.ToUInt16(data, 2);
            Packet_old tmpPacket = new Packet_old(Direction.CS, opCode, data, false);

            AppendPacket(tmpPacket);
        }
Exemplo n.º 7
0
        public void ProcessServerData()
        {
            int length = ServerPackets.NextPacketLength();

            if (length == 0)
            {
                throw new Exception("Server data reader is broken....");
            }

            byte[]     data      = ServerPackets.GetBytes(length);
            ushort     opCode    = BitConverter.ToUInt16(data, 2);
            Packet_old tmpPacket = new Packet_old(Direction.SC, opCode, data, false);

            //Debug.Print(DateTime.Now.ToLongTimeString() + " " + tmpPacket.OpName);

            AppendPacket(tmpPacket);
        }
Exemplo n.º 8
0
        public void Process()
        {
            fs.Seek(0, SeekOrigin.Begin);
            while (fs.Position < fs.Length)
            {
                Packet_old tmpPacket;
                BlockType type = (BlockType)reader.ReadByte();
                ushort len = reader.ReadUInt16();
                fs.Seek(-2, SeekOrigin.Current); ; //turn it back, our packet_old class expects a length in the packet
                byte[] payload = reader.ReadBytes(len);

                switch (type)
                {
                    case BlockType.MagicBytes:
                        string magic = ASCIIEncoding.ASCII.GetString(payload, 2, payload.Length - 2);
                        if (magic != "TeraConnectionLog") throw new Exception("Invalid Magic Block.");
                        Debug.Print("found magic");
                        break;
                    case BlockType.Region:
                        string region = ASCIIEncoding.ASCII.GetString(payload, 2, payload.Length - 2);
                        Debug.Print("region " + region);
                        break;
                    case BlockType.Start:
                        Debug.Print("start");
                        break;
                    case BlockType.Timestamp:
                        //var date = LogHelper.BytesToTimeSpan(payload);
                        //Debug.Print("time " + date.ToShortTimeString());
                        break;
                    case BlockType.Client:
                        tmpPacket = new Packet_old(Direction.CS, BitConverter.ToUInt16(payload, 2), payload, false);
                        processor.AppendPacket(tmpPacket);
                        break;
                    case BlockType.Server:
                        tmpPacket = new Packet_old(Direction.SC, BitConverter.ToUInt16(payload, 2), payload, false);
                        processor.AppendPacket(tmpPacket);
                        break;
                }
            }

            reader.Close();
        }
        public void AppendPacket(Color col, string itemText, Packet_old tmpPacket)
        {
            Dispatcher.BeginInvoke(
                new Action(
                    delegate
                    {
                        ListBoxItem item = new ListBoxItem
                        {
                            Content = itemText,
                            Background = new SolidColorBrush(col)
                        };

                        if (PacketsList.Items.Count == MaxPackets)
                        {
                            PacketsList.Items.RemoveAt(0);
                            pp.Packets.RemoveAt(0);
                        }

                        if (boxCapture.IsChecked.Value)
                        {
                            PacketsList.Items.Add(item);

                            if (boxAutoScroll.IsChecked.Value)
                            {
                                PacketsList.ScrollIntoView(item);
                            }

                            pp.Packets.Add(tmpPacket);
                        }
                    }));
        }
Exemplo n.º 10
0
 //Just needed a general function that also can be accessed from TeraLogReader
 public void AppendPacket(Packet_old tmpPacket)
 {
     //Task.Factory.StartNew(() => MainWindow.AppendPacket(Colors.WhiteSmoke, tmpPacket.ToString(), tmpPacket));
     MainWindow.AppendPacket(tmpPacket);
 }
Exemplo n.º 11
0
 //Just needed a general function that also can be accessed from TeraLogReader
 public void AppendPacket(Packet_old tmpPacket)
 {
     //Task.Factory.StartNew(() => MainWindow.AppendPacket(Colors.WhiteSmoke, tmpPacket.ToString(), tmpPacket));
     MainWindow.AppendPacket(tmpPacket);
     //ILMerge.exe /target:winexe /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" /out:PV.exe PacketViewer.exe NetworkSniffer.dll PacketDotNet.dll SharpPcap.dll Tera.Core.dll Tera.Sniffing.dll
 }
Exemplo n.º 12
0
        public void ProcessClientData()
        {
            int length = ClientPackets.NextPacketLength();
            if (length == 0) throw new Exception("Client data reader is broken....");

            byte[] data = ClientPackets.GetBytes(length);
            ushort opCode = BitConverter.ToUInt16(data, 2);
            Packet_old tmpPacket = new Packet_old(Direction.CS, opCode, data, false);
           
            AppendPacket(tmpPacket);
        }
Exemplo n.º 13
0
 //Just needed a general function that also can be accessed from TeraLogReader
 public void AppendPacket(Packet_old tmpPacket)
 { 
     //Task.Factory.StartNew(() => MainWindow.AppendPacket(Colors.WhiteSmoke, tmpPacket.ToString(), tmpPacket));
     MainWindow.AppendPacket(tmpPacket);
     //ILMerge.exe /target:winexe /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" /out:PV.exe PacketViewer.exe NetworkSniffer.dll PacketDotNet.dll SharpPcap.dll Tera.Core.dll Tera.Sniffing.dll
 }
Exemplo n.º 14
0
        public void AppendPacket(Packet_old tmpPacket)
        {
            string itemText = tmpPacket.ToString();
            Color col;
            if (tmpPacket.Dir == Direction.SC)
            {
                col = Colors.LightBlue;
            }
            else
            {
                col = Colors.WhiteSmoke;
            }

            Dispatcher.BeginInvoke(
                new Action(
                    delegate
                    {
                        ListBoxItem item = new ListBoxItem
                        {
                            Content = itemText,
                            Background = new SolidColorBrush(col)
                        };

                        while (boxPackets.Items.Count >= maxPackets)
                        {
                            boxPackets.Items.RemoveAt(0);
                            pp.Packets.RemoveAt(0);
                        }

                        if (filter.ShowPacket(tmpPacket))
                        {
                            boxPackets.Items.Add(item);

                            if (boxAutoScroll.IsChecked.Value)
                            {
                                boxPackets.ScrollIntoView(item);
                            }

                            pp.Packets.Add(tmpPacket);
                        }
                    }));
        }
Exemplo n.º 15
0
        public bool ProcessServerData()
        {
            switch (State)
            {
            case -1:
                //Garbage. Drop it.
                GetServerData(ServerBuffer.Length);
                return(false);

            case 0:
                if (ServerBuffer.Length < 128)
                {
                    //First Dword 1 Options Packet. Ignore it.
                    if (OpenFileMode == false)
                    {
                        GetServerData(ServerBuffer.Length);
                    }

                    return(false);
                }

                SecSession.ServerKey1 = GetServerData(128);
                State++;
                return(true);

            case 1:
                if (ServerBuffer.Length < 128)
                {
                    return(false);
                }
                SecSession.ServerKey2 = GetServerData(128);
                SecSession.Init();
                State++;
                return(true);
            }

            if (ServerBuffer.Length < 4)
            {
                return(false);
            }

            int length = BitConverter.ToUInt16(ServerBuffer, 0);

            if (ServerBuffer.Length < length)
            {
                return(false);
            }

            ushort opCode     = BitConverter.ToUInt16(ServerBuffer, 2);
            string opcodename = PacketTranslator.GetOpcodeName(MainWindow, opCode);

            Packet_old tmpPacket = new Packet_old(true, opCode, opcodename, GetServerData(length), false);

            ;

            string itemText = string.Format("[S] {0} [{1}]"
                                            , tmpPacket.Name
                                            , tmpPacket.Data.Length
                                            );

            MainWindow.AppendPacket(Colors.LightBlue, itemText, tmpPacket);

            return(false);
        }