コード例 #1
0
ファイル: LogBody.cs プロジェクト: JSpiner/SnortVisualizer
        public LogBody(String body)
        {
            this.raw = body;

            String[] lines = body.Split(new[] { "\n" }, StringSplitOptions.None);

            //line1 : time & ip sender receiver
            String[] seps = lines[0].Trim().Split(new[] { " " }, StringSplitOptions.None);

            this.time = DateTime.ParseExact(seps[0],
                                            "MM/dd-HH:mm:ss.ffffff",
                                            CultureInfo.InvariantCulture);

            int sendIndex = seps[1].IndexOf(":");

            if (sendIndex == -1)
            {
                senderIp   = seps[1].Trim();
                senderPort = "";
            }
            else
            {
                senderIp   = seps[1].Substring(0, sendIndex);
                senderPort = seps[1].Substring(sendIndex + 1);
            }

            int receiveIndex = seps[3].IndexOf(":");

            if (receiveIndex == -1)
            {
                receiverIp   = seps[3];
                receiverPort = "";
            }
            else
            {
                receiverIp   = seps[3].Substring(0, receiveIndex);
                receiverPort = seps[3].Substring(receiveIndex + 1);
            }

            //line2 : protocol type -> ip header
            String[] pheaders = lines[1].Trim().Split(new[] { " " }, StringSplitOptions.None);

            ipHeader = new IPHeader(pheaders);
            ipHeader.parseLine(lines);
        }
コード例 #2
0
ファイル: LogBody.cs プロジェクト: JSpiner/SnortVisualizer
        public LogBody(String body)
        {
            this.raw = body;

            String[] lines = body.Split(new[] { "\n" }, StringSplitOptions.None);

            //line1 : time & ip sender receiver
            String[] seps = lines[0].Trim().Split(new[] { " " }, StringSplitOptions.None);

            this.time = DateTime.ParseExact(seps[0],
                "MM/dd-HH:mm:ss.ffffff",
                CultureInfo.InvariantCulture);

            int sendIndex = seps[1].IndexOf(":");
            if (sendIndex == -1)
            {
                senderIp = seps[1].Trim();
                senderPort = "";
            }
            else
            {
                senderIp = seps[1].Substring(0, sendIndex);
                senderPort = seps[1].Substring(sendIndex + 1);
            }

            int receiveIndex = seps[3].IndexOf(":");
            if (receiveIndex == -1)
            {
                receiverIp = seps[3];
                receiverPort = "";
            }
            else
            {
                receiverIp = seps[3].Substring(0, receiveIndex);
                receiverPort = seps[3].Substring(receiveIndex + 1);
            }

            //line2 : protocol type -> ip header
            String[] pheaders = lines[1].Trim().Split(new[] { " " }, StringSplitOptions.None);

            ipHeader = new IPHeader(pheaders);
            ipHeader.parseLine(lines);
        }