当前位置:网站首页>Web security and defense
Web security and defense
2022-07-02 09:36:00 【niceyz】
One 、 Phishing website XSS Attack principle analysis
Script to submit the form :<script>for(var i=0;i<3;i++){alert(" I'll kill you "+i);}</script> Escape special characters in , Disable script execution .

pom.xml introduce common-lang package
<dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency>
/** * xss filter * Created by yz on 2018/4/9. */ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { private HttpServletRequest request; public XssHttpServletRequestWrapper(HttpServletRequest request) { super(request); this.request = request; } /** * take request Medium value Value rewrite , Put some script parameters Illegal parameter converted to html Element execution * @param name * @return */ @Override public String getParameter(String name) { String value = this.request.getParameter(name); if(!StringUtils.isEmpty(value)){ System.out.println(" Before conversion value:"+value); value = StringEscapeUtils.escapeHtml(value); System.out.println(" After the transformation value:"+value); } return value; } }
import org.springframework.stereotype.Component; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; /** * Created by yz on 2018/4/9. */ @Component public class XssFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { System.out.println(" Initialization method ..."); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { System.out.println(" Normal interception request ..."); HttpServletRequest req = (HttpServletRequest) request; XssHttpServletRequestWrapper xssWrapper = new XssHttpServletRequestWrapper(req); filterChain.doFilter(xssWrapper,response); } /** * Only once */ @Override public void destroy() { System.out.println(" Destruction request ..."); } }
/** * Created by yz on 2018/4/9. */ @Controller public class IndexController { @RequestMapping("/index") public ModelAndView index(HttpServletRequest request){ String name = request.getParameter("name"); System.out.println(name); ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject("name",name); modelAndView.setViewName("index"); return modelAndView; } }
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Created by yz on 2018/4/9. */ @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class); } }
index.jsp
<%@ page contentType="text/html; charset=UTF-8" language="java"%> <html> <body> <h2>Hello World!</h2> <form name="form" method="post" action="<%=request.getContextPath() %>/index"> <input type="text" name="name"> <input type="submit" name="submit" value=" Submit "> </form> name:${ name} <h3> I am a A page </h3> <img alt="" src="/log.png"> </body> </html>
Two 、web Security picture anti-theft chain
3、 ... and 、 Form operation database SQL Inject
边栏推荐
- CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
- Amq6126 problem solving ideas
- 个人经历&&博客现状
- 因上努力,果上随缘
- Matplotlib swordsman line - first acquaintance with Matplotlib
- 图像识别-数据增广
- JDBC回顾
- 告别996,IDEA中必装插件有哪些?
- Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
- Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
猜你喜欢
随机推荐
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
因上努力,果上随缘
Required request body is missing: (cross domain problem)
kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
Long summary (code with comments) number structure (C language) -- Chapter 4, string (Part 1)
自定義Redis連接池
微服务实战|熔断器Hystrix初体验
Knife4j 2.X版本文件上传无选择文件控件问题解决
Alibaba /热门json解析开源项目 fastjson2
道阻且长,行则将至
What are the differences between TP5 and laravel
Operation and application of stack and queue
企业级SaaS CRM实现
JVM instruction mnemonic
[go practical basis] how can gin get the request parameters of get and post
int与string、int与QString互转
Activity的创建和跳转
Customize redis connection pool
图像识别-数据增广
The channel cannot be viewed when the queue manager is running









