源代碼直鏈 https://pastebin.com/raw/LjsnW5Jv,直接curl下來即可,用python寫的,依賴外部命令whois,linux系統用apt之類的裝就行
可以自己修改配置任意後綴,長度,字符表,具體用法已經寫代碼註釋裡了
- #!/usr/bin/env python3
- # VERSION: 23.11.23
- # LICENSE: CC0
- # AUTHOR: Cagamine Lin
- #
- # Usage:
- # 脚本依赖于系统的whois命令,跑之前请确保已安装
- # 然后自己查询一次对应后缀未注册和已注册域名的输出
- # 找到关键词填入sample和sample_fail参数
- # sample 通常是类似'not found','not match'的文本
- # sample_fail,通常是类似'create time','expiry time'的文本
- # - 可以留空,这样会在没搜索到sample时当已注册处理,
- # - 不留空,则会既没搜索到sample,又没sample_fail时标记为 [?] , 以便您另外查
- # 关键词不要写太短,防止匹配的后面的注释导致误差, 有标点最好也带上
- # 最后把后缀,长度,字符表分别填入参数suffix, length, chars
- WORD = 'abcdefghijklmnopqrstuvwxyz'
- DIG = '0123456789'
- # Begin of params
- sample = 'was not found.'
- sample_fail = ''
- suffix = 'im'
- length = 3
- # chars = DIG+WORD
- # chars = DIG
- chars = WORD
- # End of params
- import subprocess
- from time import sleep
- from datetime import datetime
- from itertools import product
- def check(target, sample, sample_fail='', retry_rule=[5, 5, 20]):
- retry = 0
- while True:
- try:
- output = subprocess.check_output(
- ['whois', target], shell=False, text=True)
- if sample in output:
- return 'ok'
- if sample_fail in output:
- return 'fail'
- raise Exception('unknown ')
- except Exception as e:
- print(e)
- retry += 1
- sleep(retry_rule[retry])
- if retry > len(retry_rule):
- return 'unknown'
- def run(chars, length, suffix, sample, sample_fail='', retry_rule=[5, 5, 20], save=True):
- filename = save == True and datetime.now().strftime(
- f"{suffix}-{length}_%y-%m-%d_%H%M%S.txt")
- file = save and open(filename, "w")
- log = save and (lambda s: (file.write(s+'\n'),
- file.flush())) or (lambda s: s)
- print('# Targets:')
- print('[%s]{%d}.%s\n' % (chars, length, suffix))
- print('# Report:', save and f'(save to {filename})' or '')
- it = product(chars, repeat=length)
- for i in it:
- name = ''.join(i) + '.' + suffix
- print(f' {name} checking...\r', end='')
- res = check(name, sample, sample_fail, retry_rule)
- if res == 'ok':
- print(f' {name} ')
- log(name)
- elif res == 'unknown':
- print(f' {name} [?] ')
- log(name+' [?]')
- save and file.close()
- run(chars, length, suffix, sample, sample_fail)
複製代碼
|