1 shell脚本扫描主机方法
#!/bin/bash
##Filename: net-scan.sh
##Functions: 局域网主机联通性的扫描
network=$1
time=$(date +%H%M%S)
for i in $(seq $2 $3)
do
ping -c 1 -W 1 $network.$i > /dev/null
if [ $? -eq 0 ]; then
#### centos可以尝试开启,启动arp相关检测
#arp $network.$i | grep ":" | awk '{print $1,$3}' >> $time.log
echo "host $network.$i is up"
else
echo "host $network.$i is down"
fi
done
运行脚本方式如下:
./net-scan 192.168.3 1 255
2 nc扫描主机端口
#### 扫描192.168.x.x的TCP80到TCP445的所有端口
nc -nvv -w2 -z 192.168.1.1 80-445