#!/bin/sh
#
nmap_path="/usr/local/bin/nmap";
# ips to be checked.
box[1]="10.10.10.2";
box[2]="10.10.10.100";
box[3]="10.10.10.97";
box[4]="10.10.10.8";
box[5]="10.10.10.34";
box[6]="10.10.10.53";
box[7]="10.10.10.69";
box[8]="10.10.10.6";
box[9]="10.10.10.32";
box[10]="10.10.10.95";
box[11]="10.10.10.91";
box[12]="10.10.10.90";
box[13]="10.10.10.78";
box[14]="10.10.10.93";
box[15]="10.10.10.94";
box[16]="10.10.10.107";
box[17]="10.10.10.57";
box[18]="10.10.10.83";
box[19]="10.10.10.63";
box[20]="10.10.10.27";
box[21]="10.10.10.194";
box[22]="10.10.10.160";
box[23]="10.10.10.65";
box[24]="10.10.10.59";
# massive counts
c=$((${#box[@]} - 1))

#dir to store the scan logs
output_dir="/var/log/scans";
dw="down";

for ((i=1;i<$c;i++)); do
# scan string
scan_up="$nmap_path -sP";
scan_string="$nmap_path -sS -P0 -v -sV -r -p 1- -o $output_dir/scan-${box[$i]}-`date +%Y_%m_%d`";
scan_up_state=`$scan_up ${box[$i]} | grep $dw`;
if [ -z "$scan_up_state" ]; then
($scan_string ${box[$i]}) &>/dev/null
fi
done
exit 0;
