From ccedd85be3ad4aca332f3a3386734380fc048d9f Mon Sep 17 00:00:00 2001 From: UzJu <50813806+UzJu@users.noreply.github.com> Date: Mon, 7 Mar 2022 23:23:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=9F=E5=90=8D=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 自动判断扫描的URL是否为域名 --- README.en.md | 10 ++++++++++ README.md | 17 ++++++++++++++++- core/DnsResolution.py | 24 ++++++++++++++++++++++++ main.py | 19 ++++++++++++++----- 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 core/DnsResolution.py diff --git a/README.en.md b/README.en.md index deb3205..e17e64b 100644 --- a/README.en.md +++ b/README.en.md @@ -79,6 +79,13 @@ Enter the storage bucket address to automatically detect, the function is as fol + 5、Detect whether the bucket can upload Objects + 6、Batch detection function +## 4, domain name detection function + +Many storage buckets have resolved the domain name, the new judgment of the CNAME of the domain name, and then take the CNAME to detect + +**can now directly import a large number of domain name assets for detection, will automatically determine the CNAME of the domain name ** + +![image-20220307231827585](https://uzjumakdown-1256190082.cos.ap-guangzhou.myqcloud.com/UzJuMarkDownImageimage-20220307231827585.png) # 0x03 Ali cloud storage bucket utilization ### 1、Implementation idea @@ -116,6 +123,9 @@ First implement the `OssBucketCheckFromSDK` class > actually just delete this library, don't use it ^ ^ +**March 7, 2022** + ++ New Domain Name Detection # :cop:0xffffffff Disclaimer Disclaimers diff --git a/README.md b/README.md index fc486f9..7478728 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # :rooster:0x00 前言 +> 2022年3月7日 +> +> 我觉得文档写的还不是很清楚,等有空更新一下文档完整的使用教程 + **语言/Language** English README: [English](README.en.md) @@ -29,7 +33,6 @@ English README: [English](README.en.md) + pip3 install oss2 + pip3 install colorlog -+ pip3 install logging + pip3 install argparse # :gun:0x02 使用方法 @@ -89,6 +92,14 @@ python3 main.py -f filepath + 5、检测存储桶是否可上传Object + 6、批量检测功能 +## 4、域名检测功能 + +很多存储桶都解析了域名,新增判断域名的CNAME,然后取CNAME来进行检测 + +**现在可以直接导入大量域名资产来进行检测,会自动判断域名的CNAME** + +![image-20220307231827585](https://uzjumakdown-1256190082.cos.ap-guangzhou.myqcloud.com/UzJuMarkDownImageimage-20220307231827585.png) + # 0x03 阿里云存储桶利用 ### 1、实现思路 @@ -128,6 +139,10 @@ python3 main.py -f filepath > 其实是直接把这个库删了,不用了^ ^ +**2022年3月7日** + ++ 新增域名检测 + # :cop:0xffffffff 免责声明 免责声明 diff --git a/core/DnsResolution.py b/core/DnsResolution.py new file mode 100644 index 0000000..0ad3be1 --- /dev/null +++ b/core/DnsResolution.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# @Author : UzJu@菜菜狗 +# @Email : UzJuer@163.com +# @Software: PyCharm +# @Time : 2022/3/7 上午11:38 +# @File : DnsResolution.py + + +import dns.resolver +import logging + +module_logger = logging.getLogger("mainModule.Dns") + + +def GetDomainDnsResolution(domain): + try: + cname = dns.resolver.resolve(domain, 'CNAME') + for i in cname.response.answer: + for j in i.items: + return j.to_text() + except Exception as e: + return False + diff --git a/main.py b/main.py index 3bb21ac..74dec93 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,7 @@ from config import BannerInfo import requests import argparse from core import aliyunOss +from core import DnsResolution NowTime = datetime.datetime.now().strftime('%Y-%m-%d') @@ -87,14 +88,22 @@ if __name__ == '__main__': parser.add_argument('-aliyun', dest='aliyun', help='python3 -aliyun UzJu.oss-cn-beijing.aliyuncs.com') parser.add_argument('-f', '--file', dest='file', help='python3 -f/--file url.txt') args = parser.parse_args() + if args.aliyun: - getTargetBucket = args.aliyun.split(".") - aliyunOss.CheckBucket(getTargetBucket[0], getTargetBucket[1]) + existDomain = DnsResolution.GetDomainDnsResolution(args.aliyun) + if existDomain: + aliyunOss.CheckBucket(existDomain.split(".")[0], existDomain.split(".")[1]) + else: + getTargetBucket = args.aliyun.split(".") + aliyunOss.CheckBucket(getTargetBucket[0], getTargetBucket[1]) if args.file: with open(args.file, 'r') as f: for i in f.read().splitlines(): - getTargetBucket = i.split(".") - aliyunOss.CheckBucket(getTargetBucket[0], getTargetBucket[1]) - + existDomain = DnsResolution.GetDomainDnsResolution(i) + if existDomain: + aliyunOss.CheckBucket(existDomain.split(".")[0], existDomain.split(".")[1]) + else: + getTargetBucket = i.split(".") + aliyunOss.CheckBucket(getTargetBucket[0], getTargetBucket[1]) except KeyboardInterrupt: logger.error("KeyError Out")