forked from JoyChou93/java-sec-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXSS.java
More file actions
39 lines (33 loc) · 1.12 KB
/
XSS.java
File metadata and controls
39 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.joychou.controller;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
/**
* @author: JoyChou (joychou@joychou.org)
* @date: 2018.01.02
* @desc: xss vuls code
*/
@Controller
@RequestMapping("/xss")
public class XSS {
@RequestMapping("/print")
@ResponseBody
public static String ssrf_URLConnection(HttpServletRequest request)
{
String con = request.getParameter("con");
return con;
// fix code
// return encode(con);
}
public static String encode(String origin) {
origin = StringUtils.replace(origin, "&", "&");
origin = StringUtils.replace(origin, "<", "<");
origin = StringUtils.replace(origin, ">", ">");
origin = StringUtils.replace(origin, "\"", """);
origin = StringUtils.replace(origin, "'", "'");
origin = StringUtils.replace(origin, "/", "/");
return origin;
}
}