TryHackMe: Lookup

Walkthrough challenge Lookup trên TryHackMe — bao gồm privilege escalation (SUID, Sudo), elFinder command injection, và brute-force credentials.

Link: https://tryhackme.com/room/lookup

Keyword: Privilege Escalation (SUID, Sudo), elFinder, SUID

Cảm ơn TheHiker!

  • Machine's IP address: 10.10.2??.???
  • Attacker's IP address: 10.4.126.108 (OpenVPN to local)

0. RTFM

  • Lookup… liên quan đến nslookup?
  • Command injection?
  • Web application weaknesses to privilege escalation techniques: from CVEs to SSH The Root!

1. Recon và brute-force credentials

Sử dụng nmap để scan port: nmap -sC -sV 10.10.210.252

nmap scan

Phát hiện 2 port: 22 (SSH, cần password) và 80 (web server).

Truy cập http://10.10.210.252 — không vào được vì lookup.thm chưa resolve. Thêm vào /etc/hosts:

10.10.210.252   lookup.thm

Thấy login page, nhưng không có gì đặc biệt:

Login page

Test các vulnerability: SQL injection, XSS, default credentials, CVEs… không có gì hoạt động.

Giải pháp: brute-force username và password. Dùng Burp Suite Intruder.

Nếu username đúng + password sai → response khác. Test: admin + password sai:

Wrong password response

Setup Intruder:

Intruder setup

Phát hiện 2 username đúng: adminjose.

Username found

Brute-force password của jose:

Password found

Đăng nhập:

Redirect to files

Subdomain mới? Thêm vào hosts:

10.10.210.252   lookup.thm
10.10.210.252   files.lookup.thm

elFinder interface

File credentials.txt chứa: think: nopassword.

2. Attack elFinder

elFinder version

Version elFinder 2.1.47. Dùng searchsploit:

$ searchsploit elFinder 2.1.47 -w
 Exploit Title                                         |  URL
-------------------------------------------------------
elFinder 2.1.47 - 'PHP connector' Command Injection    | https://www.exploit-db.com/exploits/46481

Tìm được PoC Python: github.com/hadrian3689/elFinder_2.1.47_php_connector_rce

Running exploit

Got shell

Đã có shell ở www-data!

3. Privilege Escalation từ www-data

Đọc /etc/passwd:

$ cat /etc/passwd | grep sh$
root:x:0:0:root:/root:/usr/bin/bash
think:x:1000:1000:,,,:/home/think:/bin/bash

home directory

Cần đọc .passwordsuser.txt nhưng chỉ có quyền www-data. Tìm SUID binary: find / -perm /4000 2>/dev/null

SUID binaries

pwm là binary lạ. Chạy thử:

pwm output

pwm extract username từ id command → tạo fake /tmp/id để giả làm user "think":

Fake id trick

Dùng hydra brute-force SSH password:

Hydra results

Login SSH vào think, chuyển sang phase 2…

4. Privilege Escalation từ "think"

Kiểm tra sudo -l:

sudo -l output

Có thể dùng look binary với sudo → GTFOBins:

GTFOBins look

Kiểm tra .ssh folder:

SSH keys

  • Private key (id_rsa) proves identity, dùng để authentication
  • Public key (id_rsa.pub) allows authentication from corresponding private key

File cần đọc: private key của root's SSH.

Root SSH key

Copy key về máy, set permission 600, login lại:

Root access

Root is pwned! 🎉

Cảm ơn TheHiker rất nhiều đã giúp mình giải challenge này!