系统运维

nmap 扫描端口是否开放的shell脚本

vim checkip_nmap.sh


#!/bin/bash
. /etc/init.d/functions

FCMD="nmap -sP"
IP="192.168.31.0/24"
TCMD="nmap -sS"
UPIP=$FCMD $IP|grep "Nmap scan report for"|awk '{print $5}'
for ip in ${UPIP}
do
  action "$ip is on line" /bin/true
  UPPORT=$TCMD $ip|grep "open"|awk '{print $1}'
  for port in ${UPPORT}
  do 
    action "$ip $port is open" /bin/true
  done
done
``

留言

您的电子邮箱地址不会被公开。 必填项已用*标注

闽ICP备20008591号-1