-
Notifications
You must be signed in to change notification settings - Fork 0
/
hostports.sh
52 lines (43 loc) · 1.07 KB
/
hostports.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
#!/bin/bash
function ctrl_c(){
echo -e "\n\n [!] Leaving...\n"
tput cnorm; exit 1
}
#Ctrl+C
trap ctrl_c INT
tput civis
#Main Function
host_scan () {
network=$1
for i in $(seq 2 254); do
(
timeout 1 bash -c "ping -c 1 ${network}.$i" &>/dev/null
if [ $? -eq 0 ]; then
echo "[+] Host ${network}.$i - ACTIVE"
# TCP port scanning
for port in $(seq 1 65535); do
timeout 1 bash -c "echo '' > /dev/tcp/${network}.$i/$port" &>/dev/null
if [ $? -eq 0 ]; then
echo "[+] Host ${network}.$i ACTIVE & TCP PORT $port OPEN"
fi
done
# UDP port scanning
for port in $(seq 1 65535); do
timeout 1 bash -c "echo '' > /dev/udp/${network}.$i/$port" &>/dev/null
if [ $? -eq 0 ]; then
echo "[+] Host ${network}.$i ACTIVE & UDP PORT $port OPEN"
fi
done
fi
) &
done
wait
}
tput cnorm
main() {
bash -c "ip a"
echo -n "Enter the network like this (e.g. 10.10.0): "
read network
host_scan $network
}
main