Last active
May 17, 2021 12:21
-
-
Save adujardin/fde77dc1d630e403dc0701cafeb00c95 to your computer and use it in GitHub Desktop.
Explore local network IP and output it on slack (PC name / IP / Vendor)
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
# Should be run as root | |
Ips=$( nmap -sP 192.168.*.* | sed '/Host is up/d' | sed 's/.localdomain//' | sed 's/Nmap scan report for *//' | sed '/Nmap done/d' | sed 's/MAC Address: ..:..:..:..:..:.. //' | tr \(\) \* | paste -d ' ' - - | sed '/Starting Nmap/d' ) | |
# Check the diff between current run and previous (should be run in a cron every hour or something) | |
echo $Ips > current | |
if ! cmp current old >/dev/null 2>&1; then | |
curl -X POST -H 'Content-type: application/json' --data '{"text": "---------------------\n\n\n'"${Ips}"'" }' https://hooks.slack.com/services/<INSERT_ACTUAL_SLACK_URL_HERE> | |
mv current old | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment