gpt4 book ai didi

sql-server - 为什么 xp_cmdshell 在 SQL Server 2012 中不起作用?

转载 作者:行者123 更新时间:2023-12-02 14:12:39 25 4
gpt4 key购买 nike

Possible Duplicate:
Enable ‘xp_cmdshell’ SQL Server

当我运行xp_cmdshell时在 SQL Server 2012 中运行命令时,我收到以下消息:

SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', search for 'xp_cmdshell' in SQL Server Books Online.

但是,在 SQL Server 2000 中该查询执行成功。

最佳答案

从 SQL Server 2005 开始,当他们引入 Surface Area Configuration Tool 时,此功能已被禁用。 ,努力使 SQL Server 在默认情况下更加安全。该工具现已退役,但您仍然可以使用 sp_configure 控制行为。 An example is shown on MSDN :

-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO

(我也blogged about this many years ago。)

原因是这是一个潜在的安全漏洞。如果允许 SQL Server 执行 xp_cmdshell ,那么理论上他们可以在那里发送任何操作系统命令,绕过您认为拥有的任何和所有安全性。当 SQL Server 服务帐户和/或代理帐户已提升到系统管理员或其他级别时,这尤其成问题,因为这比仅显式定义它们应该能够执行的操作更容易。

公开操作系统功能同时仍对安全性进行一定控制的一种流行方法是使用 SQL-CLR 实现所需的操作系统级功能,而不是启用或禁用它来支持命令行交互。这是a good starting point for accessing the file system with CLR (但是,如果您四处搜索,您会发现更现代、更详尽的方法)。

关于sql-server - 为什么 xp_cmdshell 在 SQL Server 2012 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14550024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com