public GetProTaskStatus ( string taskID ) : object>.Dictionary |
||
taskID | string | |
Résultat | object>.Dictionary |
public static void Main(string[] args) { using (MetasploitSession session = new MetasploitSession("metasploit", "2c8X|a2!", "https://192.168.1.148:3790/api/1.1")) { using (MetasploitProManager manager = new MetasploitProManager(session)) { Dictionary<object, object> options = new Dictionary<object, object>(); options.Add("workspace", "default"); options.Add("DS_PATH", "/tmp/efc63839-ae8d-4caf-92f5-3f3ff7b6e306"); Dictionary<object, object> response = manager.StartImport(options); foreach (var pair in response) Console.WriteLine(pair.Key + ": " + pair.Value); response = manager.GetProTaskStatus(response["task_id"] as string); foreach (var pair in response) { string stat = (pair.Value as Dictionary<object, object>)[(object)"status"] as string; while (stat == "running") { System.Threading.Thread.Sleep(500); response = manager.GetProTaskStatus(response["task_id"] as string); foreach (var p in response) stat = (p.Value as Dictionary<object, object>)["status"] as string; } } } } }
private bool MetasploitProAssessmentIsRunning(string msfProScanID) { 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> response = manager.GetProTaskStatus (msfProScanID); if (response.ContainsKey ("error")) throw new Exception (response ["error_message"] as string); string status = (response.First ().Value as Dictionary<string, object>) ["status"] as string; if (status == "running") return true; else return false; } } }
private bool ImportFileIntoMetasploitPro(string filename, string workspace) { 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 ("workspace", workspace); options.Add ("DS_PATH", filename); options.Add ("preserve_hosts", true); Dictionary<string, object> response = manager.StartImport (options); foreach (var pair in response) Console.WriteLine (pair.Key + ": " + pair.Value); 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 file import: " + filename); Thread.Sleep (new TimeSpan (0, 0, 60)); taskResponse = manager.GetProTaskStatus (response ["task_id"] as string); taskResponse = taskResponse.First ().Value as Dictionary<string, object>; } return true; } } }
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; }
private string BeginMetasploitProAssessment(string workspace, string whitelist, bool bruteforce) { 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> (); Dictionary<string, object> response; object hosts = csv.Split (','); options.Add ("ips", hosts); options.Add ("workspace", workspace); Console.WriteLine ("Discovering..."); response = manager.StartDiscover (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 discovery"); Thread.Sleep (new TimeSpan (0, 0, 60)); taskResponse = manager.GetProTaskStatus (response ["task_id"] as string); taskResponse = taskResponse.First ().Value as Dictionary<string, object>; } options = new Dictionary<string, object> (); if (true) {//if (bruteforce) string svcs = string.Empty; foreach (string service in services) { if (service == "postgresql") svcs = svcs + "Postgresql "; else if (service == "mysql") svcs = svcs + "MySQL "; else if (service == "mssql") svcs = svcs + "MSSQL "; else if (service == "oracle") svcs = svcs + "Oracle "; else if (service == "http") svcs = svcs + "HTTP "; else if (service == "https") svcs = svcs + "HTTPS "; else if (service == "ssh") svcs = svcs + "SSH "; else if (service == "telnet") svcs = svcs + "Telnet "; else if (service == "ftp") svcs = svcs + "FTP "; else if (service == "exec") svcs = svcs + "EXEC "; else if (service == "shell") svcs = svcs + "SHELL "; else if (service == "vnc") svcs = svcs + "VNC "; } Console.WriteLine ("Bruteforcing..."); options.Add ("workspace", workspace); options.Add ("DS_WHITELIST_HOSTS", whitelist); options.Add ("DS_BRUTEFORCE_SCOPE", "quick"); options.Add ("DS_BRUTEFORCE_SERVICES", svcs); options.Add ("DS_BRUTEFORCE_SPEED", "TURBO"); options.Add ("DS_INCLUDE_KNOWN", true); options.Add ("DS_BRUTEFORCE_GETSESSION", true); response = manager.StartBruteforce (options); 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 bruteforce"); Thread.Sleep (new TimeSpan (0, 0, 30)); taskResponse = manager.GetProTaskStatus (response ["task_id"] as string); taskResponse = taskResponse.First ().Value as Dictionary<string, object>; } options = new Dictionary<string, object> (); } options.Add ("workspace", workspace); options.Add ("DS_WHITELIST", whitelist); options.Add ("DS_MinimumRank", "great"); options.Add ("DS_EXPLOIT_SPEED", 5); options.Add ("DS_EXPLOIT_TIMEOUT", 2); options.Add ("DS_LimitSessions", false); options.Add ("DS_MATCH_VULNS", true); options.Add ("DS_MATCH_PORTS", true); response = manager.StartExploit (options); foreach (var pair in response) Console.WriteLine (pair.Key + ": " + pair.Value); return response ["task_id"] as string; } } }
public static void Main(string[] args) { using (MetasploitSession session = new MetasploitSession("metasploit", "2c8X|a2!", "https://192.168.1.148: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", "default"); 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", "PDF"); 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); foreach (var pair in response) Console.WriteLine(pair.Key + ": " + pair.Value); string taskID = response["task_id"] as string; response = manager.GetProTaskStatus(taskID); bool done = false; while (!done) { System.Text.Encoding enc = System.Text.Encoding.ASCII; string status = string.Empty; foreach (var pair in response) { Console.WriteLine(pair.Key + ":"); foreach (var p in pair.Value as Dictionary<string, object>) Console.WriteLine(p.Key + ": " + p.Value); status = (pair.Value as Dictionary<string, object>)["status"] as string; } if (status != "running") { done = true; Console.WriteLine("Done!"); } else { response = manager.GetProTaskStatus(taskID); Console.WriteLine("Not done yet..."); } } } } }