查看原始值,一般都是0:
EXEC sp_configure 'show advanced options'
开启xp_cmdshell:
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
执行命令:
exec master.dbo.xp_cmdshell 'whoami'
exec master..xp_cmdshell 'whoami'
exec xp_cmdshell 'whoami'
关闭xp_cmdshell:
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;
恢复show advanced options的值:
EXEC sp_configure 'show advanced options', 0;RECONFIGURE;
本文档详细介绍了如何在SQL Server中使用xp_cmdshell存储过程执行系统命令,包括开启和关闭xp_cmdshell,以及执行具体命令的方法。通过示例展示了如何使用xp_cmdshell执行'whoami'命令。
7169

被折叠的 条评论
为什么被折叠?



