Example #1
0
        //private int _packetIndex = 1;
        private void PacketHandle(PPacket ppacket)
        {
            //if (ppacket.Packet.Ethernet == null || ppacket.Packet.Ethernet.IpV4 == null || ppacket.Packet.Ethernet.IpV4.Tcp == null)
            if (ppacket.Ipv4 == null || ppacket.Tcp == null)
                return;

            //TcpStreamPacket tcpStreamPacket = new TcpStreamPacket(packet);
            //TcpConnection tcpConnection = tcpStreamPacket.Connection;
            //TcpConnection tcpConnection = new TcpConnection(ppacket.Packet);
            TcpConnection tcpConnection = ppacket.GetTcpConnection();
            if (!_tcpStreamList.ContainsKey(tcpConnection))
            {
                TcpStream tcpStream = new TcpStream(tcpConnection);
                _tcpStreamList.Add(tcpConnection, tcpStream);

                //WriteTcpStreamToFile writeTcpStreamToFile = new WriteTcpStreamToFile(tcpStream, _directory);
                //_tcpStreamToFileList.Add(writeTcpStreamToFile);
                //new CreatePacketTcpStream(tcpStream).TcpPacketHandle = (direction, tcpPacket) => { w.PrintPacketHandler2(_ppacketManager.CreatePPacket(tcpPacket), true); };
                //if (_trace)
                //    new TraceTcpStream(tcpStream);

                tcpStream.zWriteTcpStreamToFile(_directory);
                //tcpStream.CreatePacketTcpStream((direction, tcpPacket) => { w.PrintPacketHandler2(_ppacketManager.CreatePPacket(tcpPacket), true); });
                tcpStream.zTcpStreamReassembledPacket((direction, tcpPacket) => { PrintPacket.PrintPacket1(_ppacketManager.CreatePPacket(tcpPacket), true); });
                if (_trace)
                    tcpStream.zTraceTcpStream(_directory);
            }
            //Trace.CurrentTrace.WriteLine("packet no {0} {1}:{2} - {3}:{4}", _packetIndex++, tcpConnection.Source.Address, tcpConnection.Source.Port, tcpConnection.Destination.Address, tcpConnection.Destination.Port);
            //_tcpStreamList[tcpConnection].Add(tcpStreamPacket);
            //_tcpStreamList[tcpConnection].Add(tcpConnection, ppacket);
            _tcpStreamList[tcpConnection].Add(ppacket);
        }
Example #2
0
        //private int _packetIndex = 1;
        private void PacketHandle(PPacket ppacket)
        {
            //if (ppacket.Packet.Ethernet == null || ppacket.Packet.Ethernet.IpV4 == null || ppacket.Packet.Ethernet.IpV4.Tcp == null)
            if (ppacket.Ipv4 == null || ppacket.Tcp == null)
            {
                return;
            }

            //TcpStreamPacket tcpStreamPacket = new TcpStreamPacket(packet);
            //TcpConnection tcpConnection = tcpStreamPacket.Connection;
            //TcpConnection tcpConnection = new TcpConnection(ppacket.Packet);
            TcpConnection tcpConnection = ppacket.GetTcpConnection();

            if (!_tcpStreamList.ContainsKey(tcpConnection))
            {
                TcpStream tcpStream = new TcpStream(tcpConnection);
                _tcpStreamList.Add(tcpConnection, tcpStream);

                //WriteTcpStreamToFile writeTcpStreamToFile = new WriteTcpStreamToFile(tcpStream, _directory);
                //_tcpStreamToFileList.Add(writeTcpStreamToFile);
                //new CreatePacketTcpStream(tcpStream).TcpPacketHandle = (direction, tcpPacket) => { w.PrintPacketHandler2(_ppacketManager.CreatePPacket(tcpPacket), true); };
                //if (_trace)
                //    new TraceTcpStream(tcpStream);

                tcpStream.zWriteTcpStreamToFile(_directory);
                //tcpStream.CreatePacketTcpStream((direction, tcpPacket) => { w.PrintPacketHandler2(_ppacketManager.CreatePPacket(tcpPacket), true); });
                tcpStream.zTcpStreamReassembledPacket((direction, tcpPacket) => { PrintPacket.PrintPacket1(_ppacketManager.CreatePPacket(tcpPacket), true); });
                if (_trace)
                {
                    tcpStream.zTraceTcpStream(_directory);
                }
            }
            //Trace.CurrentTrace.WriteLine("packet no {0} {1}:{2} - {3}:{4}", _packetIndex++, tcpConnection.Source.Address, tcpConnection.Source.Port, tcpConnection.Destination.Address, tcpConnection.Destination.Port);
            //_tcpStreamList[tcpConnection].Add(tcpStreamPacket);
            //_tcpStreamList[tcpConnection].Add(tcpConnection, ppacket);
            _tcpStreamList[tcpConnection].Add(ppacket);
        }