infosec/Introduccion-hacking-hack4u/hostDiscovery.sh

34 lines
621 B
Bash
Raw Normal View History

2024-02-04 15:03:46 +01:00
#!/bin/bash
function ctrl_c(){
echo -e "\n\n[!] Saliendo...\n"
tput cnorm; exit 0
}
tput civis
# Ctrl+C
trap ctrl_c SIGINT
echo -e "\n\n[+] Comprobar IPs mediante ping\n"
# Comprobar IPs
for i in $(seq 1 254); do
timeout 1 bash -c "ping -c 1 192.168.2.$i" &>/dev/null && echo "192.168.2.$i is up" &
done
wait
echo -e "\n\n[+] Comprobar puertos mediante tcp\n"
# Comprobar puertos
for j in $(seq 1 254); do
for port in 21 22 23 25 80 139 443 445 8080; do
timeout 1 bash -c "echo >/dev/tcp/192.168.2.$j/$port" 2>/dev/null && echo "192.168.2.$j:$port is up" &
done
done
wait
tput cnorm