Coder Social home page Coder Social logo

shuize_0x727's Introduction

水泽-信息收集自动化工具

GitHub release

郑重声明:文中所涉及的技术、思路和工具仅供以安全为目的的学习交流使用,任何人不得将其用于非法用途以及盈利等目的,否则后果自行承担。

0x01 介绍

作者:Ske

团队:0x727,未来一段时间将陆续开源工具,地址:https://github.com/0x727

定位:协助红队人员快速的信息收集,测绘目标资产,寻找薄弱点

语言:python3开发

功能:一条龙服务,只需要输入根域名即可全方位收集相关资产,并检测漏洞。也可以输入多个域名、C段IP等,具体案例见下文。

调用:脚本借用了ksubdomain爆破子域名和theHarvester收集邮箱,感谢ksubdomain和theHarvester作者

0x02 安装

为了避免踩坑,建议安装在如下环境中

  • 当前用户对该目录有写权限,不然扫描结果无法生成。root权限即可
  • Python环境必须是3.7以上,因为使用了异步。建议VPS环境是ubuntu20,默认是python3.8。安装模块的时候切记不要走豆瓣的源
  • 在配置文件iniFile/config.ini里加入api(fofa、shodan、github、virustotal)
chmod 777 build.sh
./build.sh

image-20210728153419131

python3 ShuiZe.py -h

image-20210728154929084

docker运行ShuiZe

较多人反馈安装的时候会出现各种报错,新增通过docker运行ShuiZe

通过下面的命令安装docker,然后拉取python3.8的容器,再git clone水泽后,运行docker_build.sh即可。

apt install docker.io
docker pull yankovg/python3.8.2-ubuntu18.04
docker run -itd yankovg/python3.8.2-ubuntu18.04 bash
docker exec -it docker的ID /bin/bash
apt-get update
apt install git --fix-missing
apt install vim
rm /usr/bin/python3
ln -s /usr/local/bin/python3.8 /usr/bin/python3
python3 -m pip install --upgrade pip
git clone https://github.com/0x727/ShuiZe_0x727.git
chmod 777 docker_build.sh
./docker_build.sh

也可参考 @1itt1eB0y 提供的Dockerfile和docker-compose.yml构建镜像并运行

链接:https://github.com/1itt1eB0y/MyCollection/tree/master/docker/shuize

请自行评估安全性

脚本自带Linux版本的Nuclei和ksubdomain,如果是windows或者mac,需要自行更换版本。

0x03 效果展示

备案反查顶级域名

image-20210728155358378

不是泛解析,调用ksubdomain爆破子域名

image-20210728155541501

theHarvest获取邮箱

image-20210728161507035

image-20210728163216047

第三方数据接口 -> 获取子域名

image-20210728160705706

github -> 从github获取子域名,并把查询结果保存到txt,并匹配关键字获取敏感信息

image-20210728161022348

百度和必应爬虫

image-20210728161117459

证书

image-20210728161711534

子域名友链

image-20210728161339208

解析子域名A记录,检测是否CDN和整理C段的IP

image-20210728162655684

image-20210728162049962

网络空间搜索引擎:Fofa和Shodan

image-20210728162119531

IP反查域名

image-20210728162303312

存活探测

image-20210728162441132

漏洞检测

image-20210728165612314

扫描结果保存在excel文件里

image-20210728170303756

excel的内容如下

备案反查顶级域名

image-20210728163926763

image-20210728163940918

邮箱

image-20210728164010063

Github敏感信息

image-20210728164040649

爬虫

image-20210728164146630

证书

image-20210728164211552

子域名A记录和CDN

image-20210728164316747

动态链接和后台地址

image-20210728164555141

网络空间搜索引擎

image-20210728164745820

ip反查域名

image-20210728164811422

存活网站标题

image-20210728164933353

指纹和漏洞

image-20210728165004202

相关域名和C段

image-20210728165052361

0x04 POC编写

POC的模板文件例子:Plugins/Vul/Web/__template__.py

只需要在run_detect方法里调用POC的利用方法即可。

0x05 使用方法

语法 功能
python3 ShuiZe.py -d domain.com 收集单一的根域名资产
python3 ShuiZe.py --domainFile domain.txt 批量跑根域名列表
python3 ShuiZe.py -c 192.168.1.0,192.168.2.0,192.168.3.0 收集C段资产
python3 ShuiZe.py -f url.txt 对url里的网站漏洞检测
python3 ShuiZe.py --fofaTitle XXX大学 从fofa里收集标题为XXX大学的资产,然后漏洞检测
python3 ShuiZe.py -d domain.com --justInfoGather 1 仅信息收集,不检测漏洞
python3 ShuiZe.py -d domain.com --ksubdomain 0 不调用ksubdomain爆破子域名

0x06 实现原理

image-20210728132752381

整理上面所有的子域名

  • 对所有子域名判断是否是CDN并解析出A记录

  • 统计每个c段出现IP的个数

  • 调用网络空间搜索引擎

    • fofa -> 需要API
    • shodan -> 需要API
  • 前面获得的ip反查域名得到相关资产的子域名,整理出所有的子域名和IP

image-20210728133047590

  • 整理所有资产探测漏洞

    • Web -> 存活探测

      • 获取标题
        • 自动跑后台路径(['admin', 'login', 'system', 'manager', 'admin.jsp', 'login.jsp', 'admin.php', 'login.php','admin.aspx', 'login.aspx', 'admin.asp', 'login.asp'])
        • 如果URL是IP则查询IP的归属地
      • 漏洞检测 -> Plugins/Vul/Web

      image-20210728134051049

      image-20210728134115608

      image-20210728134131076

    • 非Web服务 --> 未授权和弱口令

    image-20210728134212279

其他功能

image-20210728134304533

结果展示:

image-20210728132105833

完整流程图:

0x07 新增功能

2021.7.31 增加了Censys接口,需要在iniFile/config.ini的[censys api]中填入API。 功能是获取域名的所有解析IP记录,一是为了Host碰撞,二是更加准确的得到C段IP

需要censys的api,免费的账户一个月只有250次查询,所以后期需要注意,用完了要更新api

2021.7.31 增加了Host碰撞访问内网系统漏洞,感谢 横戈安全团队-小洲 提交的建议

2021.8.1 修复了CDN判断的bug,感谢 leveryd 师傅 提交的bug。

issues地址:#3

2021.8.3 修复了chinazApi接口请求超时太长的bug,设置默认时间10秒,感谢 k0njac 师傅提交的bug。

issues地址:#11

2021.8.13 增加了获取Github敏感信息地址的作者邮箱,帮助判断是否是目标员工的项目

2021.8.17 更新了ksubdomain版本,自动选择网卡,不需要重新手动输入网卡

ksubdomain项目地址:https://github.com/knownsec/ksubdomain

2021.9.1 增加了从fofa中爬去socks代理功能,后续可以手动配合proxychains进行漏洞探测,防止因为被封IP导致漏报。

感谢 安恒水滴实验室-1amfine2333师傅 提供的思路。

2021.9.2 增加了Confluence指纹识别,漏洞利用地址:https://github.com/h3v0x/CVE-2021-26084_Confluence

2021.9.4 增加了某查接口,对目标的整个架构分析,涵盖【对外投资、控股公司、分支机构、联系方式、邮箱】等信息。

感谢 pykiller师傅 提交的建议,同时参考了 吐司师傅gubeiya 的脚本

issues地址:#25

2021.9.26 增加了夸克的api接口,-d -c --fofaTitle中都会调用

限定了每次最大查询数量1000条,不然一个月5w条数据也用不了多少次

在config.ini配置文件的quake_nums值

issues地址:#33

2021.11.30 增加了奇安信hunter的api接口,-d -c --fofaTitle中都会调用

限定了每次最大查询数量200条,不然一天的几千条数据也用不了多少次

在config.ini配置文件的qianxin_nums值

