-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Hi, I'm trying to recreate your script with bash but I got stuck at the login part, I keep getting:
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>100006</code>
<message></message>
</error>
Based on the error code, it's ERROR_PARAMETER_ERROR = 100006
Here's my script:
#!/bin/bash
username="admin"
password="admin"
E5577_auth() {
curl -sc '/tmp/E5577' 'http://192.168.8.1/html/home.html' > /dev/null
cookie=$(curl -sb /tmp/E5577 http://192.168.8.1/api/webserver/SesTokInfo | awk -F "[><]" '/SesInfo/ {print $3}')
token=$(curl -sb /tmp/E5577 http://192.168.8.1/api/webserver/SesTokInfo | awk -F "[><]" '/TokInfo/ {print $3}')
echo "Cookie: $cookie"
echo "Token: $token"
if [[ -z "$cookie" ]] || [[ -z "$token" ]]; then
echo "Authentication failed."
fi
}
login() {
E5577_auth
password=$(echo -n "$password" | sha256sum | cut -d ' ' -f 1 | sed ':a;N;$!ba;s/\n//g') # 1. Original password is hashed first
password=$(echo -n "$password" | base64 | sed ':a;N;$!ba;s/\n//g') # 2. Then the hashed password is encoded with base64
password=$(echo -n "$username$password$token" | sed ':a;N;$!ba;s/\n//g') # 3. Append both username & token
password=$(echo -n "$password" | sha256sum | cut -d ' ' -f 1 | sed ':a;N;$!ba;s/\n//g') # 4. hash again
password=$(echo -n "$password" | base64 | sed ':a;N;$!ba;s/\n//g') # 5. encode again
echo "Password: $password"
data="<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Username>$username</Username><password_type>4</password_type><Password>$password</Password></request>"
curl -s 'http://192.168.8.1/api/user/login' -H "Cookie: $cookie" -H "__RequestVerificationToken: $token" --data "$data"
}
login
Can you help me fix it ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels