コード例 #1
0
ファイル: CaptureService.cs プロジェクト: valeIT/swtor-emu
        static void captureDevice_OnPacketArrival(object sender, CaptureEventArgs e)
        {
            lock (PacketProcessMutex)
            {
                TcpPacket tcpPacket = TcpPacket.GetEncapsulated(Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data) as EthernetPacket);
                if (tcpPacket.Psh)
                {
                    PacketDirection direction = (tcpPacket.SourcePort == 8995 || (tcpPacket.SourcePort > 20050 && tcpPacket.SourcePort < 20100)) ? PacketDirection.Server2Client : PacketDirection.Client2Server;
                    byte[]          data      = new byte[tcpPacket.Bytes.Length - tcpPacket.Header.Length];
                    Array.Copy(tcpPacket.Bytes, tcpPacket.Header.Length, data, 0, data.Length);

                    // calculate session id
                    int            sessionid = tcpPacket.DestinationPort * tcpPacket.SourcePort;
                    CaptureSession session   = CaptureSessionList.Instance.Find(s => s.ID == sessionid);

                    if (session == null)
                    {
                        bool login = false;
                        if ((direction == PacketDirection.Server2Client && tcpPacket.SourcePort == 8995) || (direction == PacketDirection.Client2Server && tcpPacket.DestinationPort == 8995))
                        {
                            login = true;
                        }
                        session = new CaptureSession(sessionid, (login ? (byte)0 : (byte)4));
                        CaptureSessionList.Instance.Add(session);
                    }

                    session.PacketReceived(data, direction);
                }
            }
        }
コード例 #2
0
 public TORCapturedPacket(int id, TORPacketType type, byte[] data, CaptureSession session, PacketDirection direction)
 {
     _id        = id;
     _type      = type;
     _data      = data;
     _session   = session;
     _direction = direction;
 }
コード例 #3
0
 public TORCapturedPacket(int id, TORPacketType type, byte[] data, CaptureSession session, PacketDirection direction)
 {
     _id = id;
     _type = type;
     _data = data;
     _session = session;
     _direction = direction;
 }
コード例 #4
0
ファイル: XmlFactory.cs プロジェクト: Besyaka/swtor-emu
 public static XmlDocument CreateSessionDocument(CaptureSession session)
 {
     XmlDocument doc = new XmlDocument();
     XmlElement root_element = doc.CreateElement("CaptureSession");
     root_element.Attributes.Append(CreateAttribute(doc, "SaveTime", DateTime.Now.ToString()));
     foreach (TORCapturedPacket pkt in session.CapturedPackets)
     {
         root_element.AppendChild(CreatePacketElement(doc, pkt));
     }
     doc.AppendChild(root_element);
     return doc;
 }
コード例 #5
0
ファイル: XmlFactory.cs プロジェクト: valeIT/swtor-emu
        public static XmlDocument CreateSessionDocument(CaptureSession session)
        {
            XmlDocument doc          = new XmlDocument();
            XmlElement  root_element = doc.CreateElement("CaptureSession");

            root_element.Attributes.Append(CreateAttribute(doc, "SaveTime", DateTime.Now.ToString()));
            foreach (TORCapturedPacket pkt in session.CapturedPackets)
            {
                root_element.AppendChild(CreatePacketElement(doc, pkt));
            }
            doc.AppendChild(root_element);
            return(doc);
        }
コード例 #6
0
ファイル: CaptureService.cs プロジェクト: Besyaka/swtor-emu
        static void captureDevice_OnPacketArrival(object sender, CaptureEventArgs e)
        {
            lock (PacketProcessMutex)
            {
                TcpPacket tcpPacket = TcpPacket.GetEncapsulated(Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data) as EthernetPacket);
                if (tcpPacket.Psh)
                {
                    PacketDirection direction = (tcpPacket.SourcePort == 8995 || (tcpPacket.SourcePort > 20050 && tcpPacket.SourcePort < 20100)) ? PacketDirection.Server2Client : PacketDirection.Client2Server;
                    byte[] data = new byte[tcpPacket.Bytes.Length - tcpPacket.Header.Length];
                    Array.Copy(tcpPacket.Bytes, tcpPacket.Header.Length, data, 0, data.Length);

                    // calculate session id
                    int sessionid = tcpPacket.DestinationPort * tcpPacket.SourcePort;
                    CaptureSession session = CaptureSessionList.Instance.Find(s => s.ID == sessionid);

                    if (session == null)
                    {
                        bool login = false;
                        if((direction == PacketDirection.Server2Client && tcpPacket.SourcePort == 8995) || (direction == PacketDirection.Client2Server && tcpPacket.DestinationPort == 8995))
                            login = true;
                        session = new CaptureSession(sessionid, (login ? (byte)0 : (byte)4));
                        CaptureSessionList.Instance.Add(session);
                    }

                    session.PacketReceived(data, direction);
                }
            }
        }