Beispiel #1
0
        private void matchSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //do scan here
            ScanEngine se          = new ScanEngine();
            CRScanner  newcrsanner = new CRScanner();

            newcrsanner.Patterns.Add(richTextBox1.SelectedText);
            foreach (var fex in crs.FileExtensions)
            {
                newcrsanner.FileExtensions.Add(fex);
            }

            Cursor = Cursors.WaitCursor;
            try
            {
                if (workingScanDir == "")
                {
                    DialogResult result = folderBrowserDialog1.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        var vuls = se.GetVuls(folderBrowserDialog1.SelectedPath, newcrsanner);
                        //create the output
                        StringBuilder sb = new StringBuilder();
                        foreach (var v in vuls)
                        {
                            //sb.AppendFormat("{0}\n", v.VulData());
                            sb.AppendFormat("{0}\n", v.ToString());
                        }

                        //call new reg form here
                        RegexEditorForm newref = new RegexEditorForm(newcrsanner, crl,
                                                                     RegexEditorForm.fileSavePath, this.workingScanDir, sb.ToString());
                        newref.Show();
                    }
                }
                else
                {
                    var vuls = se.GetVuls(workingScanDir, newcrsanner);
                    //create the output
                    StringBuilder sb = new StringBuilder();
                    foreach (var v in vuls)
                    {
                        //sb.AppendFormat("{0}\n", v.VulData());
                        sb.AppendFormat("{0}\n", v.ToString());
                    }
                    //call new reg form here
                    RegexEditorForm newref = new RegexEditorForm(newcrsanner, crl,
                                                                 RegexEditorForm.fileSavePath, this.workingScanDir, sb.ToString());
                    newref.Show();
                }
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
                crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while performing quick scan " +
                             ex.Message);
                Cursor = Cursors.Default;
            }
        }
Beispiel #2
0
        /// <summary>
        /// This handler starts a dialog to scan an entire directory using the current scanner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void quickScanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //TODO: add threading

            crs.CRVID = "000000";//test id
            foreach (var p in comboBox1.Items)
            {
                crs.Patterns.Add(p.ToString());
            }


            if (crs.Patterns.Count < 1)
            {
                MessageBox.Show("you must have at least one pattern ", "Warning"
                                , MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (crs.FileExtensions.Count < 1)
            {
                MessageBox.Show("you must have at least one file association ", "Warning"
                                , MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //do scan here
                ScanEngine se = new ScanEngine();
                Cursor = Cursors.WaitCursor;
                try
                {
                    if (workingScanDir == "")
                    {
                        DialogResult result = folderBrowserDialog1.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            var vuls = se.GetVuls(folderBrowserDialog1.SelectedPath, crs);
                            //create the output
                            StringBuilder sb = new StringBuilder();
                            foreach (var v in vuls)
                            {
                                //sb.AppendFormat("{0}\n", v.VulData());
                                sb.AppendFormat("{0}\n", v.ToString());
                            }
                            richTextBox1.Text = "";
                            richTextBox1.Text = sb.ToString();
                        }
                    }
                    else
                    {
                        var vuls = se.GetVuls(workingScanDir, crs);
                        //create the output
                        StringBuilder sb = new StringBuilder();
                        foreach (var v in vuls)
                        {
                            //sb.AppendFormat("{0}\n", v.VulData());
                            sb.AppendFormat("{0}\n", v.ToString());
                        }
                        richTextBox1.Text = "";
                        richTextBox1.Text = sb.ToString();
                    }
                    Cursor = Cursors.Default;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error"
                                    , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while performing quick scan " +
                                 ex.Message);
                    Cursor = Cursors.Default;
                }
            }
        }