首页 > 其他分享 >对于Spring Boot的渗透姿势

对于Spring Boot的渗透姿势

时间:2024-07-20 22:18:10浏览次数:7  
标签:渗透 Spring Boot html ui actuator swagger

0# Spring Boot概述
Spring Boot 是由Pivotal团队提供的全新框架,其设计目的是用来简化 Spring 应用的创建、运行、调试、部署等。使用 Spring Boot 可以做到专注于 Spring 应用的开发,而无需过多关注 XML 的配置。Spring Boot 使用“习惯优于配置”的理念,简单来说,它提供了一堆依赖打包,并已经按照使用习惯解决了依赖问题。使用 Spring Boot 可以不用或者只需要很少的 Spring 配置就可以让企业项目快速运行起来。

springboot-title.png

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"
Fofa语法搜索icon.png

可以搜索到25万条左右的资产数据,说明Spring Boot框架是应用广泛哈哈~
(其中还有很多服务更改了默认的ico图标,所以这个语法找不到)

2.2 通过网页内容进行识别
Fofa语法如下:

body="Whitelabel Error Page"
Fofa语法搜索body.png

哈哈,这个更夸张了,可以搜索到141万条左右的资产数据
以下是 Spring Boot 框架的典型特征:

SpringBoot典型特征.png

所以可以通过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的相关页面

JSON-Viewer.png

注意,以下测试均是在Fofa上找的实例,漏洞其实离我们并不遥远
3.2.1 访问/actuator
如果设置了 management.endpoints.web.exposure.include 为 *,就可以在 /actuator 看到所有存在的端点,截图如下:

访问actuator.png

3.2.2 访问/actuator/version
会泄露一些相关的版本信息
但这个目前很少有泄露了,一时半会没找到实例

3.2.3 访问/env或者/actuator/env
可能会泄露数据库账号密码等敏感信息

访问actuator-env.png

针对env这种路径下泄露的密码会用星号进行脱敏,想要获取相应的明文密码,可以尝试通过分析heapdump数据的方式

3.2.4 访问/actuator/metrics
获得每个度量的名称,其中主要监控了JVM内容使用、GC情况、类加载信息等

访问actuator-metrics.png

如果想要得到每个度量的详细信息,需要传递度量的名称到URL中,如下

http://xx.xx.xx.xx/actuator/metrics/http.server.requests
访问actuator-metrics-http.server.requests.png

3.2.5 访问/actuator/threaddump
获取服务器的线程堆栈信息

访问actuator-threaddump.png

3.2.6 访问/actuator/loggers
获取服务器的日志级别

访问actuator-loggers.png

3.2.7 访问/actuator/configprops
查看配置文件中设置的属性内容,以及一些配置属性的默认值

访问actuator-configprops.png

3.2.8 访问/actuator/info
展示了关于应用的一般信息,这些信息从编译文件比如 META-INF/build-info.properties 或者 git 文件比如 git.properties 或者任何环境的 property 中获取

3.2.9 访问/actuator/mappings
响应信息描述全部的URI路径,以及它们和控制器的映射关系

访问actuator-mappings.png

3.2.10 访问/actuator/health
health一般只展示了简单的UP和DOWN状态,比如这样:

访问actuator-health.png

为了获得健康检查中所有指标的详细信息,就需要通过在 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

访问actuator-threaddump.png

下载完成之后可以借助一些工具对其中的数据进行内容检索,寻找敏感信息

Eclipse Memory Analyzer(MAT)
heapdump_tool
JDumpSpider
都有参考文章,可以自行研究

4# SpringBoot-Scan的使用
日常渗透过程中,经常会碰到Spring Boot搭建的微服务,于是就想做一个针对Spring Boot的开源渗透框架

主要用作扫描SpringBoot的敏感信息泄露端点,并可以直接测试Spring Boot的相关高危漏洞。

SpringBoot-Scan截图title.png

于是,就写了这么一个工具:SpringBoot-Scan 【简称:“SB-Scan”(错乱】

开源地址:https://github.com/AabyssZG/SpringBoot-Scan

扫描单一URL.png

感觉不错的话,麻烦师傅点个Star啦~
有问题的话,也可以提交issues或者私聊我都行哈哈~

5# 参考链接
https://blog.csdn.net/u012206617/article/details/109010102
https://blog.csdn.net/m0_64867220/article/details/121728868
https://www.freebuf.com/vuls/289710.html

标签:渗透,Spring,Boot,html,ui,actuator,swagger
From: https://www.cnblogs.com/h1ck0r/p/18313896

相关文章

  • SpringAOP的简单介绍及入门案例
    文章目录一、AOP介绍二、使用步骤(日志案例)1.创建模块,导入依赖2.创建实体类3.创建业务层接口和实现类4.创建日志类5.配置切面6.创建配置类7.单元测试三、通知类型1.四大通知2.环绕通知四、切点表达式1.execution2.@annotation五、记录日志详情一、AOP介绍AOP(......
  • springboot的多环境配置
    文章目录一、多环境配置yml二、项目部署打成jar包一、多环境配置在实际开发中,项目的开发环境、测试环境中配置可能不一致,因此SpringBoot支持多环境配置java-jarxxx,jaryml这三个yml文件做配置这个一般为本地开发环境这个为生产环境这个为测试环境二、......
  • Spring boot + Mybatis 实现数据库的增删改查(CRUD)操作
    Springboot+Mybatis实现数据库的增删改查(CRUD)操作利用Springboot,我们可以快速构建Spring框架应用。利用Mybatis为Springboot提供的依赖,我们可以快捷地连接到MySQL,实现web项目对数据库的CRUD操作。一、创建项目在IDEA中新建maven项目,并在pom.xml......
  • 基于SpringBoot+Vue+uniapp的新闻资讯系统(源码+lw+部署文档+讲解等)
    文章目录前言详细视频演示具体实现截图技术栈后端框架SpringBoot前端框架Vue持久层框架MyBaitsPlus系统测试系统测试目的系统功能测试系统测试结论为什么选择我代码参考数据库参考源码获取前言......
  • bootstrap4登录注册页面
    <!DOCTYPEhtml><html><head><metacharset="utf-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><title>login</title><metaname="description"content......
  • bootstrap4注册页面
    <!DOCTYPEhtml><html><head><metacharset="utf-8"><metahttp-equiv="X-UA-Compatible"content="IE=edge"><title>register</title><metaname="description"co......
  • 揭秘@Autowired:手把手教你复刻Spring依赖注入魔法
    文章目录手写一个@Autowired注解实现自动注入@Autowired注解的作用@Autowired的实现原理手写一个@MyAutowired注解定义@MyAutowired注解创建注解处理器集成自定义处理器总结@Autowired主要功能@Autowired实现原理手写@MyAutowired注解注意事项手写一个@Autowir......
  • bootstrao文件
    /*====================================================================================================================Bootstrap4AdminTemplatehttps://bootstrapious.com/p/admin-template=====================================================================......
  • 类明显存在却报 package not found, Java程序中专门被其他工程所依赖的common jar用sp
    先上官方链接:https://docs.spring.io/spring-boot/docs/2.1.0.RELEASE/maven-plugin/examples/repackage-classifier.html在使用SpringBoot构建通用JAR库时,尤其是当通springboot默认的过spring-boot-maven-plugin插件打包时。如果遇到了类存在但报“packagenotfound......
  • 解决 SpringBoot 应用中 MySQL 时区配置引起的时间不一致问题
    在开发SpringBoot项目时,表中有两个时间字段一个通过Java代码使用newDate()方法获取当前时间再插入数据库另一个是使用MySQL的CURRENT_TIMESTAMP作为默认值实际运行时发现数据库中的这两个时间值不一致,代码插入的时间比数据库自动生成的时间早了8小时,最终发现是y......