# Hacked Cyberdefenders

* [Details](https://cyberdefenders.org/blueteam-ctf-challenges/71#nav-overview)

You have been called to analyze a compromised Linux web server. Figure out how the threat actor gained access, what modifications were applied to the system, and what persistent techniques were utilized. (e.g. backdoors, users, sessions, etc).

* [Questions](https://cyberdefenders.org/blueteam-ctf-challenges/71#nav-questions)

#### Q1 What is the system timezone?

We Can found it the `/etc/timezone` file

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

**Ans : Europe/Brussels**

#### Q2 Who was the last user to log in to the system?

We can find  it in auth file on: `/var/log/auth.log`

<figure><img src="/files/hr8bTvw6CDu5VqJTZPID" alt=""><figcaption><p>57708Accepted password for mail from 192.168.210.131 port 57708 ssh2</p></figcaption></figure>

**Ans : mail**

#### Q3 What was the source port the user 'mail' connected from?

from the priv screen we can found it the answer  **"57708"**

#### Q4 How long was the last session for user 'mail'? (Minutes only)

<figure><img src="/files/9gcVtdg8Yl5QCEc57Eew" alt=""><figcaption></figcaption></figure>

We can found the last session started at 13:23:34 and finished at 13:24:11\
then it's just 1  minute

\
**Ans : 1**&#x20;

#### Q5 Which server service did the last user use to log in to the system?

in the last screen we can found **sshd**

**Ans : sshd**&#x20;

#### Q6 What type of authentication attack was performed against the target machine

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

In the same file We found it's many failled attemped okay it's bruteforce!

&#x20;**Ans : brute-force**

**Q7 How many IP addresses are listed in the '/var/log/lastlog' file?**

<figure><img src="/files/a5Lhz4nVGTayLVyMLUYY" alt=""><figcaption><p>192.168.131- 192.168.56</p></figcaption></figure>

**Ans : 2**&#x20;

#### Q8 How many users have a login shell?

Users Having shell using **/bin/bash**

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

**Ans : 5**

#### Q9 What is the password of the mail user?

We can found password of email user in&#x20;

<mark style="color:red;">/etc/shadow</mark><br>

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

```
sudo john --wordlist==/usr/share/rockyou.txt passwd.txt

```

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

**Ans : forensics**

#### Q10 Which user account was created by the attacker?

Back to auth.log \
searching for useradd command we can found it&#x20;

<figure><img src="/files/ovpDoXvQzANRcTsjVc9Q" alt=""><figcaption><p>php</p></figcaption></figure>

**Ans : php**&#x20;

#### Q11 How many user groups exist on the machine?

we can found group in `etc/group`&#x20;

open it to count&#x20;

<figure><img src="/files/GaZV7XflRUjp0MSjMFpQ" alt=""><figcaption><p>lin 58</p></figcaption></figure>

**Ans : 58**

#### Q12 How many users have sudo access?

in the same file searching for <mark style="color:blue;">sudo</mark>

<figure><img src="/files/joIEFMpRtBkdWRkv4NXB" alt=""><figcaption><p>php,mail</p></figcaption></figure>

**Ans : 2**

#### Q13 What is the home directory of the PHP user?

From Q10 When the attacker created the user PHP,

&#x20;its home directory was <mark style="color:purple;">/usr/php</mark>

**Ans :   /usr/php**

#### Q14 What command did the attacker use to gain root privilege? (Answer contains two spaces).

We know from the prev Qusetions that the attacker logged in as the user <mark style="color:red;">mail</mark> , we find the it's home direcotry at: <mark style="color:red;">/var/mail</mark> &#x20;

let's investigate it's bash history

<figure><img src="/files/0HgDf2F1YdDgriNrjC7T" alt=""><figcaption><p>sudo su -</p></figcaption></figure>

**Ans : sudo su -**

####

#### Q15 Which file did the user 'root' delete?

let's check root’s bash history file&#x20;

<figure><img src="/files/RW4rks6uxMcO6npQW3AJ" alt=""><figcaption><p>rm 37292.c</p></figcaption></figure>

**Ans : 37292.c**

#### Q16 Recover the deleted file, open it and extract the exploit author name.

After some minutes I searching in /tmp

After i clicked on it Window defender running ")

<figure><img src="/files/3uZK7sSOCU7quVtAbRZZ" alt=""><figcaption></figcaption></figure>

After that search for the CVE in exploit-db:

<br>

<figure><img src="/files/GbkSmKrETD9oxvy6HAze" alt=""><figcaption><p>Exploit Author: rebel</p></figcaption></figure>

\
**Ans : rebel**

#### Q17 What is the content management system (CMS) installed on the machine?

it's found in etc

<figure><img src="/files/7ftqY76Tz9j6rAhfi8Io" alt=""><figcaption><p>drupal opensource CMS</p></figcaption></figure>

**Ans : drupal**&#x20;

#### Q18 What is the version of the CMS installed on the machine?

By helping of chatgpt we can found the version of Drupal Cms in info files found in /var/www/html/

<figure><img src="/files/gFj3yeeEGz5Dt7xFKEnE" alt=""><figcaption><p>7.26</p></figcaption></figure>

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

**Ans : 7.26**

#### Q19 Which port was listening to receive the attacker's reverse shell?

From the question 6 we can found the attacker ip [192.168.210.131](http://192.168.210.131/)

we can go to <mark style="color:red;">access.log</mark>&#x20;

and grep it&#x20;

we found decoded post request

<figure><img src="/files/QfjXhVmxAg533ydpXQ4S" alt=""><figcaption><p>decodebase64</p></figcaption></figure>

let's going to cyberchief

<figure><img src="/files/SINu4nmyvWMQaNwlJPAz" alt=""><figcaption><p>$port = 4444</p></figcaption></figure>

**Ans : 4444**

We fininsed , Thank UUUUUUU for reading  ❤🥰


---

# Agent Instructions: 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://0xmedhat.gitbook.io/whoami/writesup/hacked-cyberdefenders.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.
