xss

web前端防止xss 攻击

…衆ロ難τιáo~ 提交于 2019-12-28 05:23:21
对输出进行编码 在输出数据之前对潜在的威胁的字符进行编码、转义是防御XSS攻击十分有效的措施。如果使用好的话,理论上是可以防御住所有的XSS攻击的。 对所有要动态输出到页面的内容,通通进行相关的编码和转义。当然转义是按照其输出的上下文环境来决定如何转义的。 1> 作为body文本输出,作为html标签的属性输出: 比如: u s e r n a m e < / s p a n > , < p > < c : o u t v a l u e = " {username}</span>, <p><c:out value=" u s e r n a m e < / s p a n > , < p > < c : o u t v a l u e = " {username}"></c:out> 此时的转义规则如下: < 转成 < 转成 > & 转成 & " 转成 " ’ 转成 &#39 2> javascript事件 <input type=“button” οnclick=‘go_to_url("${myUrl}");’ /> 除了上面的那些转义之外,还要附加上下面的转义: \ 转成 \ / 转成 / ; 转成 ;(全角;) 3> URL属性 如果 确保:href 和 src 的值必须以 http://开头,白名单方式;不能有10进制和16进制编码字符。 HttpOnly 与 XSS防御

Generating AntiForgeryToken in WebForms

假装没事ソ 提交于 2019-12-28 05:10:09
问题 I have a .NET Webforms site thanks needs to post to my MVC Application which currently sits inside the Webform site as a separate application. The Webform application need to POST some sensitive values to the MVC Application. Is there a way to generate a AntiForgeryToken() in my WebForms Application so it can be passed with the form post. Otherwise does anyone know of any other custom anti forgery code that will allow me to do something similar to the MVC's AntiForgeryValidation. 回答1: This is

htmlspecialchars vs htmlentities when concerned with XSS

偶尔善良 提交于 2019-12-28 01:55:48
问题 I have seen a lot of conflicting answers about this. Many people love to quote that php functions alone will not protect you from xss. What XSS exactly can make it through htmlspecialchars and what can make it through htmlentities? I understand the difference between the functions but not the different levels of xss protection you are left with. Could anyone explain? 回答1: htmlspecialchars() will NOT protect you against UTF-7 XSS exploits, that still plague Internet Explorer, even in IE 9:

What is cross site scripting?

二次信任 提交于 2019-12-27 11:05:14
问题 On this site (archived snapshot) under “The Theory of XSS’, it says: the hacker infects a legitimate web page with his malicious client-side script My first question on reading this is: if the application is deployed on a server that is secure (as is the case with a bank for example), how can the hacker ever get access to the source code of the web page? Or can he/she inject the malicious script without accessing the source code? 回答1: With cross-site scripting, it's possible to infect the

What is cross site scripting?

烂漫一生 提交于 2019-12-27 11:04:24
问题 On this site (archived snapshot) under “The Theory of XSS’, it says: the hacker infects a legitimate web page with his malicious client-side script My first question on reading this is: if the application is deployed on a server that is secure (as is the case with a bank for example), how can the hacker ever get access to the source code of the web page? Or can he/she inject the malicious script without accessing the source code? 回答1: With cross-site scripting, it's possible to infect the

Why the cross-domain Ajax is a security concern?

只谈情不闲聊 提交于 2019-12-27 11:03:54
问题 Why was it decided that using XMLHTTPRequest for doing XML calls should not do calls across the domain boundary? You can retrieve JavaScript, images, CSS, iframes, and just about any other content I can think of from other domains. Why are the Ajax HTTP requests not allowed to cross the domain boundaries? It seems like an odd limitation to put, considering the only way I could see it being abused, would be if someone were to inject Javascript into the page. However, in this case, you could

Why the cross-domain Ajax is a security concern?

℡╲_俬逩灬. 提交于 2019-12-27 11:03:13
问题 Why was it decided that using XMLHTTPRequest for doing XML calls should not do calls across the domain boundary? You can retrieve JavaScript, images, CSS, iframes, and just about any other content I can think of from other domains. Why are the Ajax HTTP requests not allowed to cross the domain boundaries? It seems like an odd limitation to put, considering the only way I could see it being abused, would be if someone were to inject Javascript into the page. However, in this case, you could

