DownloadReportByTask() public method

public DownloadReportByTask ( string taskID ) : object>.Dictionary
taskID string
return object>.Dictionary
Exemplo n.º 1
0
        private XmlNode GetMetasploitProReport(string workspace)
        {
            Console.WriteLine ("Generating report for workspace: " + workspace);

            string taskID = string.Empty;
            using (MetasploitSession session = new MetasploitSession(this.Configuration["metasploitUser"],
                                                                      this.Configuration["metasploitPass"],
                                                                      "https://"+this.Configuration["metasploitHost"]+":3790/api/1.1")) {
                using (MetasploitProManager manager = new MetasploitProManager(session)) {
                    Dictionary<string, object> options = new Dictionary<string, object> ();
                    options.Add ("DS_WHITELIST_HOSTS", string.Empty);
                    options.Add ("DS_BLACKLIST_HOSTS", string.Empty);
                    options.Add ("workspace", workspace);
                    options.Add ("DS_MaskPasswords", false);
                    options.Add ("DS_IncludeTaskLog", false);
                    options.Add ("DS_JasperDisplaySession", true);
                    options.Add ("DS_JasperDisplayCharts", true);
                    options.Add ("DS_LootExcludeScreenshots", false);
                    options.Add ("DS_LootExcludePasswords", false);
                    options.Add ("DS_JasperTemplate", "msfxv3.jrxml");
                    options.Add ("DS_REPORT_TYPE", "XML");
                    options.Add ("DS_UseJasper", true);
                    options.Add ("DS_UseCustomReporting", true);
                    options.Add ("DS_JasperProductName", "AutoAssess");
                    options.Add ("DS_JasperDbEnv", "production");
                    options.Add ("DS_JasperLogo", string.Empty);
                    options.Add ("DS_JasperDisplaySections", "1,2,3,4,5,6,7,8");
                    options.Add ("DS_EnabelPCIReport", true);
                    options.Add ("DS_EnableFISMAReport", true);
                    options.Add ("DS_JasperDisplayWeb", true);

                    Dictionary<string, object> response = manager.StartReport (options);

                    Dictionary<string, object> taskResponse = manager.GetProTaskStatus (response ["task_id"] as string);

                    taskResponse = taskResponse.First ().Value as Dictionary<string, object>;

                    while (taskResponse["status"] as string == "running") {
                        Console.WriteLine ("Waiting on metasploit report");
                        Thread.Sleep (new TimeSpan (0, 0, 60));
                        taskResponse = manager.GetProTaskStatus (response ["task_id"] as string);
                        taskResponse = taskResponse.First ().Value as Dictionary<string, object>;
                    }

                    response = manager.DownloadReportByTask (response ["task_id"] as string);

                    taskID = response["data"] as string;
                }
            }

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(taskID);

            return doc.LastChild;
        }