[ROOT] Walkthrough Obscurity

Hackthebox - Linux Machine

Posted by rmn0x01 on Sunday, June 8, 2025

Medium difficulty Linux Machine on custom web server with a taste of cryptography.

Intro

Obscurity

Recon

Scan port using NMAP nmap1 nmap2 nmap3 nmap4

Default webserver on port 80 is closed, but port 8080 is open, start analyzing this port 8080

Check the source code Source Code

From the source code, file SuperSecureServer.py is interesting, use ffuf to fuzz the directory to get the file.

./ffuf -w /usr/share/dirb/wordlists/common.txt -u http://10.10.10.168:8080/FUZZ/SuperSecureServer.py

ffuf

From downloaded SuperSecureServer.py file, we can analyze it that the function ServeDoc is having a possibility to be exploited possible exploit

The variable path is an input from an URL (IP/Path), therefore we can craft a payload here

Script Exploit

payload

We can test it by setting up a listener, then ping it via crafted payload test

Ping is detected, therefore we successfully triggered an RCE rce

Now is the main exploit, we have information that the target machine has RCE, triggered via URL. Grab a payload from PayloadAllTheThings, in this case we will use Python Reverse Shell. Convert it to URL-encoded

payload

Payload is ready, now setup a listener on our local, set to port 4242, then trigger it. listener

We got shell! This time as user www-data

Recon as www-data

Enumerate and explore files and dictionaries in the machine as www-data, we found interesting files under robert’s user in /home/robert robert Download those files to local to be analyzed

Cryptography Analysis

On the SuperSecureCrypt.py we need to analyze both encrypt and decrypt function crypt From here we know that the encypt-decrypt function is doing a sum from character of the plaintext with a key, and vice versa (reversing it by subtracting). File is in UTF-8 encoded, so will be run via python3

To test the theory, we will try it with a string bajigur and key suw test

After given the ciphertext ct.txt, how to get the key back is to subtract character in ct.txt modulo 255 reverse

Getting the key: key

The theory is proven, now on to getting the real key, using file check.txt and out.txt rev1 rev2

Key: alexandrovich

With this key, we can get the password pass1 pass2

Use it as credentials for Robert’s SSH login ssh

Welcome-welcome to Robert’s access, get the user flag flag

Flag User: e4493782066b55fe2755708736ada2d7

Recon as Robert

Gaining Robert’s access, we start another recon session by enumerating files and directories inside the machine, this file surely interesting file

Cryptography Analysis

The said file’s content is: content

Analysis: After robert inputting the user password, file /etc/shadow will be read and written into /tmp/SSH/random_char while having pause for 0.1s each, then when finished it will be deleted

Strategy: With knowing the process, we can create a bash that run a while loop to continuously read /tmp/SSH/* directory as long as the file BetterSSH.py is executed, with the goal is read any output to the directory when line f.write is executed, then we can get shadow file.

  1. Prepare 1 terminal to read the /tmp/SSH/* directory Read

  2. Open another terminal, execute BetterSSH.py BetterSSH

  3. Watch the 1st terminal Terminal

We got the shadow for robert and root

Privilege Escalation

Arrange given shadow text so it mimics the real /etc/shadow file shadow

Read the /etc/passwd file passwd

Use unshadow to combine passwd and shadow files unshadow

Spin up john the ripper to bruteforce the password john

Password: mercedes

Use BetterSSH.py to gain access as root using password mercedes root

Voila! Root access taken, read the root flag:

Flag root : 512fd4429f33a113a44d5acde23609e3