1984DNS : init

This commit is contained in:
unknown 2022-01-31 00:36:18 +07:00
parent a75d59838b
commit 60be103f68
Signed by: minoplhy
GPG Key ID: 90667A59A9908AEC
6 changed files with 143 additions and 0 deletions

2
1984DNS/.env Normal file
View File

@ -0,0 +1,2 @@
AUTH_USERNAME=<set>
AUTH_PASSWORD=<set>

10
1984DNS/README Normal file
View File

@ -0,0 +1,10 @@
This was my attempted to make automatic Certbot renewal script of 1984.is FreeDNS .
But acme.sh officially support 1984.is FreeDNS : https://github.com/acmesh-official/acme.sh/wiki/dnsapi#104-use-1984hosting-domain-api
and i found that after my script was finished .
so, this script is a Certbot renewal script that's not maintained anymore, unless i returned to certbot .
certbot certonly --manual --manual-auth-hook before.sh --manual-cleanup-hook after.sh -d secure.example.com
Command Above should still working , i guess...

53
1984DNS/after.py Normal file
View File

@ -0,0 +1,53 @@
import sys
import logging
import re
from bs4 import BeautifulSoup
from dotenv import load_dotenv
from requests import Session
import os
LOGGER = logging.getLogger(__name__)
domain_id = None
session = None
session = Session()
session.get("https://umsjon.1984.is/accounts/login/?next=/")
load_dotenv()
auth_username = os.getenv('AUTH_USERNAME')
auth_password = os.getenv('AUTH_PASSWORD')
rtype="TXT"
# Hit the login page with authentication info to login the session
login_response = session.post(
"https://umsjon.1984.is/accounts/checkuserauth/",
data={
"username": auth_username or "",
"password": auth_password or "",
},
)
cookie = session.cookies
for token in cookie:
if token.name == "csrftoken":
csrftoken = token.value
elif token.name == "sessionid":
sessionid = token.value
payload = {
"Host": "umsjon.1984.is",
"Referer": "https://umsjon.1984.is",
"X-CSRFToken": csrftoken,
"Cookie": "csrftoken="+csrftoken+"; sessionid="+sessionid
}
file1 = open('entry.txt', 'r')
file = file1.read().split('\n')
for zone_id in file:
delete_response = session.post(
"https://umsjon.1984.is/domains/delentry/",
data={
"entry": zone_id,
}, headers=payload,
)
print(delete_response.text)

2
1984DNS/after.sh Normal file
View File

@ -0,0 +1,2 @@
python3 after.py
rm entry.txt

72
1984DNS/before.py Normal file
View File

@ -0,0 +1,72 @@
import sys
import logging
import json
import re
from dotenv import load_dotenv
from requests import Session
import requests
import os
from bs4 import BeautifulSoup
LOGGER = logging.getLogger(__name__)
CERTBOT_DOMAIN = '1w1.one'
CERTBOT_ZONE = '1w1.one'
CERTBOT_VALIDATION = '12345'
CERTBOT_DOMAIN = sys.argv[1]
CERTBOT_ZONE = sys.argv[2]
CERTBOT_VALIDATION = sys.argv[3]
domain = CERTBOT_ZONE
load_dotenv()
auth_username = os.getenv('AUTH_USERNAME')
auth_password = os.getenv('AUTH_PASSWORD')
domain_id = None
session = None
session = Session()
session.get("https://umsjon.1984.is/accounts/login/?next=/")
# Hit the login page with authentication info to login the session
login_response = session.post(
"https://umsjon.1984.is/accounts/checkuserauth/",
data={
"username": auth_username or "",
"password": auth_password or "",
},
)
cookie = session.cookies
for token in cookie:
if token.name == "csrftoken":
csrftoken = token.value
elif token.name == "sessionid":
sessionid = token.value
CERTBOT_HOST="_acme-challenge."+CERTBOT_DOMAIN
name=CERTBOT_HOST
rtype="txt"
# Pull a list of records and check for ours
payload = {
"Host": "umsjon.1984.is",
"Referer": "https://umsjon.1984.is",
"X-CSRFToken": csrftoken,
"Cookie": "csrftoken="+csrftoken+"; sessionid="+sessionid
}
data = {
"entry": "new",
"zone": CERTBOT_ZONE,
"type": "txt",
"host": CERTBOT_HOST,
"ttl": 900,
"priority": "",
"rdata": CERTBOT_VALIDATION,
}
risk = session.post("https://umsjon.1984.is/domains/entry/", data=data, headers=payload)
s = re.findall('"id": "..*\d"', risk.text)
s = str(s)
s = re.sub('(\[|\"|\'|:|]| |id)', "", s)
file1 = open('entry.txt', 'w')
file1.write(str(s))
exit()

4
1984DNS/before.sh Normal file
View File

@ -0,0 +1,4 @@
CERTBOT_ZONE=1w1.one
python3 before.py "$CERTBOT_DOMAIN" "$CERTBOT_ZONE" "$CERTBOT_VALIDATION"
echo "Please wait for 15 minutes, before certbot continues . This is for updating reasons"
sleep 900