Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
4cffffd
fix cors sec code
JoyChou93 Oct 25, 2018
571e0c3
bug fix
JoyChou93 Oct 26, 2018
e35f30e
add url whitelist vul code
JoyChou93 Oct 31, 2018
ea9ad0e
udpate cors
JoyChou93 Nov 22, 2018
76da576
update cors
JoyChou93 Nov 25, 2018
ca00956
update readme
JoyChou93 Nov 25, 2018
2f6c3cf
add spel, fixes #5
JoyChou93 Jan 17, 2019
56d5ba1
update readme
JoyChou93 Jan 17, 2019
48e347c
add emptyReferer of jsonp
JoyChou93 Jan 28, 2019
674f2f1
适配在IDEA中右键直接运行应用
JoyChou93 Feb 26, 2019
453e194
add jar configure
JoyChou93 Feb 27, 2019
d1963da
Actuators to RCE
JoyChou93 Mar 4, 2019
af76c38
update readme
JoyChou93 Mar 4, 2019
4c21c97
bypass using URL class to getHost
JoyChou93 Mar 6, 2019
3cd29c1
fix bug
JoyChou93 Mar 6, 2019
d1b3d6b
update jsonp
JoyChou93 Apr 9, 2019
5b60e15
add upload file only picture
JoyChou93 Apr 23, 2019
590891b
add csrf
JoyChou93 May 31, 2019
dd3792d
update readme
JoyChou93 May 31, 2019
72a54fa
add csrf whitelist uri and req method
JoyChou93 May 31, 2019
2e542b6
update readme
JoyChou93 May 31, 2019
4a02175
update csrf allowedMethods code
JoyChou93 May 31, 2019
9bed870
csrf in upload file html
JoyChou93 Jun 5, 2019
86d2551
diy csrf error code
JoyChou93 Jun 10, 2019
f0cb9a4
add filter to check referer
JoyChou93 Jun 18, 2019
0746f9d
redirect 403 forbidden page
JoyChou93 Jun 19, 2019
10e0345
add ssrf checker
JoyChou93 Jun 21, 2019
2e91353
update readme
JoyChou93 Jun 21, 2019
a605b1e
update readme
JoyChou93 Jun 21, 2019
edfc1fc
udpate readme
JoyChou93 Jun 21, 2019
12ab307
update readme
JoyChou93 Jun 21, 2019
0e4f22e
Add httpclient SSRF vul code
JoyChou93 Jun 25, 2019
85ca363
update readme
JoyChou93 Jun 28, 2019
6844b0a
add configure code of json to jsonp
JoyChou93 Jul 3, 2019
f37f9b2
add csrf switch
JoyChou93 Jul 3, 2019
d330c45
fix bug
JoyChou93 Jul 3, 2019
f24df6f
add json to jsonp
JoyChou93 Jul 8, 2019
cc94639
add mybatis sql
JoyChou93 Jul 17, 2019
839f532
Add ssti & resolveClass blacklist
JoyChou93 Jul 19, 2019
cc99e47
udpate readme
JoyChou93 Jul 19, 2019
31f5170
add deserialize
JoyChou93 Jul 20, 2019
0a9c978
update readme
JoyChou93 Jul 20, 2019
4763a3a
update readme
JoyChou93 Jul 20, 2019
8a9977d
add auth
JoyChou93 Jul 21, 2019
3e06b52
add index html page
JoyChou93 Jul 22, 2019
a2a5eee
update mybatis readme
JoyChou93 Jul 22, 2019
720da39
add pathTraversal
JoyChou93 Jul 23, 2019
179f45e
update readme
JoyChou93 Jul 23, 2019
6b8b1d1
closes #6
JoyChou93 Jul 24, 2019
a169c10
update readme
JoyChou93 Jul 24, 2019
a0e66f2
update readme
JoyChou93 Jul 24, 2019
467b74f
add docker env & add xtream rce vuln
JoyChou93 Jul 29, 2019
0a9f1ec
update readme
JoyChou93 Jul 29, 2019
ea74d17
add a xxe sink code
JoyChou93 Jul 30, 2019
40cf83b
add command inject
JoyChou93 Jul 31, 2019
301ffa6
update readme
JoyChou93 Jul 31, 2019
1f57fae
fix bug 0.0.0.0 can bypass SSRFChecker
waderwu Sep 3, 2019
1e991c1
Merge remote-tracking branch 'upstream/master'
waderwu Sep 3, 2019
40d64c1
Merge pull request #7 from waderwu/master
JoyChou93 Sep 4, 2019
1cd9a71
add xxe
JoyChou93 Sep 4, 2019
0ece942
Merge pull request #8 from JoyChou93/dev01
JoyChou93 Sep 4, 2019
39f07ff
update readme
JoyChou93 Sep 4, 2019
27df4d1
update readme
JoyChou93 Sep 5, 2019
562b956
add a jsonp case
JoyChou93 Sep 12, 2019
d0ece30
update deserialize getcookie method
JoyChou93 Sep 16, 2019
59a72ef
19/10/15 add more xss&sql vuln code
Oct 15, 2019
da5ea84
19/10/15 rm unuseful code
Oct 15, 2019
05ae55e
Merge pull request #9 from Anemone95/master
JoyChou93 Oct 24, 2019
9821216
add xxe return back filecontent
JoyChou93 Nov 2, 2019
22f0ecd
add cors security code
JoyChou93 Dec 9, 2019
6ae0527
add filter cors fix code
JoyChou93 Dec 19, 2019
85eb3b9
update cors security code
JoyChou93 Dec 26, 2019
9dd930e
update some bugs
JoyChou93 Jan 17, 2020
7b187f2
Add XXE & SSRF Vuln Code
JoyChou93 Feb 14, 2020
0d99385
update mybatis sql injection
JoyChou93 Mar 25, 2020
db6bff2
Bug fix.The method of fix ssrf can cause dos.
JoyChou93 Mar 26, 2020
fc1be1b
Add bean to parse safedomain
JoyChou93 Mar 27, 2020
89cb9d8
fix #13
JoyChou93 Mar 31, 2020
039d0f1
bug fix
JoyChou93 Mar 31, 2020
33748f3
bug fix
JoyChou93 Apr 3, 2020
fa48bad
增加socket hook模块 实现socket层拦截SSRF
liergou9981 Apr 3, 2020
d170c8f
Merge pull request #15 from liergou9981/master
JoyChou93 Apr 4, 2020
335bfef
fix hook socket's bug
JoyChou93 Apr 4, 2020
2aa0b91
bug fix
JoyChou93 Apr 6, 2020
f296f0d
add swagger-ui & ssrf of httpsyncclient
JoyChou93 Apr 10, 2020
ab69c0b
bug fix
JoyChou93 Aug 3, 2020
30dd98b
fixes #23
JoyChou93 Aug 3, 2020
37925a8
add fastjsonp
JoyChou93 Feb 5, 2021
bb94a99
fixes #31
JoyChou93 Feb 25, 2021
1f9da36
add rce
JoyChou93 Mar 26, 2021
ed28104
add log4j
JoyChou93 Mar 31, 2022
707d395
add jwt
JoyChou93 Sep 21, 2022
e4190d6
Add RestTemplate SSRF
JoyChou93 Oct 21, 2022
9acefb2
add jwt
JoyChou93 Nov 21, 2022
da04ccc
add CVE-2022-22978
JoyChou93 Jan 16, 2023
9d66a88
add alibaba security purple team recruitment
JoyChou93 Jan 17, 2023
c3c41b4
fix #25
JoyChou93 Feb 23, 2023
621c300
Add XXE
JoyChou93 Mar 15, 2023
cab74a4
fix #70
JoyChou93 Mar 24, 2023
4ede83a
add jdbc & actuator ak_secret
JoyChou93 Apr 28, 2023
0c253ad
Update index.html
May 24, 2023
8604af5
Merge pull request #76 from wzqs/patch-1
JoyChou93 Jun 7, 2023
920bd93
fix #78
Dec 27, 2023
7bf927a
Merge remote-tracking branch 'origin/master'
Dec 27, 2023
457d703
Add qlexpress and some test cases.
Dec 28, 2023
1d06b16
Add alibaba recruitment.
Jun 28, 2024
4711f4e
Add alibaba recruitment.
Jun 28, 2024
9eb8d69
Set up CI with Azure Pipelines
autumn0914 Apr 10, 2025
bdd032c
Update azure-pipelines.yml for Azure Pipelines
autumn0914 Apr 10, 2025
02d6141
Update azure-pipelines.yml for Azure Pipelines
autumn0914 Apr 10, 2025
18cdd33
Update azure-pipelines.yml for Azure Pipelines
autumn0914 Apr 10, 2025
048cee5
Update azure-pipelines.yml for Azure Pipelines
autumn0914 Apr 10, 2025
5511840
Update azure-pipelines.yml for Azure Pipelines
autumn0914 Apr 10, 2025
d16e5fc
mysql fix
autumn0914 Apr 10, 2025
1722b02
mysql fix
autumn0914 Apr 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
19/10/15 add more xss&sql vuln code
  • Loading branch information
