• DWVA-关于反射型xss的漏洞详解<xss reflected>


    反射型xss

    low级别

    代码如下:

     1 <?php
     2 
     3 header ("X-XSS-Protection: 0");
     4 
     5 // Is there any input?
     6 if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
     7     // Feedback for end user
     8     echo '<pre>Hello ' . $_GET[ 'name' ] . '</pre>';
     9 }
    10 
    11 ?> 

    从上图中可以看出来,对于接收到的输入参数,并未做任何处理,因此直接插入恶意代码

    <script>alert('hahaha')</script>

    效果如下:

    medium级别

    代码如下:

     1 <?php
     2 
     3 header ("X-XSS-Protection: 0");
     4 
     5 // Is there any input?
     6 if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
     7     // Get input
     8     $name = str_replace( '<script>', '', $_GET[ 'name' ] );
     9 
    10     // Feedback for end user
    11     echo "<pre>Hello ${name}</pre>";
    12 }
    13 
    14 ?> 

    代码中可以看出,通过str_replace将<script>,替换为空。

    这种情况下可以使用拼写<script>的方法,输入如下参数:

    <scr<script>ipt>alert('lalala')</script>

    输入后前面的<scr<script>ipt>中将<script>替换为空后,有重新组合出一个<script>,达到注入目的。

    效果如下:

    成功注入。

    high级别

    代码如下:

     1 <?php
     2 
     3 header ("X-XSS-Protection: 0");
     4 
     5 // Is there any input?
     6 if( array_key_exists( "name", $_GET ) && $_GET[ 'name' ] != NULL ) {
     7     // Get input
     8     $name = preg_replace( '/<(.*)s(.*)c(.*)r(.*)i(.*)p(.*)t/i', '', $_GET[ 'name' ] );
     9 
    10     // Feedback for end user
    11     echo "<pre>Hello ${name}</pre>";
    12 }
    13 
    14 ?> 

    high级别代码,使用正则表达式对输入参数进行搜索和替换,有效避免了组合绕过和大小写绕过。

    不过既然它仅仅是对于<script>进行过滤,我们可以使用其他表达式进行绕过、

    <img src=1 onerror=alert('hahah')>

    效果如下:

  • 相关阅读:
    DateTime.Compare how to check if a date is less than 30 days old?
    疫情防控记录
    vulnerable process has been exploited and is running
    判断NBIOT的网络信号
    FortiGate 防火墙常用命令
    常见软路由 网卡 和 处理器 对比
    telnet ssh 默认程序关联
    地磁,干扰及校准,椭球拟合
    FortiGate SDWAN 多链路负载均衡
    All In One Runtimes 3.9.2.1 Unattended
  • 原文地址:https://www.cnblogs.com/Hpineapple/p/12193610.html
Copyright © 2020-2023  润新知