dns_world4you: Fix cookie parsing issue
Signed-off-by: Lorenz Stechauner <lorenz.stechauner@necronda.net>
This commit is contained in:
parent
1b59b0b739
commit
4d8b661d51
@ -160,24 +160,25 @@ _login() {
|
|||||||
username="$WORLD4YOU_USERNAME"
|
username="$WORLD4YOU_USERNAME"
|
||||||
password="$WORLD4YOU_PASSWORD"
|
password="$WORLD4YOU_PASSWORD"
|
||||||
csrf_token=$(_get "$WORLD4YOU_API/login" | grep '_csrf_token' | sed 's/^.*<input[^>]*value=\"\([^"]*\)\".*$/\1/')
|
csrf_token=$(_get "$WORLD4YOU_API/login" | grep '_csrf_token' | sed 's/^.*<input[^>]*value=\"\([^"]*\)\".*$/\1/')
|
||||||
sessid=$(grep 'W4YSESSID' <"$HTTP_HEADER" | sed 's/^.*W4YSESSID=\([^;]*\);.*$/\1/')
|
_parse_sessid
|
||||||
|
|
||||||
export _H1="Cookie: W4YSESSID=$sessid"
|
export _H1="Cookie: W4YSESSID=$sessid"
|
||||||
export _H2="X-Requested-With: XMLHttpRequest"
|
export _H2="X-Requested-With: XMLHttpRequest"
|
||||||
body="_username=$username&_password=$password&_csrf_token=$csrf_token"
|
body="_username=$username&_password=$password&_csrf_token=$csrf_token"
|
||||||
ret=$(_post "$body" "$WORLD4YOU_API/login" '' POST 'application/x-www-form-urlencoded')
|
ret=$(_post "$body" "$WORLD4YOU_API/login" '' POST 'application/x-www-form-urlencoded')
|
||||||
unset _H2
|
unset _H2
|
||||||
|
|
||||||
_debug ret "$ret"
|
_debug ret "$ret"
|
||||||
if _contains "$ret" "\"success\":true"; then
|
if _contains "$ret" "\"success\":true"; then
|
||||||
_info "Successfully logged in"
|
_info "Successfully logged in"
|
||||||
sessid=$(grep 'W4YSESSID' <"$HTTP_HEADER" | sed 's/^.*W4YSESSID=\([^;]*\);.*$/\1/')
|
_parse_sessid
|
||||||
else
|
else
|
||||||
_err "Unable to log in: $(echo "$ret" | sed 's/^.*"message":"\([^\"]*\)".*$/\1/')"
|
_err "Unable to log in: $(echo "$ret" | sed 's/^.*"message":"\([^\"]*\)".*$/\1/')"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage _get_paketnr <fqdn> <form>
|
# Usage: _get_paketnr <fqdn> <form>
|
||||||
_get_paketnr() {
|
_get_paketnr() {
|
||||||
fqdn="$1"
|
fqdn="$1"
|
||||||
form="$2"
|
form="$2"
|
||||||
@ -200,3 +201,8 @@ _get_paketnr() {
|
|||||||
PAKETNR=$(echo "$form" | grep "data-textfilter=\".* $domain " | _tail_n 1 | sed "s|.*$WORLD4YOU_API/\\([0-9]*\\)/.*|\\1|")
|
PAKETNR=$(echo "$form" | grep "data-textfilter=\".* $domain " | _tail_n 1 | sed "s|.*$WORLD4YOU_API/\\([0-9]*\\)/.*|\\1|")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Usage: _parse_sessid
|
||||||
|
_parse_sessid() {
|
||||||
|
sessid=$(grep 'W4YSESSID' <"$HTTP_HEADER" | _tail_n 1 | sed 's/^.*W4YSESSID=\([^;]*\);.*$/\1/')
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user