> For the complete documentation index, see [llms.txt](https://jacob-taylor.gitbook.io/jacvbtaylor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jacob-taylor.gitbook.io/jacvbtaylor/offical-compromised-comms-walkthrough/compromised-comms.md).

# Compromised Comms

## <img src="/files/XERp0wBwakbN19WX0UCm" alt="" data-size="line"> COMPROMISED COMMS WRITEUP

*By Jacvbtaylor*

```
       Used openvpn and Kali Linux 
                 https://tryhackme.com/jr/compromisedcomms
         completed Jan 27, 2023
```

*"You will take on the role of a top-level agent tasked with uncovering a mole within your organization. The stakes are high, as a recent report has revealed that Agent Brian was found dead with a mysterious note reading "**921645**" in his jacket. To make matters worse, it has been leaked that he has been communicating with his Agent Handler through a seemingly innocent website, MACHINE\_IP. Your mission, should you choose to accept it, is to use your skills in forensic analysis, cryptography, and penetration testing to track down the mole who is responsible for taking down our Agents and how he potentially gained full server access. Good luck, agents!"*

### STEP 1: Recon

<figure><img src="/files/nwpcVcfD5TmoXPeAxMBJ" alt=""><figcaption><p>nmap</p></figcaption></figure>

With the information from the report, it is clear what the website is and that it is disguised for the Agent communication between the Assets, Agent, and the Agent Handler. Before viewing the website, running a scan to see additional services open will be important. \
\
From nmap, it is clear that there is a Webserver and Secure Socket Shell (SSH) access. Knowing SSH is open infers remote command line execution is allowed with the proper user credentials.

<figure><img src="/files/uCm0O85fnO29cp1I3oXn" alt=""><figcaption><p>Website</p></figcaption></figure>

Viewing the website running on the server shows nothing out of the ordinary. Most, if not all, of the buttons do not seem to work but the site functions smoothly and doesn't seem to have an CMS login - not one that stands out at least. \
\
Further investigation using a directory enumeration scanner, dirsearch, shows some directories and files worth taking note of.&#x20;

<figure><img src="/files/UfsEJi4mCWqU1vldsk1x" alt=""><figcaption><p>dirsearch</p></figcaption></figure>

The robots.txt file indicates a file that cannot be crawled, but this doesn't mean it cannot be viewed manually. It is clearly seen that there is a high chance of a secret.html file.

<figure><img src="/files/8HrEEj2zdE5Y6cOPXa1n" alt=""><figcaption><p>robots.txt</p></figcaption></figure>

As suspected, the secret.html file exists and has some interesting information. Why is this here and who's flight receipt is this?&#x20;

It will be beneficial to take note of this PII, or personal identifiable information.

<figure><img src="/files/98C20cID7FB2Qxw0RA2R" alt=""><figcaption><p>Flight Info</p></figcaption></figure>

Next up, the images directory does not have index browsing disabled and it is shown to have a random directory, DGI.

<figure><img src="/files/9ajtoa97nvMncNxdAbIx" alt=""><figcaption><p>DGI</p></figcaption></figure>

Navigating to this directory shows more file inclusion, but specifically a random image.&#x20;

<figure><img src="/files/g9CFL5H7slRfNJeyJn8g" alt=""><figcaption><p>NASA.jpg</p></figcaption></figure>

This image doesn't have anything to do with the website and seems very out of place. This is enough motive to investigate and is downloaded to the local machine using `wget`.

<figure><img src="/files/tOsD49REhx02EXFkrJRN" alt=""><figcaption><p>wget</p></figcaption></figure>

Inspecting the file, it is clear to be an image. Is it possible this image was placed here for a reason? Is it hiding crucial information? Only one way to find out.

### STEP 2: Attack

A common tactic used on images is steganography. Steganography allows for embedding text into an image by placing it in the least important bits in the photo. Viewing the photo, it is unclear there is a message because the change to that bit, or bits, isn't enough to change the image's appearance to the human eye, but there are tools that can be used to extract this information - assuming it exists.

Using *stegseek* and *rockyou.txt*, the image spewed out a message after the passcode was discovered.&#x20;

<figure><img src="/files/EatekhxAaWqsJNF40rpd" alt=""><figcaption><p>stegseek</p></figcaption></figure>

This text looks like complete gibberish though. Was this a waste of time or is it an encrypted message?&#x20;

<figure><img src="/files/AfxbMLuUCAnzNHL2XGwt" alt=""><figcaption><p>cyberchef</p></figcaption></figure>

Using Cyberchef, it becomes clear that this was in fact a hidden, encrypted message that had been encoded twice - once with Base85 and once with Base64. \
\
Seeing the message now in plaintext, it displays a file path. After adding the file path in the URL, the server now shows a login. \
\
There is not clear answer what the Username and Password are, but Agent Brian was using this channel and was found with a note. Using this information, it is worth trying his name and that message he left behind for the login..

<figure><img src="/files/USqyngd0mMNWQ9y7hsnl" alt=""><figcaption><p>login</p></figcaption></figure>

Sure enough, it worked. There seems to be an old chat log now, with another possible encrypted message.&#x20;

<figure><img src="/files/JoQEwbFn0AIa5o52FEB3" alt=""><figcaption><p>chat log</p></figcaption></figure>

Viewing the source code via the browsers allows for the encrypted message to be more accessible.&#x20;

<figure><img src="/files/DSV0t5mo02HCqwRHAO0T" alt=""><figcaption><p>source code</p></figcaption></figure>

Taking this message and using Cyberchef once more, there is more critical information that has been discovered using Base32 decryption - a password list and a username for SSH.

<figure><img src="/files/VV5cPN8WkMptmVXf4Wrm" alt=""><figcaption><p>Cyberchef</p></figcaption></figure>

Saving the password list and using Hydra to bruteforce, the password is discovered.

<figure><img src="/files/NtLsvoMTAzjIEVTLREKZ" alt=""><figcaption></figcaption></figure>

To ensure this is not a false positive, the login is attempted - and it works.

<figure><img src="/files/uM1Eoyzl8AUED8xFNMhj" alt=""><figcaption><p>SSH</p></figcaption></figure>

Inside the user's directory, a zip file is found: *Music.zip*

<figure><img src="/files/X1uHh5WfLd7v54acl2B7" alt=""><figcaption><p>Music.zip</p></figcaption></figure>

It is also password protected but the contents are displayed after an incorrect password is used. This appears to be information needed for the investigation.&#x20;

<figure><img src="/files/irXLdaQxtybLAGxTV14t" alt=""><figcaption><p>incorrect password</p></figcaption></figure>

Since this low level user has to live off the land in this Linux environment, the only way to bruteforce the zip file is by creating a script:

<figure><img src="/files/hEky3U2tD8RwtrFudbsf" alt=""><figcaption><p>crack.sh</p></figcaption></figure>

After creating the script and changing its mode to be executable, it is then ran and the password is found almost instantly.

<figure><img src="/files/sRxpnANZAK2viXPA8saV" alt=""><figcaption><p>Password found</p></figcaption></figure>

The contents are now freed but are unable to be concatenated. What does seem to work though is the *less* command.

<figure><img src="/files/PyVUf5mY7ar6Zuzr5Obg" alt=""><figcaption></figcaption></figure>

After going through these files, more important information is found that will allow for cracking down on the Agency's mole.&#x20;

<figure><img src="/files/KcJfbIinFF04zfbik3Zl" alt=""><figcaption><p>Email</p></figcaption></figure>

### STEP 3: Privilege Escalation

There is nothing else that can be done from this user, and it becomes clear that sudo will not be on our side.

<figure><img src="/files/qwB2gJlTlft9BiJnxZAs" alt=""><figcaption><p>Sudo</p></figcaption></figure>

Using the following command, this user is able to browse programs, or executables, that may have shared privileges with root

`find / -user root -perm -4000 -exec ls -l {} \; 2>/dev/null | awk '{print $9}'`

Once program stands out as it is not a standard Linux program.&#x20;

<figure><img src="/files/d8vHdvVyTfIYLpuQdeow" alt=""><figcaption><p>find suid</p></figcaption></figure>

The suid file sets the user and group ID of the running process to 0 (i.e., root) when the command '/bin/bash' is run at the same time.&#x20;

<figure><img src="/files/s0XfNtoycc5MASjCPAqL" alt=""><figcaption><p>suid</p></figcaption></figure>

Once it is executed, the low privilege user is able to be root, with out a password or sudo privileges. This indicates the vulnerability the mole would have used to gain full server access.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jacob-taylor.gitbook.io/jacvbtaylor/offical-compromised-comms-walkthrough/compromised-comms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
