渗透Five86-1

靶机描述

下载地址:https://download.vulnhub.com/five86/Five86-1.zip

1
2
3
4
5
6
7
Five86-1 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.

信息收集

扫描同网段存活主机

1
arp-scan -l

发现目标主机IP

端口扫描,发现三个开放端口

1
nmap -A 172.18.1.146

尝试访问web服务,发现是空白页面

目录搜索,寻找存活目录

1
dirsearch -u http://172.18.1.146/ -i 200

在robots下看到另一个路径/ona

访问查看

发现这个是OpenNetAdmin的管理界面

给了该工具的版本号,可以查到该版本下的此工具存在RCE漏洞

漏洞利用

利用kali自身的漏洞库搜索相关漏洞,发现第三条正好是我们此靶机工具版本

此脚本需要转换一下格式才能使用

攻击利用

1
bash 47691.sh http://172.18.1.146/ona/

成功获取shell

权限提升

在这个shell里尝试切换目录发现没有效果,查询后发现是靶机设置的,需要寻找一个特定的文件

1
使用find / -type f -user www-data命令查看这个用户可以读取的文件

1
2
读取 var/www/html/reports/.htaccess 
cat /var/www/html/reports/.htaccess

1
2
读取 /var/www/.htpasswd
cat /var/www/.htpasswd

找到一个hash过的数值

给出了提示

使用crunch生成对应的字典

1
crunch 10 10 aefhrt -o pswd.txt

使用hashcat工具碰撞,发现内存不足

1
hashcat -m 1600 -a 0 -o res hash.txt pswd.txt --force

试试其他工具

1
john --wordlist=pswd.txt hash.txt

找到真实密码fatherrrrr

使用ssh连接

1
ssh douglas@172.18.1.146

查看用户权限信息

发现可以在无密码的情况下使用jen去访问/bin/cp

如果jen用户下的/home/jen/.ssh/authorized_keys包含douglas的公钥,那就可以用douglasid_rsa文件登陆jen的ssh,也即免密登陆jen的ssh。这里复制到/tmp目录下是因为jen没有权限访问douglas目录下的文件

1
2
3
4
cp .ssh/id_rsa.pub /tmp/authorized_keys
chmod 777 /tmp/authorized_keys
sudo -u jen /bin/cp /tmp/authorized_keys /home/jen/.ssh/
ssh -i id_rsa jen@127.0.0.1

成功登录jen的远程账号

查看用户能访问的文件信息

1
find / -type f -user jen

找到一个可以读取的文件

1
cat /var/mail/jen

在这个邮件里获得的moss的用户密码

ssh连接

1
ssh moss@127.0.0.1

查看用户权限信息,发现隐藏目录.games

在目录下发现一个有root权限的二进制文件

直接运行这个二进制文件,运行之后就能获得root权限

查找flag

1
find / -name "*flag*"