0%

he dns 自动创建 ddns 记录并修改 key

思路

  • 主要通过两个接口实现, add_domain 和 update_ddns 实现.
  • cookies 可以从实际接口里面抓取
  • 为了方便设置, ddns key 和 domain 的值保持一致

脚本

1
2
3
> cat /tmp/1.txt
a.baidu.com
b.baidu.com
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
export my_cookie='xxx'
add_domain() {
domain_param=$1
curl 'https://dns.he.net/?hosted_dns_zoneid=1185512&menu=edit_zone&hosted_dns_editzone' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'Accept-Language: zh-CN,zh;q=0.9' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H "Cookie: $my_cookie" \
-H 'DNT: 1' \
-H 'Origin: https://dns.he.net' \
-H 'Pragma: no-cache' \
-H 'Referer: https://dns.he.net/?hosted_dns_zoneid=1185512&menu=edit_zone&hosted_dns_editzone' \
-H 'Sec-Fetch-Dest: document' \
-H 'Sec-Fetch-Mode: navigate' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Sec-Fetch-User: ?1' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw "account=&menu=edit_zone&Type=A&hosted_dns_zoneid=1185512&hosted_dns_recordid=&hosted_dns_editzone=1&Priority=&Name=$domain_param&Content=114.3.1.184&TTL=300&dynamic=1&hosted_dns_editrecord=Submit"
}

update_ddns() {
domain_param=$1
curl 'https://dns.he.net/?hosted_dns_zoneid=1185512&menu=edit_zone&hosted_dns_editzone' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'Accept-Language: zh-CN,zh;q=0.9' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H "Cookie: $my_cookie" \
-H 'DNT: 1' \
-H 'Origin: https://dns.he.net' \
-H 'Pragma: no-cache' \
-H 'Referer: https://dns.he.net/?hosted_dns_zoneid=1185512&menu=edit_zone&hosted_dns_editzone' \
-H 'Sec-Fetch-Dest: document' \
-H 'Sec-Fetch-Mode: navigate' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Sec-Fetch-User: ?1' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw "account=&menu=edit_zone&hosted_dns_zoneid=1185512&hosted_dns_recordid=&hosted_dns_editzone=1&Name=$domain_param&Key=$domain_param&Key2=$domain_param&generate_key=Submit"
}

for domain in `cat /tmp/1.txt`; do
echo "handle $domain"
add_domain $domain >/dev/null
update_ddns $domain >/dev/null
sleep 1
done
-------------本文结束再接再厉-------------

本文标题:he dns 自动创建 ddns 记录并修改 key

文章作者:IITII

发布时间:2024年12月31日 - 14:12

最后更新:2025年03月10日 - 14:03

原始链接:https://iitii.github.io/2024/12/31/1/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。