issues地址:#48

2022.1.17 修复了certspotter接口获取子域名过滤不严谨的问题

感谢 union-cmd师傅 提交的建议

issues地址:#57

2022.3.21 更新了fofa api的域名

2022.3.21 更新了域名备案反查的问题

2022.3.23 增加了securitytrails接口获取子域名,该接口很强大,建议在config.ini里添加你的api keys

issues地址:#48

注册地址: https://docs.securitytrails.com/

感谢 郭师傅 提交的建议

2022.3.23 修复了爱企查无法获取数据的问题

感谢 横戈安全团队-chhyx(逗逗) 的技术支持

2022.4.13 修复了奇安信测绘语法使用错误的问题

issues地址:#74

感谢 cwkiller 反馈的问题

2022.4.16 增加了调用Nuclei检测漏洞

nuclei的参数在iniFile/config.ini配置,默认为nuclei_config = -rl 300 -c 50 -timeout 5 -stats -silent -severity critical,high 根据需求自行修改

2022.7.5 Nuclei默认参数配置增加-as

issues地址: #104

-as 参数,先使用 wappalyzer 进行指纹识别,在进行扫描。

感谢 anquanbiji 反馈的建议

2022.8.12 ShuiZe增加Dockerfile安装方式

issues地址: #99

感谢 @1itt1eB0y 提供的脚本。安全性自行评估

2022.8.12 修复了大量反馈aiqicha脚本报错的问题,初步排查是被封IP的原因。

2022.8.12 修复了quakeApi没有title导致报错的情况

issues地址: #120

感谢 Zimba5880 反馈的建议

2022.8.20 增加了快代理配置,漏洞检测时会使用快代理的代理池,这样可以避免当前IP被封后导致后续的扫描出现遗漏。

购买快代理的隧道代理,地址:https://www.kuaidaili.com/cart?t=tps_c

根据自己的需求选择包年包月或者按量付费,更换IP的频率。这里注意并发请求数的,并发数量越高,在配置文件里iniFile/config.ini的thread_num就可以设置的更高。

假设并发数为5,那么thread_num不要设置超过10,具体的值自己测试。

购买后查看host、port、username、password,然后填入到配置文件里

默认关闭快代理代理池功能,如果要开启,把switch设置为on,使用快代理代理池时会先验证是否配置正确

2022.8.27 集成了ObserverWard扫描指纹

项目地址:https://github.com/0x727/ObserverWard

指纹地址:https://github.com/0x727/FingerprintHub

0x08 反馈

ShuiZe(水泽) 是一个免费且开源的项目,我们欢迎任何人为其开发和进步贡献力量。

  • 在使用过程中出现任何问题,可以通过 issues 来反馈。
  • Bug 的修复可以直接提交 Pull Request 到 dev 分支。
  • 如果是增加新的功能特性,请先创建一个 issue 并做简单描述以及大致的实现方法,提议被采纳后,就可以创建一个实现新特性的 Pull Request。
  • 欢迎对说明文档做出改善,帮助更多的人使用 ShuiZe。
  • 贡献代码请提交 PR 至 dev 分支,master 分支仅用于发布稳定可用版本。

提醒:和项目相关的问题最好在 issues 中反馈,这样方便其他有类似问题的人可以快速查找解决方法,并且也避免了我们重复回答一些问题。

Stargazers over time

Stargazers over time

shuize_0x727's People

Contributors

skewwg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shuize_0x727's Issues

Failed to build PyInstaller

环境:ubuntu20 arm,python3.8
ERROR: Failed building wheel for PyInstaller
Failed to build PyInstaller
ERROR: Could not build wheels for PyInstaller which use PEP 517 and cannot be installed directly

image

github及代理问题

最开始用的时候,github敏感信息和代理查找是正常的,可以查到谷歌和百度的代理,现在升级的虽然设置选项为1,但是仍未调用代理,且github敏感信息请求总时间超时

使用报错

UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 60: illegal multibyte sequence
image

使用报错(run_webSpace)

