-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortScan.sh
More file actions
50 lines (36 loc) · 927 Bytes
/
Copy pathPortScan.sh
File metadata and controls
50 lines (36 loc) · 927 Bytes
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
#!/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"
function ctrl_c(){
echo -e "\n\n${redColour}[!] Saliendo...\n ${endColour}"
exec 3<&-; exec 3>&-; tput cnorm; exit 1
}
# Ctrl + C
trap ctrl_c SIGINT
declare -a ports=( $(seq 1 65535) )
function checkPort(){
# host = $1 | $1 = ip | $2 = puerto
(exec 3<> /dev/tcp/$1/$2) 2>/dev/null
if [ $? -eq 0 ]; then
echo -e "\n${greenColour}[+] El puerto ${blueColour}$port ${greenColour}esta Abierto${endColour}"
fi
exec 3<&-
exec 3>&-
}
tput civis
if [ $1 ]; then
for port in ${ports[@]}; do
checkPort $1 $port &
done
else
echo -e "\n${grayColour} [!] Uso del programa: ${blueColour}$0 <ip-address>${endColour}"
fi
wait
tput cnorm