SQL漏洞(2)

1970-01-01 08:00

inurl:view_product.php?id= inurl:newsone.php?id= inurl:sw_comment.php?id= inurl:news.php?id= inurl:avd_start.php?avd= inurl:event.php?id= inurl:product-item.php?id= inurl:sql.php?id= inurl:material.php?id= inurl:clanek.php4?id= inurl:announce.php?id= inurl:chappies.php?id= inurl:read.php?id= inurl:viewapp.php?id= inurl:viewphoto.php?id= inurl:rub.php?idr= inurl:galeri_info.php?l= inurl:pages.php?id= inurl:announce.php?id= inurl:clanek.php4?id= inurl:participant.php?id= inurl:download.php?id= inurl:main.php?id= inurl:review.php?id= inurl:chappies.php?id= inurl:read.php?id= inurl:prod_detail.php?id= inurl:viewphoto.php?id= inurl:article.php?id= inurl:person.php?id= inurl:productinfo.php?id= inurl:showimg.php?id= inurl:view.php?id= inurl:website.php?id= inurl:preview.php?id= inurl:loadpsb.php?id= inurl:pages.php?id= b:初始验证网站是否可以进行SQL注入

b. 上面的字符串搜索之后,也许会得到成百上千的结果,那么如何判断这些网

站是否可以进行SQLMAP的注入呢?有很多种方法,我相信大家会争论哪种才是最好的,但是对我而言下面的方法是最简单和最有效的。

c. 我们假设你使用了字符串:inurl:item_id=,然后其中一个结果的网站是:

d. http://www.sqldummywebsite.com/cgi-bin/item.cgi?item_id=15 e. 在后面添加添加一个单引号’之后,URL成为了:

f. http://www.sqldummywebsite.com/cgi-bin/item.cgi?item_id=15' g. 如果页面返回一个SQL错误,说明页面存在SQL注入点;如果页面加载正

常显示或者重定向到一个不同的页面,跳过这个网站,用同样的方法去测试下一个网站吧! h. 【PS:现在比较多的可以使用’and 1=1’、‘or 1=1’等测试注入点的存在,这

篇文章侧重地是使用SQLMAP注入的思路和整体步骤】 i. 下面是我自己测试时的SQL错误截图:

j.

k. 不同的数据库返回的SQL错误或许会有不同,比如:

l. Microsoft SQL Server

m. Server Error in ‘/’ Application. Unclosed quotation mark before the character string ‘attack;’. n. 描述:

Description: An unhanded exception occurred during the execution of the current web request. Please review the stack trace for more information about the error where it originated in the code.

o. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark before the character string ‘attack;’ p. MySQL Errors

q. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/myawesomestore.com/buystuff.php on line 12 r. s. Error: You have an error in your SQL syntax: check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’’ at line 12 t.

u. Oracle Errors

v. java.sql.SQLException: ORA-00933: SQL command not properly ended at oracle.jdbc.dbaaccess.DBError.throwSqlException(DBError.java:180) at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208) w. x. Error: SQLExceptionjava.sql.SQLException: ORA-01756: quoted string not properly terminated y. PostgreSQL Errors

z. Query failed: ERROR: unterminated quoted string at or near ?‘’’?

5 实际案例 WooYun: 新浪SAE沦陷,oauth token/安全密码全部泄露,hack任意app 由于数据库链接的权限过于集中,通过构造合适的SQL语句,恶意用户窃取当前数据库连接里所有的数据,从一个本不是特别严重的数据库查询处攻击成功到较为敏感的数据,从而实现一个安全漏洞的最大的破坏。 WooYun: 搜狐女人频道SQL注射漏洞 同样由于程序对数据过滤不严,导致用户可以控制程序处理的SQL语句,本身该查询对数据进行攻击的意义并不大,因为数据库里不包含特别敏感的信息,精心构造该SQL语句可以将取回的结果反作用于程序,利用程序对结果的处理(这里是将取回的数据进行读模板操作),将导致可以在服务器上执行命令,从而演变为一个高危险的漏洞。

6 修复方案 比较传统的修复方式一般认为是对输入的数据进行有效的过滤,但是由于输入的来源太过广泛,可能来自于数据库,HTTP请求,文件或者其他的数据来源,较难对所有进入的数据在各种场景下进行有效的过滤。 事实上最罪恶的不是数据,而是我们使用数据的方式,最为彻底的修复一定要查找最为彻底的根源,我们可以看到最后的根源在于对数据和指令的不分离,所以在修复的时候应该极力将数据和指令分离。目前较为提倡的,同时在各种数据库操作

框架里体现的方式就是以填充模板的方式来代替传统的拼接的方式进行数据库查询,譬如:

$SqlTemplate=\id|int}\ $sb->PreSql($SqlTemplate,$_GET['userid']); 模板里有关数据及数据自身意义的描述,PreSql方法将实现将模板和数据安全的转换为SQL语句的功能,以保障最终的安全的实现。


SQL漏洞(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:安全度汛方案--

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: