WHM/cPanel – List of all ports and a script to test them

Here is a Bash script to test all inbound cPanel ports:

  • 20 FTP
  • 21 FTP
  • 22 SSH
  • 25 SMTP
  • 26 SMTP
  • 53 DNS
  • 80 HTTP
  • 110 POP3
  • 143 IMAP
  • 443 HTTPS
  • 465 SMTP
  • 587 STARTTLS
  • 993 IMAP SSL
  • 995 POP3 SSL
  • 2077 WebDAV
  • 2078 WebDAV SSL
  • 2079 CalDAV and CardDAV
  • 2080 CalDAV and CardDAV (SSL)
  • 2082 cPanel and cPanel Licensing
  • 2083 cPanel SSL and cPanel Licensing
  • 2086 WHM and cPanel Licensing
  • 2087 WHM SSL and cPanel Licensing
  • 2095 Webmail
  • 2096 Webmail SSL and cPanel Licensing
  • 3306 MySQL
#!/bin/bash

# Define ports and their friendly names
declare -A ports=(
[20]="FTP Data"
[21]="FTP"
[22]="SSH"
[25]="SMTP"
[26]="SMTP Alt"
[53]="DNS"
[80]="HTTP"
[110]="POP3"
[143]="IMAP"
[443]="HTTPS"
[465]="SMTP SSL"
[587]="SMTP STARTTLS"
[993]="IMAP SSL"
[995]="POP3 SSL"
[2077]="WebDAV"
[2078]="WebDAV SSL"
[2079]="CalDAV/CardDAV"
[2080]="CalDAV/CardDAV SSL"
[2082]="cPanel"
[2083]="cPanel SSL"
[2086]="WHM"
[2087]="WHM SSL"
[2095]="Webmail"
[2096]="Webmail SSL"
[3306]="MySQL"
)

# Target IP or hostname
TARGET="$1"

if [ -z "$TARGET" ]; then
echo "Usage: $0 <target-hostname-or-IP>"
exit 1
fi

# Build comma-separated port list for nmap
PORT_LIST=$(IFS=, ; echo "${!ports[*]}")

# Run nmap
echo "Scanning $TARGET..."
nmap -Pn -p "$PORT_LIST" "$TARGET" -oG - | while read -r line; do
for port in "${!ports[@]}"; do
if echo "$line" | grep -q "$port/open"; then
echo "✅ ${ports[$port]} (Port $port): OPEN"
elif echo "$line" | grep -q "$port/closed"; then
echo "❌ ${ports[$port]} (Port $port): CLOSED"
elif echo "$line" | grep -q "$port/filtered"; then
echo "⚠️ ${ports[$port]} (Port $port): FILTERED"
fi
done
done

Reference

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *