標(biāo)簽:本地文件包含(LFI)、FUZZ若未、PHP偽協(xié)議禾怠、nginx日志文件寫一句話恩商、反彈shell变逃、screen提權(quán)
0x00 環(huán)境準(zhǔn)備
下載地址:https://www.vulnhub.com/entry/dc-5,314/
flag數(shù)量:1
攻擊機(jī):kali
攻擊機(jī)地址:192.168.1.31
靶機(jī)描述:
DC-5 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
The plan was for DC-5 to kick it up a notch, so this might not be great for beginners, but should be ok for people with intermediate or better experience. Time will tell (as will feedback).
As far as I am aware, there is only one exploitable entry point to get in (there is no SSH either). This particular entry point may be quite hard to identify, but it is there. You need to look for something a little out of the ordinary (something that changes with a refresh of a page). This will hopefully provide some kind of idea as to what the vulnerability might involve.
And just for the record, there is no phpmailer exploit involved. :-)
The ultimate goal of this challenge is to get root and to read the one and only flag.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won't give you the answer, instead, I'll give you an idea about how to move forward.
But if you're really, really stuck, you can watch this video which shows the first step.
0x02 信息搜集
1.探測(cè)靶機(jī)地址
命令:arp-scan -l
靶機(jī)地址是192.168.1.33
2.探測(cè)靶機(jī)開(kāi)放端口
命令:nmap -sV -p- 192.168.1.33
開(kāi)放了80端口,看一下80端口怠堪,不是什么CMS揽乱。
3.掃描目錄
命令:dirb 192.168.1.33 /usr/share/wordlists/fuzzDicts/directoryDicts/php/phpFileName.txt
也沒(méi)有什么敏感目錄,只有contcat模塊和用戶有交互粟矿,看一下這個(gè)模塊凰棉。
0x03 本地文件包含LFI
在Contact模塊下可以留言,隨便填寫一下提交:
提交后頁(yè)面:
誒陌粹,下面的2019好像變成2018了撒犀,再刷新幾次看看
又變了,這里應(yīng)該是footer.php控制的掏秩,訪問(wèn)一下footer.php看看或舞。
多刷新幾次,發(fā)現(xiàn)也會(huì)改變蒙幻,所以這應(yīng)該是剛才那個(gè)頁(yè)面thankyou.php包含了footer.php映凳,這里應(yīng)該是有個(gè)文件包含。fuzz一下
這里通過(guò)index.php來(lái)爆破參數(shù)
發(fā)現(xiàn)一個(gè)file參數(shù)邮破,驗(yàn)證一下诈豌,訪問(wèn):192.168.1.33/thankyou.php?file=/etc/passwd
file確實(shí)是文件包含的參數(shù)仆救,這是一個(gè)Linux系統(tǒng)。
除了這樣驗(yàn)證队询,還可以使用PHP偽協(xié)議讀取thankyou.php代碼來(lái)查看是否存在文件包含漏洞派桩,訪問(wèn)http://192.168.1.33/thankyou.php?file=php://filter/read=convert.base64-encode/resource=thankyou.php
Base64解碼后可以看到,確實(shí)有文件包含漏洞
0x04 nginx日志文件寫入shell
使用瀏覽器插件可以看到web容器是nginx
嘗試尋找nginx的日志文件蚌斩,里面會(huì)記錄請(qǐng)求的信息。通過(guò)請(qǐng)求信息來(lái)注入惡意代碼范嘱。nginx日志文件默認(rèn)放在/var/log/nginx
下送膳,以.log
結(jié)尾,使用burp爆破一下:
發(fā)現(xiàn)該目錄下存在兩個(gè)文件丑蛤,分別是access.log和error.log叠聋。
寫入一句話
使用phpinfo驗(yàn)證
連菜刀
連接成功
0x05 反彈shell
在/tmp/
目錄下新建一個(gè)php文件,用來(lái)反彈shell:
先在kali上監(jiān)聽(tīng)指定端口受裹,然后文件包含shell.php文件
成功得到shell碌补,切換到bash外殼,命令:python -c 'import pty;pty.spawn("/bin/bash")'
0x06 提權(quán)
使用find命令棉饶,查找具有suid權(quán)限的命令厦章。命令:find / -perm -u=s -type f 2>/dev/null
發(fā)現(xiàn)有個(gè)screen,別問(wèn)我為啥用這個(gè)提權(quán)照藻,表哥們都用袜啃,咱也不敢問(wèn)。
命令:searchsploit screen 4.5.0
發(fā)現(xiàn)兩個(gè)可利用文件幸缕,使用第一個(gè)群发,復(fù)制下來(lái)進(jìn)行編譯。
首先將上部分的c語(yǔ)言代碼另存為libhax.c
文件:
編譯:gcc -fPIC -shared -ldl -o libhax.so libhax.c
將中間部分的C語(yǔ)言代碼另存為rootshell.c文件:
編譯:gcc -o rootshell rootshell.c
將41154.sh中剩下的代碼整理一下发乔,另存為dc5.sh熟妓,并輸入:set ff=unix
,保存退出
將整理好的3個(gè)文件用菜刀上傳到靶機(jī)的/tmp目錄下
為dc5.sh添加執(zhí)行權(quán)限并執(zhí)行
提權(quán)成功栏尚,在/root下找到flag文件
由于我不會(huì)每天都登錄簡(jiǎn)書起愈,所以有什么私信或者評(píng)論我都不能及時(shí)回復(fù),如果想要聯(lián)系我最好給我發(fā)郵件抵栈,郵箱:Z2djMjUxMTBAMTYzLmNvbQ==告材,如果發(fā)郵件請(qǐng)備注“簡(jiǎn)書”
參考鏈接:
1.Vulnhub靶機(jī)實(shí)戰(zhàn)——DC-5
2.VulnHub—DC-5
3.DC-5 vulnhub靶機(jī)實(shí)戰(zhàn)