懒码农。。。。。。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
xp_cmdshell 扩展存储过程将命令字符串作为操作系统命令 shell 执行,并以文本行的形式返回所有输出。由于xp_cmdshell 可以执行任何操作系统命令,所以一旦SQL Server管理员帐号(如sa)被攻破,那么攻击者就可以利用xp_cmdshell 在SQL Server中执行操作系统命令,如:创建系统管理员,也就意味着系统的最高权限已在别人的掌控之中。由于存在安全隐患,所以在SQL Server 2005中, xp_cmdshell 默认是关闭的。 

  两种方式启用xp_cmdshell 

  1.打开外围应用配置器—> 

  功能的外围应用配置器—> 

  实例名Database Enginexp_cmdshell—> 

  启用 

  2.sp_configure 

  -- 允许配置高级选项 

  EXEC sp_configure 'show advanced options', 1 

  GO 

  -- 重新配置 

  RECONFIGURE 

  GO 

  -- 启用xp_cmdshell 

  EXEC sp_configure 'xp_cmdshell', 0 

  GO 

  --重新配置 

  RECONFIGURE 

  GO 

  --执行想要的xp_cmdshell语句 

  Exec xp_cmdshell 'query user' 

  GO 

  --用完后,要记得将xp_cmdshell禁用(从安全角度安全考虑) 

  -- 允许配置高级选项 

  EXEC sp_configure 'show advanced options', 1 

  GO 

  -- 重新配置 

  RECONFIGURE 

  GO 

  -- 禁用xp_cmdshell 

  EXEC sp_configure 'xp_cmdshell', 1 

  GO 

  --重新配置 

  RECONFIGURE 

  GO 
posted on 2011-10-26 14:11  阿彬  阅读(214)  评论(0编辑  收藏  举报