pikachu XSS

北战南征 提交于 2019-12-27 01:57:31
XSS(跨站脚本)概述Cross-Site Scripting 简称为“CSS”,为避免与前端叠成样式表的缩写"CSS"冲突,故又称XSS。一般XSS可以分为如下几种常见类型: 1.反射性XSS; 2.存储型XSS; 3.DOM型XSS; XSS漏洞一直被评估为web漏洞中危害较大的漏洞,在OWASP TOP10的排名中一直属于前三的江湖地位。 XSS是一种发生在前端浏览器端的漏洞,所以其危害的对象也是前端用户。 形成XSS漏洞的主要原因是程序对输入和输出没有做合适的处理,导致“精心构造”的字符输出在前端时被浏览器当作有效代码解析执行从而产生危害。 因此在XSS漏洞的防范上,一般会采用“对输入进行过滤”和“输出进行转义”的方式进行处理: 输入过滤:对输入进行过滤,不允许可能导致XSS攻击的字符输入; 输出转义:根据输出点的位置对输出到前端的内容进行适当转义; 攻击流程 假设存在漏洞的是一个论坛,攻击者将恶意的JS代码通过XSS漏洞插入到论文的某一页面中 当用户访问这个页面时,都会执行这个恶意的JS代码,这个代码就会在用户的浏览器端执行 XSS攻击类型 危害:存储型 > 反射型 > DOM型 反射型:交互的数据一般不会被存在数据库里面, 一次性 ,所见即所得,一般出现在查询页面等 存储型:交互的数据会被存在数据库里面, 永久性存储 ,一般出现在留言板,注册等页面 DOM型

XSS(跨站脚本攻击)及部分解决方案

浪子不回头ぞ 提交于 2019-12-26 17:21:46
最近做的部门内部用的一个小项目要上线,上线前安全测试测出了存储型XSS漏洞,自己也通过这个机会学习了一下,在此记录 1、什么是XSS XSS的中文含义是跨站脚本攻击,Cross Site Scripting,缩写为CSS,但容易与层叠样式表的缩写混淆,所以有人将其缩写为XSS 2、XSS原理 html是超文本标记语言,通过一些字符特殊对待来区分文本和标记,例如:<被看作html标签的开始,>被看作html标签的结束,那么<title>与</title>之间的内容就会被看作是标题。如果动态页面中插入的内容包含这些特殊字符(如:<等),用户浏览器就会将其误认为是html标签,如果被认为是html标签的内容中引入了一些js脚本,那么这些脚本就会在用户浏览器中执行,所以当这些特殊字符不能被动态界面检查或识别的时候,就会出现XSS漏洞。 3、XSS危害 1、窃取管理员帐号或Cookie,入侵者可以冒充管理员的身份登录后台。使得入侵者具有恶意操纵后台数据的能力,包括读取、更改、添加、删除一些信息。 2、窃取用户的个人信息或者登录帐号,对网站的用户安全产生巨大的威胁。例如冒充用户身份进行各种操作。 3、网站挂马。先将恶意攻击代码嵌入到Web应用程序之中。当用户浏览该挂马页面时,用户的计算机会被植入木马。 4、发送广告或者垃圾信息。攻击者可以利用XSS漏洞植入广告,或者发送垃圾信息

DVWA_XSS(DOM)

自古美人都是妖i 提交于 2019-12-25 22:39:18
XSS(DOM)是一种基于DOM树的一种代码注入攻击方式,可以是反射型的,也可以是存储型的,所以它一直被划分第三种XSS 与前两种XSS相比,它最大的特点就是不与后台服务器交互,只是通过浏览器的DOM树解析产生 除了js,flash等脚本语言也有可能存在XSS漏洞 关于DOM,墙裂推荐《JavaScriptDOM编程艺术》,写得真的很好 下面直接开始实践吧!(所有攻击都在火狐浏览器下进行的,谷歌做了XSS filter好烦、、、) Low: 作者太皮了,居然没有做任何的防护和过滤 Payload:?default=<script>alert("You have been hacked!");</script> Medium: PHP脚本代码: <?php // Is there any input? if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) { $default = $_GET['default']; # Do not allow script tags if (stripos ($default, "<script") !== false) { header ("location: ?default=English"); exit; } } ?>  前端代码: