chriszg 发表于 2016-11-1 05:59:35

SQL Server 2000 中的扩展存储过程

  ·XP_cmdshell
xp_cmdshell 操作系统命令外壳

这个过程是一个扩展存储过程,用于执行指定命令串,并作为文本行返回任何输出。

语法:
xp_cmdshell command_string[,no_output]

command_string要执行的命令串
no_output不返回命令执行的输出

说明:

在把xp_cmdshell的执行许可权授予用户时,用户将能够在Windows NT命令
外壳执行运行SQL Server(通常是本地系统)的帐号有执行特权的任何
操作系统命令。

例:

1、EXEC master..xp_cmdshell "dir *.exe"
返回可执行文件的列表

2、EXEC master..xp_cmdshell "copy d:/test1.jpg e:/" no_output
不返回输出

3、特别是执行
EXEC master..xp_cmdshell "net start awhost32"
EXEC master..xp_cmdshell "net stop awhost32"
可以启动和停止远程的PCAnywhere服务。对远程服务器操作很有帮助。
如果你不需要扩展存储过程xp_cmdshell请把它去掉。使用这个SQL语句:

  use master

  sp_dropextendedproc 'xp_cmdshell'

  xp_cmdshell是进入操作系统的最佳捷径,是数据库留给操作系统的一个大后门。如果你需要这个存储过程,请用这个语句也可以恢复过来。

  sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'  
  
·注册表操作存储过程(Xp_regaddmultistring 、Xp_regdeletekey 、Xp_regdeletevalue、Xp_regenumkeys、Xp_regenumvalues、Xp_regread、Xp_regremovemultistring、Xp_regwrite)
  如果不使用可以通过使用这个SQL语句去除
  use master

  sp_dropextendedproc ''Xp_regaddmultistring'
  
如果要恢复可以使用这个SQL语句
  use master

  sp_dropextendedproc ''Xp_regaddmultistring','xpstar.dll'
其余几个同样操作
页: [1]
查看完整版本: SQL Server 2000 中的扩展存储过程