码迷,mamicode.com
首页 > 其他好文 > 详细

nmap导出处理脚本

时间:2018-03-08 20:22:14      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:body   div   pytho   gpo   split   adl   [1]   pre   inf   

 

 

 

 

import sys

log = open("result.gnmap","r")
xls = open("output.csv","a")
xls.write("IP,port,status,protocol,service,version\n")
for line in log.readlines():
        if line.startswith("#") or line.endswith("Status: Up\n"):
                continue
        result = line.split("        ")
        host = result[0].split(" ")[1]
        port_info = result[1].split("/, ")
        port_info[0] = port_info[0].strip("Ports: ")
        for i in port_info:
                j = i.split("/")
                #print j
                output = host + "," + j[0] + "," + j[1] + "," + j[2] + "," + j[4] + "," + j[6] + "\n"
                xls.write(output)

  

nmap导出处理脚本

标签:body   div   pytho   gpo   split   adl   [1]   pre   inf   

原文地址:https://www.cnblogs.com/nul1/p/8530472.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!