Last active
December 30, 2015 20:37
-
-
Save aaronmelton/03aae1140ba5ea1f0808 to your computer and use it in GitHub Desktop.
Port scan targets and send email w/ attachment if results different than previous execution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| TARGETS="192.168.1.0/24" | |
| FILENAME="nmap_192.168.1.0" | |
| OPTIONS="-v -n --open -sS -sU -F --scan-delay 1s" | |
| DATE=`date +%F` | |
| cd /var/log/nmap | |
| nmap $OPTIONS $TARGETS -oA $FILENAME\_$DATE > /dev/null | |
| if [ -e $FILENAME\-prev.xml ]; then | |
| ndiff $FILENAME\-prev.xml $FILENAME\_$DATE.xml > $FILENAME\-diff_$DATE.txt | |
| if [ "$?" -eq "1" ]; then | |
| echo "See attachment for NMAP differences." | mutt -s "NMAP Differences Discovered" -a $FILENAME\-diff_$DATE.txt -- user@email.com | |
| fi | |
| fi | |
| ln -sf $FILENAME\_$DATE.xml $FILENAME\-prev.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment