Skip to content

Commit 5257abe

Browse files
committed
🍺 Java Sec 1.15
1 parent c224d71 commit 5257abe

Some content is hidden

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

97 files changed

+3969
-2337
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM java:8
22

33
VOLUME /tmp
44

5-
ADD ./target/javasec-1.7.jar app.jar
5+
ADD ./target/javasec-1.15.jar app.jar
66

77
EXPOSE 8888
88

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# ☕️ Hello Java Sec ![Stage](https://img.shields.io/badge/Release-DEV-brightgreen.svg) ![Build Status](https://img.shields.io/badge/Version-1.11-red.svg)
2-
> Java漏洞平台,结合漏洞代码和安全编码,帮助研发同学理解和减少漏洞,代码仅供参考
1+
# ☕️ Hello Java Sec ![Stage](https://img.shields.io/badge/Release-DEV-brightgreen.svg) ![Build Status](https://img.shields.io/badge/Version-1.15-red.svg)
32

4-
![](media/16304933749187.jpg)
3+
> Hello Java Security 通过结合漏洞场景和安全编码,帮助安全和研发团队理解漏洞原理,从而减少漏洞的产生,代码仅供参考 :)
54
5+
![](media/1.png)
66

77
- 默认账号:admin/admin
88

99
## Vulnerability
10+
1011
- [x] SQLi
1112
- [x] XSS
1213
- [x] RCE
13-
- [x] Deserialize
14+
- [x] Deserialization
1415
- [x] SSTI
1516
- [x] SpEL
1617
- [x] SSRF
18+
- [x] IDOR
1719
- [x] Directory Traversal
1820
- [x] Redirect
1921
- [x] CSRF
@@ -26,39 +28,50 @@
2628
- [x] JNDI
2729
- [x] Dos
2830
- [x] Xpath
31+
- [x] IPForgery
2932
- [x] Jwt
33+
- [x] Password Reset
3034
- [ ] more and more
3135

3236
![](media/16304936834843.jpg)
3337

3438
## Run
35-
### IDEA
36-
配置数据库连接,数据库文件`src/main/resources/db.sql`
39+
40+
### 配置数据库
41+
42+
导入数据库文件 `src/main/resources/db.sql`
43+
44+
配置数据库连接 `src/main/application.properties`
45+
3746
```
3847
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test
3948
spring.datasource.username=root
4049
spring.datasource.password=1234567
4150
```
4251

4352
### Jar运行
44-
> JDK 1.8环境
53+
54+
> JDK 1.8环境,高版本会报错
55+
4556
```
4657
git clone https://github.com/j3ers3/Hello-Java-Sec
4758
cd Hello-Java-Sec
4859
mvn clean package -DskipTests
49-
java -jar target/hello-1.0.0-SNAPSHOT.jar
60+
java -jar target/javasec-x.x.jar
5061
```
5162

5263
### Docker运行
64+
5365
```
5466
mvn clean package
5567
./deploy.sh
5668
```
57-
![](media/16512152886514.jpg)
5869

70+
![](media/16512152886514.jpg)
5971

6072
## 技术架构
73+
6174
- Java 1.8
62-
- SpringBoot 4.0
75+
- SpringBoot 2.4.1
6376
- Bootstrap 4.6.0
6477
- Codemirror 5.62.0

media/1.png

1.58 MB
Loading

pom.xml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>com.best</groupId>
1313
<artifactId>javasec</artifactId>
14-
<version>1.11</version>
14+
<version>1.15</version>
1515
<name>hello java sec</name>
1616
<description>Java Sec</description>
1717
<packaging>jar</packaging>
@@ -315,25 +315,6 @@
315315
</configuration>
316316
</plugin>
317317

318-
<plugin>
319-
<!-- OWASP 生成物料清单SBOM,提供Dependency Track分析 -->
320-
<groupId>org.cyclonedx</groupId>
321-
<artifactId>cyclonedx-maven-plugin</artifactId>
322-
<version>2.7.2</version>
323-
<executions>
324-
<execution>
325-
<phase>compile</phase>
326-
<goals>
327-
<goal>makeAggregateBom</goal>
328-
</goals>
329-
</execution>
330-
</executions>
331-
<configuration>
332-
<outputFormat>xml</outputFormat>
333-
</configuration>
334-
</plugin>
335-
336-
337318
</plugins>
338319
</build>
339320

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ public void addViewControllers(ViewControllerRegistry registry) {
2222
registry.addViewController("/index/ssrf").setViewName("ssrf");
2323
registry.addViewController("/index/traversal").setViewName("traversal");
2424
registry.addViewController("/index/xxe").setViewName("xxe");
25-
registry.addViewController("/index/deserialize").setViewName("deserialize");
25+
registry.addViewController("/index/deserialization").setViewName("deserialization");
2626
registry.addViewController("/index/redirect").setViewName("redirect");
2727
registry.addViewController("/index/actuator").setViewName("actuator");
28-
registry.addViewController("/index/idor").setViewName("idor");
28+
registry.addViewController("/index/idor").setViewName("idor/idor_horizontal");
29+
registry.addViewController("/index/idor/horizontal").setViewName("idor/idor_horizontal");
30+
registry.addViewController("/index/idor/vertical").setViewName("idor/idor_vertical");
2931
registry.addViewController("/index/upload").setViewName("upload");
3032
registry.addViewController("/index/xstream").setViewName("xstream");
3133
registry.addViewController("/index/fastjson").setViewName("fastjson");
32-
registry.addViewController("/index/xff").setViewName("xff");
34+
registry.addViewController("/index/ipforgery").setViewName("ip_forgery");
3335
registry.addViewController("/index/unauth").setViewName("unauth");
3436
registry.addViewController("/index/jackson").setViewName("jackson");
3537
registry.addViewController("/index/log4j").setViewName("log4j");
@@ -42,6 +44,8 @@ public void addViewControllers(ViewControllerRegistry registry) {
4244
registry.addViewController("/index/jwt").setViewName("jwt");
4345
registry.addViewController("/index/xpath").setViewName("xpath");
4446
registry.addViewController("/index/csv").setViewName("csv_injection");
47+
registry.addViewController("/index/shiro").setViewName("shiro");
48+
registry.addViewController("/index/passwordreset").setViewName("logicflaw/passwordreset");
4549

4650
}
4751

@@ -50,6 +54,6 @@ public void addViewControllers(ViewControllerRegistry registry) {
5054
public void addInterceptors(InterceptorRegistry registry) {
5155
registry.addInterceptor(new LoginHandlerInterceptor())
5256
.addPathPatterns("/**")
53-
.excludePathPatterns("/user/login", "/user/ldap", "/login", "/css/**", "/js/**", "/img/**", "/Unauth/**", "/captcha");
57+
.excludePathPatterns("/user/login", "/user/ldap", "/login", "/css/**", "/js/**", "/img/**", "/video/**", "/vulnapi/unauth/**", "/captcha");
5458
}
5559
}

src/main/java/com/best/hello/controller/Admin.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import lombok.extern.slf4j.Slf4j;
66
import org.apache.catalina.util.ServerInfo;
77

8+
import org.springframework.boot.SpringBootVersion;
9+
import org.springframework.core.SpringVersion;
810
import org.springframework.stereotype.Controller;
911

1012
import org.springframework.web.bind.annotation.*;
@@ -19,16 +21,18 @@
1921
public class Admin {
2022

2123
@ApiOperation(value = "查询系统基本信息")
22-
@GetMapping("/info")
24+
@GetMapping("/sysinfo")
2325
@ResponseBody
2426
public String sysInfo() {
2527
Map<String, String> m = new HashMap<>();
26-
2728
m.put("app", "Hello Java SEC");
2829
m.put("author", "nul1");
30+
m.put("github", "https://github.com/j3ers3/Hello-Java-Sec");
2931
m.put("tomcat_version", ServerInfo.getServerInfo());
3032
m.put("java_version", System.getProperty("java.version"));
3133
m.put("fastjson_version", JSON.VERSION);
34+
m.put("springboot_version", SpringBootVersion.getVersion());
35+
m.put("spring_version", SpringVersion.getVersion());
3236

3337
return JSON.toJSONString(m);
3438
}

src/main/java/com/best/hello/controller/BAC.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/main/java/com/best/hello/controller/CORS.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@Api("跨域资源伪造漏洞")
1414
@RestController
15-
@RequestMapping("/CORS")
15+
@RequestMapping("/vulnapi/cors")
1616
public class CORS {
1717

1818
/**
@@ -34,9 +34,9 @@ public String corsVul(HttpServletRequest request, HttpServletResponse response)
3434
@ApiOperation(value = "safe:白名单判断Origin")
3535
@CrossOrigin(origins = {"127.0.0.1", "http://127.0.0.1", "https://127.0.0.1"})
3636
@GetMapping("/safe")
37-
public String corsSafe(HttpServletRequest request, HttpServletResponse response) {
37+
public String corsSafe(HttpServletResponse response) {
3838
response.setHeader("Access-Control-Allow-Credentials", "true");
39+
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
3940
return "cors safe";
4041
}
41-
4242
}

src/main/java/com/best/hello/controller/CSRF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@Api("跨站请求伪造")
1616
@RestController
17-
@RequestMapping("/CSRF")
17+
@RequestMapping("/vulnapi/CSRF")
1818
public class CSRF {
1919
@ApiOperation(value = "vul: 危险的转账")
2020
@GetMapping("/transfer/vul")

src/main/java/com/best/hello/controller/CSVInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
@Api("CSV注入漏洞")
2323
@RestController
24-
@RequestMapping("/CSVInjection")
24+
@RequestMapping("/vulnapi/CSVInjection")
2525
public class CSVInjection {
2626
@Autowired
2727
private XSSMapper xssMapper;

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.JSONObject;
55
import io.swagger.annotations.Api;
6+
import io.swagger.annotations.ApiOperation;
67
import lombok.extern.slf4j.Slf4j;
78
import org.springframework.web.bind.annotation.RequestBody;
89
import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,19 +18,29 @@
1718
@Api("Fastjson反序列化漏洞")
1819
@Slf4j
1920
@RestController
20-
@RequestMapping("/Fastjson")
21+
@RequestMapping("/vulnapi/Fastjson")
2122
public class FastjsonVul {
2223

2324
@RequestMapping(value = "/vul", method = {RequestMethod.POST})
2425
public String vul(@RequestBody String content) {
25-
2626
try {
27-
// 转换成object
28-
JSONObject jsonToObject = JSON.parseObject(content);
29-
log.info("[vul] Fastjson");
30-
31-
return jsonToObject.get("name").toString();
27+
Object obj = JSON.parse(content);
28+
return obj.toString();
29+
} catch (Exception e) {
30+
return e.toString();
31+
}
32+
}
3233

34+
@ApiOperation(value = "safe: safeMode")
35+
@RequestMapping(value = "/safeMode", method = {RequestMethod.POST})
36+
public String safeMode(@RequestBody String content) {
37+
try {
38+
/*
39+
开启safeMode特性,(这里低版本就注释了)
40+
ParserConfig.getGlobalInstance().setSafeMode(true);
41+
Object obj = JSON.parse(content);
42+
*/
43+
return "safeMode";
3344
} catch (Exception e) {
3445
return e.toString();
3546
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@Api("Jackson反序列化漏洞")
1010
@RestController
11-
@RequestMapping("/Jackson")
11+
@RequestMapping("/vulnapi/Jackson")
1212
public class JacksonVul {
1313

1414
@RequestMapping("/vul")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@Api("Log4j2 反序列化漏洞")
1010
@RestController
11-
@RequestMapping("/Log4j")
11+
@RequestMapping("/vulnapi/Log4j")
1212
public class Log4jVul {
1313

1414
private static final Logger logger = LogManager.getLogger(Log4jVul.class);

0 commit comments

Comments
 (0)