Anemone95 committed Oct 15, 2019
commit 59a72efaf04fc4ea603ef0b910bd4c6f9f3dd3c3
47 changes: 37 additions & 10 deletions src/main/java/org/joychou/controller/SQLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import org.joychou.mapper.UserMapper;
import org.joychou.dao.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.sql.*;
import java.util.List;


/**
Expand All @@ -16,14 +19,18 @@
* @desc SQL Injection
*/

@SuppressWarnings("Duplicates")
@RestController
@RequestMapping("/sqli")
public class SQLI {

private static String driver = "com.mysql.jdbc.Driver";
private static String url = "jdbc:mysql://localhost:3306/java_sec_code";
private static String user = "root";
private static String password = "woshishujukumima";
@Value("${spring.datasource.url}")
private String url;
@Value("${spring.datasource.username}")
private String user;
@Value("${spring.datasource.password}")
private String password;

@Autowired
private UserMapper userMapper;
Expand All @@ -36,7 +43,7 @@ public class SQLI {
* @param username username
*/
@RequestMapping("/jdbc/vul")
public static String jdbc_sqli_vul(@RequestParam("username") String username){
public String jdbc_sqli_vul(@RequestParam("username") String username){
String result = "";
try {
Class.forName(driver);
Expand Down Expand Up @@ -88,7 +95,7 @@ public static String jdbc_sqli_vul(@RequestParam("username") String username){
* @param username username
*/
@RequestMapping("/jdbc/sec")
public static String jdbc_sqli_sec(@RequestParam("username") String username){
public String jdbc_sqli_sec(@RequestParam("username") String username){

String result = "";
try {
Expand Down Expand Up @@ -134,6 +141,28 @@ public static String jdbc_sqli_sec(@RequestParam("username") String username){
return result;
}

/**
* vul code
* http://localhost:8080/sqli/mybatis/vul01?username=joychou' or '1'='1
*
* @param username username
*/
@GetMapping("/mybatis/vul01")
public List<User> mybatis_vul1(@RequestParam("username") String username) {
return userMapper.findByUserNameVul(username);
}

/**
* vul code
* http://localhost:8080/sqli/mybatis/vul02?username=joychou' or '1'='1' %23
*
* @param username username
*/
@GetMapping("/mybatis/vul02")
public List<User> mybatis_vul2(@RequestParam("username") String username) {
return userMapper.findByUserNameVul2(username);
}


/**
* security code
Expand All @@ -142,20 +171,18 @@ public static String jdbc_sqli_sec(@RequestParam("username") String username){
* @param username username
*/
@GetMapping("/mybatis/sec01")
public User mybatis_vul1(@RequestParam("username") String username) {
public User mybatis_sec1(@RequestParam("username") String username) {
return userMapper.findByUserName(username);
}



/**
* security code
* http://localhost:8080/sqli/mybatis/sec02?id=1
*
* @param id id
*/
@GetMapping("/mybatis/sec02")
public User mybatis_v(@RequestParam("id") Integer id) {
public User mybatis_sec2(@RequestParam("id") Integer id) {
return userMapper.findById(id);
}

Expand All @@ -165,7 +192,7 @@ public User mybatis_v(@RequestParam("id") Integer id) {
* http://localhost:8080/sqli/mybatis/sec03
**/
@GetMapping("/mybatis/sec03")
public User mybatis_vul2() {
public User mybatis_sec3() {
return userMapper.OrderByUsername();
}

Expand Down
67 changes: 61 additions & 6 deletions src/main/java/org/joychou/controller/XSS.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package org.joychou.controller;

import org.apache.commons.lang.StringUtils;
import org.joychou.dao.User;
import org.joychou.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
* @author JoyChou ([email protected])
Expand All @@ -16,15 +27,59 @@
@Controller
@RequestMapping("/xss")
public class XSS {
@RequestMapping("/print")

/**
* Vul Code.
* ReflectXSS
* http://localhost:8080/xss/reflect?xss=<script>alert(1)</script>
*
* @param xss unescape string
*/
@RequestMapping("/reflect")
@ResponseBody
public static String reflect(String xss)
{
return xss;
}

/**
* Vul Code.
* StoredXSS Step1
* http://localhost:8080/xss/stored/store?xss=<script>alert(1)</script>
*
* @param xss unescape string
*/
@RequestMapping("/stored/store")
@ResponseBody
public static String ssrf_URLConnection(HttpServletRequest request)
public String store(String xss, HttpServletResponse response)
{
String con = request.getParameter("con");
return con;
Cookie cookie = new Cookie("xss", xss);
response.addCookie(cookie);
return "Set param into cookie";
}

// fix code
// return encode(con);
/**
* Vul Code.
* StoredXSS Step2
* http://localhost:8080/xss/stored/show
*
* @param xss unescape string
*/
@RequestMapping("/stored/show")
@ResponseBody
public String show(@CookieValue("xss") String xss)
{
return xss;
}
/**
* safe Code.
* http://localhost:8080/xss/safe
*
*/
@RequestMapping("/safe")
@ResponseBody
public static String safe(String xss){
return encode(xss);
}

public static String encode(String origin) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/joychou/mapper/UserMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.apache.ibatis.annotations.Select;
import org.joychou.dao.User;

import java.util.List;

@Mapper
public interface UserMapper {

Expand All @@ -15,7 +17,13 @@ public interface UserMapper {
@Select("select * from users where username = #{username}")
User findByUserName(@Param("username") String username);

@Select("select * from users where username = '${username}'")
List<User> findByUserNameVul(@Param("username") String username);

List<User> findByUserNameVul2(String username);

User findById(Integer id);

User OrderByUsername();

}
3 changes: 1 addition & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

spring.datasource.url=jdbc:mysql://localhost:3306/java_sec_code?AllowPublicKeyRetrieval=true&useSSL=false
spring.datasource.url=jdbc:mysql://localhost:3306/java_sec_code?AllowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=woshishujukumima
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
mybatis.mapper-locations=classpath:mapper/*.xml


# Spring Boot Actuator Vulnerable Config
management.security.enabled=false
# logging.config=classpath:logback-online.xml
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/create_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
USE `java_sec_code`;
CREATE TABLE IF NOT EXISTS `users`(
`id` INT UNSIGNED AUTO_INCREMENT,
`username` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `users` VALUES (1, 'admin', 'admin123');
INSERT INTO `users` VALUES (2, 'joychou', 'joychou123');
5 changes: 5 additions & 0 deletions src/main/resources/mapper/UserMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@
<!--select * from users where username = #{username}-->
<!--</select>-->

<select id="findByUserNameVul2" parameterType="String" resultMap="User">
select * from users where username like '%${_parameter}%'
</select>

<select id="findById" resultMap="User">
select * from users where id = #{id}
</select>


<select id="OrderByUsername" resultMap="User">
select * from users order by id asc limit 1
</select>
Expand Down