Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                {
                    Exclude exclude = db.SingleOrDefaultById <Exclude>(_id);
                    if (exclude == null)
                    {
                        UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (chkFalsePositive.Checked == true)
                    {
                        exclude.FalsePositive = true;
                    }
                    else
                    {
                        exclude.FalsePositive = false;
                    }

                    exclude.Comment = txtComment.Text;
                    db.Update(exclude);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                UserInterface.DisplayErrorMessageBox("An error occurred whilst editing the exclude: " + ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextDecodeGzip_Click(object sender, EventArgs e)
        {
            (new Thread(() =>
            {
                MethodInvoker methodInvoker = delegate
                {
                    using (new HourGlass(this))
                    {
                        Session temp = (Session)listSession.SelectedObjects[0];
                        if (temp == null)
                        {
                            contextDecodeGzip.Enabled = false;
                            return;
                        }

                        if (temp == null)
                        {
                            UserInterface.DisplayErrorMessageBox(this, "Unable to locate session");
                            return;
                        }

                        var httpParser = new HttpParser();
                        httpParser.Process(this.dataDirectory, temp);
                        LoadSession(temp);

                        using (DbConnection connection = Db.GetOpenConnection(this.dataDirectory))
                        using (var db = new NPoco.Database(connection, NPoco.DatabaseType.SQLCe))
                        {
                            try
                            {
                                var session = db.SingleOrDefaultById<Session>(temp.Id);
                                if (session != null)
                                {
                                    listSession.RefreshObject(session);
                                }
                            }
                            catch (Exception ex)
                            {
                                UserInterface.DisplayErrorMessageBox(this, "An error occurred whilst retreiving the sessions details: " + ex.Message);
                            }
                        }
                    }
                };

                if (this.InvokeRequired == true)
                {
                    this.BeginInvoke(methodInvoker);
                }
                else
                {
                    methodInvoker.Invoke();
                }
            })).Start();
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            if (listExcludes.SelectedObjects.Count == 0)
            {
                return;
            }

            if (listExcludes.SelectedObjects.Count == 1)
            {
                Exclude exclude = (Exclude)listExcludes.SelectedObjects[0];

                DialogResult dialogResult = MessageBox.Show(this,
                                                            "Are you sure you want to delete the exclude?",
                                                            Application.ProductName,
                                                            MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question);

                if (dialogResult == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }

                try
                {
                    using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                    {
                        Exclude temp = db.SingleOrDefaultById<Exclude>(exclude.Id);
                        if (temp == null)
                        {
                            UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                            return;
                        }

                        int ret = db.Delete(temp);
                        if (ret != 1)
                        {
                            UserInterface.DisplayErrorMessageBox(this, "The exclude could not be deleted");
                            return;
                        }
                    }

                    LoadExcludes();
                }
                catch (Exception ex)
                {
                    UserInterface.DisplayErrorMessageBox("An error occurred whilst deleting the exclude" + ex.Message);
                }
            }
            else
            {
                int count = listExcludes.SelectedObjects.Count;
                DialogResult dialogResult = MessageBox.Show(this,
                                                            "Are you sure you want to delete all " + count + " excludes?",
                                                            Application.ProductName,
                                                            MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question);

                if (dialogResult == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }

                try
                {
                    using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                    {
                        foreach (var item in listExcludes.SelectedObjects)
                        {
                            Exclude exclude = (Exclude)item;
                            Exclude temp = db.SingleOrDefaultById<Exclude>(exclude.Id);
                            if (temp == null)
                            {
                                UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                                return;
                            }

                            int ret = db.Delete(temp);
                            if (ret != 1)
                            {
                                UserInterface.DisplayErrorMessageBox(this,
                                                                     "The exclude could not be deleted: " + Environment.NewLine +
                                                                     exclude.ToString());
                                continue;
                            }
                        }
                    }

                    LoadExcludes();
                }
                catch (Exception ex)
                {
                    UserInterface.DisplayErrorMessageBox("An error occurred whilst deleting the exclude" + ex.Message);
                }

            }
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            if (listExcludes.SelectedObjects.Count == 0)
            {
                return;
            }

            if (listExcludes.SelectedObjects.Count == 1)
            {
                Exclude exclude = (Exclude)listExcludes.SelectedObjects[0];

                DialogResult dialogResult = MessageBox.Show(this,
                                                            "Are you sure you want to delete the exclude?",
                                                            Application.ProductName,
                                                            MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question);

                if (dialogResult == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }

                try
                {
                    using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                    {
                        Exclude temp = db.SingleOrDefaultById <Exclude>(exclude.Id);
                        if (temp == null)
                        {
                            UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                            return;
                        }

                        int ret = db.Delete(temp);
                        if (ret != 1)
                        {
                            UserInterface.DisplayErrorMessageBox(this, "The exclude could not be deleted");
                            return;
                        }
                    }

                    LoadExcludes();
                }
                catch (Exception ex)
                {
                    UserInterface.DisplayErrorMessageBox("An error occurred whilst deleting the exclude" + ex.Message);
                }
            }
            else
            {
                int          count        = listExcludes.SelectedObjects.Count;
                DialogResult dialogResult = MessageBox.Show(this,
                                                            "Are you sure you want to delete all " + count + " excludes?",
                                                            Application.ProductName,
                                                            MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question);

                if (dialogResult == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }

                try
                {
                    using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                    {
                        foreach (var item in listExcludes.SelectedObjects)
                        {
                            Exclude exclude = (Exclude)item;
                            Exclude temp    = db.SingleOrDefaultById <Exclude>(exclude.Id);
                            if (temp == null)
                            {
                                UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                                return;
                            }

                            int ret = db.Delete(temp);
                            if (ret != 1)
                            {
                                UserInterface.DisplayErrorMessageBox(this,
                                                                     "The exclude could not be deleted: " + Environment.NewLine +
                                                                     exclude.ToString());
                                continue;
                            }
                        }
                    }

                    LoadExcludes();
                }
                catch (Exception ex)
                {
                    UserInterface.DisplayErrorMessageBox("An error occurred whilst deleting the exclude" + ex.Message);
                }
            }
        }
Example #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                using (NPoco.Database db = new NPoco.Database(Db.GetOpenMySqlConnection()))
                {
                    Exclude exclude = db.SingleOrDefaultById<Exclude>(_id);
                    if (exclude == null)
                    {
                        UserInterface.DisplayMessageBox(this, "Unable to locate exclude", MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (chkFalsePositive.Checked == true)
                    {
                        exclude.FalsePositive = true;
                    }
                    else
                    {
                        exclude.FalsePositive = false;
                    }

                    exclude.Comment = txtComment.Text;
                    db.Update(exclude);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                UserInterface.DisplayErrorMessageBox("An error occurred whilst editing the exclude: " + ex.Message);
            }
        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        private void UpdateDatabaseSession()
        {
            List<string> methods = new List<string>();
            string host = string.Empty;
            foreach (Message message in this.parser.Messages)
            {
                // Ensure that the request object is valid
                if (message.Request.Method.Length == 0)
                {
                    continue;
                }

                host = message.Request.Host;

                if (methods.Contains(message.Request.Method) == false)
                {
                    methods.Add(message.Request.Method);
                }
            }

            using (DbConnection dbConnection = Db.GetOpenConnection(this.outputPath))
            using (var db = new NPoco.Database(dbConnection, NPoco.DatabaseType.SQLCe))
            {
                var obj = db.SingleOrDefaultById<Session>(this.session.Id);
                if (obj != null)
                {
                    methods.Sort();
                    this.session.HttpMethods = string.Join(",", methods);
                    this.session.HttpHost = host;
                    int ret = db.Update(this.session);
                }
            }
        }