资产导出可以每个端口为一条吗?
目前导出结果:
| IP | 端口 | 协议 |
|---|---|---|
| 124.xxxxx.151.xxxx | 8081,8080,443,80,3306,1521,8009 | web,web,web,web,unknown,oracle,ajp |
| 111.xxxx.1x4.xxx | 80,22,6379,123,3306,27017,4369 | web,ssh,redis,ntp,mysql,mongodb,epmd |
| 111.xxx.184.xxx | 5985,443,80,3389,3306,21 | web,web,web,rdp,mysql,ftp |
| 49.xx.166.xxx | 443,80,500,22,6379,123,3306 | web,web,unknown,ssh,redis,ntp,mysql |
希望结果:
| IP | 端口 | 协议 |
|---|---|---|
| 124.xxx.151.xxx | 8081 | web |
| 124.xxx.151.xxx | 8080 | web |
| 124.xxx.151.xxx | 443 | web |
| 124.xxx.151.xxx | 80 | web |
| 111.xxx.134.xxx | 80 | web |
| 111.xxx.134.xxx | 22 | ssh |
| 111.xxx.134.xxx | 6379 | redis |
| 111.xxx.134.xxx | 3306 | mysql |
或者这样也行:
| IP/url | 协议 |
|---|---|
| 124.xxx.151.xxx:8081 | web |
| 124.xxx.151.xxx:8080 | web |
| 124.xxx.151.xxx:443 | web |
| 124.xxx.151.xxx:80 | web |
| 111.xxx.134.xxx:80 | web |
| 111.xxx.134.xxx:22 | ssh |
| 111.xxx.134.xxx:6379 | redis |
| 111.xxx.134.xxx:3306 | mysql |
+1
写了个脚本自己试试吧 import os import xlrd as xlrd import xlsxwriter
workbook = xlsxwriter.Workbook('output.xlsx') worksheet = workbook.add_worksheet() newXlsLineNum=0 data=xlrd.open_workbook("input.xls") table=data.sheet_by_name(u'all-goby') con=table.col_values(1)#第二列数据 端口 protocol=table.col_values(2)#第三列数据 协议 for x in xrange(1,len(con)): #print(con[x]) portList=con[x].split(',') protocolList=protocol[x].split(',') #print portList if (len(portList)>1): #print portList for i in range(len(portList)): newXlsLineNum+=1 worksheet.write(newXlsLineNum,1,portList[i]) worksheet.write(newXlsLineNum,0,table.col_values(0)[x]) worksheet.write(newXlsLineNum,2,protocolList[i]) else: newXlsLineNum+=1 worksheet.write(newXlsLineNum,1,portList[0]) worksheet.write(newXlsLineNum,0,table.col_values(0)[x]) worksheet.write(newXlsLineNum,2,table.col_values(2)[x]) workbook.close()