override protected void endTag(string tag) { if (elementStack.Count != 0) { if (tag.CompareTo("ReportItem") == 0 && elementStack.Peek().CompareTo("ReportItem") == 0) { elementStack.Pop(); tempAffectedItemList.Add(tempAffectedItem); AcunetixDataEntry entry = new AcunetixDataEntry(tempPluginName, tempIpList, tempDescription, tempImpact, tempRiskFactor, tempRecommendation, tempFileName, tempAffectedItemList, tempModuleName, tempIsFalsePositive, tempAOP_SourceFile, tempAOP_SourceLine, tempAOP_Additional, tempDetailedInformation, tempType, tempAcunetixReferenceList); tempRecord.acunetixAddEntry(entry); } else if (tag.CompareTo("Reference") == 0 && elementStack.Peek().CompareTo("Reference") == 0) { elementStack.Pop(); tempAcunetixReferenceList.Add(tempAcunetixReference); } else if (elementStack.Peek().CompareTo(tag) == 0) { elementStack.Pop(); } } }
/// <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; } } }