From a338591b1700bfd8c9e8f8f16ccbbb36299378d7 Mon Sep 17 00:00:00 2001 From: ahdoawhfo Date: Tue, 20 Aug 2024 09:37:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8D=95=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/daily_domain_check.yml | 6 +- DICT | 26 ---- DOMAIN | 10 -- DOMAINS | 151 +++--------------------- domain.txt | 2 - domain_check.py | 4 +- single_domain_check.py | 141 ---------------------- 7 files changed, 18 insertions(+), 322 deletions(-) delete mode 100644 DICT delete mode 100644 DOMAIN delete mode 100644 domain.txt delete mode 100644 single_domain_check.py diff --git a/.gitea/workflows/daily_domain_check.yml b/.gitea/workflows/daily_domain_check.yml index d2d327e..d404072 100644 --- a/.gitea/workflows/daily_domain_check.yml +++ b/.gitea/workflows/daily_domain_check.yml @@ -20,21 +20,17 @@ jobs: with: python-version: '3.12.5' - - name: Run single domain check - run: python single_domain_check.py - - name: Run domain check run: python domain_check.py - name: Save output with date run: | today=$(date +%Y-%m-%d) - mv domain.txt "domain_$today.txt" mv domains.txt "domains_$today.txt" - name: Create release and upload result run: | today=$(date +%Y-%m-%d) - gitea release create --title "Single Domain Check $today" --assets "domain_$today.txt" --assets "domains_$today.txt" + gitea release create --title "Domain Check $today" --assets "domains_$today.txt" env: TOKEN: ${{ secrets.TOKEN }} diff --git a/DICT b/DICT deleted file mode 100644 index 0edb856..0000000 --- a/DICT +++ /dev/null @@ -1,26 +0,0 @@ -a -b -c -d -e -f -g -h -i -j -k -l -m -n -o -p -q -r -s -t -u -v -w -x -y -z diff --git a/DOMAIN b/DOMAIN deleted file mode 100644 index e19ff2a..0000000 --- a/DOMAIN +++ /dev/null @@ -1,10 +0,0 @@ -am -at -cx -cz -de -gs -lc -lu -mk -nu \ No newline at end of file diff --git a/DOMAINS b/DOMAINS index 16d7d92..bb40c8a 100644 --- a/DOMAINS +++ b/DOMAINS @@ -1,155 +1,34 @@ -ae -ag am -at -be -ai -ar -aw -ax -bg -bi -bj -bn -br -bw -bz -ca -cc -cd -cf -ci -cl cm -cn -co -cr +im +bi +ci +ge +lv +at +by +cl cx cz de -dk -dm -do -dz -ec -ee -eu fi -fj -fm -fo -fr -ge -gg -gi -gl +gd gs -gy -hk -hm -hn -hr -ht -hu -id -ie -il -in -io -iq -ir -is -it -je -jp -ke -kg -ki -kn -kr -ky -kz -la lc -li lt lu -lv -ly -ma -md -me -mg mk -ml -mm -mn -mo -ms -mu -mx -my -mz -na -nc -nf -ng -nl -no nu nz -om -pe -pf -pl -pm -pr -ps -pt -qa -re +pw ro rs ru -rw -sa -sb -sc -se -sg -sh si -sk -sl -sm -sn -so su -sx -sy -tc -tf -tg -th -tk -tl -tm -tn -to -tr -tv -tw -tz -ua -ug -uk -us -uy -uz -vc -ve -vu -wf +vg ws -yt -zm \ No newline at end of file +gy +st +qa +moe \ No newline at end of file diff --git a/domain.txt b/domain.txt deleted file mode 100644 index 637f248..0000000 --- a/domain.txt +++ /dev/null @@ -1,2 +0,0 @@ -AVAILABLE DOMAIN NAME LIST: ---------------------------------- diff --git a/domain_check.py b/domain_check.py index dc36a50..abb3566 100644 --- a/domain_check.py +++ b/domain_check.py @@ -77,7 +77,7 @@ def main(): # Automatically read domain extensions (TLDs) from the DOMAINS file try: - with open("DOMAINS", "r") as fp: + with open("CHEAP", "r") as fp: exts = [line.strip() for line in fp.readlines() if line.strip()] except FileNotFoundError: print("DOMAINS FILE NOT FOUND!") @@ -126,7 +126,7 @@ def main(): ) # Use a thread pool to check multiple domains concurrently - with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: + with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: futures = [ executor.submit(domain_megabot, domain, pattern, server) for domain, pattern, server in domains diff --git a/single_domain_check.py b/single_domain_check.py deleted file mode 100644 index 244423a..0000000 --- a/single_domain_check.py +++ /dev/null @@ -1,141 +0,0 @@ -import os -import socket -import sys -import concurrent.futures -import time -import random - - -def domain_megabot(domain, no_match_pattern, whois_server): - retry_count = 0 - while True: - response = whois_query(whois_server, domain) - if response: - if no_match_pattern in response: - print(f"{domain} AVAILABLE FOR REGISTRATION!") - with open("domain.txt", "a") as f: - f.write(f"{domain}\n") - else: - print(f"{domain} NOT AVAILABLE.") - # Add random delay to avoid triggering rate limits - time.sleep(random.uniform(1, 5)) - break - else: - retry_count += 1 - sleep_time = min(60, 2**retry_count + random.uniform(0, 1)) - print(f"Retrying query for {domain} in {sleep_time:.2f} seconds...") - time.sleep(sleep_time) - - -def whois_query(server, query): - ip = hostname_to_ip(server) - if not ip: - print("FAILED TO RESOLVE HOSTNAME") - return "" - - try: - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.settimeout(10) - s.connect((ip, 43)) - s.sendall(f"{query}\r\n".encode()) - response = b"" - while True: - data = s.recv(4096) - if not data: - break - response += data - return response.decode() - except socket.error as err: - print(f"Error during WHOIS query: {err}") - return None - - -def hostname_to_ip(hostname): - try: - return socket.gethostbyname(hostname) - except socket.error as err: - print(f"Error resolving hostname: {err}") - return None - - -def str_split(s, delimiter): - return s.split(delimiter) - - -def str_conn(s1, s2): - return f"{s1}{s2}" - - -def main(): - # Automatically read TLDs from the TLD_DATA file in the current directory - try: - with open("TLD_DATA", "r") as fp: - tld_data = fp.readlines() - except FileNotFoundError: - print("TLD DATABASE NOT FOUND!") - sys.exit(1) - - # Automatically read domain extensions (TLDs) from the DOMAINS file - try: - with open("DOMAIN", "r") as fp: - exts = [line.strip() for line in fp.readlines() if line.strip()] - except FileNotFoundError: - print("DOMAINS FILE NOT FOUND!") - sys.exit(1) - - # Load TLD information - tld_info = {} - for line in tld_data: - arr = str_split(line.strip(), "=") - if arr[0] in exts: - tld_info[arr[0]] = { - "whois_server": arr[1], - "no_match_pattern": arr[2], - } - - if not tld_info: - print("NO VALID TLDs FOUND IN DOMAINS FILE!") - sys.exit(2) - - # Automatically read the dictionary from the DICT file - try: - with open("DICT", "r") as fp_dict: - dictionary = fp_dict.readlines() - except FileNotFoundError: - print("DICTIONARY FILE NOT FOUND!") - sys.exit(3) - - with open("domain.txt", "w") as fp_result: - fp_result.write( - "AVAILABLE DOMAIN NAME LIST:\n" "---------------------------------\n" - ) - - # Prepare domain names to check - domains = [] - for line in dictionary: - domain_prefix = line.strip() - if domain_prefix: - for ext in exts: - domain = str_conn(str_conn(domain_prefix, "."), ext) - domains.append( - ( - domain, - tld_info[ext]["no_match_pattern"], - tld_info[ext]["whois_server"], - ) - ) - - # Use a thread pool to check multiple domains concurrently - with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: - futures = [ - executor.submit(domain_megabot, domain, pattern, server) - for domain, pattern, server in domains - ] - for future in concurrent.futures.as_completed(futures): - future.result() # Handle any exceptions in threads - - print("TASK FINISHED! RESULTS SAVED TO domain.txt") - - -if __name__ == "__main__": - main()