示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        private void LoadSession(Session session)
        {
            (new Thread(() =>
            {
                MethodInvoker methodInvoker = delegate
                {
                    try
                    {
                        using (new HourGlass(this))
                        {
                            if (session == null)
                            {
                                UserInterface.DisplayErrorMessageBox(this, "Unable to locate session");
                                return;
                            }

                            string filePath = System.IO.Path.Combine(this.dataDirectory, session.Guid.Substring(0, 2), session.Guid + ".bin");

                            if (File.Exists(filePath) == false)
                            {
                                UserInterface.DisplayErrorMessageBox(this, "Session data file does not exist: " + filePath);
                                return;
                            }

                            byte[] temp = File.ReadAllBytes(filePath);
                            DynamicByteProvider dynamicByteProvider = new DynamicByteProvider(temp);
                            hexBox.ByteProvider = dynamicByteProvider;

                            temp = woanware.Text.ReplaceNulls(temp);

                            FileInfo fileInfo = new FileInfo(filePath);

                            // Colourised (HTML)
                            if (fileInfo.AlternateDataStreamExists("html") == true)
                            {
                                AlternateDataStreamInfo ads = fileInfo.GetAlternateDataStream("html", FileMode.Open);
                                using (TextReader reader = ads.OpenText())
                                {
                                    webControl.DocumentText = reader.ReadToEnd();
                                }
                            }
                            else
                            {
                                webControl.DocumentText = string.Empty;
                            }

                            // ASCII
                            if (fileInfo.AlternateDataStreamExists("txt") == true)
                            {
                                AlternateDataStreamInfo ads = fileInfo.GetAlternateDataStream("txt", FileMode.Open);
                                using (TextReader reader = ads.OpenText())
                                {
                                    txtSession.Text = reader.ReadToEnd();
                                    txtSession.ScrollToTop();
                                }
                            }
                            else
                            {
                                txtSession.Text = ASCIIEncoding.ASCII.GetString(temp);
                                txtSession.ScrollToTop();
                            }

                            // Info
                            if (fileInfo.AlternateDataStreamExists("info") == true)
                            {
                                AlternateDataStreamInfo ads = fileInfo.GetAlternateDataStream("info", FileMode.Open);
                                using (TextReader reader = ads.OpenText())
                                {
                                    txtInfo.Text = reader.ReadToEnd();
                                    txtInfo.ScrollToTop();
                                }
                            }
                            else
                            {
                                txtInfo.Text = string.Empty;
                                txtInfo.ScrollToTop();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        this.Log().Error(ex.ToString());
                    }
                };

                if (this.InvokeRequired == true)
                {
                    this.BeginInvoke(methodInvoker);
                }
                else
                {
                    methodInvoker.Invoke();
                }

            })).Start();
        }
示例#2
0
        /// <summary>
        /// Run any applicable parsers
        /// </summary>
        /// <param name="session"></param>
        /// <param name="db"></param>
        /// <param name="pk"></param>
        private void PerformSessionProcessing(Session session, 
                                              int pk)
        {
            //OnMessage("Performing session parsing...");

            var parsers = from p in this._parsers where (p.Port == session.SourcePort | p.Port == session.DestinationPort) & p.Type == ParserType.Session select p;
            foreach (InterfaceParser parser in parsers)
            {
                if (parser.Enabled == false)
                {
                    continue;
                }

                SessionTask sessionTask = new SessionTask(parser.Name, session, _outputPath, pk);
                this.sessionParser.Add(sessionTask);
            }
        }
示例#3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="session"></param>
 public void Add(Session session)
 {
     this.blockingCollection.Add(session);
 }
示例#4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="dataSize"></param>
        /// <param name="connection"></param>
        /// <returns></returns>
        private Session CreateNewSession(string guid, 
                                         long dataSize, 
                                         Connection connection)
        {
            Session session = new Session(guid);
            session.DataSize = dataSize;
            session.SourceIp = connection.SourceIpNumeric;
            session.SourcePort = connection.SourcePort;

            try
            {
                Country country = _ls.getCountry(connection.SourceIp);
                if (country != null)
                {
                    session.SourceCountry = country.getCode();
                }
            }
            catch (Exception) { }

            session.DestinationIp = connection.DestinationIpNumeric;
            session.DestinationPort = connection.DestinationPort;

            try
            {
                Country country = _ls.getCountry(connection.DestinationIp);
                if (country != null)
                {
                    session.DestinationCountry = country.getCode();
                }
            }
            catch (Exception) { }

            session.TimestampFirstPacket = _dictionary[connection].TimestampFirstPacket;
            session.TimestampLastPacket = _dictionary[connection].TimestampLastPacket;

            return session;
        }