private void UpdateRows(DataGridViewSelectedRowCollection rows, bool scan) { try { BindingList <ScanLib.ScanEntry> results = this.nmapResults.DataSource as BindingList <ScanLib.ScanEntry>; this.statusMessage.Text = "Update rows"; this.progressBar.Maximum = rows.Count; this.progressBar.Value = 0; foreach (DataGridViewRow row in rows) { if (row.IsNewRow) { continue; } ScanLib.ScanEntry entry = row.DataBoundItem as ScanLib.ScanEntry; if (entry.Scan != scan && entry.IsScanable()) { entry.Scan = scan; } this.progressBar.Value += 1; } this.nmapResults.ResetBindings(true); this.statusMessage.Text = "Update completed"; UpdateServiceCount(); } catch (Exception ex) { this.LogMessage(ex); } }
public ScanEntry(ScanEntry entry) { this.Host = entry.Host; this.Protocol = entry.Protocol; this.State = entry.State; this.Port = entry.Port; this.Tls = entry.Tls; this.NmapNameNew = entry.NmapNameNew; this.NmapNameOriginal = entry.NmapNameOriginal; this.Version = entry.Version; this.Confidence = entry.Confidence; this.OsType = entry.OsType; this.Scan = entry.Scan; this.Source = entry.Source; }
/// <summary> /// This method parses the service XML nodes of the given host XML node. /// </summary> /// <param name="nodeHost">The host XML node whose services shall be parsed.</param> /// <returns></returns> private List <ScanEntry> ParseServices(XmlNode nodeHost, string os) { var result = new List <ScanEntry>(); var dedup = new Dictionary <string, object>(); foreach (XmlNode nodePort in nodeHost.SelectNodes("ReportItem")) { int port = this.GetAttributeInt(nodePort, "port"); if (port > 0) { string protocol = this.GetAttributeString(nodePort, "protocol"); int confidence = 10; string serviceName = this.GetAttributeString(nodePort, "svc_name"); if (serviceName.EndsWith("?")) { serviceName = serviceName.Substring(0, serviceName.Length - 1); confidence = 3; } string serviceNameNew = serviceName == "www" || serviceName == "https" ? "http" : serviceName; string key = String.Format("{0}/{1}", protocol, serviceName); if (!dedup.ContainsKey(key)) { dedup.Add(key, null); XmlNode tlsNode = nodeHost.SelectSingleNode(String.Format("ReportItem[@protocol='{0}' and @port='{1}' and " + "@pluginID='56984' and @pluginName='SSL / TLS Versions Supported']", protocol, port)); ScanEntry entry = new ScanEntry(protocol , port , "open" , serviceNameNew , serviceName , null , tlsNode != null , confidence , os , this.Source); result.Add(entry); } } } return(result); }
/// <summary> /// This method parses the service XML nodes of the given host XML node. /// </summary> /// <param name="nodeHost">The host XML node whose services shall be parsed.</param> /// <returns></returns> private List <ScanEntry> ParseServices(XmlNode nodeHost) { var result = new List <ScanEntry>(); foreach (XmlNode nodePort in nodeHost.SelectNodes("ports/port")) { int port = this.GetAttributeInt(nodePort, "portid"); string protocol = this.GetAttributeString(nodePort, "protocol"); XmlNode nodeState = nodePort.SelectSingleNode("state"); XmlNode nodeService = nodePort.SelectSingleNode("service"); XmlNode nodeScript = nodePort.SelectSingleNode("script[@id='fingerprint-strings']"); string state = this.GetAttributeString(nodeState, "state"); string serviceName = this.GetAttributeString(nodeService, "name"); string serviceNameNew = this.GetAttributeString(nodeService, "name"); string product = this.GetAttributeString(nodeService, "product"); string tunnel = this.GetAttributeString(nodeService, "tunnel"); string osType = this.GetAttributeString(nodeService, "ostype"); string version = this.GetAttributeString(nodeService, "version"); bool tls = !string.IsNullOrEmpty(tunnel) && tunnel == "ssl"; int confidence = this.GetAttributeInt(nodeService, "conf"); string productVersion = null; string scriptOutput = this.GetAttributeString(nodeScript, "output"); if (Properties.Settings.Default.HttpsNmapServiceNames.Contains(serviceName)) { tls = true; serviceNameNew = "http"; } else if (Properties.Settings.Default.HttpNmapServiceNames.Contains(serviceName)) { serviceNameNew = "http"; } if (serviceNameNew != "http" && !string.IsNullOrEmpty(scriptOutput)) { if (this.HttpResponseRegex.IsMatch(scriptOutput)) { serviceNameNew = "http"; } } if (!string.IsNullOrEmpty(product) && !string.IsNullOrEmpty(version)) { productVersion = String.Format("{0} {1}", product, version); } else if (!string.IsNullOrEmpty(product) && string.IsNullOrEmpty(version)) { productVersion = product; } else if (string.IsNullOrEmpty(product) && !string.IsNullOrEmpty(version)) { productVersion = version; } ScanEntry nmapEntry = new ScanEntry(protocol , port , state , serviceNameNew , serviceName , productVersion , tls , confidence , osType , this.Source); if (nmapEntry.HasState(this.States)) { result.Add(nmapEntry); } } return(result); }
public ScanEntry(string host, ScanEntry entry) : this(entry) { this.Host = host; }