-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadPortsv2.sh
executable file
·69 lines (49 loc) · 1.45 KB
/
readPortsv2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#Colours
greenColour="\e[0;32m\033[1m"
endColour="\033[0m\e[0m"
redColour="\e[0;31m\033[1m"
blueColour="\e[0;34m\033[1m"
yellowColour="\e[0;33m\033[1m"
purpleColour="\e[0;35m\033[1m"
turquoiseColour="\e[0;36m\033[1m"
grayColour="\e[0;37m\033[1m"
# Ctrl + c
function ctrl_c(){
echo -e "\n\n\t${redColour}[!]${endColour} ${grayColour}Saliendo...${endColour}\n\n"
tput cnorm; exit 1
}
trap ctrl_c SIGINT
# Help
function help(){
echo -e "\n\n\t${grayColour}Uso ${endColour}${yellowColour}----> ${endColour} ${purpleColour}$0${endColour} ${yellowColour}{ip_to_scan}${endColour}\n"
echo -e "\t${yellowColour}(i)${endColour} ${grayColour}Ejemplo: ${endColour}${purpleColour}$0 ${endColour}${yellowColour}192.168.1.1${endColour}\n\n"
tput cnorm; exit 0
}
# Exec
function checkPort(){
ip=$1
port=$2
(exec 3<> /dev/tcp/$ip/$port) 2>/dev/null
if [ $? -eq 0 ]; then
echo -e "\t${yellowColour}(!)${endColour} ${grayColour}Puerto${endColour} ${yellowColour}$port${endColour} ${grayColour}abierto.${endColour}"
fi
exec 3<&-
exec 3>&-
}
function main(){
tput civis # Ocultar el cursor
declare -a ports=( $(seq 1 65535) )
ip=$1
if [ ! $1 ]; then
help
else
echo -e "\n\n\t${purpleColour}[+] ${endColour}${grayColour}Puertos del host${endColour} ${yellowColour}$ip${endColour}${grayColour}:${endColour}\n"
for port in ${ports[@]}; do
checkPort $ip $port
done
fi
wait
tput cnorm # Devolver el cursor
}
main $1