33 lines
1.2 KiB
Bash
Executable File
33 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
dependency_check(){
|
|
for DEPENDENCY; do
|
|
if ! command -v "$DEPENDENCY" 1>/dev/null; then
|
|
printf "%s not found. Please install it.\n" "$DEPENDENCY" >&2
|
|
exit 2
|
|
fi
|
|
done
|
|
unset DEPENDENCY
|
|
}
|
|
dependency_check "htmlq" "xmlstarlet" "tail" "head" "curl"
|
|
|
|
home_html=$(curl -s $ROUTER_ADDRESS/html/home.html)
|
|
csrf_token1=$(echo $home_html | htmlq 'meta[name="csrf_token"]' --attribute content | head -n1)
|
|
csrf_token2=$(echo $home_html | htmlq 'meta[name="csrf_token"]' --attribute content | tail -n1)
|
|
token=$(curl -c .cookie $ROUTER_ADDRESS/api/webserver/token -s | xmlstarlet sel -t -v "/response/token")
|
|
token_start=$(echo "${token::${#token}-32}")
|
|
token_end=$(echo ${token:32})
|
|
|
|
echo $token
|
|
echo $token_start$token_end
|
|
echo $token_start
|
|
echo $token_end
|
|
|
|
|
|
#curl -s -b .cookie "$ROUTER_ADDRESS/api/user/challenge_login" \
|
|
# -H "Origin: $ROUTER_ADDRESS" \
|
|
# -H "Referer: $ROUTER_ADDRESS/html/home.html" \
|
|
# -H "_ResponseSource: Broswer" \
|
|
# -H "__RequestVerificationToken: $token_end" \
|
|
# --data-raw "<?xml version="1.0" encoding="UTF-8"?><request><username>admin</username><firstnonce>58eb18b0cf49b69cb2b5b6204d32394a464ca082c0cb5a80b51811883cf4f076</firstnonce><mode>1</mode></request>" \
|