-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathportscanbash.sh
More file actions
36 lines (28 loc) · 918 Bytes
/
portscanbash.sh
File metadata and controls
36 lines (28 loc) · 918 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
#!/bin/bash
TARGET="127.0.0.1"
START_PORT=20
END_PORT=1024
RATE_LIMIT=0.1
echo "Scanning $TARGET"
echo "Reverse DNS:"
host $TARGET
for ((port=$START_PORT; port<=$END_PORT; port++))
do
# TCP Scan
timeout 1 bash -c "echo > /dev/tcp/$TARGET/$port" 2>/dev/null &&
echo "[+] TCP Port $port OPEN"
# UDP Scan
timeout 1 nc -u -z $TARGET $port 2>/dev/null &&
echo "[+] UDP Port $port OPEN|RESPONSIVE"
# Banner grabbing (TCP only)
banner=$(echo -e "HEAD / HTTP/1.0\r\n\r\n" | timeout 1 nc $TARGET $port 2>/dev/null)
if [[ ! -z "$banner" ]]; then
echo "[+] Banner on port $port:"
echo "$banner"
fi
# SSL Detection
echo | timeout 1 openssl s_client -connect $TARGET:$port 2>/dev/null | grep -q "BEGIN CERTIFICATE" &&
echo "[+] SSL/TLS detected on port $port"
sleep $RATE_LIMIT
done
echo "Scan complete."