当前位置:网站首页>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
边栏推荐
- 别找了,Chrome浏览器必装插件都在这了
- Insight into cloud native | microservices and microservice architecture
- C语言之数据插入
- 上班第一天的报错(Nessus安装winpcap报错)
- In depth analysis of how the JVM executes Hello World
- 大学生四六级作文模板(自创版,成功跨过六级)
- int与string、int与QString互转
- Attributes of classfile
- Creation and jump of activity
- How to use pyqt5 to make a sensitive word detection tool
猜你喜欢

Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack

DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!

Required request body is missing:(跨域问题)

微服务实战|原生态实现服务的发现与调用

概率还不会的快看过来《统计学习方法》——第四章、朴素贝叶斯法

洞见云原生|微服务及微服务架构浅析

Matplotlib剑客行——布局指南与多图实现(更新)

Chrome browser plug-in fatkun installation and introduction

记录一下初次使用Xray的有趣过程

Chrome视频下载插件–Video Downloader for Chrome
随机推荐
Who is better for Beijing software development? How to find someone to develop system software
深入剖析JVM是如何执行Hello World的
Enterprise level SaaS CRM implementation
Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
一篇详解带你再次重现《统计学习方法》——第二章、感知机模型
What are the waiting methods of selenium
记录一下初次使用Xray的有趣过程
Watermelon book -- Chapter 6 Support vector machine (SVM)
VIM operation command Encyclopedia
AMQ 4043 solution for errors when using IBM MQ remote connection
MySQL multi column in operation
Mathematics in machine learning -- point estimation (I): basic knowledge
C语言之分草莓
Idea view bytecode configuration
[go practical basis] how to verify request parameters in gin
Matplotlib swordsman - a stylist who can draw without tools and code
College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
From concept to method, the statistical learning method -- Chapter 3, k-nearest neighbor method
Micro service practice | introduction and practice of zuul, a micro service gateway
QT信号槽总结-connect函数错误用法