Exemple #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                //do add
                string[] sa     = textBox1.Text.Split('\n');
                int      pCount = 0;
                for (int i = 0; i < sa.Length; i++)
                {
                    if (!this.crs.Patterns.Contains(sa[i].ToString()) && sa[i].ToString() != "")
                    {
                        //clean the \r
                        string s = Regex.Replace(sa[i].ToString(), "\r", string.Empty);
                        this.crs.Patterns.Add(s);

                        pCount++;
                    }
                }
                MessageBox.Show("Added " + pCount + " patterns", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while performing add patterns " +
                             ex.Message);
            }

            //exit
            this.Close();
        }
Exemple #2
0
        /// <summary>
        /// Opens the SaveFile dialog and sets the save path
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //get attributes
                crScanner.Name        = textBox1.Text;
                crScanner.Description = textBox2.Text;

                CRObjSerializer cros = new CRObjSerializer();
                saveFileDialog1.ShowDialog();
                cros.SaveCRObj(saveFileDialog1.FileName, crScanner);
                RegexEditorForm.fileSavePath = saveFileDialog1.FileName;
                MessageBox.Show("file saved to: " + RegexEditorForm.fileSavePath,
                                "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
                crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while save file " +
                             ex.Message);
            }
        }
        /// <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;
                }
            }
        }