masscan扫描结果转成Excel

# -*- coding: UTF-8 -*-
from openpyxl import Workbook

wb = Workbook()
ws = wb.active

row = 2
#filedir=['result1.txt','result2.txt']
filedir=['live.xml']
for a in filedir:
    with open(a, "r",encoding='UTF-8') as live:
        ws.append(['IP','端口','状态','service'])
        for line in live.readlines():
            if 'open ' in line:
                data= line.split(' ')
                ws['A' + str(row)] = data[3]
                ws['B' + str(row)] = data[2]
                ws['C' + str(row)] = data[0]
                ws['D' + str(row)] = data[1]
                row += 1
        print(a+'[ok]')
        wb.save(u'live_all_ip_port.xlsx')
        #live.close()
wb.close()

 

你可能感兴趣的:(masscan扫描结果转成Excel)