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
fix hook socket's bug
  • Loading branch information
JoyChou93 committed Apr 4, 2020
commit 335bfef5cb34d2e7e0a6f822226c82c7a8b37b80
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Tomcat's default JSESSION session is valid for 30 minutes, so a 30-minute non-op

## Contributors

Core developers : [JoyChou](https://github.com/JoyChou93).
Core developers : [JoyChou](https://github.com/JoyChou93), [liergou9981](https://github.com/liergou9981)
Other developers: [lightless](https://github.com/lightless233), [Anemone95](https://github.com/Anemone95), [waderwu](https://github.com/waderwu).


Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/joychou/config/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

public class Constants {

private Constants(){}
private Constants() {
}

public static final String REMEMBER_ME_COOKIE = "rememberMe";
}
20 changes: 10 additions & 10 deletions src/main/java/org/joychou/config/SafeDomainParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

public class SafeDomainParser {

private static Logger logger= LoggerFactory.getLogger(SafeDomainParser.class);
private static Logger logger = LoggerFactory.getLogger(SafeDomainParser.class);

public SafeDomainParser(){
public SafeDomainParser() {

String rootTag = "domains";
String safeDomainTag = "safedomains";
Expand All @@ -38,8 +38,8 @@ public SafeDomainParser(){
NodeList rootNode = doc.getElementsByTagName(rootTag); // 解析根节点domains
Node domainsNode = rootNode.item(0);
NodeList child = domainsNode.getChildNodes();
for (int i = 0; i < child.getLength(); i++){

for (int i = 0; i < child.getLength(); i++) {
Node node = child.item(i);
// 解析safeDomains节点
if (node.getNodeName().equals(safeDomainTag)) {
Expand All @@ -51,7 +51,7 @@ public SafeDomainParser(){
safeDomains.add(finalTagNode.getTextContent());
}
}
}else if (node.getNodeName().equals(blockDomainTag)) {
} else if (node.getNodeName().equals(blockDomainTag)) {
NodeList finalTagNode = node.getChildNodes();
for (int j = 0; j < finalTagNode.getLength(); j++) {
Node tagNode = finalTagNode.item(j);
Expand All @@ -62,7 +62,7 @@ public SafeDomainParser(){
}
}
}
}catch (Exception e){
} catch (Exception e) {
logger.error(e.toString());
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public SafeDomainParser(){
Node domainsNode = rootNode.item(0);
NodeList child = domainsNode.getChildNodes();

for (int i = 0; i < child.getLength(); i++){
for (int i = 0; i < child.getLength(); i++) {
Node node = child.item(i);
// 解析safeDomains节点
if (node.getNodeName().equals(ssrfSafeDomainTag)) {
Expand All @@ -107,15 +107,15 @@ public SafeDomainParser(){
ssrfSafeDomains.add(tagFinalNode.getTextContent());
}
}
}else if (node.getNodeName().equals(ssrfBlockDomainTag)) {
} else if (node.getNodeName().equals(ssrfBlockDomainTag)) {
NodeList tagChild = node.getChildNodes();
for (int j = 0; j < tagChild.getLength(); j++) {
Node tagFinalNode = tagChild.item(j);
if (tagFinalNode.getNodeName().equals(ssrfFinalTag)) {
ssrfBlockDomains.add(tagFinalNode.getTextContent());
}
}
}else if(node.getNodeName().equals(ssrfBlockIpsTag)){
} else if (node.getNodeName().equals(ssrfBlockIpsTag)) {
NodeList tagChild = node.getChildNodes();
for (int j = 0; j < tagChild.getLength(); j++) {
Node tagFinalNode = tagChild.item(j);
Expand All @@ -126,7 +126,7 @@ public SafeDomainParser(){
}
}
}
}catch (Exception e){
} catch (Exception e) {
logger.error(e.toString());
}

Expand Down
66 changes: 39 additions & 27 deletions src/main/java/org/joychou/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,112 +15,124 @@
public class WebConfig {

private static String[] callbacks;
private static Boolean jsonpReferCheckEnabled = false;
private static Boolean jsonpReferCheckEnabled = false;
private static String[] jsonpRefererHost;
private static String[] referWhitelist;
private static String[] referUris;
private static Boolean referSecEnabled = false;
private static String businessCallback;
private static ArrayList<String> safeDomains= new ArrayList<>();
private static ArrayList<String> blockDomains= new ArrayList<>();
private static ArrayList<String> safeDomains = new ArrayList<>();
private static ArrayList<String> blockDomains = new ArrayList<>();
private static ArrayList<String> ssrfSafeDomains = new ArrayList<>();
private static ArrayList<String> ssrfBlockDomains= new ArrayList<>();
private static ArrayList<String> ssrfBlockDomains = new ArrayList<>();
private static ArrayList<String> ssrfBlockIps = new ArrayList<>();

/**
* application.properties里object自动转jsonp的referer校验开关
*
* @param jsonpReferCheckEnabled jsonp校验开关
*/
@Value("${joychou.security.jsonp.referer.check.enabled}")
public void setJsonpReferCheckEnabled(Boolean jsonpReferCheckEnabled){
public void setJsonpReferCheckEnabled(Boolean jsonpReferCheckEnabled) {
WebConfig.jsonpReferCheckEnabled = jsonpReferCheckEnabled;
}
public static Boolean getJsonpReferCheckEnabled(){

public static Boolean getJsonpReferCheckEnabled() {
return jsonpReferCheckEnabled;
}


@Value("${joychou.security.jsonp.callback}")
public void setJsonpCallbacks(String[] callbacks){
public void setJsonpCallbacks(String[] callbacks) {
WebConfig.callbacks = callbacks;
}
public static String[] getJsonpCallbacks(){

public static String[] getJsonpCallbacks() {
return callbacks;
}


@Value("${joychou.security.referer.enabled}")
public void setReferSecEnabled(Boolean referSecEnabled){
public void setReferSecEnabled(Boolean referSecEnabled) {
WebConfig.referSecEnabled = referSecEnabled;
}
public static Boolean getReferSecEnabled(){

public static Boolean getReferSecEnabled() {
return referSecEnabled;
}


@Value("${joychou.security.referer.host}")
public void setReferWhitelist(String[] referWhitelist){
public void setReferWhitelist(String[] referWhitelist) {
WebConfig.referWhitelist = referWhitelist;
}
public static String[] getReferWhitelist(){

public static String[] getReferWhitelist() {
return referWhitelist;
}


@Value("${joychou.security.referer.uri}")
public void setReferUris(String[] referUris)
{
public void setReferUris(String[] referUris) {
WebConfig.referUris = referUris;
}
public static String[] getReferUris(){

public static String[] getReferUris() {
return referUris;
}


@Value("${joychou.business.callback}")
public void setBusinessCallback(String businessCallback){
public void setBusinessCallback(String businessCallback) {
WebConfig.businessCallback = businessCallback;
}
public static String getBusinessCallback(){

public static String getBusinessCallback() {
return businessCallback;
}


void setSafeDomains(ArrayList<String> safeDomains){
void setSafeDomains(ArrayList<String> safeDomains) {
WebConfig.safeDomains = safeDomains;
}
public static ArrayList<String> getSafeDomains(){

public static ArrayList<String> getSafeDomains() {
return safeDomains;
}


void setBlockDomains(ArrayList<String> blockDomains){
void setBlockDomains(ArrayList<String> blockDomains) {
WebConfig.blockDomains = blockDomains;
}
public static ArrayList<String> getBlockDomains(){

public static ArrayList<String> getBlockDomains() {
return blockDomains;
}


void setSsrfSafeDomains(ArrayList<String> ssrfSafeDomains){
void setSsrfSafeDomains(ArrayList<String> ssrfSafeDomains) {
WebConfig.ssrfSafeDomains = ssrfSafeDomains;
}
public static ArrayList<String> getSsrfSafeDomains(){

public static ArrayList<String> getSsrfSafeDomains() {
return ssrfSafeDomains;
}


void setSsrfBlockDomains(ArrayList<String> ssrfBlockDomains){
void setSsrfBlockDomains(ArrayList<String> ssrfBlockDomains) {
WebConfig.ssrfBlockDomains = ssrfBlockDomains;
}
public static ArrayList<String> getSsrfBlockDomainsDomains(){

public static ArrayList<String> getSsrfBlockDomainsDomains() {
return ssrfBlockDomains;
}


void setSsrfBlockIps(ArrayList<String> ssrfBlockIps){
void setSsrfBlockIps(ArrayList<String> ssrfBlockIps) {
WebConfig.ssrfBlockIps = ssrfBlockIps;
}
public static ArrayList<String> getSsrfBlockIps(){

public static ArrayList<String> getSsrfBlockIps() {
return ssrfBlockIps;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/joychou/controller/CRLFInjection.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Java 1.7/1.8 no CRLF vulns (test in Java 1.7/1.8)
*
* @author JoyChou ([email protected]) @2018-01-03
* @author JoyChou ([email protected]) @2018-01-03
*/
@Controller
@RequestMapping("/crlf")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joychou/controller/CSRF.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* check csrf using spring-security
* Access http://localhost:8080/csrf/ -> click submit
*
* @author JoyChou ([email protected]) @2019-05-31
* @author JoyChou ([email protected]) @2019-05-31
*/
@Controller
@RequestMapping("/csrf")
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/joychou/controller/CommandInject.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public String codeInject(String filepath) throws IOException {
* Host Injection
* Host: hacked by joychou;cat /etc/passwd
* http://localhost:8080/codeinject/host
*
*/
@GetMapping("/codeinject/host")
public String codeInjectHost(HttpServletRequest request) throws IOException {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/joychou/controller/Cookies.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import org.joychou.util.WebUtils;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.util.WebUtils.getCookie;

@RestController
Expand Down Expand Up @@ -43,7 +45,7 @@ public String vuln03(HttpServletRequest req) {
for (Cookie cookie : cookies) {
// key code. Equals can also be equalsIgnoreCase.
if (NICK.equals(cookie.getName())) {
nick = cookie.getValue();
nick = cookie.getValue();
}
}
}
Expand All @@ -58,15 +60,14 @@ public String vuln04(HttpServletRequest req) {
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equalsIgnoreCase(NICK)) { // key code
nick = cookie.getValue();
nick = cookie.getValue();
}
}
}
return "Cookie nick: " + nick;
}



@RequestMapping(value = "/vuln05")
public String vuln05(@CookieValue("nick") String nick) {
return "Cookie nick: " + nick;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/joychou/controller/Cors.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.servlet.http.HttpServletResponse;

/**
* @author JoyChou ([email protected]) @2018.10.24
* @author JoyChou ([email protected]) @2018.10.24
* https://github.com/JoyChou93/java-sec-code/wiki/CORS
*/

Expand Down Expand Up @@ -106,7 +106,7 @@ public String seccode(HttpServletRequest request, HttpServletResponse response)

// 如果origin不为空并且origin不在白名单内,认定为不安全。
// 如果origin为空,表示是同域过来的请求或者浏览器直接发起的请求。
if ( origin != null && SecurityUtil.checkURL(origin) == null ) {
if (origin != null && SecurityUtil.checkURL(origin) == null) {
return "Origin is not safe.";
}
response.setHeader("Access-Control-Allow-Origin", origin);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/joychou/controller/Deserialize.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Deserialize {
/**
* java -jar ysoserial.jar CommonsCollections5 "open -a Calculator" | base64
* Add the result to rememberMe cookie.
*
* <p>
* http://localhost:8080/deserialize/rememberMe/vuln
*/
@RequestMapping("/rememberMe/vuln")
Expand All @@ -40,7 +40,7 @@ public String rememberMeVul(HttpServletRequest request)

Cookie cookie = getCookie(request, Constants.REMEMBER_ME_COOKIE);

if (null == cookie){
if (null == cookie) {
return "No rememberMe cookie. Right?";
}

Expand All @@ -57,7 +57,7 @@ public String rememberMeVul(HttpServletRequest request)

/**
* Check deserialize class using black list.
*
* <p>
* http://localhost:8080/deserialize/rememberMe/security
*/
@RequestMapping("/rememberMe/security")
Expand All @@ -66,15 +66,15 @@ public String rememberMeBlackClassCheck(HttpServletRequest request)

Cookie cookie = getCookie(request, Constants.REMEMBER_ME_COOKIE);

if (null == cookie){
if (null == cookie) {
return "No rememberMe cookie. Right?";
}
String rememberMe = cookie.getValue();
byte[] decoded = Base64.getDecoder().decode(rememberMe);

ByteArrayInputStream bytes = new ByteArrayInputStream(decoded);

try{
try {
AntObjectInputStream in = new AntObjectInputStream(bytes); // throw InvalidClassException
in.readObject();
in.close();
Expand Down
Loading