1

This is the script i build

for i in `cat cain.txt`
do
uuid=$(curl   -X POST -H "ACCEPT-LANGUAGE:en"   -H "Content-Type:application/json"   -H "Accept: application/json" -d  '{"username":"TheUserName"}'  H) 
> final.txt
fuid=$(echo "$uuid" | sed -nE 's/.*"serviceUuid":"(.*)","user.*/\1/p' >>  final.txt)
eval $fuid
echo $fuid

service_uuid=$(cat final.txt)
password=$(sed -n 1p cain.txt)
echo $service_uuid
echo $password

login=$(curl -X POST -H "ACCEPT-LANGUAGE:en"  -H "Content-Type: application/json;charset=utf-8"  -H "Accept-Encoding:gzip,deflate"   -H "Accept: application/json"  -H "Connection: keep-alive" -d  '{"serviceUuid":"${service_uuid}","password":"${password}"}'  HereTheUrl)

echo "$login"
if [ "$login" = "STATUS_OK" ]
then
echo "Password: $password"
break
else
echo "Trying: $password"
fi
done

When i run it the server response is:

{"status":{"code":"NOT_AUTHENTICATED","message":"HereTheUrl"},"body":{}}

How to fix that?

(the response for password error need to be "ERROR" not "NOT_AUTHENTICATED")

  • Without understanding the API it's going to be a bit difficult to say. It looks like the server is responding that authentication failed. This is deeply in the domain of the application though. – Bratchley Dec 5 '16 at 17:55
  • @Bratchley I think i know what happens...the first one response is good [STATUS_OK] when i send the username...then starts the error...i think can be that i don't send the username everytime but only one time then i try password but without sending before username. – op32 Dec 6 '16 at 14:51
0

I fixed this problem. The problem was created for an syntax error.

The error was about the position of the " and the ' Just needed to change the ' in " and then it works.

login=$(curl -X POST -H "ACCEPT-LANGUAGE:en"  -H "Content-Type: application/json;charset=utf-8"  -H "Accept-Encoding:gzip,deflate"   -H "Accept: application/json"  -H "Connection: keep-alive" -d  "{"serviceUuid":"${service_uuid}","password":"${password}"}"  HereTheUrl)

and

uuid=$(curl   -X POST -H "ACCEPT-LANGUAGE:en"   -H "Content-Type:application/json"   -H "Accept: application/json" -d  "{"username":"TheUserName"}"

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.