initial commit
This commit is contained in:
133
ud_ddns.sh
Executable file
133
ud_ddns.sh
Executable file
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
# requires: wget, ca-certificates, grep, jq
|
||||
#rm -f /tmp/cookies.txt
|
||||
|
||||
cookiefile="/tmp/cookies.txt"
|
||||
|
||||
#username=""
|
||||
#password=""
|
||||
#domain=""
|
||||
|
||||
#domain should contain "domain_id:record_id"
|
||||
domain_id=$(echo $domain | tr ":" "\n" | sed -n "1p")
|
||||
record_id=$(echo $domain | tr ":" "\n" | sed -n "2p")
|
||||
ipv4=$1
|
||||
|
||||
# fake user agent
|
||||
ua="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"
|
||||
|
||||
|
||||
|
||||
# GET LOGIN PAGE
|
||||
#csrf tokens for login + language xmlhttprequest required to login (nice try blocking my API access, UD)
|
||||
loginpage=$(/usr/bin/wget -U "$ua" \
|
||||
--save-cookies $cookiefile \
|
||||
--keep-session-cookies \
|
||||
-qO- "https://www.united-domains.de/login/")
|
||||
|
||||
csrf=$(echo "$loginpage" | /bin/grep -oP -m 2 "(?<=<input type=\"hidden\" name=\"csrf\" value=\")[^\"]*(?=\"( /)?>)" | tail -1)
|
||||
echo "csrfr=${csrf}"
|
||||
csrfmeta=$(echo "$loginpage" | /bin/grep -oP -m 1 "(?<=<meta name=\"csrf\" content=\")[^\"]*(?=\"( /)?>)")
|
||||
echo "csrfmeta=${csrfmeta}"
|
||||
csrfscript=$(echo "$loginpage" | /bin/grep -oP -m 1 "(?<=\"CSRF_TOKEN\":\")[^\"]*(?=\")")
|
||||
echo "csrfscript=${csrfscript}"
|
||||
|
||||
/usr/bin/wget -U "$ua" \
|
||||
--load-cookies $cookiefile \
|
||||
--save-cookies $cookiefile \
|
||||
--keep-session-cookies \
|
||||
--delete-after \
|
||||
--post-data "language=en-US" \
|
||||
--header="HTTP-X-CSRF-TOKEN: $csrfmeta" \
|
||||
--header="X-Csrf-Token: $csrfscript" \
|
||||
--header="X-Requested-With: XMLHttpRequest" \
|
||||
-qO- "https://www.united-domains.de/set-user-language"
|
||||
|
||||
|
||||
# DO THE LOGIN
|
||||
#login
|
||||
echo 'login'
|
||||
loginresp=$(/usr/bin/wget -U "$ua" \
|
||||
--load-cookies $cookiefile \
|
||||
--save-cookies $cookiefile \
|
||||
--keep-session-cookies \
|
||||
--post-data "csrf=$csrf&email=$username&pwd=$password&selector=login&loginBtn=Login" \
|
||||
-qO- "https://www.united-domains.de/login/")
|
||||
|
||||
|
||||
|
||||
#check if successful by requesting domain list
|
||||
#echo 'domain list'
|
||||
#DOMAIN_LIST=$(/usr/bin/wget -U "$ua" \
|
||||
# --load-cookies $cookiefile \
|
||||
# --save-cookies $cookiefile \
|
||||
# --keep-session-cookies \
|
||||
# -qO- 'https://www.united-domains.de/pfapi/dns/domain-list')
|
||||
#if [ "$DOMAIN_LIST" = "" ] ; then
|
||||
# echo "Login not successful"
|
||||
# exit 1
|
||||
#else
|
||||
# echo $DOMAIN_LIST
|
||||
#fi
|
||||
|
||||
|
||||
####################################################################################################
|
||||
# WE'RE IN
|
||||
|
||||
|
||||
|
||||
#get current dns record json object & modify ip
|
||||
echo "get current dns record json object"
|
||||
current=$(/usr/bin/wget -U "$ua" \
|
||||
--load-cookies $cookiefile \
|
||||
--save-cookies $cookiefile \
|
||||
--keep-session-cookies \
|
||||
-qO- "https://www.united-domains.de/pfapi/dns/domain/$domain_id/records")
|
||||
#echo "CURRENT: $current"
|
||||
|
||||
record=$(echo $current |
|
||||
jq -cM ".data.A | map(select(.id == $record_id)) | .[0]" | \
|
||||
sed "s/ //g" | \
|
||||
sed "s/\"address\":\"[0-9.]\+\"/\"address\":\"$ipv4\",\"formId\":${record_id}/g")
|
||||
#echo "NEW: $record"
|
||||
|
||||
payload="{\"record\":$record,\"domain_lock_state\":{\"domain_locked\":false,\"email_locked\":false}}"
|
||||
url="https://www.united-domains.de/pfapi/dns/domain/$domain_id/records"
|
||||
|
||||
|
||||
# load the DNS page for the given domain_id to get the latest csrf code
|
||||
dnspage=$(/usr/bin/wget -U "$ua" \
|
||||
--load-cookies $cookiefile \
|
||||
--save-cookies $cookiefile \
|
||||
--keep-session-cookies \
|
||||
-qO- "https://www.united-domains.de/portfolio/a/domain-admin/dns/$domain_id")
|
||||
|
||||
csrfscript=$(echo "$loginpage" | /bin/grep -oP -m 1 "(?<=\"CSRF_TOKEN\":\")[^\"]*(?=\")")
|
||||
echo "csrfscript=${csrfscript}"
|
||||
|
||||
|
||||
#send changes
|
||||
echo "send changes"
|
||||
#echo -ne "PUT ${url}\n${payload}\n"
|
||||
|
||||
output=$(/usr/bin/wget -U "$ua" \
|
||||
--load-cookies $cookiefile \
|
||||
--save-cookies $cookiefile \
|
||||
--keep-session-cookies \
|
||||
--method=PUT \
|
||||
--header="Accept: application/json" \
|
||||
--header="Accept-Encoding: gzip, deflate, br" \
|
||||
--header="Accept-Language: de-DE,de;q=0.8,en-US;q=0.5,en;q=0.3" \
|
||||
--header="Content-Type: application/json;charset=utf-8" \
|
||||
--header="Referer: https://www.united-domains.de/portfolio/a/domain-admin/dns/$domain_id" \
|
||||
--header="Origin: https://www.united-domains.de" \
|
||||
--header="Http-X-Csrf-Token: $csrfscript" \
|
||||
--body-data=$payload -O- $url 2>&1)
|
||||
echo "UD answered: $output"
|
||||
#write_log 7 "UD answered:\n$output"
|
||||
|
||||
echo $output | /bin/grep "$ipv4" >/dev/null 2>&1
|
||||
success=$?
|
||||
#write_log 7 "Retval: $success"
|
||||
echo "Retval: $success"
|
||||
#return $success
|
||||
40
ud_list.sh
Executable file
40
ud_list.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
#UD_USERNAME=''
|
||||
#UD_PASSWORD=''
|
||||
|
||||
#setup stuff
|
||||
COOKIEFILE="/tmp/cookies.txt"
|
||||
CURL="/usr/bin/curl -s -S -b $COOKIEFILE -c $COOKIEFILE"
|
||||
|
||||
#load website
|
||||
WEBSITE=$($CURL 'https://www.united-domains.de/')
|
||||
|
||||
#get csrf tokens
|
||||
CSRF_WEBSITE=$(/bin/echo $WEBSITE | /bin/grep -oP -m 1 "(?<=<meta name=\"csrf\" content=\")[^\"]*(?=\"( /)?>)")
|
||||
CSRF_LOGIN=$(/bin/echo $WEBSITE | /bin/grep -A 1 "login-form-1" | /bin/grep -oP -m 1 "(?<=<input type=\"hidden\" name=\"csrf\" value=\")[^\"]*(?=\"( /)?>)")
|
||||
|
||||
#get sessionid from cookie
|
||||
SESSIONID=$(/usr/bin/tail -n 1 $COOKIEFILE | /usr/bin/awk '{print $7}')
|
||||
|
||||
#accept the cookie usage popup on united-domains.de
|
||||
ACCEPT_COOKIES=$($CURL "https://www.united-domains.de/cookie-settings?SESSID=$SESSIONID" -X PATCH -H "HTTP-X-CSRF-TOKEN: $CSRF_WEBSITE" -H 'Content-Type: application/json' -d '{"ids":[13]}')
|
||||
|
||||
#set language
|
||||
LANGUAGE=$($CURL "https://www.united-domains.de/set-user-language?SESSID=$SESSIONID" -H "HTTP-X-CSRF-TOKEN: $CSRF_WEBSITE" -H "X-Csrf-Token: $CSRF_WEBSITE" -d 'language=de')
|
||||
|
||||
#generate login data string
|
||||
LOGIN_DATA="csrf=$CSRF_LOGIN&selector=login&email=$UD_USERNAME&pwd=$UD_PASSWORD&submit=Login"
|
||||
|
||||
#send login
|
||||
WEBSITE_LOGIN=$($CURL 'https://www.united-domains.de/login' -d "$LOGIN_DATA")
|
||||
|
||||
#check if successful by requesting domain list
|
||||
DOMAIN_LIST=$($CURL 'https://www.united-domains.de/pfapi/dns/domain-list')
|
||||
if [ "$DOMAIN_LIST" = "" ] ; then
|
||||
echo "Login not successful"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $DOMAIN_LIST
|
||||
|
||||
Reference in New Issue
Block a user