服务端口快扫shell

#set -x
var_start=8000
array=()
index=0
while [ 1 ]
do
        array=$(curl -s "http://*.*.*.*:8080/disk_info/storeunit_ip")
        for ip in ${array[@]}
        do
                result=$(sudo nmap -sS -P0 -n -p8001-8036 $ip | grep open| wc -l | grep -v ssh | grep -v Failed |sed 's/\r//');
                if [ "$result" = "0" ] ; then
                        echo curl
                        curl -i 'http://*.*.*.*:8080/alarm?k='$ip'&v=all+store-unit+closed&l=FATAL'
                        continue
                fi
                closemsg=$(sudo nmap -sS -P0 -n -p8001-8036 $ip | grep close | awk -F'/' '{print $1}' | grep -v ssh |  grep -Eo '[0-9]{1,5}' );
                if [ $(expr length "$closemsg") -eq 2 ];then
                        echo $ip" port count $closemsg all closed"
                        curl -i 'http://*.*.*.*:8080/alarm?k='$ip'&v=port+count+'$closemsg'+all+closed&l=FATAL'
                        continue
                fi
                if [ "$closemsg" = "36" ] ; then
                        echo $ip" all 8001-8036 all closed"
                        curl -i 'http://*.*.*.*:8080/alarm?k='$ip'&v=all+8001-8036+all+closed&l=FATAL'
                        continue
                fi
                for close_port in $closemsg
                do
                        curl -i 'http://*.*.*.*:8080/alarm?k='$ip:$close_port'&v=port+closed&l=WARN'
                        echo $ip" port count:"$result" close port:"$close_port
                done
        done
        sleep 60
done

猜你喜欢

转载自raojl.iteye.com/blog/2108512
今日推荐