mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
361 lines
21 KiB
Markdown
361 lines
21 KiB
Markdown
# OneForAll
|
||
|
||
[](https://travis-ci.org/shmilylty/OneForAll)
|
||
[](https://codecov.io/gh/shmilylty/OneForAll)
|
||
[](https://codeclimate.com/github/shmilylty/OneForAll/maintainability)
|
||
[](https://github.com/shmilylty/OneForAll/tree/master/LICENSE)
|
||
[](https://github.com/shmilylty/OneForAll/tree/master/)
|
||
[](https://github.com/shmilylty/OneForAll/releases)
|
||
|
||
👊**OneForAll是一款功能强大的子域收集工具** 📝[English Document](https://github.com/shmilylty/OneForAll/tree/master/README.en.md)
|
||
|
||

|
||
|
||
## 🎉项目简介
|
||
|
||
项目主页:[https://shmilylty.github.io/OneForAll/](https://shmilylty.github.io/OneForAll/)
|
||
|
||
项目地址:[https://github.com/shmilylty/OneForAll](https://github.com/shmilylty/OneForAll)
|
||
|
||
在渗透测试中信息收集的重要性不言而喻,子域收集是信息收集中必不可少且非常重要的一环,目前网上也开源了许多子域收集的工具,但是总是存在以下部分问题:
|
||
|
||
* **不够强大**,子域收集的接口不够多,不能做到对批量子域自动收集,没有自动子域解析,验证,FUZZ以及信息拓展等功能。
|
||
* **不够友好**,固然命令行模块比较方便,但是当可选的参数很多,要实现的操作复杂,用命令行模式就有点不够友好,如果有交互良好,高可操作的前端那么使用体验就会好很多。
|
||
|
||
* **缺少维护**,很多工具几年没有更新过一次,issues和PR是啥,不存在的。
|
||
|
||
* **效率问题**,没有利用多进程,多线程以及异步协程技术,速度较慢。
|
||
|
||
为了解决以上痛点,此项目应用而生,OneForAll一词是来自我喜欢的一部日漫《[我的英雄学院](https://manhua.fzdm.com/131/)》,它是一种通过一代代的传承不断变强的潜力无穷的顶级个性,目前[番剧](https://www.bilibili.com/bangumi/media/md7452/)也更新到了第四季了,欢迎大佬们入坑😄。正如其名,我希望OneForAll是一款集百家之长,功能强大的全面快速子域收集终极神器🔨。
|
||
|
||
目前OneForAll还在开发中,肯定有不少问题和需要改进的地方,欢迎大佬们提交[Issues](https://github.com/shmilylty/OneForAll/issues)和[PR](https://github.com/shmilylty/OneForAll/pulls),用着还行给个小星星✨吧,目前有一个专门用于OneForAll交流和反馈QQ群👨👨👦👦::[**824414244**](//shang.qq.com/wpa/qunwpa?idkey=125d3689b60445cdbb11e4ddff38036b7f6f2abbf4f7957df5dddba81aa90771)(加群验证:我的英雄学院),也可以给我发邮件📧[admin@hackfun.org]。
|
||
|
||
## 👍功能特性
|
||
|
||
* **收集能力强大**,详细模块请阅读[收集模块说明](https://github.com/shmilylty/OneForAll/tree/master/docs/collection_modules.md)。
|
||
1. 利用证书透明度收集子域(目前有6个模块:`censys_api`,`spyse_api`,`certspotter`,`crtsh`,`entrust`,`google`)
|
||
|
||
2. 常规检查收集子域(目前有4个模块:域传送漏洞利用`axfr`,检查跨域策略文件`cdx`,检查HTTPS证书`cert`,检查内容安全策略`csp`,检查robots文件`robots`,检查sitemap文件`sitemap`,后续会添加检查NSEC记录,NSEC3记录等模块)
|
||
|
||
3. 利用网上爬虫档案收集子域(目前有2个模块:`archivecrawl`,`commoncrawl`,此模块还在调试,该模块还有待添加和完善)
|
||
|
||
4. 利用DNS数据集收集子域(目前有19个模块:`CeBaidu`, `binaryedge_api`, `circl_api`, `hackertarget`, `riddler`, `bufferover`, `dnsdb`, `ipv4info`, `robtex`, `chinaz`, `dnsdb_api`, `netcraft`, `securitytrails_api`, `chinaz_api`, `dnsdumpster`, `passivedns_api`, `ptrarchive`, `sitedossier`,`threatcrowd`)
|
||
|
||
5. 利用DNS查询收集子域(目前有1个模块:通过枚举常见的SRV记录并做查询来收集子域`srv`,该模块还有待添加和完善)
|
||
|
||
6. 利用威胁情报平台数据收集子域(目前有5个模块:`riskiq_api`,`threatbook_api`,`threatminer`,`virustotal`,`virustotal_api`该模块还有待添加和完善)
|
||
|
||
7. 利用搜索引擎发现子域(目前有16个模块:`ask`, `bing_api`, `fofa_api`, `shodan_api`, `yahoo`, `baidu`, `duckduckgo`, `github`, `google`, `so`, `yandex`, `bing`, `exalead`, `google_api`, `sogou`, `zoomeye_api`),在搜索模块中除特殊搜索引擎,通用的搜索引擎都支持自动排除搜索,全量搜索,递归搜索。
|
||
* **支持子域爆破**,该模块有常规的字典爆破,也有自定义的fuzz模式,支持批量爆破和递归爆破,自动判断泛解析并处理。
|
||
* **支持子域验证**,默认开启子域验证,自动解析子域DNS,自动请求子域获取title和banner,并综合判断子域存活情况。
|
||
* **支持子域接管**,默认开启子域接管风险检查,支持子域自动接管(目前只有Github,有待完善),支持批量检查。
|
||
* **处理功能强大**,发现的子域结果支持自动去除,自动DNS解析,HTTP请求探测,自动筛选出有效子域,拓展子域的Banner信息,最终支持的导出格式有`txt`, `rst`, `csv`, `tsv`, `json`, `yaml`, `html`, `xls`, `xlsx`, `dbf`, `latex`, `ods`。
|
||
* **速度极快**,[收集模块](https://github.com/shmilylty/OneForAll/tree/master/oneforall//collect.py)使用多线程调用,[爆破模块](https://github.com/shmilylty/OneForAll/tree/master/oneforall/aiobrute.py)使用异步多进程多协程,子域验证中DNS解析和HTTP请求使用异步多协程,多线程检查[子域接管](https://github.com/shmilylty/OneForAll/tree/master/oneforall/takeover.py)风险。
|
||
* **体验良好**,日志和终端输出全使用中文,各模块都有进度条,异步保存各模块结果。
|
||
|
||
## 🚀上手指南
|
||
|
||
📢由于该项目**处于开发中**,会不断进行更新迭代,下载使用最好**克隆**最新项目,请务必花一点时间阅读此文档,有助于你快速熟悉OneForAll!
|
||
|
||
**🐍安装要求**
|
||
|
||
OneForAll是基于CPython开发的,所以你需要Python环境才能运行,如果你的系统还没有Python环境你可以参考[Python 3 安装指南](https://pythonguidecn.readthedocs.io/zh/latest/starting/installation.html#python-3),理论上Python 3.7和3.8都可以正常运行OneForAll,**但是**许多测试都是在Python 3.8上进行的,所以**推荐**你使用**Python 3.8**版本运行OneForAll。运行以下命令检查Python和pip3版本:
|
||
```bash
|
||
python -V
|
||
pip3 -V
|
||
```
|
||
如果你看到以下类似输出便说明Python环境没有问题:
|
||
```bash
|
||
Python 3.8.0
|
||
pip 19.2.2 from C:\Users\shmilylty\AppData\Roaming\Python\Python38\site-packages\pip (python 3.8)
|
||
```
|
||
|
||
**✔安装步骤**
|
||
|
||
1. **下载**
|
||
本项目已经在[码云](https://gitee.com/shmilylty/OneForAll.git)(Gitee)镜像了一份,国内推荐使用码云进行克隆比较快:
|
||
|
||
```bash
|
||
git clone https://gitee.com/shmilylty/OneForAll.git
|
||
```
|
||
或者:
|
||
```bash
|
||
git clone https://github.com/shmilylty/OneForAll.git
|
||
```
|
||
|
||
2. **安装**
|
||
你可以通过pip3安装OneForAll的依赖(如果你熟悉[pipenv](https://docs.pipenv.org/en/latest/),那么推荐你使用[pipenv安装依赖]((https://github.com/shmilylty/OneForAll/tree/master/docs/Installation_dependency.md))),以下为**Windows系统**下使用**pip3**安装依赖的示例:(注意:如果你的Python3安装在系统Program Files目录下,如:`C:\Program Files\Python37`,那么请以管理员身份运行命令提示符cmd执行以下命令!)
|
||
|
||
```bash
|
||
cd OneForAll/
|
||
python -m pip install -U pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple/
|
||
pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
||
cd oneforall/
|
||
python oneforall.py --help
|
||
```
|
||
其他系统平台的请参考[依赖安装](https://github.com/shmilylty/OneForAll/tree/master/docs/installation_dependency.md),如果在安装依赖过程中发现编译某个依赖库失败时可以参考[Q&A](https://github.com/shmilylty/OneForAll/tree/master/docs/Q&A.md)中解决方法,如果还没有解决欢迎加群反馈。
|
||
|
||
3. **更新**
|
||
❗注意:如果你之前已经克隆了项目运行之前请**备份**自己修改过的文件到项目外的地方(如**config.py**),然后执行以下命令**更新**项目:
|
||
|
||
```bash
|
||
git fetch --all
|
||
git reset --hard origin/master
|
||
git pull
|
||
```
|
||
|
||
**✨使用演示**
|
||
|
||
1. 如果你是通过pip3安装的依赖则使用以下命令运行示例:
|
||
```bash
|
||
cd oneforall/
|
||
python3 oneforall.py --target example.com run
|
||
```
|
||
|
||

|
||
|
||
2. 如果你通过pipenv安装的依赖则使用以下命令运行示例:
|
||
```bash
|
||
cd oneforall/
|
||
pipenv run python oneforall.py --target example.com run
|
||
```
|
||
|
||
**🤔使用帮助**
|
||
|
||
命令行参数只提供了一些常用参数,更多详细的参数配置请见[config.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/config.py),如果你认为有些参数是命令界面经常使用到的或缺少了什么参数等问题非常欢迎反馈。由于众所周知的原因,如果要使用一些被墙的收集接口请先到[config.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/config.py)配置代理,有些收集模块需要提供API(大多都是可以注册账号免费获取),如果需要使用请到[config.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/config.py)配置API信息,如果不使用请忽略有关报错提示。(详细模块请阅读[收集模块说明](https://github.com/shmilylty/OneForAll/tree/master/docs/collection_modules.md))
|
||
|
||
OneForAll命令行界面基于[Fire](https://github.com/google/python-fire/)实现,有关Fire更高级使用方法请参阅[使用Fire CLI](https://github.com/google/python-fire/blob/master/docs/using-cli.md),有任何使用疑惑欢迎加群交流。
|
||
|
||
[oneforall.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/oneforall.py)是主程序入口,oneforall.py可以调用[aiobrute.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/aiobrute.py),[takerover.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/takerover.py)及[dbexport.py](https://github.com/shmilylty/OneForAll/tree/master/oneforall/dbexport.py)等模块,为了方便进行子域爆破独立出了aiobrute.py,为了方便进行子域接管风险检查独立出了takerover.py,为了方便数据库导出独立出了dbexport.py,这些模块都可以单独运行,并且所接受参数要更丰富一点。
|
||
|
||
❗注意:当你在使用过程中遇到一些问题或者疑惑时,请先到[Issues](https://github.com/shmilylty/OneForAll/issues)里使用搜索找找答案,还可以参阅[常见问题与回答](https://github.com/shmilylty/OneForAll/tree/master/docs/Q&A.md)。
|
||
|
||
1. **oneforall.py使用帮助**
|
||
|
||
```bash
|
||
python oneforall.py --help
|
||
```
|
||
```bash
|
||
NAME
|
||
oneforall.py - OneForAll是一款功能强大的子域收集工具
|
||
|
||
SYNOPSIS
|
||
oneforall.py --target=TARGET <flags>
|
||
|
||
DESCRIPTION
|
||
Version: 0.0.6
|
||
Project: https://git.io/fjHT1
|
||
|
||
Example:
|
||
python3 oneforall.py --target example.com run
|
||
python3 oneforall.py --target ./domains.txt run
|
||
python3 oneforall.py --target example.com --brute True run
|
||
python3 oneforall.py --target example.com --verify False run
|
||
python3 oneforall.py --target example.com --valid None run
|
||
python3 oneforall.py --target example.com --port medium run
|
||
python3 oneforall.py --target example.com --format csv run
|
||
python3 oneforall.py --target example.com --show True run
|
||
|
||
Note:
|
||
参数valid可选值1,0,None分别表示导出有效,无效,全部子域
|
||
参数verify为True会尝试解析和请求子域并根据结果给子域有效性打上标签
|
||
参数port可选值有'default', 'small', 'medium', 'large' 详见config.py配置
|
||
参数format可选格式有'txt', 'rst', 'csv', 'tsv', 'json', 'yaml', 'html',
|
||
'jira', 'xls', 'xlsx', 'dbf', 'latex', 'ods'
|
||
参数path为None会根据format参数和域名名称在项目结果目录生成相应文件
|
||
|
||
ARGUMENTS
|
||
TARGET
|
||
单个域名或者每行一个域名的文件路径(必需参数)
|
||
|
||
FLAGS
|
||
--brute=BRUTE
|
||
使用爆破模块(默认False)
|
||
--verify=VERIFY
|
||
验证子域有效性(默认True)
|
||
--port=PORT
|
||
请求验证的端口范围(默认只探测80端口)
|
||
--valid=VALID
|
||
导出子域的有效性(默认1)
|
||
--path=PATH
|
||
导出路径(默认None)
|
||
--format=FORMAT
|
||
导出格式(默认xls)
|
||
--show=SHOW
|
||
终端显示导出数据(默认False)
|
||
```
|
||
|
||
2. **aiobrute.py使用帮助**
|
||
|
||
关于泛解析问题处理程序首先会访问一个随机的子域判断是否泛解析,如果使用了泛解析则是通过以下判断处理:
|
||
- 一是主要是与泛解析的IP集合和TTL值做对比,可以参考[这篇文章](http://sh3ll.me/archives/201704041222.txt)。
|
||
- 二是多次解析到同一IP集合次数(默认设置为10,可以在config.py设置大小)。
|
||
- 三是考虑爆破效率问题目前还没有加上HTTP响应体相似度对比和响应体内容判断,如果有必要后续添加。
|
||
经过不严谨测试在16核心的CPU,使用16进程64协程,100M带宽的环境下,设置任务分割为50000,跑两百万字典大概10分钟左右跑完,大概3333个子域每秒。
|
||
|
||
```bash
|
||
python aiobrute.py --help
|
||
```
|
||
|
||
```bash
|
||
NAME
|
||
aiobrute.py - OneForAll多进程多协程异步子域爆破模块
|
||
|
||
SYNOPSIS
|
||
aiobrute.py --target=TARGET <flags>
|
||
|
||
DESCRIPTION
|
||
Example:
|
||
python3 aiobrute.py --target example.com run
|
||
python3 aiobrute.py --target ./domains.txt run
|
||
python3 aiobrute.py --target example.com --process 4 --coroutine 64 run
|
||
python3 aiobrute.py --target example.com --wordlist subdomains.txt run
|
||
python3 aiobrute.py --target example.com --recursive True --depth 2 run
|
||
python3 aiobrute.py --target m.{fuzz}.a.bz --fuzz True --rule [a-z] run
|
||
|
||
Note:
|
||
参数segment的设置受CPU性能,网络带宽,运营商限制等问题影响,默认设置500个子域为任务组,
|
||
当你觉得你的环境不受以上因素影响,当前爆破速度较慢,那么强烈建议根据字典大小调整大小:
|
||
十万字典建议设置为5000,百万字典设置为50000
|
||
参数valid可选值1,0,None,分别表示导出有效,无效,全部子域
|
||
参数format可选格式有'txt', 'rst', 'csv', 'tsv', 'json', 'yaml', 'html',
|
||
'jira', 'xls', 'xlsx', 'dbf', 'latex', 'ods'
|
||
参数path为None会根据format参数和域名名称在项目结果目录生成相应文件
|
||
|
||
ARGUMENTS
|
||
TARGET
|
||
单个域名或者每行一个域名的文件路径
|
||
|
||
FLAGS
|
||
--process=PROCESS
|
||
爆破的进程数(默认CPU核心数)
|
||
--coroutine=COROUTINE
|
||
每个爆破进程下的协程数(默认64)
|
||
--wordlist=WORDLIST
|
||
指定爆破所使用的字典路径(默认使用config.py配置)
|
||
--segment=SEGMENT
|
||
爆破任务分割(默认500)
|
||
--recursive=RECURSIVE
|
||
是否使用递归爆破(默认False)
|
||
--depth=DEPTH
|
||
递归爆破的深度(默认2)
|
||
--namelist=NAMELIST
|
||
指定递归爆破所使用的字典路径(默认使用config.py配置)
|
||
--fuzz=FUZZ
|
||
是否使用fuzz模式进行爆破(默认False,开启须指定fuzz正则规则)
|
||
--rule=RULE
|
||
fuzz模式使用的正则规则(默认使用config.py配置)
|
||
--export=EXPORT
|
||
是否导出爆破结果(默认True)
|
||
--valid=VALID
|
||
导出子域的有效性(默认None)
|
||
--format=FORMAT
|
||
导出格式(默认xls)
|
||
--path=PATH
|
||
导出路径(默认None)
|
||
--show=SHOW
|
||
终端显示导出数据(默认False)
|
||
```
|
||
|
||
3. 其他模块使用请参考[使用帮助](https://github.com/shmilylty/OneForAll/tree/master/docs/using_help.md)
|
||
|
||
## 👏主要框架
|
||
|
||
* [aiodns](https://github.com/saghul/aiodns) - 简单DNS异步解析库。
|
||
* [aiohttp](https://github.com/aio-libs/aiohttp) - 异步http客户端/服务器框架
|
||
* [aiomultiprocess](https://github.com/jreese/aiomultiprocess) - 将Python代码提升到更高的性能水平(multiprocessing和asyncio结合,实现异步多进程多协程)
|
||
* [beautifulsoup4](https://pypi.org/project/beautifulsoup4/) - 可以轻松从HTML或XML文件中提取数据的Python库
|
||
* [fire](https://github.com/google/python-fire) - Python Fire是一个纯粹根据任何Python对象自动生成命令行界面(CLI)的库
|
||
* [loguru](https://github.com/Delgan/loguru) - 旨在带来愉快的日志记录Python库
|
||
* [records](https://github.com/kennethreitz/records) - Records是一个非常简单但功能强大的库,用于对大多数关系数据库进行最原始SQL查询。
|
||
* [requests](https://github.com/psf/requests) - Requests 唯一的一个非转基因的 Python HTTP 库,人类可以安全享用。
|
||
* [tqdm](https://github.com/tqdm/tqdm) - 适用于Python和CLI的快速,可扩展的进度条库
|
||
|
||
感谢这些伟大优秀的Python库!
|
||
|
||
## 🌲目录结构
|
||
|
||
```bash
|
||
D:.
|
||
|
|
||
+---.github
|
||
+---docs
|
||
| collection_modules.md 收集模块说明
|
||
+---images
|
||
\---oneforall
|
||
| aiobrute.py 异步多进程多协程子域爆破模块,可以单独运行
|
||
| collect.py 各个收集模块上层调用
|
||
| config.py 配置文件
|
||
| dbexport.py 数据库导出模块,可以单独运行
|
||
| domains.txt 要批量爆破的域名列表
|
||
| oneforall.py OneForAll主入口,可以单独运行
|
||
| __init__.py
|
||
|
|
||
+---common 公共调用模块
|
||
+---data 存放一些所需数据
|
||
| next_subdomains.txt 下一层子域字典
|
||
| public_suffix_list.dat 顶级域名后缀
|
||
| srv_names.json 常见SRV记录前缀名
|
||
| subdomains.txt 子域爆破常见字典
|
||
|
|
||
\---modules
|
||
+---certificates 利用证书透明度收集子域模块
|
||
+---check 常规检查收集子域模块
|
||
+---crawl 利用网上爬虫档案收集子域模块
|
||
+---datasets 利用DNS数据集收集子域模块
|
||
+---dnsquery 利用DNS查询收集子域模块
|
||
+---intelligence 利用威胁情报平台数据收集子域模块
|
||
\---search 利用搜索引擎发现子域模块
|
||
|
||
```
|
||
|
||
## 🙏贡献
|
||
|
||
非常热烈欢迎各位大佬一起完善本项目!
|
||
|
||
## ⌛后续计划
|
||
|
||
- [ ] 各模块持续优化和完善
|
||
- [x] 子域监控(标记每次新发现的子域)
|
||
- [ ] 子域收集爬虫实现(包括从JS等静态资源文件中收集子域)
|
||
- [ ] 操作强大交互人性的前端界面实现(暂定:前端:Element + 后端:Flask)
|
||
|
||
更多详细信息请阅读[TODO.md](https://github.com/shmilylty/OneForAll/tree/master/TODO.md)。
|
||
|
||
## 🔖版本控制
|
||
|
||
该项目使用[SemVer](https://semver.org/)语言化版本格式进行版本管理,你可以在[Releases](https://github.com/shmilylty/OneForAll/releases)查看可用版本。
|
||
|
||
## 👨💻贡献者
|
||
|
||
* **[Jing Ling](https://github.com/shmilylty)**
|
||
* 核心开发
|
||
|
||
* **[Black Star](https://github.com/blackstar24)**,**[Echocipher](https://github.com/Echocipher)**
|
||
* 模块贡献
|
||
|
||
* **[iceMatcha](https://github.com/iceMatcha)**,**[mikuKeeper](https://github.com/mikuKeeper)**
|
||
* 工具测试
|
||
|
||
* **Anyone**
|
||
* 工具反馈
|
||
|
||
你可以在[CONTRIBUTORS.md](https://github.com/shmilylty/OneForAll/tree/master/CONTRIBUTORS.md)中参看所有参与该项目的开发者。
|
||
|
||
## 📄版权
|
||
|
||
该项目签署了GPL-3.0授权许可,详情请参阅[LICENSE](https://github.com/shmilylty/OneForAll/LICENSE)。
|
||
|
||
## 😘鸣谢
|
||
|
||
感谢网上开源的各个子域收集项目!
|
||
|
||
感谢[A-Team](https://github.com/QAX-A-Team)大哥们热情无私的问题解答!
|
||
|
||
## 📜免责声明 ##
|
||
|
||
本工具仅限于合法授权的企业安全建设,在使用本工具过程中,您应确保自己所有行为符合当地的法律法规,并且已经取得了足够的授权。
|
||
如您在使用本工具的过程中存在任何非法行为,您需自行承担所有后果,本工具所有作者和所有贡献者不承担任何法律及连带责任。
|
||
除非您已充分阅读、完全理解并接受本协议所有条款,否则,请您不要安装并使用本工具。
|
||
您的使用行为或者您以其他任何明示或者默示方式表示接受本协议的,即视为您已阅读并同意本协议的约束。
|