Пример #1
0
        private void FindCandidatesBtn_Click(object sender, EventArgs e)
        {
            List <string> SelectedHosts = new List <string>();

            foreach (TreeNode Node in HostnamesScopeTree.Nodes)
            {
                SelectedHosts.AddRange(GetSelectedHosts(Node));
            }

            List <string> SelectedFileTypes = new List <string>();

            foreach (DataGridViewRow Row in FileTypesScopeGrid.Rows)
            {
                if ((bool)Row.Cells[0].Value)
                {
                    if (Row.Cells[1].Value.ToString().Equals(" NO EXTENSION "))
                    {
                        SelectedFileTypes.Add("");
                    }
                    else
                    {
                        SelectedFileTypes.Add(Row.Cells[1].Value.ToString());
                    }
                }
            }

            TokenName             = CsrfTokenParameterNameTB.Text;
            TokenReplacementValue = CsrfTokenReplacementValueTB.Text;
            RemoveParameter       = TestModeRemoveTokenRB.Checked;

            if (Recording.Recording.GetNames().Contains(SessionRecordingCombo.Text))
            {
                LoginRecording = Recording.Recording.Get(SessionRecordingCombo.Text);
            }
            else if (SessionRecordingCombo.Text.Trim().Length > 0)
            {
                MessageBox.Show("Invalid Login recording name, enter a valid name.");
                return;
            }
            if (TokenName.Trim().Length == 0)
            {
                MessageBox.Show("Name of the CSRF token parameter cannot be blank.");
                return;
            }
            if (SelectedHosts.Count == 0)
            {
                MessageBox.Show("Atleast one host must be selected for testing");
                return;
            }
            if (SelectedFileTypes.Count == 0)
            {
                MessageBox.Show("Atleast one file extension must be selected for testing");
                return;
            }

            CandidatesBaseSplit.Visible       = false;
            CandidatesStepProgressBar.Visible = true;
            BaseTabs.SelectTab(1);
            try
            {
                WorkerThread.Abort();
            }
            catch { }
            WorkerThread = new Thread(FindCandidatesFromDB);
            WorkerThread.Start(new Dictionary <string, List <string> >()
            {
                { "Hosts", SelectedHosts }, { "File", SelectedFileTypes }, { "TokenName", new List <string>()
                                                                             {
                                                                                 TokenName
                                                                             } }
            });
        }
Пример #2
0
        private void FindCandidatesBtn_Click(object sender, EventArgs e)
        {
            if (Recording.Recording.Has(RecordingSelectBox.Text))
            {
                LoginRecording = Recording.Recording.Get(RecordingSelectBox.Text);
            }
            else if (RecordingSelectBox.Text.Trim().Length > 0)
            {
                MessageBox.Show("Invalid Login recording name, enter a valid name.");
                return;
            }

            foreach (DataGridViewRow Row in ParametersGrid.Rows)
            {
                if (Row.Cells[0].Value != null && Row.Cells[1].Value != null && Row.Cells[2].Value != null && Row.Cells[3].Value != null && Row.Cells[4].Value != null && Row.Cells[5].Value != null)
                {
                    string[] ParameterNameValue = new string[] { (string)Row.Cells[4].Value, (string)Row.Cells[5].Value };
                    if ((bool)Row.Cells[0].Value)
                    {
                        ParametersToAdd["Query"].Add(ParameterNameValue);
                    }
                    if ((bool)Row.Cells[1].Value)
                    {
                        ParametersToAdd["Body"].Add(ParameterNameValue);
                    }
                    if ((bool)Row.Cells[2].Value)
                    {
                        ParametersToAdd["Cookie"].Add(ParameterNameValue);
                    }
                    if ((bool)Row.Cells[3].Value)
                    {
                        ParametersToAdd["Headers"].Add(ParameterNameValue);
                    }
                }
            }

            int ParamsToAddCount = 0;

            foreach (string Section in ParametersToAdd.Keys)
            {
                ParamsToAddCount += ParametersToAdd[Section].Count;
            }
            if (ParamsToAddCount == 0)
            {
                MessageBox.Show("Atleast one host must be selected for testing");
                return;
            }

            List <string> SelectedHosts = new List <string>();

            foreach (TreeNode Node in HostnamesScopeTree.Nodes)
            {
                SelectedHosts.AddRange(GetSelectedHosts(Node));
            }

            List <string> SelectedFileTypes = new List <string>();

            foreach (DataGridViewRow Row in FileTypesScopeGrid.Rows)
            {
                if ((bool)Row.Cells[0].Value)
                {
                    if (Row.Cells[1].Value.ToString().Equals(" NO EXTENSION "))
                    {
                        SelectedFileTypes.Add("");
                    }
                    else
                    {
                        SelectedFileTypes.Add(Row.Cells[1].Value.ToString());
                    }
                }
            }
            if (SelectedHosts.Count == 0)
            {
                MessageBox.Show("Atleast one host must be selected for testing");
                return;
            }
            if (SelectedFileTypes.Count == 0)
            {
                MessageBox.Show("Atleast one file extension must be selected for testing");
                return;
            }


            CandidatesBottomSplit.Visible = false;
            CandidatesProgressBar.Visible = true;
            BaseTabs.SelectTab(1);
            try
            {
                WorkerThread.Abort();
            }
            catch { }
            WorkerThread = new Thread(FindCandidatesFromDB);
            WorkerThread.Start(new Dictionary <string, List <string> >()
            {
                { "Hosts", SelectedHosts }, { "File", SelectedFileTypes }
            });
        }