├── README.assets ├── 1705506871779.jpg ├── 1705507033845.jpg └── 1705507078732.jpg ├── README.md ├── domain.txt ├── main.py ├── module ├── Pearrank.py ├── __init__.py ├── __pycache__ │ ├── Pearrank.cpython-310.pyc │ ├── Pearrank.cpython-38.pyc │ ├── __init__.cpython-310.pyc │ ├── __init__.cpython-37.pyc │ ├── __init__.cpython-38.pyc │ ├── argParse.cpython-310.pyc │ ├── argParse.cpython-37.pyc │ ├── argParse.cpython-38.pyc │ ├── baiduRank.cpython-37.pyc │ ├── baiduRank.cpython-38.pyc │ ├── banner.cpython-310.pyc │ ├── banner.cpython-37.pyc │ ├── banner.cpython-38.pyc │ ├── icpRecord.cpython-310.pyc │ ├── icpRecord.cpython-37.pyc │ ├── icpRecord.cpython-38.pyc │ ├── searchDomain.cpython-310.pyc │ ├── searchDomain.cpython-37.pyc │ └── searchDomain.cpython-38.pyc ├── aizhanrank.py ├── argParse.py ├── baiduRank.py ├── banner.py ├── icpRecord.py └── searchDomain.py ├── output └── domain_2024-01-17_23-55-58.csv └── requirements.txt /README.assets/1705506871779.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/README.assets/1705506871779.jpg -------------------------------------------------------------------------------- /README.assets/1705507033845.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/README.assets/1705507033845.jpg -------------------------------------------------------------------------------- /README.assets/1705507078732.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/README.assets/1705507078732.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 🕷ip2domain - 批量查询ip对应域名、备案信息、百度等引擎权重 2 | 3 | 本工具二开自https://github.com/sma11new/ip2domain 4 | 5 | 在批量挖SRC时,通常会用较新的漏洞POC批量跑fofa或其他空间测绘的相关资产ip,该工具可用于对跑到的ip批量查询域名及百度权重、备案信息,快速确定ip所属企业,方便提交漏洞。 6 | 7 | 本来不想重复造轮子的,但查了一圈发现大家都是自己用,接口藏着掖着 8 | 9 | 所以本项目会一直维护,欢迎大家提交更多接口,一起维护项目 10 | 11 | ### 😏更新日志: 12 | #### **2025-1-25 `(v1.4)` :** 13 | 14 | 修复接口,美化输出,增加谷歌权重 15 | 16 | #### **2024-3-29 `(v1.3)` :** 17 | 感谢LuckyRiver99的修复:[issue4](https://github.com/mhtsec/ip2domain/issues/4) 18 | 19 | #### **2024-1-19 `(v1.2)` :** 20 | 21 | 找接口作者修复了下接口,现在可以用了 22 | 23 | 多接口版本在做了,避免因为一个接口不稳定导致程序不能用 24 | 25 | 下个版本增加多接口,大家也整点接口哇 26 | 27 | #### **2024-1-19 `(v1.1)` :** 28 | 接口爆掉了,在考虑换回爱站接口或者写多接口版本,如果你有,欢迎提交issues 29 | 30 | 暂时修复了下因为接口不能获取百度权重而造成不能获取其他权重的bug 31 | 32 | 新增了360权重,将就还能用 33 | 34 | #### **2024-1-17 `(v1.0)`:** 35 | 36 | - 在原来的百度PC权重基础上加入百度移动权重、神马权重、搜狗权重,-r可指定显示的权重阈值 37 | - 优化ICP备案查询(默认关闭),--icp开启 38 | - 修复部分问题,替换已失效的接口,减少频率限制 39 | 40 | ### 🤓参数说明 41 | 42 | 关键参数是-s、-r、-T和--icp四个: 43 | 44 | - **-s 控制请求时延**,一般1稍快,但偶尔出现请求出错;**2速度适中**,基本不会出现问题;**3最为稳定**,程序挂在后台可稳定输出。 45 | - **-r 控制百度权重阈值**,0到10代表输出**大于等于**相应百度权重的结果,通常设定为1,可根据需求增减(-1会导致程序出现不可预料的错误)。 46 | - **--icp 控制是否查询ICP备案信息**,使用该参数即表示开启icp备案查询(默认关闭)。 47 | - **-T 控制请求延时**,默认12秒。 48 | 49 | 所有参数: 50 | 51 | ``` 52 | usage: main.py [-h] [-t TARGET] [-f FILE] [-s DELAY] [-T TIMEOUT] [-r RANK] [-o OUTPUT] [--icp] 53 | 54 | optional arguments: 55 | -h, --help show this help message and exit 56 | -t TARGET, --target TARGET 57 | Target ip/domain 58 | -f FILE, --file FILE 指定目标文件,一行一个,ip或者域名 59 | -s DELAY, --delay DELAY 60 | 请求延迟 (默认 2s) 61 | -T TIMEOUT, --Timeout TIMEOUT 62 | 超时时间 (默认 12s) 63 | -r RANK, --rank RANK 大于指定的百度权重值则输出,范围0-10 (默认 0) 64 | -o OUTPUT, --output OUTPUT 65 | 输出文件 (文件路径: ./output/ip2domain_{fileName}_{date}.csv) 66 | --icp 是否开启ICP备案查询 (默认不开启) 67 | ``` 68 | 69 | ### 🚩使用示例 70 | python ≥ 3.10 71 | 72 | 安装依赖: 73 | 74 | ``` 75 | pip install -r requirements.txt 76 | ``` 77 | 78 | 将要查询的ip/domain放在txt文件内一行一个,`python main.py -f [file]` 指定,并加入其他参数即可。 79 | 80 | **1、**百度权重阈值为1,请求时延为2,不开启ICP备案查询 81 | 82 | ``` 83 | python .\main.py -f E:\Desktop\target.txt -s 2 -r 1 84 | ``` 85 | 86 | ![1705506871779](README.assets/1705506871779.jpg) 87 | 88 | **2、**百度权重阈值为1,请求时延为2,开启ICP备案查询 89 | 90 | ``` 91 | python .\main.py -f E:\Desktop\target.txt -s 2 -r 1 --icp 92 | ``` 93 | 94 | ![1705507078732](README.assets/1705507078732.jpg) 95 | 96 | 结果保存在output目录下csv文件内 97 | 98 | ![1705507033845](README.assets/1705507033845.jpg) 99 | 100 | ### 🚩关注 101 | ![image](https://github.com/user-attachments/assets/7c34f13e-b904-4957-95ac-8cb2f9de5d31) 102 | 103 | -------------------------------------------------------------------------------- /domain.txt: -------------------------------------------------------------------------------- 1 | ahglgs.com 2 | 221.215.16.2 3 | wlkh888.com 4 | nokjuc.top 5 | aizhan.com 6 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | import os 7 | import re 8 | import csv 9 | import time 10 | import requests 11 | import tldextract 12 | from module.banner import banner 13 | from module.argParse import parseArgs 14 | from module.Pearrank import Pearrank 15 | from module.icpRecord import searchRecord 16 | from module.searchDomain import searchDomain 17 | 18 | from colorama import init 19 | 20 | init(autoreset=True) 21 | 22 | from wcwidth import wcswidth as ww 23 | 24 | 25 | def rpad(s, n, c=" "): 26 | # 新增:过滤ANSI颜色代码后再计算显示宽度 27 | clean_str = re.sub(r'\033\[[\d;]*m', '', s) 28 | return s + (n - ww(clean_str)) * c 29 | 30 | 31 | requests.packages.urllib3.disable_warnings() # 抑制https错误信息 32 | 33 | 34 | def init(parseClass): 35 | args = parseClass.parse_args() 36 | if not args.file and not args.target: 37 | print(parseClass.print_usage()) 38 | exit(0) 39 | 40 | if args.file: 41 | if not os.path.isfile(args.file): 42 | print( 43 | f"\n[\033[36m{time.strftime('%H:%M:%S', time.localtime())}\033[0m] - \033[31m[ERRO] - Load file [{args.file}] Failed\033[0m") 44 | exit(0) 45 | 46 | targetList = loadTarget(args.file, args.target) # 所有目标 47 | 48 | print( 49 | f"[\033[36m{time.strftime('%H:%M:%S', time.localtime())}\033[0m] - \033[36m[INFO] - Timeout: {args.timeout}s\033[0m") 50 | print( 51 | f"[\033[36m{time.strftime('%H:%M:%S', time.localtime())}\033[0m] - \033[36m[INFO] - Delay: {args.delay}s\033[0m") 52 | print( 53 | f"[\033[36m{time.strftime('%H:%M:%S', time.localtime())}\033[0m] - \033[36m[INFO] - Rank Size: >{args.rank}\033[0m") 54 | print( 55 | f"[\033[36m{time.strftime('%H:%M:%S', time.localtime())}\033[0m] - \033[36m[INFO] - ICP: {args.icp}\033[0m") 56 | print( 57 | f"[\033[36m{time.strftime('%H:%M:%S', time.localtime())}\033[0m] - \033[36m[INFO] - ipCount: {len(targetList)}\033[0m\n") 58 | 59 | return targetList 60 | 61 | 62 | # 加载目标 63 | def loadTarget(file, target): 64 | targetList = [] 65 | 66 | # 解析输入目标数据 67 | def parseData(data): 68 | val = tldextract.extract(data) 69 | if not val.suffix: 70 | # 校验解析的数据 71 | if re.match(r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", 72 | val.domain): 73 | return f"{val.domain}" 74 | else: 75 | return "" 76 | else: 77 | return f"{val.domain}.{val.suffix}" 78 | 79 | if file: 80 | f = open(file, encoding="utf8") 81 | for line in f.readlines(): 82 | target_ = parseData(line.strip()) 83 | if target_: 84 | targetList.append(target_) 85 | f.close() 86 | 87 | if target: 88 | target_ = parseData(target.strip()) 89 | if target_: 90 | targetList.append(target_) 91 | 92 | return list(set(targetList)) 93 | 94 | 95 | def outputResult(argsFile, argsOutput, resultList, icp): 96 | fileName = list(os.path.splitext(os.path.basename(argsFile)))[0] 97 | outputFile = f"./output/{fileName}_{argsOutput}.csv" 98 | if not os.path.isdir(r"./output"): 99 | os.mkdir(r"./output") 100 | with open(outputFile, "a", encoding="gbk", newline="") as f: 101 | csvWrite = csv.writer(f) 102 | if icp: 103 | csvWrite.writerow(["ip", "反查域名", "百度PC权重", "百度移动权重", "360权重", "神马权重", "搜狗权重", "Google权重", "单位名称", "备案编号"]) 104 | else: 105 | csvWrite.writerow(["ip", "反查域名", "百度PC权重", "百度移动权重", "360权重", "神马权重", "搜狗权重", "Google权重"]) 106 | 107 | for result in resultList: 108 | # 简化转换逻辑,直接写入字符串值 109 | try: 110 | # 确保结果有足够的列(包含新增的google排名) 111 | if len(result) < 8: # 原有7列 + 新增1列 112 | result += ["N/A"]*(8 - len(result)) 113 | csvWrite.writerow(result[:8] + (result[8:] if icp else [])) 114 | except Exception as e: 115 | print(f"写入错误: {e}") 116 | 117 | 118 | def ip2domian(target, args, targetNum, targetCount): 119 | resultList = [] 120 | if re.match(r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", target): 121 | time.sleep(args.delay) 122 | searchDomainResult = searchDomain(target, args.timeout) 123 | 124 | domainList = searchDomainResult["domainList"] 125 | else: 126 | domainList = [target] 127 | 128 | for domain in domainList: 129 | time.sleep(args.delay) 130 | 131 | # 修改后的Pearrank结果处理逻辑 132 | try: 133 | PearrankResult = Pearrank(domain=domain, timeout=args.timeout) if args.model in [1, 2] else {} 134 | 135 | if PearrankResult.get("code") == 1: 136 | # 统一处理所有排名字段,使用get方法避免KeyError 137 | ranks = [ 138 | PearrankResult.get("bdpc_rank", "N/A"), 139 | PearrankResult.get("bdmb_rank", "N/A"), 140 | PearrankResult.get("360rank", "N/A"), 141 | PearrankResult.get("sm_rank", "N/A"), 142 | PearrankResult.get("sg_rank", "N/A"), 143 | PearrankResult.get("google_rank", "N/A") # 新增的google排名 144 | ] 145 | # 转换数字类型的排名 146 | ranks = [str(r) if isinstance(r, int) else r for r in ranks] 147 | resultList.append([target, domain] + ranks) 148 | else: 149 | # 全部排名字段标记为错误 150 | resultList.append([target, domain] + ["Error"]*6) 151 | 152 | except Exception as e: 153 | resultList.append([target, domain] + ["Error"]*6) 154 | 155 | if args.icp: 156 | for result in resultList: 157 | icpResult = searchRecord(domain=result[1], timeout=args.timeout) 158 | time.sleep(args.delay) 159 | if icpResult["code"] == 1: 160 | result += [icpResult["unitName"], icpResult["unitICP"]] 161 | 162 | if len(resultList) == 0: 163 | print(f"\r({targetNum}/{targetCount})", end="", flush=True) 164 | 165 | return resultList 166 | 167 | 168 | def printTitle(icp): 169 | headers = [ 170 | ("ip/domain", 17), 171 | ("反查域名", 20), 172 | ("百度PC", 10), 173 | ("百度移动", 10), 174 | ("360", 8), 175 | ("神马", 8), 176 | ("搜狗", 8), 177 | ("Google", 8) 178 | ] 179 | 180 | if icp: 181 | headers += [("单位名称", 30), ("备案编号", 24)] 182 | 183 | # 生成分隔线 184 | separator = "+".join(["-" * width for _, width in headers]) 185 | print(f"+{separator}+") 186 | 187 | # 生成标题行 188 | title_row = "|".join([rpad(name, width) for name, width in headers]) 189 | print(f"|{title_row}|") 190 | 191 | # 生成底部线 192 | print(f"+{separator}+") 193 | 194 | 195 | def printMsg(result, icp): 196 | try: 197 | COLOR_RED = "\033[31m" 198 | COLOR_GREEN = "\033[32m" 199 | COLOR_RESET = "\033[0m" 200 | 201 | def is_valid(value): 202 | # 有效性判断增强:包含None的情况 203 | if value in [None, "Error", "N/A"]: 204 | return False 205 | return str(value).isdigit() 206 | 207 | def format_field(value, width): 208 | # 处理None值 209 | value = value if value is not None else "Error" 210 | color = COLOR_GREEN if is_valid(value) else COLOR_RED 211 | value_str = str(value)[:width//2] # 防止超长内容破坏格式 212 | return f"{color}{value_str.center(width)}{COLOR_RESET}" 213 | 214 | # 基础字段优化(调整格式) 215 | fields = [ 216 | f"{COLOR_GREEN}{result[0][:15].ljust(17)}{COLOR_RESET}", 217 | f"{COLOR_GREEN}{result[1][:18].ljust(20)}{COLOR_RESET}", 218 | format_field(result[2], 8), # 宽度保持10列 219 | format_field(result[3], 8), 220 | format_field(result[4], 6), 221 | format_field(result[5], 6), 222 | format_field(result[6], 6), 223 | format_field(result[7], 6) 224 | ] 225 | 226 | if icp and len(result) >= 9: 227 | # 单位名称颜色处理 228 | unit_name = result[8] or "N/A" 229 | unit_color = COLOR_GREEN if unit_name not in ["N/A", ""] else COLOR_RED 230 | fields.append(f"{unit_color}{rpad(unit_name, 30)}{COLOR_RESET}") 231 | 232 | # 备案编号颜色处理 233 | icp_value = result[9] if len(result) > 9 else "N/A" 234 | icp_color = COLOR_GREEN if icp_value not in ["N/A", ""] else COLOR_RED 235 | fields.append(f"{icp_color}{rpad(str(icp_value)[:24], 24)}{COLOR_RESET}") 236 | 237 | # 动态生成分隔线(保持不变) 238 | col_widths = [17, 20, 10, 10, 8, 8, 8, 8] 239 | if icp: 240 | col_widths += [30, 24] 241 | separator = "+".join(["-" * w for w in col_widths]) 242 | 243 | # 构建输出行(保持不变) 244 | output = "|".join([ 245 | rpad(field, width) 246 | for field, width in zip(fields, col_widths) 247 | ]) 248 | 249 | print(f"\r|{output}|") 250 | print(f"+{separator}+") 251 | 252 | except Exception as e: 253 | print(f"\n输出错误: {str(e)}") 254 | 255 | if __name__ == "__main__": 256 | banner() 257 | parseClass = parseArgs() 258 | args = parseClass.parse_args() 259 | targetList = init(parseClass) 260 | resultList = [] 261 | printTitle(args.icp) 262 | targetCount = len(targetList) 263 | try: 264 | for i in range(len(targetList)): 265 | resultTmpList = [] 266 | resultTmpList += ip2domian(targetList[i], args, targetNum=i+1, targetCount=targetCount) 267 | resultList += resultTmpList 268 | for i in resultTmpList: 269 | printMsg(i, args.icp) 270 | 271 | outputResult(args.file, args.output, resultList, args.icp) 272 | 273 | except KeyboardInterrupt: 274 | # 捕获异常,并将异常信息赋值给变量e 275 | pass 276 | -------------------------------------------------------------------------------- /module/Pearrank.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | import re 7 | import requests 8 | import json 9 | 10 | 11 | def Pearrank(domain, timeout): 12 | try: 13 | # 更新请求地址和参数 14 | response = requests.get( 15 | f"https://api.mir6.com/api/bdqz?domain={domain}&type=json", 16 | timeout=timeout 17 | ) 18 | response.raise_for_status() 19 | data = response.json() 20 | 21 | # 统一使用新的数据结构解析 22 | return { 23 | "code": 1, 24 | "bdpc_rank": data["data"]["baidupc"], 25 | "bdmb_rank": data["data"]["baidum"], 26 | "360rank": data["data"]["so360"], 27 | "sm_rank": data["data"]["shenma"], 28 | "sg_rank": data["data"]["sougou"], 29 | # 新增google字段 30 | "google_rank": data["data"]["google"] 31 | } 32 | except Exception as e: 33 | print(f"请求异常: {e}") 34 | return {"code": -1} 35 | 36 | 37 | if __name__ == '__main__': 38 | rank = Pearrank("aizhan.com", 12) 39 | print(rank) 40 | 41 | 42 | def get_pearrank(domain): 43 | try: 44 | response = requests.get(f"https://api.mir6.com/api/bdqz?domain={domain}&type=json") 45 | response.raise_for_status() 46 | data = response.json() 47 | 48 | return { 49 | 'domain': domain, 50 | 'baidu': data['data']['baidupc'], 51 | 'baidu_mobile': data['data']['baidum'], 52 | '360': data['data']['so360'], 53 | 'shenma': data['data']['shenma'], 54 | 'sogou': data['data']['sougou'], 55 | 'google': data['data']['google'], 56 | 'status': 'success' 57 | } 58 | except Exception as e: 59 | return {'status': 'error', 'message': str(e)} 60 | 61 | -------------------------------------------------------------------------------- /module/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | 7 | if __name__ == "__main__": 8 | pass 9 | -------------------------------------------------------------------------------- /module/__pycache__/Pearrank.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/Pearrank.cpython-310.pyc -------------------------------------------------------------------------------- /module/__pycache__/Pearrank.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/Pearrank.cpython-38.pyc -------------------------------------------------------------------------------- /module/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /module/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /module/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /module/__pycache__/argParse.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/argParse.cpython-310.pyc -------------------------------------------------------------------------------- /module/__pycache__/argParse.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/argParse.cpython-37.pyc -------------------------------------------------------------------------------- /module/__pycache__/argParse.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/argParse.cpython-38.pyc -------------------------------------------------------------------------------- /module/__pycache__/baiduRank.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/baiduRank.cpython-37.pyc -------------------------------------------------------------------------------- /module/__pycache__/baiduRank.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/baiduRank.cpython-38.pyc -------------------------------------------------------------------------------- /module/__pycache__/banner.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/banner.cpython-310.pyc -------------------------------------------------------------------------------- /module/__pycache__/banner.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/banner.cpython-37.pyc -------------------------------------------------------------------------------- /module/__pycache__/banner.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/banner.cpython-38.pyc -------------------------------------------------------------------------------- /module/__pycache__/icpRecord.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/icpRecord.cpython-310.pyc -------------------------------------------------------------------------------- /module/__pycache__/icpRecord.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/icpRecord.cpython-37.pyc -------------------------------------------------------------------------------- /module/__pycache__/icpRecord.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/icpRecord.cpython-38.pyc -------------------------------------------------------------------------------- /module/__pycache__/searchDomain.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/searchDomain.cpython-310.pyc -------------------------------------------------------------------------------- /module/__pycache__/searchDomain.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/searchDomain.cpython-37.pyc -------------------------------------------------------------------------------- /module/__pycache__/searchDomain.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/module/__pycache__/searchDomain.cpython-38.pyc -------------------------------------------------------------------------------- /module/aizhanrank.py: -------------------------------------------------------------------------------- 1 | import re 2 | import requests 3 | import json 4 | 5 | 6 | def baiduRank(domain, timeout): 7 | 8 | reqURL = "https://api.pearktrue.cn/api/website/weight.php?domain="+domain 9 | 10 | 11 | baiduRankResult = {"code": 1, "bdpc_rank": -1,"bdmb_rank":-1,"sm_rank":-1,"sg_rank":-1} 12 | try: 13 | rep = requests.get(url=reqURL, timeout=timeout) 14 | response = rep.text 15 | 16 | data =json.loads(response) 17 | 18 | # pc_br_value = data["data"]["success"][0]["pc_br"] 19 | #m_br_value = data["data"]["success"][0]["m_br"] 20 | baiduRankRegular = {"code": 1, "bdpc_rank": int(data["data"]["Baidu_PC"]),"bdmb_rank": int(data["data"]["Baidu_Mobile"]),"sm_rank": int(data["data"]["ShenMa"]),"sg_rank": int(data["data"]["SoGou"])} 21 | 22 | 23 | return baiduRankRegular 24 | 25 | except: 26 | 27 | baiduRankResult["code"] = -1 28 | return baiduRankResult 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | rank = baiduRank("fer.cn", 3) 34 | print(rank["rank"]) 35 | 36 | -------------------------------------------------------------------------------- /module/argParse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | import time 7 | from argparse import ArgumentParser 8 | 9 | def parseArgs(): 10 | date = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()) 11 | parser = ArgumentParser() 12 | parser.add_argument("-t", "--target", required=False, type=str, help=f"Target ip/domain") 13 | parser.add_argument("-f", "--file", dest="file", required=False, type=str, default="", help=f"指定目标文件,一行一个,ip或者域名") 14 | parser.add_argument("-s", "--delay", dest="delay", required=False, type=int, default=1, help=f"请求延迟 (默认 1s)") 15 | parser.add_argument("-T", "--Timeout", dest="timeout", required=False, type=int, default=30, help="超时时间 (默认 30s)") 16 | parser.add_argument("-r", "--rank", required=False, type=int, default=0, help="大于指定的百度权重值则输出,范围0-10 (默认 0)") 17 | parser.add_argument("-o", "--output", dest="output", required=False, type=str, default=f"{date}", help="输出文件 (文件路径: ./output/ip2domain_{fileName}_{date}.csv)") 18 | parser.add_argument("--icp", required=False, action="store_true", default=False, help="是否开启ICP备案查询 (默认不开启)") 19 | parser.add_argument("-m", "--model", dest="model", required=False, type=int, default=1, help=f"选择使用的api接口,默认1") 20 | return parser 21 | 22 | if __name__ == "__main__": 23 | args = parseArgs() 24 | 25 | -------------------------------------------------------------------------------- /module/baiduRank.py: -------------------------------------------------------------------------------- 1 | import re 2 | import requests 3 | import json 4 | 5 | 6 | def baiduRank(domain, timeout): 7 | 8 | reqURL = "https://api.pearktrue.cn/api/website/weight.php?domain="+domain 9 | 10 | 11 | baiduRankResult = {"code": 1, "bdpc_rank": -1,"bdmb_rank":-1,"sm_rank":-1,"sg_rank":-1} 12 | try: 13 | rep = requests.get(url=reqURL, timeout=timeout) 14 | response = rep.text 15 | 16 | data =json.loads(response) 17 | 18 | # pc_br_value = data["data"]["success"][0]["pc_br"] 19 | #m_br_value = data["data"]["success"][0]["m_br"] 20 | baiduRankRegular = {"code": 1, "bdpc_rank": int(data["data"]["Baidu_PC"]),"bdmb_rank": int(data["data"]["Baidu_Mobile"]),"sm_rank": int(data["data"]["ShenMa"]),"sg_rank": int(data["data"]["SoGou"])} 21 | 22 | 23 | return baiduRankRegular 24 | 25 | except: 26 | 27 | baiduRankResult["code"] = -1 28 | return baiduRankResult 29 | 30 | 31 | 32 | if __name__ == '__main__': 33 | rank = baiduRank("fer.cn", 3) 34 | print(rank["rank"]) 35 | 36 | -------------------------------------------------------------------------------- /module/banner.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | from module.argParse import parseArgs 7 | 8 | def banner(): 9 | parseClass = parseArgs() 10 | args = parseClass.parse_args() 11 | logo = f""" 12 | _________ 13 | | 14 | | 15 | _|_ 16 | ///\(\033[0m\033[31mo\033[0m\033[92m_\033[0m\033[31mo\033[0m\033[92m)/\\\\\\ 17 | ||| ` ' ||| 18 | ip2domain 25.1.25 棉花糖修复增强版 公众号:棉花糖fans 19 | v1.4 20 | """ 21 | msg = f""" ip2domain:IP反查域名,查询备案信息、查询百度等引擎权重 22 | 23 | (由于接口对请求频率有限制,故查询速率较慢,请耐心等待) 24 | """ 25 | match args.model: 26 | case 1: 27 | msg1 = f""" 您当前选择的接口为1,提供百度PC、百度移动、360、神马、搜狗权重""" 28 | case 2: 29 | msg1 = f""" 您当前选择的接口为2,提供百度PC、百度移动权重,其他会显示为n""" 30 | 31 | 32 | print("\033[92m" + logo + "\033[0m") 33 | print(msg) 34 | print(msg1) 35 | if __name__ == "__main__": 36 | pass 37 | -------------------------------------------------------------------------------- /module/icpRecord.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | import requests 7 | import json 8 | 9 | def searchRecord(domain, timeout): 10 | 11 | resultDic = {"code":1, "domain":domain, "unitName": "None", "unitICP": "None"} 12 | try: 13 | rep = requests.get(url=f"https://api.pearktrue.cn/api/icp/?domain="+domain, timeout=timeout) 14 | response = rep.text 15 | data =json.loads(response) 16 | try: 17 | resultDic["unitName"] = data["data"]["hostingparty"] 18 | except: 19 | pass 20 | try: 21 | resultDic["unitICP"] = data["data"]["filingnumber"] 22 | except: 23 | pass 24 | 25 | return resultDic 26 | except: 27 | 28 | return resultDic 29 | 30 | if __name__ == "__main__": 31 | __name__ 32 | 33 | -------------------------------------------------------------------------------- /module/searchDomain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3.7 2 | # -*- coding: utf-8 -*- 3 | # @Author : mhtsec 4 | # @Github : https://github.com/mhtsec 5 | 6 | import re 7 | import tldextract 8 | import requests 9 | 10 | def searchDomain(ip, timeout): 11 | mainDomainNameList = [] 12 | searchDomainResult = {"code": 0, "ip":ip, "domainList": []} 13 | 14 | headers = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36" 15 | } 16 | try: 17 | rep = requests.get(url=f"http://api.webscan.cc/?action=query&ip={ip}", headers=headers, timeout=timeout) 18 | if rep.text != "null": 19 | results = rep.json() 20 | for result in results: 21 | domainName = result["domain"] 22 | if re.match(r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", domainName): 23 | continue 24 | if domainName in mainDomainNameList: 25 | continue 26 | # 取主域 27 | val = tldextract.extract(domainName) 28 | if f"{val.domain}.{val.suffix}" not in mainDomainNameList: 29 | mainDomainNameList.append(f"{val.domain}.{val.suffix}") 30 | searchDomainResult["code"] = 1 31 | searchDomainResult["domainList"] = mainDomainNameList 32 | else: 33 | searchDomainResult["code"] = 0 34 | except: 35 | searchDomainResult["code"] = -1 36 | 37 | return searchDomainResult 38 | 39 | if __name__ == "__main__": 40 | s = searchDomain("211.103.136.242", 3) 41 | if s["code"] == 1: 42 | for i in s["domainList"]: 43 | print(f"{s['ip']} {i}") -------------------------------------------------------------------------------- /output/domain_2024-01-17_23-55-58.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/output/domain_2024-01-17_23-55-58.csv -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mhtsec/ip2domain/9a26783bb0d87c40ae3a82bf669107e7f20699e5/requirements.txt --------------------------------------------------------------------------------