jitty-scripts/nmip.sh
2020-04-14 09:40:17 -07:00

29 lines
607 B
Bash
Executable File

#!/bin/bash
lanip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
# Colors
RED='\033[0;31m'
LRED="\033[1;31m"
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
GREEN="\033[0;32m"
LGREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[0;36m"
LCYAN="\033[1;36m"
PURPLE="\033[0;35m"
LPURPLE="\033[1;35m"
BWHITE="\e[1m"
NC='\033[0m' # No Color
if [ ! -f /usr/bin/nmap ];then
printf "${LRED} Nmap is not installed...${NC}\n"
elif [ ! -z "${1}" ];then
nmap -sP "${1}/24"
else
printf "${LGREEN}Looking up ${lanip}...${NC}\n"
nmap -sP ${lanip}/24 # Use sudo to get names of devies
fi