当前位置:网站首页>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
边栏推荐
- Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
- 一篇详解带你再次重现《统计学习方法》——第二章、感知机模型
- c语言编程题
- 大学生四六级作文模板(自创版,成功跨过六级)
- 微服务实战|熔断器Hystrix初体验
- From concept to method, the statistical learning method -- Chapter 3, k-nearest neighbor method
- Chrome视频下载插件–Video Downloader for Chrome
- 数构(C语言--代码有注释)——第二章、线性表(更新版)
- Microservice practice | teach you to develop load balancing components hand in hand
- 记录下对游戏主机配置的个人理解与心得
猜你喜欢
微服务实战|Eureka注册中心及集群搭建
告别996,IDEA中必装插件有哪些?
BugkuCTF-web24(解题思路及步骤)
web安全与防御
Activity的创建和跳转
Redis installation and deployment (windows/linux)
Insight into cloud native | microservices and microservice architecture
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
Required request body is missing:(跨域问题)
Microservice practice | load balancing component and source code analysis
随机推荐
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
Chrome浏览器插件-Fatkun安装和介绍
ClassFile - Attributes - Code
Required request body is missing:(跨域问题)
Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
VIM operation command Encyclopedia
CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
Hystrix implements request consolidation
Microservice practice | teach you to develop load balancing components hand in hand
C语言之做木桶
Fragmenttabhost implements the interface of housing loan calculator
C语言之到底是不是太胖了
idea查看字节码配置
Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
web安全与防御
Knowledge points are very detailed (code is annotated) number structure (C language) -- Chapter 3, stack and queue
Mathematics in machine learning -- point estimation (I): basic knowledge
保存视频 opencv::VideoWriter
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
Knife4j 2. Solution to the problem of file control without selection when uploading x version files