CN108171051A - 一种对抗xss攻击的方法 - Google Patents
一种对抗xss攻击的方法 Download PDFInfo
- Publication number
- CN108171051A CN108171051A CN201711428031.7A CN201711428031A CN108171051A CN 108171051 A CN108171051 A CN 108171051A CN 201711428031 A CN201711428031 A CN 201711428031A CN 108171051 A CN108171051 A CN 108171051A
- Authority
- CN
- China
- Prior art keywords
- iframe
- parent page
- data
- submitting button
- sent
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/50—Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
- G06F21/55—Detecting local intrusion or implementing counter-measures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Information Transfer Between Computers (AREA)
Abstract
本发明涉及网站安全技术领域,具体涉及一种对抗XSS攻击的方法。本发明所述的方法是通过脚本创建一个提交按钮放在不同源的iframe中,通过iframe中的提交按钮提交父页面的表单,服务端通过检测referer是否由iframe发起判断提交合法性。本发明解决对外开放的网页表单提交功能容易受到跨站脚本攻击(XSS)的问题。
Description
技术领域
本发明涉及网站安全技术领域,具体涉及一种对抗XSS攻击的方法。
背景技术
目前网站的表单很多都是通过点击提交按钮发起的,例如提交评论、发布留言。如果留言系统有XSS漏洞,用户中招后,除了基本攻击外,XSS还会自动填入留言内容并模拟点击提交按钮发布带有恶意代码的留言。其他用户看到中招后又传播给其他用户,从而形成蠕虫扩散。
发明内容
本发明解决的技术问题在于提供一种对抗XSS攻击的方法,解决原来对外开放的网页表单提交功能容易受到跨站脚本攻击(XSS)的问题。
本发明解决上述技术问题的技术方案是:
所述的方法是通过脚本创建一个提交按钮放在不同源的iframe中,通过iframe中的提交按钮提交父页面的表单,服务端通过检测referer是否由iframe发起判断提交合法性。
所述的方法具体包含以下几个步骤:
步骤一、父页面初始化,通过脚本创建一个提交按钮,放在不同源的iframe中;
步骤二、用户点击iframe的提交按钮,设置变量clicked为true,同时通知父页面;
步骤三、父页面收到消息后,将表单数据发送到iframe并调用iframe页面的提交方法;
步骤四、iframe页面的提交方法检验变量clicked,如果为true,则将父页面发过来的数据通过Ajax发送;
步骤五、服务端接收数据,检验referer,如果为iframe的地址,则检验通过,否则提示数据来源错误;
步骤六、iframe页面的提交方法收到服务端返回数据后,将结果发送回父页面;
步骤七、父页面处理收到的返回数据,如果成功则提示提交成功,如果失败则提示详细错误。
本发明的有益效果:在页面中通过脚本创建提交按钮,放在不同源的iframe中,这样就和XSS所在的环境隔离了,XSS无法访问到这个提交按钮也就无法模拟点击提交恶意代码。而且通过iframe提交父页面的表单,服务端通过referer即可检测请求是否由iframe发起的,这样就算XSS破解上一道防线,通过直接调用http接口提交数据,XSS也无法伪造referer。采用这种方法可以实现对抗XSS攻击的目的。本发明有效解决了对外开放的网页表单提交功能容易受到跨站脚本攻击(XSS)的问题。
附图说明
下面结合附图对本发明进一步说明:
图1为本发明的方法流程图。
具体实施方式
如图1所示,本发明采用如下步骤:
步骤一、父页面初始化,通过脚本创建一个提交按钮,放在不同源的iframe中,父页面url为“http://www.test.com/form.html”,iframe的url为“http://cross.test.com/proxy.html”;
步骤二、用户点击iframe的提交按钮,设置变量clicked为true,同时通知父页面;
步骤三、父页面收到消息后,将表单数据发送到iframe并调用iframe页面的提交方法;
步骤四、iframe页面的提交方法检验变量clicked,如果为true,则将父页面发过来的数据通过Ajax发送;
步骤五、服务端接收数据,检验referer,如果为iframe的地址,则检验通过,否则提示数据来源错误;
步骤六、iframe页面的提交方法收到服务端返回数据后,将结果发送回父页面;
步骤七、父页面处理收到的返回数据,如果成功则提示提交成功,如果失败则提示详细错误。
Claims (2)
1.一种对抗XSS攻击的方法,其特征在于:所述的方法是通过脚本创建一个提交按钮放在不同源的iframe中,通过iframe中的提交按钮提交父页面的表单,服务端通过检测referer是否由iframe发起判断提交合法性。
2.根据权利要求1所述的方法,其特征在于:所述的方法具体包含以下几个步骤:
步骤一、父页面初始化,通过脚本创建一个提交按钮,放在不同源的iframe中;
步骤二、用户点击iframe的提交按钮,设置变量clicked为true,同时通知父页面;
步骤三、父页面收到消息后,将表单数据发送到iframe并调用iframe页面的提交方法;
步骤四、iframe页面的提交方法检验变量clicked,如果为true,则将父页面发过来的数据通过Ajax发送;
步骤五、服务端接收数据,检验referer,如果为iframe的地址,则检验通过,否则提示数据来源错误;
步骤六、iframe页面的提交方法收到服务端返回数据后,将结果发送回父页面;
步骤七、父页面处理收到的返回数据,如果成功则提示提交成功,如果失败则提示详细错误。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711428031.7A CN108171051A (zh) | 2017-12-26 | 2017-12-26 | 一种对抗xss攻击的方法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711428031.7A CN108171051A (zh) | 2017-12-26 | 2017-12-26 | 一种对抗xss攻击的方法 |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108171051A true CN108171051A (zh) | 2018-06-15 |
Family
ID=62520593
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711428031.7A Pending CN108171051A (zh) | 2017-12-26 | 2017-12-26 | 一种对抗xss攻击的方法 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108171051A (zh) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101588382A (zh) * | 2008-05-19 | 2009-11-25 | 北京亿企通信息技术有限公司 | 一种在Web页面中附件提交的方法 |
CN102447726A (zh) * | 2010-10-15 | 2012-05-09 | 中兴通讯股份有限公司 | 页面访问方法及系统 |
CN103581321A (zh) * | 2013-11-06 | 2014-02-12 | 北京奇虎科技有限公司 | 一种refer链的创建方法、装置及安全检测方法和客户端 |
CN103856493A (zh) * | 2012-11-28 | 2014-06-11 | 纽海信息技术(上海)有限公司 | 跨域登录系统及方法 |
CN105512559A (zh) * | 2014-10-17 | 2016-04-20 | 阿里巴巴集团控股有限公司 | 一种用于提供访问页面的方法与设备 |
-
2017
- 2017-12-26 CN CN201711428031.7A patent/CN108171051A/zh active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101588382A (zh) * | 2008-05-19 | 2009-11-25 | 北京亿企通信息技术有限公司 | 一种在Web页面中附件提交的方法 |
CN102447726A (zh) * | 2010-10-15 | 2012-05-09 | 中兴通讯股份有限公司 | 页面访问方法及系统 |
CN103856493A (zh) * | 2012-11-28 | 2014-06-11 | 纽海信息技术(上海)有限公司 | 跨域登录系统及方法 |
CN103581321A (zh) * | 2013-11-06 | 2014-02-12 | 北京奇虎科技有限公司 | 一种refer链的创建方法、装置及安全检测方法和客户端 |
CN105512559A (zh) * | 2014-10-17 | 2016-04-20 | 阿里巴巴集团控股有限公司 | 一种用于提供访问页面的方法与设备 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11126723B2 (en) | Systems and methods for remote detection of software through browser webinjects | |
US8448241B1 (en) | Browser extension for checking website susceptibility to cross site scripting | |
US8949990B1 (en) | Script-based XSS vulnerability detection | |
US8839369B1 (en) | Methods and systems for detecting email phishing attacks | |
US8474048B2 (en) | Website content regulation | |
CN101964025B (zh) | Xss检测方法和设备 | |
US20100042687A1 (en) | System and method for combating phishing | |
CN104954372B (zh) | 一种钓鱼网站的取证与验证方法及系统 | |
Shrivastava et al. | XSS vulnerability assessment and prevention in web application | |
US20140201270A1 (en) | Distributed comment moderation | |
US20170371888A1 (en) | Method for advertisement interception in dual-kernel browser and browser apparatus | |
CN104767747A (zh) | 点击劫持安全检测方法和装置 | |
CN105635064B (zh) | Csrf攻击检测方法及装置 | |
Ambedkar et al. | A comprehensive inspection of cross site scripting attack | |
CN104660556B (zh) | 跨站伪造请求漏洞检测的方法及装置 | |
CN108171051A (zh) | 一种对抗xss攻击的方法 | |
CN111523123A (zh) | 一种网站漏洞智能检测方法 | |
CN104732144A (zh) | 一种基于伪协议的远程代码注入漏洞检测方法 | |
CN108650230A (zh) | 一种防止按钮自动点击的方法及系统 | |
CN108073627B (zh) | 一种跨域网页的JavaScript函数调用方法以及装置 | |
CN107294920B (zh) | 一种反向信任登录方法和装置 | |
Hadpawat et al. | Analysis of prevention of XSS attacks at client side | |
CN107124386B (zh) | 黑色产业内容的检测分析方法及装置 | |
US20230007913A1 (en) | Rendering of unsafe webpages | |
Liu et al. | Financial websites oriented heuristic anti-phishing research |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20180615 |