#!/bin/bash# `$1` 传入类似如下格式的csv文件,第二列为 ip,第三列为 端口TMPFILE=tmp.txt
RESULT_FILE="results-$(date +%Y%m%d_%H%M%S).csv"echo"Executed on $(curl -4 myip.ipip.net)" | tee -a $RESULT_FILEecho"" | tee -a $RESULT_FILEwhile IFS=","read -r rec_column1 ip port rec_column4
do
nmap -p $port -Pn $ip > $TMPFILEecho"$ip, $port, $(cat $TMPFILE | awk '/PORT\s+STATE\s+SERVICE/{getline;print;}' | awk -F' ''{print $2}')" | tee -a $RESULT_FILEdone < $1