Beispiel #1
0
        public POPMsg(PDUStreamReader reader)
        {
            // fill default values and store things we'll need later
            this._reader        = reader;
            this.Valid          = true;
            this.InvalidReason  = string.Empty;
            this.MessageContent = string.Empty;
            this.Type           = POPMsgType.OTHER;
            this.DataContent    = null;
            this.ExportSources  = new List <IExportSource>();

            // do the parsing itself
            this.Parse();
        }
Beispiel #2
0
        private void Parse()
        {
            // transform reader to stream provider to get timestamp and frame numbers values
            var _streamProvider = this._reader.PDUStreamBasedProvider;

            this.Frames = _streamProvider.ProcessedFrames;
            if (_streamProvider.GetCurrentPDU() != null)
            {
                this.Timestamp = _streamProvider.GetCurrentPDU().FirstSeen;
            }
            else
            {
                this.InvalidReason = "could not retrieve PDU";
                this.ExportSources.Add(_streamProvider.Conversation);
                this.Valid = false;
                return;
            }

            //Console.WriteLine("FTPMsg created, frame numbers: " + string.Join(",", Frames.ToArray()));
            if (!_streamProvider.GetCurrentPDU().L7Conversation.ApplicationTags.Any())
            {
                this.Valid         = false;
                this.InvalidReason = "no application tag";
                this.ExportSources.Add(_streamProvider.GetCurrentPDU());
                return;
            }

            this.ExportSources.Add(_streamProvider.GetCurrentPDU());

            var _line         = this._reader.ReadLine();
            var _splittedLine = _line.Split(' ');

            //Console.Write("  "+_line.Trim()+"\n");
            if (_splittedLine[0].IndexOf("USER", StringComparison.OrdinalIgnoreCase) == 0)
            {
                this.Type           = POPMsgType.USER;
                this.MessageContent = _splittedLine[1];
                //Console.WriteLine("  USER: "******"PASS", StringComparison.OrdinalIgnoreCase) == 0)
            {
                this.Type           = POPMsgType.PASS;
                this.MessageContent = _splittedLine[1];
                //Console.WriteLine("  PASS: "******"RETR", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (!this._reader.NewMessage())
                {
                    return;                              // actual messsage will be in the next PDU
                }
                _line         = this._reader.ReadLine(); // get the first line
                _splittedLine = _line.Split(' ');
                if (_splittedLine[0].IndexOf("+OK", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    this.Type           = POPMsgType.RETR;
                    this.MessageContent = this._reader.ReadToEnd();
                    //Console.WriteLine("  RETR: " + MessageContent);
                }
            }
        }