有一个ip列表需要分开进行nmap扫描输出处理
直接上python代码处理:
import os
import sys
ip_file = sys.argv[1]
with open(ip_file,'r') as f:
for ip in f:
ip = ip.strip()
# 拼接要执行的命令
cmd = "start powershell -NoExit -command \"nmap -Pn -A -n -p 1-65535 -v {} -oA .\\{}_result\"".format(ip,ip)
print(cmd)
# 将要批处理的命令写入到 bat 文件中
print(cmd,file=open('.\\nmap_scan.bat','a+'))
start powershell -NoExit -command "nmap"
start 开启一个新的进程 powershell,-NoExit 执行后不退出,-command 指定要执行的命令
以上python脚本会输出一个bat脚本文件,直接双击bat脚本即可同时开启多个窗口,执行不同的命令了!