当前位置:网站首页>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
边栏推荐
- Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
- 微服务实战|Eureka注册中心及集群搭建
- 微服务实战|原生态实现服务的发现与调用
- BugkuCTF-web24(解题思路及步骤)
- 洞见云原生|微服务及微服务架构浅析
- 微服务实战|负载均衡组件及源码分析
- 微服务实战|手把手教你开发负载均衡组件
- 破茧|一文说透什么是真正的云原生
- Hystrix implements request consolidation
- College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
猜你喜欢

上班第一天的报错(AWVS卸载不彻底)

Enterprise level SaaS CRM implementation

Mysql默认事务隔离级别及行锁

Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)

图像识别-数据采集

Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别

c语言编程题

图像识别-数据增广

Read 30 minutes before going to bed every day_ day4_ Files

hystrix 实现请求合并
随机推荐
Typora installation package sharing
In depth analysis of how the JVM executes Hello World
Operation and application of stack and queue
自定义Redis连接池
自定義Redis連接池
微服务实战|微服务网关Zuul入门与实战
FragmentTabHost实现房贷计算器界面
Chrome browser plug-in fatkun installation and introduction
[go practical basis] how can gin get the request parameters of get and post
Demand delineation executive summary
Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
Say goodbye to 996. What are the necessary plug-ins in idea?
zk配置中心---Config Toolkit配置与使用
保存视频 opencv::VideoWriter
数构(C语言)——第四章、矩阵的压缩存储(下)
Who is better for Beijing software development? How to find someone to develop system software
Chrome用户脚本管理器-Tampermonkey 油猴
Idea view bytecode configuration
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
VIM操作命令大全