打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
【Tips】对于Spring Boot的渗透姿势
userphoto

2023.07.21 广东

关注
Tips+1
0# Spring Boot概述
Spring Boot 是由Pivotal团队提供的全新框架,其设计目的是用来简化 Spring 应用的创建、运行、调试、部署等。使用 Spring Boot 可以做到专注于 Spring 应用的开发,而无需过多关注 XML 的配置。Spring Boot 使用“习惯优于配置”的理念,简单来说,它提供了一堆依赖打包,并已经按照使用习惯解决了依赖问题。使用 Spring Boot 可以不用或者只需要很少的 Spring 配置就可以让企业项目快速运行起来。
Spring Boot 是开发者和 Spring 本身框架的中间层,帮助开发者统筹管理应用的配置,提供基于实际开发中常见配置的默认处理(即习惯优于配置),简化应用的开发,简化应用的运维;总的来说,其目的 Spring Boot 就是为了对 Java web 的开发进行“简化”和加“快”速度,简化开发过程中引入或启动相关 Spring 功能的配置。这样带来的好处就是降低开发人员对于框架的关注点,可以把更多的精力放在自己的业务代码上。
1# Spring Boot Actuator概述
Actuator 是 Spring Boot 提供的用来对应用系统进行自省和监控的功能模块,借助于 Actuator 开发者可以很方便地对应用系统某些监控指标进行查看、统计等。
Actuator 的核心是端点 Endpoint,它用来监视应用程序及交互,spring-boot-actuator 中已经内置了非常多的 Endpoint(health、info、beans、metrics、httptrace、shutdown等等),同时也允许我们自己扩展自己的 Endpoints。每个 Endpoint 都可以启用和禁用。要远程访问 Endpoint,还必须通过 JMX 或 HTTP 进行暴露,大部分应用选择HTTP。
Actuator 在带来方便的同时,如果没有管理好,会导致一些敏感的信息泄露;可能会导致我们的服务器,被暴露到外网,服务器可能会沦陷。
2# Spring Boot框架的识别
2.1 通过icon图标进行识别
Fofa语法如下:
icon_hash='116323821'
可以搜索到25万条左右的资产数据,说明Spring Boot框架是应用广泛哈哈~
(其中还有很多服务更改了默认的ico图标,所以这个语法找不到)
2.2 通过网页内容进行识别
Fofa语法如下:
body='Whitelabel Error Page'
哈哈,这个更夸张了,可以搜索到141万条左右的资产数据
以下是 Spring Boot 框架的典型特征:
所以可以通过Fofa对网页的body内容进行搜索找到那么多的资产
3# Spring Boot框架 敏感信息泄露
如果对 Spring Boot 框架熟悉的师傅,肯定知道对 Spring Boot 的渗透测试过程中,肯定不会少了敏感信息泄露和未授权访问相关的漏洞
不同版本分类讨论
Spring Boot < 1.5:默认未授权访问所有端点、
Spring Boot >= 1.5:默认只允许访问 /health 和 /info 端点,但是此安全性通常被应用程序开发人员禁用了
3.1 常见端点及其作用:
路径是否默认启用功能描述
/auditevents是显示当前应用程序的审计事件信息
/beans是显示一个应用中所有Spring Beans的完整列表
/conditions是显示配置类和自动配置类的状态及它们被应用或未被应用的原因
/configprops是显示一个所有@ConfigurationProperties的集合列表
/env是显示来自Spring的 ConfigurableEnvironment的属性
/flyway是显示数据库迁移路径(如果存在)
/health是显示应用的健康信息(当使用一个未认证连接访问时显示一个简单的’status’,使用认证连接访问则显示全部信息详情)
/info是显示任意的应用信息
/liquibase是展示任何Liquibase数据库迁移路径(如果存在)
/metrics是展示当前应用的metrics信息
/mappings是显示一个所有@RequestMapping路径的集合列表
/scheduledtasks是显示应用程序中的计划任务
/sessions否允许从Spring会话支持的会话存储中检索和删除用户会话
/shutdown否允许应用以优雅的方式关闭(默认情况下不启用)
/threaddump是执行一个线程dump
/heapdump是返回一个GZip压缩的hprof堆dump文件
/jolokia是通过HTTP暴露JMX beans(当Jolokia在类路径上时,WebFlux不可用)
/logfile是返回日志文件内容(如果设置了logging.file或logging.path属性的话),支持使用HTTP Range头接收日志文件内容的部分信息
/prometheus是以可以被Prometheus服务器抓取的格式显示metrics信息
独家字典
于是,我这里独家整理了一份信息泄露字典(欢迎补充哈哈)
actuator
actuator/auditLog
actuator/auditevents
actuator/autoconfig
actuator/beans
actuator/caches
actuator/conditions
actuator/configurationMetadata
actuator/configprops
actuator/dump
actuator/env
actuator/events
actuator/exportRegisteredServices
actuator/features
actuator/flyway
actuator/health
actuator/heapdump
actuator/healthcheck
actuator/heapdump
actuator/httptrace
actuator/hystrix.stream
actuator/info
actuator/integrationgraph
actuator/jolokia
actuator/logfile
actuator/loggers
actuator/loggingConfig
actuator/liquibase
actuator/metrics
actuator/mappings
actuator/scheduledtasks
actuator/swagger-ui.html
actuator/prometheus
actuator/refresh
actuator/registeredServices
actuator/releaseAttributes
actuator/resolveAttributes
actuator/scheduledtasks
actuator/sessions
actuator/springWebflow
actuator/shutdown
actuator/sso
actuator/ssoSessions
actuator/statistics
actuator/status
actuator/threaddump
actuator/trace
auditevents
autoconfig
api.html
api/index.html
api/swagger-ui.html
api/v2/api-docs
api-docs
beans
caches
cloudfoundryapplication
conditions
configprops
distv2/index.html
docs
druid/index.html
druid/login.html
druid/websession.html
dubbo-provider/distv2/index.html
dump
entity/all
env
env/(name)
eureka
flyway
gateway/actuator
gateway/actuator/auditevents
gateway/actuator/beans
gateway/actuator/conditions
gateway/actuator/configprops
gateway/actuator/env
gateway/actuator/health
gateway/actuator/heapdump
gateway/actuator/httptrace
gateway/actuator/hystrix.stream
gateway/actuator/info
gateway/actuator/jolokia
gateway/actuator/logfile
gateway/actuator/loggers
gateway/actuator/mappings
gateway/actuator/metrics
gateway/actuator/scheduledtasks
gateway/actuator/swagger-ui.html
gateway/actuator/threaddump
gateway/actuator/trace
health
heapdump
heapdump.json
httptrace
hystrix
hystrix.stream
info
integrationgraph
jolokia
jolokia/list
liquibase
list
logfile
loggers
liquibase
metrics
mappings
monitor
prometheus
refresh
scheduledtasks
sessions
shutdown
spring-security-oauth-resource/swagger-ui.html
spring-security-rest/api/swagger-ui.html
static/swagger.json
sw/swagger-ui.html
swagger
swagger/codes
swagger/index.html
swagger/static/index.html
swagger/swagger-ui.html
swagger-dubbo/api-docs
swagger-ui
swagger-ui.html
swagger-ui/html
swagger-ui/index.html
system/druid/index.html
threaddump
template/swagger-ui.html
trace
user/swagger-ui.html
version
v1.1/swagger-ui.html
v1.2/swagger-ui.html
v1.3/swagger-ui.html
v1.4/swagger-ui.html
v1.5/swagger-ui.html
v1.6/swagger-ui.html
v1.7/swagger-ui.html
/v1.8/swagger-ui.html
/v1.9/swagger-ui.html
/v2.0/swagger-ui.html
v2.1/swagger-ui.html
v2.2/swagger-ui.html
v2.3/swagger-ui.html
v2/swagger.json
webpage/system/druid/index.html
%20/swagger-ui.html
3.2 端点的敏感信息泄露样例
这里先安利一款谷歌浏览器插件哈,名字叫 JSON Viewer ,可以美化JSON的相关页面
注意,以下测试均是在Fofa上找的实例,漏洞其实离我们并不遥远
3.2.1 访问/actuator
如果设置了 management.endpoints.web.exposure.include 为 *,就可以在 /actuator 看到所有存在的端点,截图如下:
3.2.2 访问/actuator/version
会泄露一些相关的版本信息
但这个目前很少有泄露了,一时半会没找到实例
3.2.3 访问/env或者/actuator/env
可能会泄露数据库账号密码等敏感信息
针对env这种路径下泄露的密码会用星号进行脱敏,想要获取相应的明文密码,可以尝试通过分析heapdump数据的方式
3.2.4 访问/actuator/metrics
获得每个度量的名称,其中主要监控了JVM内容使用、GC情况、类加载信息等
如果想要得到每个度量的详细信息,需要传递度量的名称到URL中,如下
http://xx.xx.xx.xx/actuator/metrics/http.server.requests
3.2.5 访问/actuator/threaddump
获取服务器的线程堆栈信息
3.2.6 访问/actuator/loggers
获取服务器的日志级别
3.2.7 访问/actuator/configprops
查看配置文件中设置的属性内容,以及一些配置属性的默认值
3.2.8 访问/actuator/info
展示了关于应用的一般信息,这些信息从编译文件比如 META-INF/build-info.properties 或者 git 文件比如 git.properties 或者任何环境的 property 中获取
3.2.9 访问/actuator/mappings
响应信息描述全部的URI路径,以及它们和控制器的映射关系
3.2.10 访问/actuator/health
health一般只展示了简单的UP和DOWN状态,比如这样:
为了获得健康检查中所有指标的详细信息,就需要通过在 application.yaml 中增加如下内容:
management:
endpoint:
health:
show-details: always
一旦打开上述开关,那么在 /health 中可以看到详细内容,比如下面这样
{
'status': 'UP',
'diskSpace': {
'status': 'UP',
'total': 209715195904,
'free': 183253909504,
'threshold': 10485760
}
'db': {
'status': 'UP',
'database': 'MySQL',
'hello': 1
}
}3.2.11 访问/heapdump或者/actuator/heapdump
Heap Dump也叫堆转储文件,是一个Java进程在某个时间点上的内存快照
Heap Dump是有着多种类型的,不过总体上heap dump在触发快照的时候都保存了java对象和类的信息
通常在写heap dump文件前会触发一次FullGC,所以heap dump文件中保存的是FullGC后留下的对象信息。其中可能会含有敏感数据,如数据库的密码明文等
直接访问路径会返回一个GZip压缩的JVM堆dump,其中是jvm heap信息。下载的heapdump文件大小通常在 50M—500M 之间,有时候也可能会大于 2G
下载完成之后可以借助一些工具对其中的数据进行内容检索,寻找敏感信息
Eclipse Memory Analyzer(MAT)
heapdump_tool
JDumpSpider
都有参考文章,可以自行研究
4# SpringBoot-Scan的使用
日常渗透过程中,经常会碰到Spring Boot搭建的微服务,于是就想做一个针对Spring Boot的开源渗透框架
主要用作扫描SpringBoot的敏感信息泄露端点,并可以直接测试Spring Boot的相关高危漏洞。
于是,就写了这么一个工具:SpringBoot-Scan 【简称:“SB-Scan”(错乱】
开源地址:https://github.com/AabyssZG/SpringBoot-Scan
原文链接:https://blog.zgsec.cn/index.php/archives/129/
End
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Spring Boot 面试题
推荐一款 Java 零注解 API 文档生成工具
Spring Boot 集成 Swagger,再也不写接口文档了!
【安全鉴权】Spring Boot Actuator如何进行安全鉴权?还得是这样。
「Spring Boot 2.4 新特性」启动耗时详细监控
新出 SpringBoot 2.5 更新功能变动说明
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服