当前位置:网站首页>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 user script manager tempermonkey monkey
- 洞见云原生|微服务及微服务架构浅析
- JVM instruction mnemonic
- Microservice practice | load balancing component and source code analysis
- hystrix 实现请求合并
- 记录下对游戏主机配置的个人理解与心得
- Customize redis connection pool
- 个人经历&&博客现状
- Creation and jump of activity
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
猜你喜欢
自定義Redis連接池
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
微服务实战|原生态实现服务的发现与调用
Oracle modify database character set
告别996,IDEA中必装插件有哪些?
Mysql默认事务隔离级别及行锁
Chrome browser plug-in fatkun installation and introduction
个人经历&&博客现状
Microservice practice | Eureka registration center and cluster construction
Chrome video download Plug-in – video downloader for Chrome
随机推荐
Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
tinyxml2 读取和修改文件
Watermelon book -- Chapter 6 Support vector machine (SVM)
[go practical basis] gin efficient artifact, how to bind parameters to structures
自定義Redis連接池
记录下对游戏主机配置的个人理解与心得
vs+qt 设置应用程序图标
The channel cannot be viewed when the queue manager is running
Micro service practice | introduction and practice of zuul, a micro service gateway
CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
C语言之数据插入
西瓜书--第五章.神经网络
Mysql 多列IN操作
Typora安装包分享
What is the function of laravel facade
cmake的命令-官方文档
Supplier selection and prequalification of Oracle project management system
Oracle delete tablespace and user
Attributes of classfile
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd