-
-
Save mcrmonkey/9ea27d265d1e002fedf4f13a775f5150 to your computer and use it in GitHub Desktop.
Script to NMAP a network and Post Differences to Slack
This file contains 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=${TARGETS:="192.168.1.0/24"} | |
OPTIONS=${NMAPOPS:="-v -T4 -F -sV"} | |
DATE=$(date +%Y-%m-%d-%H-%M-%S) | |
cd /nmap/diffs | |
nmap $OPTIONS $TARGETS -oA scan-$DATE > /dev/null | |
slack(){ | |
curl -F file=@diff-$DATE -F initial_comment="Internal Port Change Detected" -F channels=#$SLACKCHAN -F token=$SLACKTOKEN https://slack.com/api/files.upload | |
} | |
if [ -e scan-prev.xml ]; then | |
ndiff scan-prev.xml scan-$DATE.xml > diff-$DATE | |
[ "$?" -eq "1" ] && sed -i -e 1,3d diff-$DATE && slack | |
fi | |
ln -sf scan-$DATE.xml scan-prev.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
something like: