首先吐槽一下这玩意不能自动合并相同IP的端口挺蛋疼的..实现这个功能废了不少脑细胞.
由于比较仓促变量名以及注释没怎么搞(没有注释) :)
基本原理就是酱紫~如果需要添加什么入库啊、什么添加banner字段啊、添加各种字段啊,相信各位码神秒秒钟的事儿就不多说啦~

        Console.Title = "MasscanXml V0.1 By:MythHack@SecBig.com"
        Dim xmldoc As New XmlDocument
        xmldoc.Load("d:\File.xml")
        Dim xmldoc1 As New XmlDocument
        Dim xmldocs As XmlNodeList = xmldoc.SelectNodes("//host/address[@addr]")
        Dim xmlstate As XmlNodeList = xmldoc.SelectNodes("//host/ports/port/state[@reason]")
        Dim xmldocs1 As XmlNodeList = Nothing
        Dim sb As New StringBuilder
        Dim i As Integer = 0
        Dim IPPortList As New List(Of String)
        Dim IPPortList2 As New List(Of String)
        Console.WriteLine("开始处理~")
        For Each node1 As XmlNode In xmldocs
            If IsNothing(xmlstate.Item(i).Attributes.GetNamedItem("reason").Value) = True Or xmlstate.Item(i).Attributes.GetNamedItem("reason").Value = "response" Then
                i += 1
                Continue For
            End If
            xmldoc1.LoadXml(node1.NextSibling.OuterXml)
            xmldocs1 = xmldoc1.SelectNodes("//port[@portid]")
            If IPPortList2.Contains(node1.Attributes.GetNamedItem("addr").Value) = False Then
                sb.Append(node1.Attributes.GetNamedItem("addr").Value)
                sb.Append(":")
                For Each node2 As XmlNode In xmldocs1
                    sb.Append(node2.Attributes.GetNamedItem("portid").Value)
                    sb.Append(";")
                Next
                IPPortList.Add(sb.ToString)
                IPPortList2.Add(node1.Attributes.GetNamedItem("addr").Value)
                sb.Clear()
            Else
                Dim num As Integer = IPPortList2.IndexOf(node1.Attributes.GetNamedItem("addr").Value)
                For Each node2 As XmlNode In xmldocs1
                    IPPortList.Item(num) = IPPortList.Item(num).Replace(vbLf, "") & node2.Attributes.GetNamedItem("portid").Value & ";"
                Next
            End If
            i += 1
        Next
        Console.WriteLine("正在生成文件~")
        Dim write1 As New StreamWriter("out1.txt")
        For Each temp As String In IPPortList
            write1.WriteLine(temp.TrimEnd(";"))
            Console.WriteLine(temp.TrimEnd(";"))
        Next
        write1.Close()
        write1.Dispose()
        GC.Collect()
        Console.WriteLine("处理完毕~")
        Console.ReadKey()
Comments
Write a Comment