⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 介绍了数据库方面的基础知识
💻
📖 第 1 页 / 共 2 页
字号:
的描述:http://www.microsoft.com/technet/security/bulletin/fq00-014.asp

关于上面的漏洞,可以使用下面的xploit来获得权利的提升:

SELECT * FROM OPENROWSET('SQLOLEDB','Trusted_Connection=Yes;Data Source=myserver',
'SET FMTONLY OFF execute master..xp_cmdshell "dir c:\"')

这是大家比较喜欢的一种可以执行其他命令,自己想吧。

---------------------------------------------------------------------------

还有就是最近的一个漏洞:Extended Stored Procedure Parameter Parsing (扩展存储
过程参数解析)的漏洞,详细信息在这个URL有介绍:
http://www.microsoft.com/technet/security/bulletin/ms00-092.asp。

起主要问题是在MSD中提供一个API函数srv_paraminfo(),它是用来扩展存储过程调用时
解释深入参数的,如:

exec <存储过程名> <参数1>, <参数2>, ...
如要查询“c:\winnt”的目录树,可以如下表达:
exec xp_dirtree 'c:\winnt'

但没有检查各个参数的长度,传递相当长的字符串,就存在了覆盖其他堆栈
参数的可能导致缓冲溢出。

目前已经知道的过程如下:
目前已知受影响的扩展存储过程如下:

1、xp_peekqueue (xpqueue.dll)
xp_printstatements (xprepl.dll)

给第一个参数传递超长的字符串会覆盖异常处理程序所保存的返回地址。

2、xp_proxiedmetadata (xprepl.dll)

该存储过程使用4个参数。给第二个参数传递超长的字符串会覆盖异常处
理程序所保存的返回地址。

3、xp_SetSQLSecurity (xpstar.dll)

该存储过程使用4个参数。给第三个参数传递超长的字符串会使整个SQL 
Server进程立即终止。

4、xp_displayparamstmt(xprepl.dll)
xp_enumresultset(xprepl.dll)
xp_showcolv (xprepl.dll)
xp_updatecolvbm (xprepl.dll)

给第一个参数传递超长的串将导致非法操作并覆盖异常处理程序所保存的返
回地址。

这里告诉大家一个技巧性的东西,如果想要知道这些扩展存储过程调用了那写dll
文件,你可以如下操作,如:

select o.name,c.text from dbo.syscomments c, dbo.sysobjects o where c.id = o.id and o.name 
= 'xp_peekqueue' 

这样你就可以获得调用这个扩展存储过程的DLL了,如果微软没有出补丁的话,你就
暂时把这个DLL文件改名吧,当然有些DLL文件调用几个扩展存储过程,不能盲目更改,
否则导致其他的也不能使用,你需要使用下面的操作来知道DLL调用那些扩展存储过程:

select o.name,c.text from dbo.syscomments c, dbo.sysobjects o where c.id = o.id and c.text = 'xpqueue.dll' 

幸好微软出了补丁,你可以到下面的地方找到,不用一个一个找DLL程序了,呵呵:

http://support.microsoft.com/support/sql/xp_security.asp

这个漏洞@stake发现并提供演示的测试代码,大家可在这里找到:

http://www.atstake.com/research/advisories/2000/sqladv2-poc.c

--------------------------------------------------------------------------

OK,当然SQL SERVER也有一些其他漏洞,相对轻微些,如ISS发现的管理员
LOGIN ID存储在注册表中,其加密的方法比较简单,很容易获得,详细情况
请看:http://xforce.iss.net/alerts/advise45.php3。大家可以到其他
地方找找。

---------------------------------------------------------------------

一些对SQL SERVER系统的安全建议:

--保证打上最新的安全补丁,如下:
Windows NT 4.0 - Service Pack 6a

SQL Server 6.5 - Service Pack 5a

SQL Server 7.0 - Service Pack 2. (Various hotfixes - check 
http://www.microsoft.com/download) 

SQL Server 2000 - Hotfix S80233i.exe (Intel)
当然大家要密切注意微软的安全公告。

--不要在IP sockets使用端口1433,如果你使用Multi-protocol也请
修改端口。

--不要把'sa'密码嵌入到任意应用程序如VB/DELPHI apps里,或者一
global.asa文件里,因为"sa"是SQL Server 的一个默认密码,其权限
类似与WINDOWS NT系统里的管理员帐户,而且密码为空。

--改变'sa'和'probe'帐户的密码。

--保证SQL SERVER的错误记录在NTFS系统上。

--如果你不需要xp_cmdshell( use sp_dropextendedproc 'xp_cmdshell' ) 
就不要把xp_cmdshell extended stored proc(扩展存储过程) 留在服务
器上。在任何isql窗口中输入:
use master
sp_dropextendedproc 'xp_cmdshell'

--丢弃不需要OLE自动存储过程,当然Enterprise Manager中的某些特征也
会不能使用,这些过程包括如下:

Sp_OACreate Sp_OADestroy 

Sp_OAGetErrorInfo Sp_OAGetProperty 

Sp_OAMethod Sp_OASetProperty 

Sp_OAStop

--去掉不需要的注册表访问过程,如下:

Xp_regaddmultistring 

Xp_regdeletekey 

Xp_regdeletevalue 

Xp_regenumvalues 

Xp_regread 

Xp_regremovemultistring 

Xp_regwrite

--去掉其他系统存储过程,如果你认为你觉得你还有威胁,当然
要小心Drop这些过程,你可以在测试机器上测试,保证你正常的
系统能完成工作,这些过程包括:

sp_bindsession sp_cursor sp_cursorclose
sp_cursorfetch sp_cursoropen sp_cursoroption
sp_getbindtoken sp_GetMBCSCharLen sp_IsMBCSLeadByte
sp_OACreate sp_OADestroy sp_OAGetErrorInfo
sp_OAGetProperty sp_OAMethod sp_OASetProperty
sp_OAStop sp_replcmds sp_replcounters
sp_repldone sp_replflush sp_replstatus
sp_repltrans sp_sdidebug xp_availablemedia
xp_cmdshell xp_deletemail xp_dirtree 
xp_dropwebtask xp_dsninfo xp_enumdsn
xp_enumerrorlogs xp_enumgroups xp_enumqueuedtasks
xp_eventlog xp_findnextmsg xp_fixeddrives
xp_getfiledetails xp_getnetname xp_grantlogin
xp_logevent xp_loginconfig xp_logininfo
xp_makewebtask xp_msver xp_perfend
xp_perfmonitor xp_perfsample xp_perfstart
xp_readerrorlog xp_readmail xp_revokelogin
xp_runwebtask xp_schedulersignal xp_sendmail
xp_servicecontrol xp_snmp_getstate xp_snmp_raisetrap
xp_sprintf xp_sqlinventory xp_sqlregister
xp_sqltrace xp_sscanf xp_startmail
xp_stopmail xp_subdirs xp_unc_to_drive 

--去掉数据库中guest用户。
--关闭SQL MAIL兼容能力,防止传递一些木马病毒等。
--设置一个任务处理来定时运行下面的程序:

findstr /C:"Login Failed" \mssql7\log\*.*'

再重定向到其他文件或者MAIL到管理员信箱。

--经常检查带有空密码的帐户:

Use master
Select name,
Password
from syslogins
where password is null
order by name

--检查所有不需要'sa'权限的存储过程和扩展存储过程访问权限:

Use master
Select sysobjects.name
From sysobjects, sysprotects
Where sysprotects.uid = 0
AND xtype IN ('X','P')
AND sysobjects.id = sysprotects.id
Order by name


--保证SQL SERVER的传输信息在隔离的网络段中。

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -