static void OtherMain(string[] args) { using (NexposeSession session = new NexposeSession("admin", "password", "192.168.2.171")) { using (NexposeManager manager = new NexposeManager(session)) { Console.WriteLine(manager.GetSystemInformation().ToString()); } } }
static void FinalMain(string[] args) { using (NexposeSession session = new NexposeSession("admin", "password", "xxx.xxx.xxx.xxx")) { using (NexposeManager manager = new NexposeManager(session)) { string[][] ips = { new string[] { "192.168.2.169", string.Empty } }; XDocument site = manager.CreateOrUpdateSite(Guid.NewGuid().ToString(), null, ips); int siteID = int.Parse(site.Root.Attribute("site-id").Value); XDocument scan = manager.ScanSite(siteID); XElement ele = scan.XPathSelectElement("//SiteScanResponse/Scan"); int scanID = int.Parse(ele.Attribute("scan-id").Value); XDocument status = manager.GetScanStatus(scanID); while (status.Root.Attribute("status").Value != "finished") { Thread.Sleep(1000); status = manager.GetScanStatus(scanID); Console.WriteLine(DateTime.Now.ToLongDateString() + ":" + status.ToString()); } // Generate pdf report and delete site byte[] report = manager.GetPdfSiteReport(siteID); string outdir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string outpath = Path.Combine(outdir, siteID + ".pdf"); File.WriteAllBytes(outpath, report); manager.DeleteSite(siteID); } } }