--------------------------------------------------run_webSpace ...--------------------------------------------------
Traceback (most recent call last):
File "ShuiZe.py", line 1536, in
_init()
File "ShuiZe.py", line 1516, in _init
run_subdomain()
File "ShuiZe.py", line 1035, in run_subdomain
run_cSubnet(CIP_List, Subdomains_ips, notCDNSubdomains, param_Links)
File "ShuiZe.py", line 1056, in run_cSubnet
webSpace_web_host_port, webSpace_service_host_port = run_webSpace(domain, SubdomainAndNotCDNIPs, [], '')
File "ShuiZe.py", line 439, in run_webSpace
from Plugins.infoGather.WebspaceSearchEngine import fofaApi, shodanApi, quakeApi
File "/root/ShuiZe_0x727/Plugins/infoGather/WebspaceSearchEngine/quakeApi.py", line 17, in
X_QuakeToken = cf.get('quake api', 'X-QuakeToken')
File "/usr/local/python38/lib/python3.8/configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "/usr/local/python38/lib/python3.8/configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'quake api'

功能问题

感觉添加dirsearch目录扫描,poc缺少fastjson检测 这样更完美一点

代码运行bug反馈

在运行过程中报错'gbk' codec can't decode byte 0xae in position 570
后面在checkCDN.py修改了
cdnDict = {}
with io.open(r'Plugins/infoGather/subdomain/CDN/cdn-domain.conf', 'rt', encoding='utf-8') as f:
现在又有了新错误,不知道该修改哪个模块
'encoding' is an invalid keyword argument for print()
image
作者可以抽空帮忙看看吗

一些bug

遇到waf拦截返回0 length 会误报存在漏洞
image

以及不知道对于vcenter的判断是什么。但是它好像也误报了。
image

image

跨平台

如果可以支持Windows就完美了

给作者的一个建议

作者可以加个360quake的api,感觉比fofa的好用,目前这个版本fofa的api经常出问题,而且360quake不用会员即可查看所有的数据,语法也基本和fofa一致

bug反馈

感觉fofa接口有点问题,key什么都配置还是会出现无法访问的情况,而且加了fofa的key以后 shodan的接口貌似默认不启用了,爆破子域名的时间有点长测了一下大概跑完需要十几分钟,如果很多站是不是就需要很久时间,感觉添加一个是否启用域名爆破这个选项比较好一点。建议增加waf识别功能。 获取标题也存在一点的问题,一些域名获取标题失败,但是手动复制到浏览器可以正常访问,然后再把浏览器的完整路径复制到脚本里面就能获取标题成功。

使用过程中的小问题和需求

(1)可以把查询的子域名单独放在一个文件夹并且合并一个总的txt文档,可以比如在新项目文件夹中加一个文件夹用来放子域名文档.。要不然放在水泽根目录下面每次都要去先下载复制才行,也比较占地方
(2)可以增加一个更新版本的操作吗,因为之前安装的,后面遇到的一些更新,似乎只能重新下载一个,然后配置才能是最新版

github接口调用错误

[password] [line:130090] username: ${ELASTICSEARCH_USERNAME}
[password] [line:130091] password: ${ELASTICSEARCH_PASSWORD}
[password] [line:130092] ---
github address: [line:138643] https://raw.githubusercontent.com/Wang-Kai/cherish-today/7f352e89a9ec85470a5765486b057c0b6bd33f70/2019/Collect_K8S_Log.md.back
[emails] : []
[password] [line:138985] username: ${ELASTICSEARCH_USERNAME}
[password] [line:138986] password: ${ELASTICSEARCH_PASSWORD}
[password] [line:138987] ---

