-
-
Save mueslo/9258f8b75fe942d36eea4a6d67019f81 to your computer and use it in GitHub Desktop.
#!/bin/sh | |
# requires: wget, ca-certificates, grep | |
#rm /tmp/cookies.txt | |
cookiefile="/tmp/cookies.txt" | |
#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") | |
#csrf tokens for login + language xmlhttprequest required to login (nice try blocking my API access, UD) | |
loginpage=$(/usr/bin/wget --save-cookies $cookiefile --keep-session-cookies --delete-after -qO- "https://www.united-domains.de/login/") | |
csrf=$(echo "$loginpage" | /bin/grep -oP -m 2 "(?<=<input type=\"hidden\" name=\"csrf\" value=\")[^\"]*(?=\"( /)?>)" | tail -1) | |
csrfmeta=$(echo "$loginpage" | /bin/grep -oP -m 1 "(?<=<meta name=\"csrf\" content=\")[^\"]*(?=\"( /)?>)") | |
csrfscript=$(echo "$loginpage" | /bin/grep -oP -m 1 "(?<=\"CSRF_TOKEN\":\")[^\"]*(?=\")") | |
/usr/bin/wget --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" | |
ipv4=$1 | |
#login | |
echo 'login' | |
loginresp=$(/usr/bin/wget --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/") | |
#get current dns record json object & modify ip | |
record=$(/usr/bin/wget --load-cookies $cookiefile --save-cookies $cookiefile --keep-session-cookies -qO- "https://www.united-domains.de/pfapi/dns/domain/$domain_id/records" | jsonfilter -e "$[\"data\"][\"A\"][@.id=$record_id]" | sed "s/ //g" | sed "s/\"address\":\"[0-9.]\+\"/\"address\":\"$ipv4\"/g") | |
payload="{\"record\":$record,\"domain_lock_state\":{\"domain_locked\":false,\"email_locked\":false}}" | |
url="https://www.united-domains.de/pfapi/dns/domain/$domain_id/records" | |
#send changes | |
output=$(/usr/bin/wget --load-cookies $cookiefile --method=PUT --header=Content-Type:application/json --header="Http-X-Csrf-Token: $csrf" --body-data=$payload -qO- $url 2>&1) | |
echo "UD answered: $output" | |
write_log 7 "UD answered:\n$output" | |
echo $output | /usr/grep "$ipv4" >/dev/null 2>&1 | |
success=$? | |
#write_log 7 "Retval: $success" | |
echo "Retval: $success" | |
return $success |
This seems to be broken.
I tried to fix it but i get a 404 response...
this is my payload (Ip already xhanged):
{"data":{"A":[{"address":"157.91.144.248","content":"157.91.144.248","id":102270702,"filter_value":"some.one","ttl":600,"type":"A","standard_value":false,"sub_domain":"","domain":"some.one","webspace":false,"ssl":false,"udag_record_type":5},{"address":"157.91.144.248","content":"157.91.144.248","id":102270705,"filter_value":"some,one","ttl":600,"type":"A","standard_value":false,"sub_domain":"*","domain":"some.one","webspace":false,"ssl":false,"udag_record_type":5},{"address":"95.222.29.243","content":"116.203.91.142","id":106534996,"filter_value":"cloud.some.one","ttl":600,"type":"A","standard_value":false,"sub_domain":"cloud","domain":"some.one","webspace":false,"ssl":false,"udag_record_type":5}],"MX":[{"prio":10,"mail_server":"mx00.udag.de","content":"mx00.udag.de","id":101973276,"filter_value":"some.one","ttl":3600,"type":"MX","standard_value":true,"sub_domain":"","domain":"some.one","webspace":false,"ssl":false,"udag_record_type":4},{"prio":20,"mail_server":"mx01.udag.de","content":"mx01.udag.de","id":101973279,"filter_value":"some.one","ttl":3600,"type":"MX","standard_value":true,"sub_domain":"","domain":"some.one","webspace":false,"ssl":false,"udag_record_type":4}],"AAAA":[],"TXT":[],"SRV":[],"CNAME":[],"NS":[],"CAA":[]}}
I tried also with the original Payload but its the same.
upload to united...
Useing this command:
/usr/bin/wget --load-cookies $cookiefile --method=PUT --header=Content-Type:application/json --header="Http-X-Csrf-Token: $csrfscript" --body-data=$payload -qO- $url
--2022-07-30 16:09:10-- https://www.united-domains.de/pfapi/dns/domain/7130160/records
Resolving www.united-domains.de (www.united-domains.de)... 89.31.137.221
Connecting to www.united-domains.de (www.united-domains.de)|89.31.137.221|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-07-30 16:09:10 ERROR 404: Not Found.
Response code is 8
Any tipps ?
Thanks!
I migrated to another DNS Provider which has an API. Not worth the struggle.
In my optinion united-domains DNS is inferior. Last time I checked you couldn't even set CAA etc.
You can keep your Domain at UD, you can simply set NS to point to another Provider.
You can even keep the Mail functionality by setting MX to UDs Servers at the net Provider.
I used dynv6 (perfect for ipv6 dyndns) for a long time but it is very unreliable.
I am now using cloudflare and he.net
Hi @ManuGithubSteam,
it's not really clear to me why you're getting a 404. Script is still working for me. Were you able to resolve it?
Hi,
did they change the login again? cannot login with this script.
EDIT: using the curl command from here: https://gist.github.com/bjuretko/abee8435c8d6f6de39a61322ad44699a does work, but cannot update the ip
still worked for me this morning
Hi @izphi78,
where did you go?
I'm severly thinking about moving my domain to another hoster, that offers an API.
I'm fed up with with that scripting stuff. The shell script here worked for a while, but United Domains seem to permanently change their website. For a while I worked around this with a python script, but even this fails more and more often, because of permanent changes in the html/css code of UD.
This is extremely annoying!
Can you recommend me a good hoster, that has an API?
@rapkin61 FWIW, inwx was recommended to me by a friend, specifically for API access
@rapkin61 I went to cloudflare. No need to transfer your Domain. Just add it to the Dashboard and set the NS records. If you want to keep mail functionality, set it accordingly in the UD settings and set the MX records as shown in the instructions.
Never had any trouble with it after going that route. And much stuff has integration for Cloudflare like certbot.
had some issues getting it to work with openwrt 21.02.1. One issue is related to a different path of grep (simple fix). The other is caused by http422 errors that were thrown and could be resolved by using a different
Http-X-Csrf-Token
header. Also I couldn't pass:
for the domain via luci, so I changed the separator to-
.Below you find my patch