Skip to content

Instantly share code, notes, and snippets.

@mcrmonkey
Forked from jgamblin/slackmap.sh
Last active February 4, 2018 23:49
Show Gist options
  • Save mcrmonkey/9ea27d265d1e002fedf4f13a775f5150 to your computer and use it in GitHub Desktop.
Save mcrmonkey/9ea27d265d1e002fedf4f13a775f5150 to your computer and use it in GitHub Desktop.
Script to NMAP a network and Post Differences to Slack
#!/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
@mcrmonkey
Copy link
Author

something like:

SLACKTOKEN="1234" SLACKCHAN="alerts" TARGETS="10.10.10.0/24" slackmap.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment