Created
May 14, 2017 04:34
-
-
Save bmoore01/2dca95537e62f4618798b15193b554a6 to your computer and use it in GitHub Desktop.
A script to find out out information and do a ports can of everything on your network
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/bash | |
# get local ip from ifconfig | |
localIP=($(sudo ifconfig | grep "inet " | awk '{print $2}' | awk 'END{print}' )) | |
# affix two wildcards to the end of local IP | |
startIP=`echo $localIP | cut -d "." -f1-3` | |
searchIP=`echo "$startIP.*"` | |
echo "search IP is: $searchIP" | |
# get IPs running on the local network | |
echo "Scanning for IPs (This may take a while)" | |
networkIPs=($(nmap -sP $searchIP | grep -E '\d{2,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' | awk '{print $5}')) | |
# Find details of stuff on network | |
for index in ${!networkIPs[*]}; do | |
echo "Device found on: ${networkIPs[$index]}" | |
sudo nmap -v -O ${networkIPs[$index]} | grep -E "PORT|^\d{1,}/tcp|Running|MAC" | |
printf "\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment