示例#1
0
文件: Program.cs 项目: pvbenini/wcsa
        static void Main(string[] args)
        {
            string path = "";
            string str = @"\//";
            //path = @"SampleConfigs/n2-web.config";
            if ((args.Length < 1 ) || (!File.Exists(args[0])))
            {
                Console.WriteLine("Input file doesn't found at provided location or no location provided !");
                Usage();
            }
            else
            {
                try
                {
                    path = args[0];
                    ScanEngine engine = new ScanEngine();
                    Reporter reporter = new Reporter();
                    engine.StartScan(path);
                    reporter.GenerateReport(engine.vulns, path);
                    path = "Report-" + path.Substring(path.LastIndexOfAny(str.ToCharArray()) + 1) + "-"+System.DateTime.Now.ToFileTime().ToString() +".html";
                    Console.WriteLine("---------------------------------");
                    Console.WriteLine("The Happy End");
                    path = Path.Combine("OutputReports",path.ToString());

                    if (File.Exists(Constants.REPORT_NAME))
                    {
                        if (!Directory.Exists("OutputReports"))
                            Directory.CreateDirectory("OutputReports");
                        if (File.Exists(path))
                            System.IO.File.Delete(path);

                        System.IO.File.Move(Constants.REPORT_NAME, path);
                        System.IO.File.Delete(Constants.REPORT_NAME);
                        Console.WriteLine("Report is outputted with name {0}", path);
                    }

                }

                catch (WCSAException wcsaexception)
                {
                    Console.WriteLine(Constants.FILE_NOT_FOUND_MESSAGE);
                    Environment.Exit(1);
                }

            }
        }
示例#2
0
文件: Form1.cs 项目: pvbenini/wcsa
        private void openAnotherWebConfirForAnalyzeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filePath = "";
            System.IO.Stream myStream;
            OpenFileDialog ofd = new OpenFileDialog();
            StreamReader streamReader;
            ofd.Filter = "web.config Files (*.config)|*.config|Text Files (*.txt)|*.txt| All Files (*.*)|*.*";
            ofd.RestoreDirectory = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = ofd.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            try
                            {
                                ScanEngine scanEngine = new ScanEngine();
                                Reporter reporter = new Reporter();
                                scanEngine.StartScan(ofd.FileName);
                                filePath = reporter.GenerateReport(scanEngine.vulns, ofd.FileName);

                            }
                            catch (WCSAException wcsaexception)
                            {
                                MessageBox.Show(Constants.FILE_NOT_FOUND_MESSAGE);
                                Application.Exit();
                            }

                            streamReader = new StreamReader(filePath);
                            filePath = Application.StartupPath + @"\" + filePath;
                            streamReader.Close();
                            webBrowser1.Navigate(filePath);

                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
            else
                if(webBrowser1.Url == null)
                    webBrowser1.Navigate("http://code.google.com/p/wcsa");
        }