infosec/Introduccion-hacking-hack4u/tema_2_Reconocimiento/portScan.sh

39 lines
549 B
Bash
Executable File

#!/bin/bash
function ctrl_c() {
echo -e "\n\n[!] Saliendo... \n"
tput cnorm; exit 1
}
# Ctrl+C
trap ctrl_c SIGINT
declare -a ports=($(seq 1 65535))
function checkPort() {
(exec 3<> /dev/tcp/$1/$2) 2>/dev/null
if [ $? -eq 0 ]; then
echo -e "[+] Host $1 - Puerto $2 (abierto)"
fi
exec 3>&-
exec 3<&-
}
tput civis # Ocultar cursor
if [ $1 ]; then
for port in "${ports[@]}"; do
checkPort $1 $port &
done
else
echo -e "\n[!] Uso: $0 <ip-address>\n"
fi
wait
tput cnorm # Mostrar cursor