Skip to content

Instantly share code, notes, and snippets.

@OmkarKirpan
Forked from jgamblin/slackmap.sh
Created December 2, 2019 19:17
Show Gist options
  • Save OmkarKirpan/e2e0179b50b58a89bfac92efe9c5890c to your computer and use it in GitHub Desktop.
Save OmkarKirpan/e2e0179b50b58a89bfac92efe9c5890c to your computer and use it in GitHub Desktop.

Revisions

  1. @jgamblin jgamblin created this gist Nov 5, 2016.
    15 changes: 15 additions & 0 deletions slackmap.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/bin/sh
    TARGETS="192.168.1.0/24"
    OPTIONS="-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=#alerts -F token=xxxx-xxxx-xxxx 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