private bool isDuplicate(Dictionary <int, DataEntry> risk, DataEntry entry) { foreach (KeyValuePair <int, DataEntry> keyValuePair in risk) { DataEntry tempEntry = keyValuePair.Value; if (entry.getRiskFactor() != RiskFactor.OPEN) { if (tempEntry.getIp() == entry.getIp() && tempEntry.getPluginName() == entry.getPluginName() && tempEntry.getDescription() == entry.getDescription() && tempEntry.getReferenceLink() == entry.getReferenceLink()) { return(true); } else if (tempEntry.getPluginName() == entry.getPluginName() && tempEntry.getDescription() == entry.getDescription() && tempEntry.getReferenceLink() == entry.getReferenceLink()) { List <String> ips = entry.getIpList(); foreach (String ip in ips) { tempEntry.addIp(ip); } return(true); } } else { if (tempEntry.getRiskFactor() != RiskFactor.OPEN) { return(false); } else { List <String> ips = tempEntry.getIpList(); foreach (String ip in ips) { if (ip == entry.getIp()) { String tempDescription = tempEntry.getDescription(); String[] tempSplitter = { ", " }; String[] descriptionList = entry.getDescription().Split(tempSplitter, StringSplitOptions.None); foreach (String description in descriptionList) { if (!tempDescription.Contains(description)) { tempDescription += ", " + description; } } tempEntry.setDescription(tempDescription); return(true); } } } } } return(false); }
/// <summary> /// This is the nmapAddEntry method. /// It is used to add an Nmap finding to the Record. /// </summary> /// <param name="entry">the whole nmap dataentry finding</param> public void nmapAddEntry(DataEntry entry) { // return if entry is with non-openPort RiskFactor if (entry.getRiskFactor() != RiskFactor.OPEN) { checkNARaw.Add(entry.deepCopy()); return; } string fileName = entry.getFileName(); if (!fileNameRaw.ContainsKey(DataEntry.EntryType.NMAP)) { fileNameRaw.Add(DataEntry.EntryType.NMAP, new List <string>()); } if (!fileNameRaw[DataEntry.EntryType.NMAP].Contains(fileName)) { fileNameRaw[DataEntry.EntryType.NMAP].Add(fileName); } openPortRaw.Add(entry.deepCopy()); // If the entry is not duplicate String ip = entry.getIp(); if (!openPortTableItem.ContainsKey(ip)) { openPortTableItem[ip] = new OpenPortTableItemData(); } openPortTableItem[ip].addNmapOpenPort(((NmapDataEntry)entry).getOpenPortList()); openPortTableItem[ip].addNmapFilteredPort(((NmapDataEntry)entry).getFilteredPortList()); if (!isDuplicate(openPort, entry)) { //// Add ReportItem entry to dictionary //openPort.Add(openPort.Count, entry); // Change risk stat riskStats.addHost(entry.getIp(), entry.getRiskFactor()); } }
public void nmapAddEntry(DataEntry entry) { Dictionary <int, DataEntry> targetHashMap = openPort; if (!isDuplicate(openPort, entry)) { //Add ReportItem entry to hashmap (dictionary) targetHashMap.Add(targetHashMap.Count, entry); // Change risk stat riskStats.add(entry.getIp(), entry.getRiskFactor()); } }
private DataEntry.EntryType getEntryType(Dictionary <int, DataEntry> risk, DataEntry entry) { foreach (DataEntry tempEntry in risk.Values) { if (tempEntry.getIp() == entry.getIp() && tempEntry.getPluginName() == entry.getPluginName() && tempEntry.getDescription() == entry.getDescription() && tempEntry.getImpact() == entry.getImpact() && tempEntry.getCve() == entry.getCve() && tempEntry.getBid() == entry.getBid() && tempEntry.getOsvdb() == entry.getOsvdb() && tempEntry.getRiskFactor() == entry.getRiskFactor()) { return(tempEntry.getEntryType()); } } return(DataEntry.EntryType.NULL); }
public void mbsaAddEntry(DataEntry entry) { Dictionary <int, DataEntry> targetHashMap = null; switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetHashMap = highRisk; break; case RiskFactor.MEDIUM: targetHashMap = mediumRisk; break; case RiskFactor.LOW: targetHashMap = lowRisk; break; case RiskFactor.NONE: targetHashMap = noneRisk; break; case RiskFactor.OPEN: targetHashMap = openPort; break; } if (!isDuplicate(entry)) { //Add ReportItem entry to hashmap (dictionary) targetHashMap.Add(targetHashMap.Count, entry); // Change risk stat riskStats.add(entry.getIp(), entry.getRiskFactor()); } }
/// <summary> /// This is the mbsaAddEntry method. /// It is used to add an MBSA finding to the Record. /// </summary> /// <param name="entry">the whole mbsa dataentry finding</param> public void mbsaAddEntry(DataEntry entry) { Dictionary <int, DataEntry> targetDictionary = null; List <DataEntry> targetDictionaryRaw = null; // find which Dictionary the entry to be stored switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetDictionary = highRisk; targetDictionaryRaw = highRiskRaw; break; case RiskFactor.MEDIUM: targetDictionary = mediumRisk; targetDictionaryRaw = mediumRiskRaw; break; case RiskFactor.LOW: targetDictionary = lowRisk; targetDictionaryRaw = lowRiskRaw; break; case RiskFactor.NONE: targetDictionary = noneRisk; targetDictionaryRaw = noneRiskRaw; break; case RiskFactor.OPEN: targetDictionary = openPort; targetDictionaryRaw = openPortRaw; break; case RiskFactor.NA: case RiskFactor.NULL: targetDictionary = checkNA; targetDictionaryRaw = checkNARaw; break; } // return if entry is with unknow RiskFactor if (targetDictionary == null) { return; } string fileName = entry.getFileName(); if (!fileNameRaw.ContainsKey(DataEntry.EntryType.MBSA)) { fileNameRaw.Add(DataEntry.EntryType.MBSA, new List <string>()); } if (!fileNameRaw[DataEntry.EntryType.MBSA].Contains(fileName)) { fileNameRaw[DataEntry.EntryType.MBSA].Add(fileName); } targetDictionaryRaw.Add(entry.deepCopy()); // if the entry if not duplicate if (!isDuplicate(entry)) { // Add ReportItem entry to hashmap (dictionary) targetDictionary.Add(targetDictionary.Count, entry); // Change risk stat riskStats.addHost(entry.getIp(), entry.getRiskFactor()); } }
/// <summary> /// This is the nessusAddEntry method. /// It is used to add an Nessus finding to the Record. /// </summary> /// <param name="pluginId">the pluginID of the nessus finding</param> /// <param name="ip">the host name of the nessus finding</param> /// <param name="entry">the whole nessus dataentry finding</param> public void nessusAddEntry(DataEntry entry) { int pluginId = int.Parse(((NessusDataEntry)entry).getPluginID()); string ip = entry.getIp(); Dictionary <int, DataEntry> targetDictionary = null; List <DataEntry> targetDictionaryRaw = null; // Find which Dictionary the entry to be stored switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetDictionary = highRisk; targetDictionaryRaw = highRiskRaw; break; case RiskFactor.MEDIUM: targetDictionary = mediumRisk; targetDictionaryRaw = mediumRiskRaw; break; case RiskFactor.LOW: targetDictionary = lowRisk; targetDictionaryRaw = lowRiskRaw; break; case RiskFactor.NONE: targetDictionary = noneRisk; targetDictionaryRaw = noneRiskRaw; break; case RiskFactor.OPEN: targetDictionary = openPort; targetDictionaryRaw = openPortRaw; break; default: targetDictionary = checkNA; targetDictionaryRaw = checkNARaw; break; } // return if entry is with unknow RiskFactor if (targetDictionary == null) { return; } string fileName = entry.getFileName(); if (!fileNameRaw.ContainsKey(DataEntry.EntryType.NESSUS)) { fileNameRaw.Add(DataEntry.EntryType.NESSUS, new List <string>()); } if (!fileNameRaw[DataEntry.EntryType.NESSUS].Contains(fileName)) { fileNameRaw[DataEntry.EntryType.NESSUS].Add(fileName); } targetDictionaryRaw.Add(entry.deepCopy()); if (!openPortTableItem.ContainsKey(ip)) { openPortTableItem[ip] = new OpenPortTableItemData(); } openPortTableItem[ip].addNessusOpenPort(((NessusDataEntry)entry).getPort(), ((NessusDataEntry)entry).getProtocol()); // Change risk stat riskStats.addHost(ip, entry.getRiskFactor()); // Add ReportItem entry to the dictionary (for an non-openPort finding) if (entry.getRiskFactor() != RiskFactor.OPEN) { if (targetDictionary.ContainsKey((int)pluginId)) { //String p_w_p = entry.getportwithprotocol(); //@@@@@System.Windows.Forms.MessageBox.Show(entry.getIpList().IndexOf(ip.Substring(0, ip.Length)).ToString() + "))" + ip + ">>" + ip.Substring(0, ip.IndexOf("("))); //Plan 3targetDictionary[pluginId].addIp(ip, entry.getportwithprotocol()[entry.getIpList().IndexOf(ip.Substring(0,ip.IndexOf("(")))]); //@@@@@ //Plan 2 targetDictionary[pluginId].addIp(ip, entry.getportwithprotocol(), entry.getpluginoutput_findingdetail()); } else { targetDictionary[pluginId] = entry; //plan 2 //targetDictionary[pluginId].combine_ip_with_corresponding_port(); } } // Add Open Port finding to dictionary else { //entry.combine_ip_with_corresponding_port(); // bool isDuplicate = false; // foreach (KeyValuePair<int, DataEntry> keyValuePair in targetDictionary) // { // DataEntry tempEntry = keyValuePair.Value; // List<String> ipList = tempEntry.getIpList(); // foreach (String host in ipList) // { // // merging of open port finding if host exist in open port findings // if (host == entry.getIp()) // { // if (!tempEntry.getDescription().Contains(entry.getDescription())) // { // tempEntry.setDescription(tempEntry.getDescription() + ", " + entry.getDescription()); // } // isDuplicate = true; // break; // } // } // if (isDuplicate) // { // break; // } // } // // If the current entry is not an Duplicate entry // if (!isDuplicate) // { // // Add it to the OpenPort findings // targetDictionary.Add(targetDictionary.Count, entry); // } } }
public void acunetixAddEntry(DataEntry entry) { string ip = entry.getIp(); Dictionary <int, DataEntry> targetDictionary = null; List <DataEntry> targetDictionaryRaw = null; // Find which Dictionary the entry to be stored switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetDictionary = highRisk; targetDictionaryRaw = highRiskRaw; break; case RiskFactor.MEDIUM: targetDictionary = mediumRisk; targetDictionaryRaw = mediumRiskRaw; break; case RiskFactor.LOW: targetDictionary = lowRisk; targetDictionaryRaw = lowRiskRaw; break; case RiskFactor.NONE: targetDictionary = noneRisk; targetDictionaryRaw = noneRiskRaw; break; case RiskFactor.OPEN: targetDictionary = openPort; targetDictionaryRaw = openPortRaw; break; default: targetDictionary = checkNA; targetDictionaryRaw = checkNARaw; break; } // return if entry is with unknow RiskFactor if (targetDictionary == null) { return; } string fileName = entry.getFileName(); if (!fileNameRaw.ContainsKey(DataEntry.EntryType.Acunetix)) { fileNameRaw.Add(DataEntry.EntryType.Acunetix, new List <string>()); } if (!fileNameRaw[DataEntry.EntryType.Acunetix].Contains(fileName)) { fileNameRaw[DataEntry.EntryType.Acunetix].Add(fileName); } targetDictionaryRaw.Add(entry.deepCopy()); // Add ReportItem entry to hashmap (dictionary) targetDictionary.Add(targetDictionary.Count, entry); // Change risk stat riskStats.addHost(ip, entry.getRiskFactor()); }
public void nessusAddEntry(int pluginId, String ip, DataEntry entry) { Dictionary <int, DataEntry> targetHashMap = null; switch (entry.getRiskFactor()) { case RiskFactor.HIGH: targetHashMap = highRisk; break; case RiskFactor.MEDIUM: targetHashMap = mediumRisk; break; case RiskFactor.LOW: targetHashMap = lowRisk; break; case RiskFactor.NONE: targetHashMap = noneRisk; break; case RiskFactor.OPEN: targetHashMap = openPort; break; } // Change risk stat riskStats.add(ip, entry.getRiskFactor()); // Add ReportItem entry to hashmap (Dictionary) if (entry.getRiskFactor() != RiskFactor.OPEN) { if (targetHashMap.ContainsKey((int)pluginId)) { targetHashMap[pluginId].addIp(ip); } else { targetHashMap[pluginId] = entry; } } // Add Open Port entry to hashmap (Dictionary) else { bool isDuplicate = false; foreach (KeyValuePair <int, DataEntry> keyValuePair in targetHashMap) { DataEntry tempEntry = keyValuePair.Value; List <String> ipList = tempEntry.getIpList(); foreach (String s in ipList) { if (s == entry.getIp()) { tempEntry.setDescription(tempEntry.getDescription() + ", " + entry.getDescription()); isDuplicate = true; break; } } if (isDuplicate) { break; } } if (!isDuplicate) { targetHashMap.Add(targetHashMap.Count, entry); } } }