Traceback (most recent call last):
File "ShuiZe.py", line 1435, in
_init()
File "ShuiZe.py", line 1355, in _init
run_subdomain()
File "ShuiZe.py", line 921, in run_subdomain
githubApiSubdomains = githubApiSubdomain()
File "ShuiZe.py", line 243, in githubApiSubdomain
gitSensitiveInfo = get_GitSensitiveInfo(github_txt, raw_url_emails)
File "ShuiZe.py", line 116, in get_GitSensitiveInfo
emails = str(raw_url_emails[raw_url])
KeyError: 'https://raw.githubusercontent.com/ucloud/ucloud-sdk-python2/90fb43198df73a78d64bbd98675dc7b302856057/ucloud/services/uhost/client.py'

调用子域名爆破报错

程序调用子域名爆破得时候报如下错误:

error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory

环境用的docker,配置过程按照安装说明来的

seebug.org?

........................................................|DNS-response|: 9qv6paper.seebug.org does not exist
|DNS-request| 9qv6paper.seebug.org
|S-chain|-<>-192.168.30.179:10808-<><>-4.2.2.2:53-<><>-OK
|DNS-response|: 9qv6paper.seebug.org does not exist
|DNS-request| 9qv6paper.seebug.org
|S-chain|-<>-192.168.30.179:10808-<><>-4.2.2.2:53-<><>-OK
|DNS-response|: 9qv6paper.seebug.org does not exist
|DNS-request| 9qv6paper.seebug.org
|S-chain|-<>-192.168.30.179:10808-<><>-4.2.2.2:53-<><>-OK
|DNS-response|: 9qv6paper.seebug.org does not exist
|DNS-request| 9qv6paper.seebug.org
|S-chain|-<>-192.168.30.179:10808-<><>-4.2.2.2:53-<><>-OK

由于网络问题做了proxychains,选择网卡后一直在重复发这种DNS请求,如果是代理的问题,这个只在这个选择网卡调用ksubdomain后出现,其他功能正常

API失效

Load ximcx api ...
[-] curl ximcx api error. (MaxRetryError("HTTPConnectionPool(host='sbd.ximcx.cn', port=80): Max retries exceeded with url: /DomainServlet (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f826114bd00>: Failed to establish a new connection: [Errno -2] Name or service not known'))"),)
image

[-] curl url.fht.im api error. (MaxRetryError("HTTPSConnectionPool(host='url.fht.im', port=443): Max retries exceeded with url: /domain_search?domain=one-hao.cn (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f826114b940>: Failed to establish a new connection: [Errno -2] Name or service not known'))"),)
image

requirements.txt中存在重复Cython

ERROR: Double requirement given: Cython==0.29.15 (from -r requirements.txt (line 20)) (already in Cython (from -r requirements.txt (line 2)), name='Cython')

bug反馈

Load ce.baidu.com api ...
[-] curl ce.baidu.com api error. ('Expecting value: line 1 column 1 (char 0)',)
[0] []
Load url.fht.im api ...
[-] curl url.fht.im api error. (MaxRetryError("HTTPSConnectionPool(host='url.fht.im', port=443): Max retries exceeded with url: /domain_search?domain=baidu.com (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f0ded8a14a8>: Failed to establish a new connection: [Errno -2] Name or service not known'))"),)

针不错

用了一点BUg都没有 顶顶顶顶顶顶顶顶顶顶顶顶顶顶

Found a small wrong or mistake about the program script name

when I use script to collection information, first I use to -d domain.com, then end, the program will tell me to -c ip, but some wrong in this , in the directory the script name is the ShuiZe.py in the program, that tell you to use the ShuiZe_0x727.py, this maybe has some wrong
0918

安装问题

如果是纯净环境,则按照ReadMe.md直接安装即可。image如果不是纯净环境,可能出现下面的问题
image
解决方法如下
python3 -m pip install XlsxWriter --upgrade --ignore-installed XlsxWriter -i https://pypi.tuna.tsinghua.edu.cn/simple
此处指定镜像源是为了防止请求不可达。
同样还会出现如下报错
image
image
解决问题同上所示。
安装版本建议为python3.8,如果太高的话,复杂环境下依然会报错。

调用ksubdomain出现错误

docker方式安装
错误信息如下:
./Plugins/infoGather/subdomain/ksubdomain/ksubdomain_linux: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.