/// <summary> /// This is the processData method. /// It is used to process each line on the text file. /// </summary> /// <param name="content"></param> protected override void processData(string content) { if (!String.IsNullOrEmpty(content)) { //if (startHardCodeLineCount) // hardCodeLineCount++; // in here, only content start with "Host" and contains "is up" // would trigger the action to get the host list if (content.Contains("Scan of http://")) { int e = content.IndexOf("Scan of http://"); int start = e + 15; int end = content.IndexOf(":80/", start); if (start < content.Length && end < content.Length) { tempIpList = content.Substring(start, end - start); while (tempIpList.Length > 0 && tempIpList[tempIpList.Length - 1] == ' ') { tempIpList = tempIpList.Substring(0, tempIpList.Length - 1); } } } else if (content.Contains("Alert details")) { startReadEntry = true; } else if (startReadEntry == true && !finishReadPluginName && content.Contains(pluginNameKey)) { int start = content.IndexOf(pluginNameKey) + pluginNameKey.Length; int end = content.IndexOf("</td>", start); tempPluginName = content.Substring(start, end - start); finishReadPluginName = true; } //else if (startReadEntry == true && !finishReadPluginName && content.Contains(pluginNameKeyType2)) //{ // int start = pluginNameKeyType2.Length; // int end = content.IndexOf("</td>", start); // tempPluginName = content.Substring(start, end - start); // finishReadPluginName = true; //} else if (startReadEntry == true && content.Contains(severityKey)) { int start = content.IndexOf(severityContentKey) + severityContentKey.Length; int end = content.IndexOf("</td>", start); string temp = content.Substring(start, end - start); tempRiskFactor = RiskFactorFunction.getEnum(temp); // get risk factor } else if (startReadEntry == true && content.Contains(descriptionKey)) { startReadDescription = true; } else if (startReadEntry == true && startReadDescription == true && content.Contains(descriptionContentKey)) { int start = content.IndexOf(descriptionContentKey) + descriptionContentKey.Length; int end = content.IndexOf("</td>", start); tempDescription = content.Substring(start, end - start); } else if (startReadEntry == true && content.Contains(impactKey)) { startReadDescription = false; startReadImpact = true; } else if (startReadEntry == true && startReadImpact == true && content.Contains(impactContentKey)) { int start = content.IndexOf(impactContentKey) + impactContentKey.Length; int end = content.IndexOf("</td>", start); tempImpact = content.Substring(start, end - start); } else if (startReadEntry == true && content.Contains(recommendationKey)) { startReadImpact = false; startReadRecommendation = true; } else if (startReadEntry == true && startReadRecommendation == true && finishReadRecommendation == false && content.Contains(recommendationContentKey)) { int start = content.IndexOf(recommendationContentKey) + recommendationContentKey.Length; int end = content.IndexOf("</td>", start); tempRecommendation = content.Substring(start, end - start); } else if (startReadEntry == true && content.Contains(affectedItemKey)) { startReadRecommendation = false; finishReadRecommendation = true; tempAffectedItemList = new List <AffectedItem>(); startReadAffectedItem = true; } else if (startReadEntry == true && startReadAffectedItem == true && content.Contains(affectedItemContentKey)) { int start = content.IndexOf(affectedItemContentKey) + affectedItemContentKey.Length; int end = content.IndexOf("</td>", start); String tempName = content.Substring(start, end - start); tempAffectedItem = new AffectedItem(tempName); tempAffectedItemList.Add(tempAffectedItem); startFindAffectedItemDetail = true; //hardCodeLineCount = 0; //startHardCodeLineCount = false; } else if (startReadEntry == true && startFindAffectedItemDetail == true && content.Contains(affectedItemDetailKey)) { //startReadAffectedItem = false; startFindAffectedItemDetail = false; startReadAffectedItemDetail = true; } else if (startReadEntry == true && startReadAffectedItemDetail == true && content.Contains(affectedItemDetailContentKey)) { int start = content.IndexOf(affectedItemDetailContentKey) + affectedItemDetailContentKey.Length; int end = content.IndexOf("</td>", start); String tempDetail = content.Substring(start, end - start); tempAffectedItem.addDetail(tempDetail); startFindAffectedItemRequest = true; startFindEndTag = true; //startHardCodeLineCount = true; } else if (startReadEntry == true && startFindAffectedItemRequest == true && content.Contains(affectedItemRequestKey)) { startReadAffectedItemDetail = false; startFindAffectedItemRequest = false; startReadAffectedItemRequest = true; } else if (startReadEntry == true && startReadAffectedItemRequest == true && content.Contains(affectedItemRequestContentKey)) { int start = content.IndexOf(affectedItemRequestContentKey) + affectedItemRequestContentKey.Length; int end = content.IndexOf("</td>", start); String tempRequest = content.Substring(start, end - start); tempAffectedItem.addRequest(tempRequest); startFindAffectedItemResponse = true; } else if (startReadEntry == true && startFindAffectedItemResponse == true && content.Contains(affectedItemResponseKey)) { startReadAffectedItemRequest = false; startFindAffectedItemResponse = false; startReadAffectedItemResponse = true; } else if (startReadEntry == true && startReadAffectedItemResponse == true && content.Contains(affectedItemResponseContentKey)) { int start = content.IndexOf(affectedItemRequestContentKey) + affectedItemRequestContentKey.Length; int end = content.IndexOf("</td>", start); String tempResponse = content.Substring(start, end - start); tempAffectedItem.addResponse(tempResponse); } else if (startReadEntry == true && startFindEndTag == true && (content.Contains("<tr style=\"height:5px\">") || content.Contains("</body></html>") || content.Contains("<tr style=\"height:13px\">"))) { AcunetixDataEntry entry = new AcunetixDataEntry(tempPluginName, tempIpList, tempDescription, tempImpact, tempRiskFactor, tempRecommendation, tempFileName, tempAffectedItemList, "", "", "", "", "", "", "", null); this.tempRecord.acunetixAddEntry(entry); tempPluginName = ""; tempDescription = ""; tempImpact = ""; tempRiskFactor = RiskFactor.NULL; tempRecommendation = ""; tempAffectedItem = null; tempAffectedItemList = null; //hardCodeLineCount = 0; //startHardCodeLineCount = false; startReadDescription = false; startReadImpact = false; startReadRecommendation = false; finishReadRecommendation = false; startReadAffectedItem = false; startFindAffectedItemDetail = false; startReadAffectedItemDetail = false; finishReadPluginName = false; startFindAffectedItemRequest = false; startReadAffectedItemRequest = false; startFindAffectedItemResponse = false; startReadAffectedItemResponse = false; startFindEndTag = false; } } }
private String[] buildAcunetixStringArray(DataEntry entry, RiskFactor riskFactor, AffectedItem item) { String[] stringArray = new String[23]; // Plugin Name stringArray[0] = entry.getPluginName(); // Hosts Affected stringArray[1] = entry.getIp(); // Description stringArray[2] = entry.getDescription(); // Impact stringArray[3] = entry.getImpact(); // Risk Level stringArray[4] = RiskFactorFunction.getEnumString(riskFactor); // Recommendations stringArray[5] = entry.getRecommendation(); stringArray[6] = entry.getFileName(); stringArray[7] = ((AcunetixDataEntry)entry).getSubDomain(); stringArray[8] = item.getSubDirectory(); stringArray[9] = item.getDepartment(); stringArray[10] = item.getName(); stringArray[11] = item.getLink(); stringArray[12] = item.getDetail(); stringArray[13] = item.getRequest(); stringArray[14] = item.getResponse(); stringArray[15] = ((AcunetixDataEntry)entry).getModuleName(); stringArray[16] = ((AcunetixDataEntry)entry).getIsFalsePositive(); stringArray[17] = ((AcunetixDataEntry)entry).getAOP_SourceFile(); stringArray[18] = ((AcunetixDataEntry)entry).getAOP_SourceLine(); stringArray[19] = ((AcunetixDataEntry)entry).getAOP_Additional(); stringArray[20] = ((AcunetixDataEntry)entry).getDetailedInformation(); stringArray[21] = ((AcunetixDataEntry)entry).getAcunetixType(); stringArray[22] = ((AcunetixDataEntry)entry).getAcunetixReferenceListString(); return(stringArray); }
override protected void startTag(string tag, Dictionary <string, string> attributes) { if (tag.CompareTo("StartURL") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("ReportItem") == 0) { tempPluginName = ""; tempRecommendation = ""; tempDescription = ""; tempImpact = ""; tempRiskFactor = RiskFactor.NULL; tempAffectedItemList = new List <AffectedItem>(); tempAffectedItem = new AffectedItem(); tempModuleName = ""; tempIsFalsePositive = ""; tempAOP_SourceFile = ""; tempAOP_SourceLine = ""; tempAOP_Additional = ""; tempDetailedInformation = ""; tempType = ""; tempAcunetixReferenceList = null; tempAcunetixReference = null; elementStack.Push(tag); } else if (elementStack.Count != 0) { if (tag.CompareTo("Name") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Details") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Affects") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Severity") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Impact") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Description") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Recommendation") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Request") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Response") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("ModuleName") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("IsFalsePositive") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("AOP_SourceFile") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("AOP_SourceLine") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("AOP_Additional") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("Type") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("DetailedInformation") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("References") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { tempAcunetixReferenceList = new List <AcunetixReference>(); elementStack.Push(tag); } else if (tag.CompareTo("Reference") == 0 && elementStack.Peek().CompareTo("References") == 0) { tempAcunetixReference = new AcunetixReference(); elementStack.Push(tag); } else if (tag.CompareTo("Database") == 0 && elementStack.Peek().CompareTo("Reference") == 0) { elementStack.Push(tag); } else if (tag.CompareTo("URL") == 0 && elementStack.Peek().CompareTo("Reference") == 0) { elementStack.Push(tag); } } }