网安引领时代,弥天点亮未来
import requests
from bs4 import BeautifulSoup
import tldextract
import time
# 读取包含域名的文本文件
with open('domains.txt', 'r', encoding='utf-8') as file:
domains = [domain.strip() for domain in file]
# 提取主域名(使用tldextract库)
def get_main_domain(domain):
extracted = tldextract.extract(domain)
return f"{extracted.domain}.{extracted.suffix}"
# 更新域名列表为主域名并去重
domains = list({get_main_domain(domain) for domain in domains})
# 定义域名黑名单
domain_blacklist = {'myds.me', 'qq.com', 'eu.org', 'baidu.com', '163.com', 'aliyuncs.com', '51mypc.cn', 'oray.net', '55555.io', '51vip.biz', 'jicp.fun', 'oraycloud.cn', '51vip.biz', 'zicp.io', '花生壳.中国', 'oray.cc', '53http.tech', 'hfsdata.net', 'vicp.net', 'oray.org.cn', 'hfslink.net', 'vicp.hk', 'cdhttp.cn', 'yicp.io', 'sunlogin.in', 'pgyos.net', '11111.io', '51nas.vip', 'yicp.vip', 'iego.vip', 'qicp.net', 'iok.la', 'peanutbox.com', 'picp.io', 'oraybox.net', '5155.co', 'ticp.io', 'ticp.vip', 'payor.com.cn', 'hicp.fun', 'xicp.net', 'uicp.hk', 'pgycaas.com', 'hicp.net', 'imblog.in', 'hfsrun.cn', 'oray.us', 'xrk.host', 'sdwans.net', '5166.info', 'zhexi.tech', 'xrkyun.com', 'oicp.vip', 'voeos.com', 'oray.hk', 'imshop.in', 'hskrc.com', 'orayfocus.com', 'exmetis.com', '320.io', 'oray.net', 'imwork.net', 'hfsready.net', 'hfsdata.cn', '向日葵.我爱你', 'tudu.net', 'iego.net', 'vicp.la', 'wicp.top', '6655.la', '8005566.com.cn', 'xuduan.tech', 'xrkcloud.com', 'oraydns.cn', 'sunlogin.com', '花生壳.com', 'bjhttp.cn', 'openoray.cn', '800.si', 'wicp.net', 'hsk.top', 'vothea.com', 'tudu.co', 'xicp.vip', 'picp.net', 'oicp.net', '图度.cn', '51mypc.net', 'pgybox.com', '1366.co', 'pgyapi.com', 'hskbox.com', 'careit.cn', 'oraydev.cn', 'imzone.in', 'hfslink.cn', 'sunlogin.cn', 'oraydns.net', '51tcp.vip', '51http.tech', 'orgaea.com', 'openoray.com', 'vicp.tech', 'openorayos.com', 'nat-ddns.com', 'zicp.net', 'payor.cn', 'ticp.net', 'oraydev.com', 'hsk.la', 'nicp.fun', '1866.co', 'tudu.cn', 'hskyun.net', 'olivemail.net', 'micp.fun', 'eicp.net', 'tudu.com', 'pgybox.net', 'orayos.cn', 'iask.in', '远程协助.中国', 'olivemail.net.cn', 'vicp.cc', 'yicp.net', 'xrk.top', 'focuska.com', 'sdwans.cn', 'orleto.com', 'eicp.top', 'pgyos.com', 'zicp.vip', '远程控制.中国', 'xuduan.vip', '网站监控.中国', 'oray.cn', '5122.co', 'oray.me', 'cqhttp.cn', 'vdns.tech', 'olivemail.com.cn', 'sunlogin.com.cn', 'hfslink.com', 'zicp.fun', 'wicp.io', 'uicp.io', 'orayimg.com', 'qicp.vip', 'openoray.com.cn', 'xicp.io', 'ficp.fun', 'ehom.cn', 'vicp.io', 'wicp.vip', 'payer.com.cn', '图度.中国', 'oray.name', 'exhera.com', 'iego.org', 'svhttp.com', '51mypc.cn', 'sunlogin.net', 'iicp.net', 'imspace.in', 'yicp.top', 'qicp.io', 'dnsoray.cn', 'uicp.top', 'orayerbeta.com', 'cicp.net', 'vicp.fun', 'orayer.net', 'vicp.me', 'oraydev.net', 'iicp.fun', 'kicp.fun', 'hskyun.cn', 'picp.vip', '52http.com', 'yctou.com', 'payor.net', 'edns.tech', 'shhttp.cn', 'goho.co', 'imtodo.cn', 'gtodo.cn', 'pgyos.cn', 'yctou.net', 'hfsready.cn', 'uicp.cn', 'imdo.co', 'hskcloud.com', 'ioray.com', 'gzhttp.cn', 'gicp.fun', 'oraybox.cn', 'imbbs.in', 'sunlogin.hk', 'yicp.fun', 'hskyun.com', 'oray.top', '51same.vip', '在线办公.中国', 'oray.com', 'orayer.cn', '3322.la', 'eicp.fun', 'oicp.io', 'xrkyun.cn', 'hfsrun.com', 'gdns.tech', 'provisas.com', '55http.tech', '54http.tech', 'orayer.com', '8005566.net', '8005566.com', 'gicp.net', 'hfsready.com', 'eicp.vip', 'vicp.co', '55555.io', 'orhebe.com', '51nas.pro', 'hfsrun.net', 'uicp.fun', 'xrkyun.net', 'xicp.fun', 'sunlogin.cc', 'faseng.com', 'sunlogin.us', 'oray.com.cn', 'uicp.vip', 'olivemail.cn', '橄榄邮.中国', 'oraycloud.net', 'oray.tw', 'iego.cn', '51nat.tech', 'sunlogin.tw', 'exdoris.com', 'oray.in', '566.sh', 'dnsoray.net', 'oraybox.com', '洋葱头.中国', 'oraybeta.com', 'oray.org', '8910.io', 'yctou.cn', 'iego.com.cn', 'orayos.net', 'uicp.net', 'oray.net.cn', '花生壳.我爱你', 'openorayos.net', 'ffhttp.com', 'vicp.asia', 'xicp.cn', 'dnsoray.com', 'wocp.fun', 'licp.fun', '52http.tech', 'openoray.net'}
# 目标URL模板和请求头
url_template = "https://www.aizhan.com/cha/{}"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36',
'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',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Cookie': 'PHPSESSID=3man5ck60uiev9bhpcu6pm9mq3; _csrf=b62c2f8cfdef843e2603d2c5650ddefcad3877fe26cc81ce656db27b17514efea%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22miHbURvN5cG0IRixx9rEhpAMDVPyCwwH%22%3B%7D; allSites=51mypc.cn%7Csdsf.com.cn%7Cjointas.com%7Cskf.com%7Csoftwareasaservice.cn%7Cpicp.net%7Chskyun.com%7Cvoyager-tech.com%7Cgoho.co%7Cxicp.cn',
'Host': 'www.aizhan.com',
'Referer': 'https://www.aizhan.com/',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'sec-ch-ua': '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"'
}
# ID到权重名称的映射
id_to_weight = {
'baidurank_br': '百度权重',
'baidurank_mbr': '移动权重',
'360_pr': '360权重',
'sm_pr': '神马',
'sogou_pr': '搜狗',
'google_pr': '谷歌PR',
}
def fetch_weights(domain, retries=3, timeout=10):
url = url_template.format(domain)
weights = {weight_name: 0 for weight_name in id_to_weight.values()} # 初始化权重字典
for attempt in range(retries):
try:
response = requests.get(url, headers=headers, timeout=timeout)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
for a_tag in soup.find_all('a', id=True):
weight_id = a_tag['id']
if weight_id in id_to_weight:
img_tag = a_tag.find('img', alt=True)
weight_value = int(img_tag['alt']) if img_tag and img_tag['alt'].isdigit() else 0
weights[id_to_weight[weight_id]] = weight_value
return weights
except requests.exceptions.Timeout:
print(f"Timeout error for {domain}, retrying ({attempt + 1}/{retries})...")
time.sleep(1)
except requests.exceptions.RequestException as e:
print(f"Request error for {domain}: {e}")
break
return weights # 返回初始化的权重字典
# 其他代码保持不变
def should_output(weights):
return any(weights[weight] >= threshold for weight, threshold in {
'百度权重': 1, '移动权重': 1, '谷歌PR': 3
}.items())
# 写入结果到文件
with open('output_results.txt', 'w', encoding='utf-8') as output_file:
for domain in domains:
if domain in domain_blacklist:
print(f"跳过黑名单中的域名: {domain}")
continue
weights = fetch_weights(domain)
if should_output(weights):
output_file.write(f"{domain}n")
print(f"{domain}:{weights}")
else:
print(f"不满足:{domain}:{weights}")
使用脚本对数据进行筛选,符合权重的写出到txt,增加了黑名单功能,像花生壳这些动态域名,都是不收的,然后直接跳过
知识分享完了
喜欢别忘了关注我们哦~
弥 天
安全实验室
推荐站内搜索:最好用的开发软件、免费开源系统、渗透测试工具云盘下载、最新渗透测试资料、最新黑客工具下载……
还没有评论,来说两句吧...