Skip to content

Commit aadacd6

Browse files
committed
V1.2
1 parent 204f482 commit aadacd6

File tree

26 files changed

+1594
-67
lines changed

26 files changed

+1594
-67
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ build/
3434
### Mac OS ###
3535
.DS_Store
3636

37-
/logs/
37+
/logs/
38+
/.idea/
39+
/src/test/

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 更新记录✨
2+
3+
## V1.2 - 2024-11-17
4+
5+
- 修复已知问题
6+
- 多Session会话共存
7+
- 文件上传bug修复
8+
- 新增漏洞模块:验证码安全(图形验证码、短信验证码)
9+
10+
## V1.1 - 2024-11-10
11+
12+
- 修复已知问题
13+
- 平台页面UI:简化对应缺陷/安全代码、优化DashBoard页面
14+
- 新增漏洞模块:IDOR(水平/垂直越权)、拒绝服务、XPATH注入
15+
16+
## V1.0 - 2024-10
17+
- 初始功能实现:跨站脚本(XSS)、SQL 注入、任意文件上传、SSRF、XXE、CSRF、CORS、JSONP、RCE、URL 重定向、XFF 伪造、敏感信息泄漏、SPEL 注入、SSTI 注入、反序列化、组件漏洞等。
18+
19+
## 系统设计 - 2024-05
20+
21+
- 完成系统技术选型、架构设计、相关靶场项目调研……
22+
- 技术栈:**SpringBoot+Spring Security+MyBatis+Thymeleaf+Layui**
23+
- 这里暂时只做了简单认证实现、权限分级/人员管理等复杂鉴权功能后续待实现……
24+
- 架构设计:前后端不分离,在通用后端管理框架基础上,添加一个个漏洞模块……
25+
- 参考项目:[Hello-Java-Sec](https://github.com/j3ers3/Hello-Java-Sec) [JavaSec](https://github.com/j3ers3/Hello-Java-Sec)
26+
27+
## 灵感来源 - 2024-03
28+
- 一个想法💡

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ FROM openjdk:8
33
WORKDIR /work
44

55
LABEL maintainer="whgojp@foxmail.com"
6-
LABEL version="1.0"
6+
LABEL version="1.2"
77
LABEL description="I think therefore I am."
88

99
COPY target/JavaSecLab.jar /work/JavaSecLab.jar
1010

11-
EXPOSE 8080
12-
EXPOSE 9090
11+
RUN mkdir -p /tmp/upload && chmod -R 777 /tmp/upload
12+
13+
EXPOSE 80
1314

1415
ENV IMAGE_NAME=JavaSecLab
1516

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
[//]: # (# <img src="./pic/logo.png" alt="logo" style="zoom:5%;" />JavaSecLab 一款综合Java漏洞平台)
21
# JavaSecLab 一款综合Java漏洞平台
32

4-
<p align="center">
5-
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/transmittable-thread-local?color=4D7A97&logo=apache" alt="License"></a>
6-
<img src="https://img.shields.io/badge/Release-DEV-brightgreen.svg" alt="Release">
7-
<a href="https://github.com/whgojp/JavaSecLab"><img src="https://img.shields.io/badge/Version-1.1-red.svg" alt="Version"></a>
8-
<a href="https://blog.csdn.net/weixin_53009585"><img src="https://img.shields.io/badge/Developed%20by-whgojp-blue.svg" alt="Developed by whgojp"></a>
9-
</p>
3+
<div style="text-align: center;">
4+
<a href="https://www.apache.org/licenses/LICENSE-2.0.html"><img src="https://img.shields.io/github/license/alibaba/transmittable-thread-local?color=4D7A97&logo=apache" alt="License"></a>
5+
<img src="https://img.shields.io/badge/Release-DEV-brightgreen.svg" alt="Release">
6+
<a href="https://github.com/whgojp/JavaSecLab"><img src="https://img.shields.io/badge/Version-1.2-red.svg" alt="Version"></a>
7+
<a href="https://blog.csdn.net/weixin_53009585"><img src="https://img.shields.io/badge/Developed%20by-whgojp-blue.svg" alt="Developed by whgojp"></a>
8+
<img src="https://img.shields.io/github/stars/whgojp/JavaSecLab?color=green&style=flat-square" alt="GitHub Repo stars">
9+
<img src="https://img.shields.io/github/forks/whgojp/JavaSecLab?style=flat-square" alt="GitHub forks">
10+
</div>
11+
1012

1113
----------------------------------------
1214

@@ -23,6 +25,13 @@
2325
- 甲方安全方面:可作为开发安全培训演示,友好的交互方式,帮助研发同学更容易理解漏洞
2426
- 安全研究方面:各种漏洞的不同触发场景,可用于xAST等安全工具测试
2527

28+
## 支持漏洞模块
29+
30+
- 跨站脚本攻击、跨站请求伪造、CORS、JSONP、URL重定向、XFF伪造、拒绝服务、XPATH注入
31+
- SQL注入、任意文件系列、跨服务端请求伪造、XML实体注入、RCE
32+
- 逻辑漏洞(IDOR、验证码安全、支付安全、并发安全)、敏感信息泄漏系列、登录框对抗系列
33+
- SPEL注入、SSTI注入、反序列化、组件漏洞
34+
2635
## 在线环境体验
2736

2837
http://whgojp.top/
@@ -112,6 +121,10 @@ docker-compose -p javaseclab up -d
112121

113122
本项目遵循 [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) 协议,详细的许可证内容请参见项目中的 [LICENSE](./LICENSE) 文件。
114123

124+
## 更新记录
125+
126+
项目的详细更新记录请参阅 [CHANGELOG.md](./CHANGELOG.md)
127+
115128
## 一些Tips🙋
116129

117130
1. 安全问题:由于是漏洞靶场,因此不建议搭建在公网上使用
@@ -129,3 +142,4 @@ docker-compose -p javaseclab up -d
129142
<img src="./pic/wechat.png" alt="description" width="271" height="366" />
130143
<img src="./pic/group.png" alt="description" width="271" height="366" />
131144
</div>
145+

docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,24 @@ services:
1515
- JavaSecLabNet
1616

1717
JavaSecLab:
18-
image: javaseclab:1.1
18+
image: javaseclab:1.2
1919
container_name: Container-JavaSecLab
2020
restart: always
2121
build: .
2222
ports:
2323
- 80:80
24-
- 8080:8080
25-
- 9090:9090
2624
environment:
27-
- TZ=Asia/Shanghai # 设置时区为上海(GMT+8)
25+
- TZ=Asia/Shanghai # 设置时区上海(GMT+8)
2826
depends_on:
2927
- mysql
3028
volumes:
3129
- ./logs:/logs # 记录日志信息
30+
3231
networks:
3332
- JavaSecLabNet
3433

35-
# 密码 admin@portainer.com
3634
portainer:
37-
image: portainer/portainer-ce
35+
image: portainer/portainer-ce:latest
3836
container_name: portainer
3937
restart: always
4038
ports:

pic/group.png

12.7 KB
Loading

pic/home.png

16.3 KB
Loading

pom.xml

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

77
<groupId>top.whgojp</groupId>
88
<artifactId>JavaSecLab</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.2.0</version>
1010
<name>Java综合漏洞平台</name>
1111
<description>hello JavaSec!</description>
1212
<parent>

src/main/java/top/whgojp/common/constant/SysConstant.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package top.whgojp.common.constant;
22

33
import lombok.Data;
4-
import lombok.SneakyThrows;
54
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.beans.factory.annotation.Value;
66
import org.springframework.core.io.ResourceLoader;
77
import org.springframework.stereotype.Component;
88

99
import javax.annotation.PostConstruct;
10+
import java.io.File;
1011
import java.io.IOException;
1112

1213
/**
@@ -36,20 +37,32 @@ public class SysConstant {
3637
@Autowired
3738
private ResourceLoader resourceLoader;
3839

40+
@Value("${upload.folder:/tmp/upload}") // 容器内部固定路径,默认值为/tmp/upload
3941
private String uploadFolder;
42+
4043
private String staticFolder;
4144

45+
public SysConstant(ResourceLoader resourceLoader) {
46+
this.resourceLoader = resourceLoader;
47+
}
48+
49+
4250
@PostConstruct
4351
public void init() throws IOException {
4452
// 获取资源对象
45-
Resource uploadResource = resourceLoader.getResource("classpath:/static/upload/");
53+
File uploadDir = new File(uploadFolder);
54+
if (!uploadDir.exists()) {
55+
if (!uploadDir.mkdirs()) {
56+
throw new IOException("Failed to create upload directory: " + uploadFolder);
57+
}
58+
}
59+
60+
// Resource uploadResource = resourceLoader.getResource("classpath:/static/upload/");
4661
Resource staticResource = resourceLoader.getResource("classpath:/static/");
47-
if (uploadResource.exists() && staticResource.exists()) {
62+
if (staticResource.exists()) {
4863
try {
49-
this.uploadFolder = uploadResource.getFile().getPath(); // 仅在资源存在于文件系统中时有效
5064
this.staticFolder = staticResource.getFile().getPath();
5165
} catch (IOException e) {
52-
this.uploadFolder = uploadResource.getURL().toString(); // 获取资源的URL
5366
this.staticFolder = staticResource.getURL().toString();
5467
}
5568
} else {
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
package top.whgojp.common.utils;
22

3-
import cn.hutool.core.date.DateUtil;
43
import lombok.extern.slf4j.Slf4j;
54
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.core.io.ResourceLoader;
75
import org.springframework.stereotype.Component;
8-
import org.springframework.util.StringUtils;
96
import org.springframework.web.multipart.MultipartFile;
107
import top.whgojp.common.constant.SysConstant;
118

129
import java.io.File;
1310
import java.io.IOException;
14-
import java.nio.file.Files;
15-
import java.nio.file.Path;
16-
import java.nio.file.Paths;
17-
import java.util.Objects;
1811

1912
@Slf4j
2013
@Component
@@ -23,26 +16,26 @@ public class UploadUtil {
2316
@Autowired
2417
private SysConstant sysConstant;
2518

26-
27-
private static final String UPLOAD_DIR = "uploads"; // 可以改成配置文件中的路径
28-
29-
public String uploadFile(MultipartFile file, String suffix,String path) throws IOException {
30-
19+
public String uploadFile(MultipartFile file, String suffix, String path) throws IOException {
20+
// 从配置中获取上传目录
3121
String uploadFolderPath = sysConstant.getUploadFolder();
32-
3322
try {
34-
35-
String fileName = +DateUtil.current() + "."+suffix;
36-
String newFilePath = uploadFolderPath + "/" + fileName;
37-
38-
file.transferTo(new File(newFilePath)); // 将文件保存到指定路径
23+
// 确保目录存在
24+
File uploadDir = new File(uploadFolderPath);
25+
if (!uploadDir.exists() && !uploadDir.mkdirs()) {
26+
throw new IOException("Failed to create upload directory: " + uploadFolderPath);
27+
}
28+
// 构建文件路径
29+
String fileName = System.currentTimeMillis() + "." + suffix;
30+
String newFilePath = uploadFolderPath + File.separator + fileName;
31+
// 保存文件
32+
file.transferTo(new File(newFilePath));
3933
log.info("上传文件成功,文件路径:" + newFilePath);
4034
return "上传文件成功,文件路径:" + path + fileName;
4135
} catch (IOException e) {
42-
e.printStackTrace(); // 打印异常堆栈信息
43-
log.info("文件上传失败" + e.getMessage());
44-
return "文件上传失败" + e.getMessage();
36+
log.error("文件上传失败:{}", e.getMessage(), e);
37+
throw e; // 重新抛出异常供上层处理
4538
}
46-
4739
}
40+
4841
}

0 commit comments

Comments
 (0)