#!/bin/bash PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin host="$(hostname)" date="$(date)" # do not print anything before headers for sendmail echo "To: ${MAILTO:-root}" echo "Subject: WEEKLY SCAN $host $date" echo "" date echo if [[ -n `pgrep nmap` ]]; then echo previous week\'s scan not finished? pgrep -a nmap exit 1 fi [[ -f /root/targets.conf ]] && targets=`grep -vE '^#|^$' /root/targets.conf` for target in $targets; do records=`host $target` echo "$records" echo addresses=`echo "$records" | grep -v 'mail is handled' | awk '{print $NF}'` for address in $addresses; do host $address done; unset address unset records addresses echo #echo TOP 1000 PORTS AGAINST $target echo ALL PORTS AGAINST $target echo time nmap -sTUV -T4 -p0-65535 $target # -Pn echo done; unset target date