1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| # nmap-egrep
# 主机和开放端口 egrep -v "^#|Status: Up" file.gnmap | cut -d' ' -f2,4- | \ sed -n -e 's/Ignored.*//p' | \ awk '{print "Host: " $1 " Ports: " NF-1; $1=""; for(i=2; i<=NF; i++) { a=a" "$i; }; split(a,s,","); for(e in s) { split(s[e],v,"/"); printf "%-8s %s/%-7s %s\n" , v[2], v[3], v[1], v[5]}; a="" }'
# 打印端口 egrep -v "^#|Status: Up" file.gnmap | cut -d' ' -f4- | \ sed -n -e 's/Ignored.*//p' | tr ',' '\n' | sed -e 's/^[ \t]*//' | \ sort -n | uniq -c | sort -k 1 -r | head -n 10
# 统计端口数 egrep -v "^#|Status: Up" file.gnmap | cut -d' ' -f2,4- | \ sed -n -e 's/Ignored.*//p' | \ awk -F, '{split($0,a," "); printf "Host: %-20s Ports Open: %d\n" , a[1], NF}' \ | sort -k 5 -g
# 横幅爬取 egrep -v "^#|Status: Up" file.gnmap | cut -d' ' -f2,4- | \ awk -F, '{split($1,a," "); split(a[2],b,"/"); print a[1] " " b[1]; for(i=2; i<=NF; i++) { split($i,c,"/"); print a[1] c[1] }}' \ | xargs -L1 nc -v -w1
# 顶级服务标识符 egrep -v "^#|Status: Up" file.gnmap | cut -d ' ' -f4- | tr ',' '\n' | \ sed -e 's/^[ \t]*//' | awk -F '/' '{print $7}' | grep -v "^$" | sort | uniq -c \ | sort -k 1 -nr
|