#! /bin/bash broadcast=$(ip a | awk '$1 == "inet" && $4 !~ /^127/ { print $4"/24" }' | uniq) RED='\033[0;31m' GRAY='\033[0;37m' GREEN='\033[0;32m' NC='\033[0m' clear printf "${GRAY}Executing nmap on the subnets: ${RED}\n$broadcast\n" candidates=$( for brdip in ${broadcast}; do nmap -sP $brdip | awk '$2 == "scan" { print $5 }' done) printf "${GRAY}\nFound the following candidates: ${GREEN}\n$candidates\n" for ip in ${candidates}; do printf "${GRAY}\nProbing $ip...\n${NC}" ssh -q root@$ip done clear echo "Nothing found"