当前位置:网站首页>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
边栏推荐
- JDBC回顾
- A detailed explanation takes you to reproduce the statistical learning method again -- Chapter 2, perceptron model
- Alibaba / popular JSON parsing open source project fastjson2
- Read 30 minutes before going to bed every day_ day4_ Files
- 别找了,Chrome浏览器必装插件都在这了
- 机器学习实战:《美人鱼》属于爱情片还是动作片?KNN揭晓答案
- Required request body is missing: (cross domain problem)
- [go practical basis] gin efficient artifact, how to bind parameters to structures
- College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
- BugkuCTF-web21(详细解题思路及步骤)
猜你喜欢

Don't look for it. All the necessary plug-ins for Chrome browser are here

Chrome视频下载插件–Video Downloader for Chrome

每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime

MySQL multi column in operation

How to use PHP spoole to implement millisecond scheduled tasks

数构(C语言)——第四章、矩阵的压缩存储(下)
![[go practical basis] how to customize and use a middleware in gin](/img/fb/c0a4453b5d3fda845c207c0cb928ae.png)
[go practical basis] how to customize and use a middleware in gin

Supplier selection and prequalification of Oracle project management system

Required request body is missing: (cross domain problem)

The channel cannot be viewed when the queue manager is running
随机推荐
Customize redis connection pool
JDBC回顾
Oracle modify database character set
Activity的创建和跳转
Micro service practice | introduction and practice of zuul, a micro service gateway
Matplotlib swordsman line - first acquaintance with Matplotlib
idea查看字节码配置
QT QLabel样式设置
Fragmenttabhost implements the interface of housing loan calculator
vs+qt 设置应用程序图标
道阻且长,行则将至
Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
How to use PHP spoole to implement millisecond scheduled tasks
Amq6126 problem solving ideas
web安全与防御
Don't look for it. All the necessary plug-ins for Chrome browser are here
How to choose between efficiency and correctness of these three implementation methods of distributed locks?
MySql报错:unblock with mysqladmin flush-hosts
知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
图像识别-数据增广