Esempio n. 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);
        }
Esempio n. 2
0
 public WriteTcpStreamToFile(TcpStream tcpStream, string directory)
 {
     tcpStream.WriteData += WriteData;
     TcpConnection tcpConnection = tcpStream.TcpConnection;
     //_file = zPath.Combine(directory, string.Format("{0}.{1}-{2}.{3}", tcpConnection.Source.IpAddress, tcpConnection.Source.Port,
     //    tcpConnection.Destination.IpAddress, tcpConnection.Destination.Port));
     _file = zPath.Combine(directory, tcpConnection.GetConnectionName());
 }
Esempio n. 3
0
        public WriteTcpStreamToFile(TcpStream tcpStream, string directory)
        {
            tcpStream.WriteData += WriteData;
            TcpConnection tcpConnection = tcpStream.TcpConnection;

            //_file = zPath.Combine(directory, string.Format("{0}.{1}-{2}.{3}", tcpConnection.Source.IpAddress, tcpConnection.Source.Port,
            //    tcpConnection.Destination.IpAddress, tcpConnection.Destination.Port));
            _file = zPath.Combine(directory, tcpConnection.GetConnectionName());
        }
Esempio n. 4
0
        public TraceTcpStream(TcpStream tcpStream, string directory)
        {
            TcpConnection tcpConnection = tcpStream.TcpConnection;

            //_connectionName = string.Format("{0}.{1}-{2}.{3}", tcpConnection.Source.IpAddress, tcpConnection.Source.Port, tcpConnection.Destination.IpAddress, tcpConnection.Destination.Port);
            _connectionName = tcpConnection.GetConnectionName();
            //_log = new Log(zPath.Combine(directory, _connectionName + ".txt"), LogOptions.RazLogFile);
            _trace = new TTrace();
            _trace.SetWriter(zPath.Combine(directory, _connectionName + ".txt"), FileOption.RazFile);
            tcpStream.WriteData += TraceData;
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
 public TcpStreamReassembledPacket(TcpStream tcpStream)
 {
     _tcpConnection = tcpStream.TcpConnection;
     tcpStream.WriteData += WriteData;
 }
Esempio n. 7
0
 public TcpStreamReassembledPacket(TcpStream tcpStream)
 {
     _tcpConnection       = tcpStream.TcpConnection;
     tcpStream.WriteData += WriteData;
 }
Esempio n. 8
0
 public static void zTraceTcpStream(this TcpStream tcpStream, string directory)
 {
     new TraceTcpStream(tcpStream, directory);
 }
Esempio n. 9
0
        public static void zWriteTcpStreamToFile(this TcpStream tcpStream, string directory)
        {
            WriteTcpStreamToFile writeTcpStreamToFile = new WriteTcpStreamToFile(tcpStream, directory);

            tcpStream.OnDispose += () => { writeTcpStreamToFile.Close(); };
        }
Esempio n. 10
0
 public static void zTcpStreamReassembledPacket(this TcpStream tcpStream, Action <TcpDirection, Packet> tcpPacketHandle)
 {
     new TcpStreamReassembledPacket(tcpStream).PacketHandle = tcpPacketHandle;
 }
Esempio n. 11
0
 public TraceTcpStream(TcpStream tcpStream, string directory)
 {
     TcpConnection tcpConnection = tcpStream.TcpConnection;
     //_connectionName = string.Format("{0}.{1}-{2}.{3}", tcpConnection.Source.IpAddress, tcpConnection.Source.Port, tcpConnection.Destination.IpAddress, tcpConnection.Destination.Port);
     _connectionName = tcpConnection.GetConnectionName();
     //_log = new Log(zPath.Combine(directory, _connectionName + ".txt"), LogOptions.RazLogFile);
     _trace = new TTrace();
     _trace.SetWriter(zPath.Combine(directory, _connectionName + ".txt"), FileOption.RazFile);
     tcpStream.WriteData += TraceData;
 }