GithubHelp home page GithubHelp logo

aabysszg / springboot-scan Goto Github PK

View Code? Open in Web Editor NEW
1.4K 12.0 131.0 3.21 MB

针对SpringBoot的开源渗透框架,以及Spring相关高危漏洞利用工具

Home Page: https://blog.zgsec.cn/archives/129.html

License: MIT License

Python 100.00%
spring spring-boot spring-vulnerability springboot vul security security-tools cve-2018-1273 cve-2021-21234 cve-2022-22947

springboot-scan's Introduction

SpringBoot-Scan

✈️ 一、工具概述

日常渗透过程中,经常会碰到Spring Boot搭建的微服务,于是就想做一个针对Spring Boot的开源渗透框架,主要用作扫描Spring Boot的敏感信息泄露端点,并可以直接测试Spring的相关高危漏洞。于是,就写了这么一个工具:SpringBoot-Scan 【简称:“SB-Scan”(错乱】

当前工具版本号:V2.51-2024/05/19

我还整理了一篇SpringBoot的相关渗透姿势在我的个人博客,欢迎各位师傅前来交流哈哈:https://blog.zgsec.cn/archives/129.html

📝 二、TODO

漏洞支持的更新

  • 添加支持2023 JeeSpringCloud 任意文件上传漏洞
  • 添加支持CVE-2022-22947 (Spring Cloud Gateway SpELRCE漏洞)
  • 添加支持CVE-2022-22963 (Spring Cloud Function SpEL RCE漏洞)
  • 添加支持CVE-2022-22965 (Spring Core RCE漏洞)
  • 添加支持CVE-2021-21234 (任意文件读取漏洞)
  • 添加支持2021 SnakeYAML_RCE 漏洞
  • 添加支持2021 Eureka_Xstream 反序列化漏洞
  • 添加支持2020 Jolokia配置不当导致RCE漏洞
  • 添加支持CVE-2018-1273(Spring Data Commons RCE漏洞)
  • 增加漏洞利用选择模块,可以选择单一或多个漏洞进行检测
  • 命令执行漏洞式支持交互式执行命令
  • 增加批量漏洞验证模块(你们一直想要的来啦)

后期将加入更多漏洞利用内置模块(各位师傅能不能赏个Star嘛~ 码代码挺辛苦的哈哈)

功能支持的更新

  • 感谢 @Viking 师傅,增加了部分 Dir.txt 敏感端点爆破字典的内容
  • 感谢 @Fkalis 师傅,使用 aiohttp 对批量信息泄露扫描进行并发处理,大大提高 -uf 参数的扫描速度
  • 新增支持多个参数自定义HTTP头部(请求头)进行操作,功能实现啦,快来试试吧~
  • 新增支持资产测绘导出的时候自定义查询语句,更加灵活的导出目标资产数据
  • 新增在敏感端点爆破爆破(单一和批量)的时候进行延时扫描,防止扫描速度太快被拦截
  • 新增 Hunter资产测绘 导出模块,自动对接API接口将资产导出至 hunterout.txt
  • 新增 Fofa资产测绘 导出模块,自动对接API接口将资产导出至 fofaout.txt
  • 新增 ZoomEye资产测绘 导出模块,自动对接API接口将资产导出至 zoomout.txt
  • 在Spring端点爆破的时候,新增过滤一些无效回显的页面,提高工作效率
  • 对端点爆破字典进行优化,增加一些绕过语句,如果有补充欢迎提交
  • 支持自动对Spring进行指纹识别
  • 在漏洞利用模块,对错误进行输出为 error.log
  • 支持使用带认证的HTTP代理节点,自动检测节点状态
  • 13exp 师傅友情制作GUI图形化版本
  • 验证代理是否存活,并可以使用HTTP代理认证,支持使用HTTP/HTTPS代理所有流量
  • 随机User-Agent请求头
  • 解决SSL证书问题 (自签名证书请改成 http:// 即可)
  • 智能识别目标地址 (example.comhttp://example.com/ 以及http://example.com 都不会报错)

注明

  • 本工具优化了使用者体验,不管是对单一URL扫描还是读取TXT进行批量扫描,example.comhttp://example.com/ 以及http://example.com 都不会报错,程序会自行判断并识别
  • 解决了SSL证书问题,可以对采用SSL证书的Spring Boot框架进行扫描(自签名证书请改成 http:// 即可)
  • 对于二级目录部署的Spring项目,直接给工具相应的路径就行了(比如 example.com/test/ 这个路径部署了Spring项目,那直接将 example.com/test/ 传参给工具就行了)

GUI图形化版本,由 @13exp 师傅友情制作,GUI地址:https://github.com/13exp/SpringBoot-Scan-GUI

GUI

注:因为本项目的 vul.py 和GUI项目均包含漏洞利用模块,杀软报毒和查杀为正常情况。如果觉得工具不错,师傅们可以点个Star哈哈~

🚨 三、安装Python依赖库

pip install -r requirements.txt

如果pip安装速度慢,可以采用国内源进行安装:

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

🐉 四、工具使用

如何找到互联网上的Spring框架,ZoomEye语法如下:

app:"Spring Framework"

Fofa语法如下:

icon_hash="116323821"||body="Whitelabel Error Page"

本工具的参数如下:

# python3 SpringBoot-Scan.py
  ______                       __                      _______                        __     
 /      \                     |  \                    |       \                      |  \    
|  $$$$$$\  ______    ______   \$$ _______    ______  | $$$$$$$\  ______    ______  _| $$_   
| $$___\$$ /      \  /      \ |  \|       \  /      \ | $$__/ $$ /      \  /      \|   $$ \  
 \$$    \ |  $$$$$$\|  $$$$$$\| $$| $$$$$$$\|  $$$$$$\| $$    $$|  $$$$$$\|  $$$$$$\\$$$$$$  
 _\$$$$$$\| $$  | $$| $$   \$$| $$| $$  | $$| $$  | $$| $$$$$$$\| $$  | $$| $$  | $$ | $$ __ 
|  \__| $$| $$__/ $$| $$      | $$| $$  | $$| $$__| $$| $$__/ $$| $$__/ $$| $$__/ $$ | $$|  \
 \$$    $$| $$    $$| $$      | $$| $$  | $$ \$$    $$| $$    $$ \$$    $$ \$$    $$  \$$  $$
  \$$$$$$ | $$$$$$$  \$$       \$$ \$$   \$$ _\$$$$$$$ \$$$$$$$   \$$$$$$   \$$$$$$    \$$$$ 
          | $$                              |  \__| $$                                       
          | $$                               \$$    $$                                       
           \$$                                \$$$$$$                                        
            ______                                                                           
           /      \                                  +-------------------------------------+ 
          |  $$$$$$\  _______  ______   _______      + Version: 2.51                       + 
          | $$___\$$ /       \|      \ |       \     + Author: 曾哥(@AabyssZG)             + 
           \$$    \ |  $$$$$$$ \$$$$$$\| $$$$$$$\    + Whoami: https://github.com/AabyssZG + 
           _\$$$$$$\| $$      /      $$| $$  | $$    +-------------------------------------+ 
          |  \__| $$| $$_____|  $$$$$$$| $$  | $$    + 多进程速度提升: Fkalis              + 
           \$$    $$ \$$     \\$$    $$| $$  | $$    + Whoami: https://github.com/FFR66    + 
            \$$$$$$   \$$$$$$$ \$$$$$$$ \$$   \$$    +-------------------------------------+ 

用法:
        对单一URL进行信息泄露扫描:         python3 SpringBoot-Scan.py -u example.com
        读取目标TXT进行批量信息泄露扫描:    python3 SpringBoot-Scan.py -uf url.txt
        对单一URL进行漏洞利用:             python3 SpringBoot-Scan.py -v example.com
        读取目标TXT进行批量漏洞扫描:      python3 SpringBoot-Scan.py -vf url.txt
        扫描并下载SpringBoot敏感文件:      python3 SpringBoot-Scan.py -d example.com
        使用HTTP代理并自动进行连通性测试:    python3 SpringBoot-Scan.py -p <代理IP:端口>
        从TXT文件中导入自定义HTTP头部:       python3 SpringBoot-Scan.py -t header.txt
        通过ZoomEye密钥进行API下载数据:      python3 SpringBoot-Scan.py -z <ZoomEye的API-KEY>
        通过Fofa密钥进行API下载数据:         python3 SpringBoot-Scan.py -f <Fofa的API-KEY>
        通过Hunter密钥进行API下载数据:       python3 SpringBoot-Scan.py -y <Hunter的API-KEY>

🛸 五、工具演示

0# Spring资产测绘

通过ZoomEye进行Spring资产测绘

本工具专门对接了 ZoomEye的API接口,使用API-KEY即可批量下载Spring的资产测绘数据:

python3 SpringBoot-Scan.py -z <ZoomEye的API-KEY>

ZoomEye

注:目前该模块已经支持自定义语法的资产测绘导出;资产测绘结束后,会把通过API下载的结果导出到 zoomout.txt,就可以使用其他参数进行操作啦

通过Fofa进行Spring资产测绘

本工具专门对接了 Fofa的API接口,使用API-KEY即可批量下载Spring的资产测绘数据:

python3 SpringBoot-Scan.py -f <Fofa的API-KEY>

Fofa

注:目前该模块已经支持自定义语法的资产测绘导出;资产测绘结束后,会把通过API下载的结果导出到 fofaout.txt,就可以使用其他参数进行操作啦

通过Hunter鹰图进行Spring资产测绘

本工具专门对接了 鹰图的API接口,使用API-KEY即可批量下载Spring的资产测绘数据:

python3 SpringBoot-Scan.py -y <Hunter的API-KEY>

Hunter

注:目前该模块已经支持自定义语法的资产测绘导出;资产测绘结束后,会把通过API下载的结果导出到 hunterout.txt,就可以使用其他参数进行操作啦

1# 测试并使用代理和自定义HTTP头部

测试并使用代理

python3 SpringBoot-Scan.py -p <代理IP:端口>
python3 SpringBoot-Scan.py -p <HTTP认证账号:HTTP认证密码@代理IP:端口>

测试代理

比如我想对单一URL进行信息泄露扫描并使用代理

python3 SpringBoot-Scan.py -u example.com -p <代理IP:端口>
python3 SpringBoot-Scan.py -p <HTTP认证账号:HTTP认证密码@代理IP:端口>

同样,其他参数(-u / -uf / -v / -vf / -d)均可以配合代理使用

测试并使用自定义HTTP头部(自定义请求头)

python3 SpringBoot-Scan.py -t header.txt

Headers

使用该自定义HTTP头部功能请自行更改 header.txt 内的内容,允许(-u / -uf / -v / -d)参数使用,因为批量漏洞扫描没有明确需求故没加入该功能

2# 对单一URL进行敏感端点爆破

Dir.txt 为内置的Spring端点爆破字典,我基本收集齐了Spring Boot的相关敏感信息泄露端点

如果有遗漏,欢迎各位师傅跟我联系哈哈

python3 SpringBoot-Scan.py -u example.com

扫描单一URL

新增延时扫描选项,如果不想延时扫描输入 0 回车即可

注:扫描结束后,会把成功的结果导出为同目录下的 urlout.txt

3# 读取目标TXT进行批量信息泄露扫描

python3 SpringBoot-Scan.py -uf url.txt

读取TXT并批量扫描

新增延时扫描选项,如果不想延时扫描输入 0 回车即可;感谢 @Fkalis 师傅,新增并发扫描选项,默认并发数为10

注:由于版本更新,在2.21版本之后,读取TXT并扫描的参数改为 uf,扫描结束后,会把成功的结果导出为同目录下的 output.txt

4# 对单一URL进行漏洞利用

python3 SpringBoot-Scan.py -v example.com

对单一URL进行漏洞利用

已经实现RCE漏洞,命令自定义功能(不要拿去干坏事哦)

同时,后期将加入更多漏洞利用内置模块,请师傅们敬请期待~

5# 读取目标TXT进行批量漏洞扫描

python3 SpringBoot-Scan.py -vf url.txt

Poc

可以自由选择漏洞库里面的漏洞进行批量验证,扫描结束后将导出成功的内容至 vulout.txt

6# 扫描并下载SpringBoot敏感文件

python3 SpringBoot-Scan.py -d example.com

扫描并下载SpringBoot敏感文件

注:扫描到的敏感文件,会自动下载到脚本的运行目录,有进度条可以看到实时下载进度

目前敏感文件目录内置了5个,如下:

actuator/heapdump
gateway/actuator/heapdump
heapdump
heapdump.json
hystrix.stream
artemis-portal/artemis/heapdump

如果有师傅有其他敏感文件的目录,可以提交issues,谢谢!!!

🖐 六、免责声明

  1. 如果您下载、安装、使用、修改本工具及相关代码,即表明您信任本工具
  2. 在使用本工具时造成对您自己或他人任何形式的损失和伤害,我们不承担任何责任
  3. 如您在使用本工具的过程中存在任何非法行为,您需自行承担相应后果,我们将不承担任何法律及连带责任
  4. 请您务必审慎阅读、充分理解各条款内容,特别是免除或者限制责任的条款,并选择接受或不接受
  5. 除非您已阅读并接受本协议所有条款,否则您无权下载、安装或使用本工具
  6. 您的下载、安装、使用等行为即视为您已阅读并同意上述协议的约束

🙏 七、感谢各位师傅

Stargazers

Stargazers repo roster for @AabyssZG/SpringBoot-Scan

Forkers

Forkers repo roster for @AabyssZG/SpringBoot-Scan

Star History

Star History Chart

springboot-scan's People

Contributors

aabysszg avatar ffr66 avatar vk2000 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

springboot-scan's Issues

缺少代理

可以把延迟、和代理开发以下么 我看 使用的requests包 应该可以实现 有时候会卡
image

CVE_2022_22947漏报

师傅的漏洞检测逻辑是访问注册的hacktest路由,读取id命令的回显,但是这个只使用于linux系统,看师傅内置了payload2用于执行whoami,但是并没有针对windows漏洞检测逻辑,如果Spring Cloud Gateway部署在windows上,漏洞会误报。
而且师傅的逻辑是只要读取到id的回显时,才会删除注册的hacktest路由
if ('uid=' in str(re3.text)) and ('gid=' in str(re3.text)) and ('groups=' in str(re3.text)):
cprint(f'[+] [CVE-2022-22947] {url}', "red")
f2 = open("vulout.txt", "a")
f2.write("[+] [CVE-2022-22947] " + url + '\n')
f2.close()
re4 = requests.delete(url=url + "actuator/gateway/routes/hacktest", headers=headers2, timeout=10 ,verify=False, proxies=proxies)
re5 = requests.post(url=url + "actuator/gateway/refresh", headers=headers2, timeout=10 ,verify=False, proxies=proxies)
但是如果是windows平台,由于执行的是id命令,java.lang.ProcessBuilder.start会抛出异常,也就走不到删除路由的逻辑了,导致注册的路由持久性的留着了服务器上面,渗透结束后,需要手工清除,可以调整一下逻辑。官方补丁中是用SimpleEvaluationContext 替换 StandardEvaluationContext,限制了SPEL表达式的执行,并没有限制路由注册。

还有一个问题就是,SPEL表达式执行发生在/refresh刷新路由缓存逻辑的时候,后续所有正常的/refresh操作也会抛出异常,影响服务器正常功能以及其它扫描器对CVE_2022_22947漏洞的探测

扫描报错

在扫描时发生错误,实际上应该存在这个目录,用其他扫描工具是正常的
111

SpringBoot-Scan的一些建议

你好,作者!
我觉得这个脚本是不是可以添加一些爬虫功能 而不是只爆破字典中的内容 比如一些spring未授权环境下 访问/actuator/ 里面会有一些非字典中的内容如 /actuator/nacosconfig 、/actuator/nacosdiscovery等 这种情况下感觉加上爬虫爬取/actuator/会好一些

error

requests.exceptions.ConnectionError: HTTPConnectionPool(host='spring-dev-vab.apps.grv.scbs.ch', port=80): Max retries exceeded with url: /actuator (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc216eb1160>: Failed to establish a new connection: [Errno 111] Connection refused'))

I think you have to wait for 10 second if not response then you have to move other target

安装库后,还是报错

Traceback (most recent call last):
File "E:\Tools\SpringBoot-Scan-main\SpringBoot-Scan.py", line 7, in
from inc import output, console, run ,proxycheck
File "E:\Tools\SpringBoot-Scan-main\inc\console.py", line 4, in
from inc import output,run,vul,springcheck
File "E:\ools\SpringBoot-Scan-main\inc\springcheck.py", line 4, in
from inc import output,run,vul,console
ImportError: cannot import name 'vul' from 'inc' (unknown location)

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.