# -*- coding:utf-8 -*-
import requests
import json
'''
Author: Mat
Created: 2021/8/04
Version:1.0
此脚本用于火器资产收集(仅能获取小于1万条数据的域名)
只有加入过的项目才能获取数据,header参数的cookie和x-token为个人账号认证请自行修改
'''
url = "https://www.huoxian.cn/fireapi/user/search/subdomain?sort=update_time_desc"
header = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9",
"content-type": "application/json;charset=UTF-8",
"cookie": "",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"x-token": "", }
#获取小于1w条函数,将结果写huoxian_small.txt文件
def small(subdomains):
f = open('huoxian_small.txt','w',encoding = 'UTF-8')
data = '{"query":[{"column":"domain","op":"eq","content":"%s","logic":"and"}],"size":10000,"pageIndex":1}'% subdomains
resp = requests.post(url=url, data = data , headers=header)
data_json = resp.json()
items = data_json.get("data",{}).get("items",[])
for item in items:
info = (item.get("source",{}).get("subdomain"))
print("获取的域名:",info)
f.writelines(info+'
')
f.close()
if __name__ == '__main__':
subdomains = input("请输入根域名:")
small(subdomains)
接下来继续完善大于1万条数据以及其他功能