> For the complete documentation index, see [llms.txt](https://ajaykumar-kanthi.gitbook.io/write-ups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ajaykumar-kanthi.gitbook.io/write-ups/hack-the-box-oscp-machines/htb-dog.md).

# HTB - Dog

## Enumeration and Foothold

### NMAP

```bash
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.12 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

### HTTP

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FTsEZq1etvWb7OtG3uVTn%2Fimage.png?alt=media&amp;token=4b51be96-7d58-479f-91da-39b6a05d4045" alt=""><figcaption></figcaption></figure>

clicking on dog obesity results in the below url request

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fh2hg9aE1hVtG8c1YXa44%2Fimage.png?alt=media&amp;token=1598a947-fc87-405b-beef-1baec2d1e74c" alt=""><figcaption></figcaption></figure>

the parameter q references local files directly could be a good opportunity to look for LFI

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FFee8hedaqlnteRSVK9dt%2Fimage.png?alt=media&amp;token=03a986a8-3e8b-446e-9f59-e2be553e2286" alt=""><figcaption></figcaption></figure>

no LFI but there is also a login page.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fy3njH180mWJPGAHlRUei%2Fimage.png?alt=media&amp;token=3f1cce1b-75d5-4186-bd44-4e41eb469565" alt=""><figcaption></figcaption></figure>

weak credentials like `admin : admin` do not work here.

directory enumeration revealed a git directory.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FbPkPqAL9LBv1cVaYzkql%2Fimage.png?alt=media&amp;token=298f7b9d-dc17-44d4-874f-51dd1aa88c8f" alt=""><figcaption></figcaption></figure>

i can dump the git directory locally and investigate

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FK1zuZkhwqxGirnwk4TXe%2Fimage.png?alt=media&amp;token=303a3eec-c726-47d4-b639-8fb150bc4dd0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FtS9jjueEO5Mbik5BMQen%2Fimage.png?alt=media&amp;token=4b92922f-df4a-4c05-ac63-73d6892e9405" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FJ2lKYkPjiH6Nih35an9D%2Fimage.png?alt=media&amp;token=fa59f471-4e4e-4a20-ae7a-06f524088f15" alt=""><figcaption></figcaption></figure>

found database credentials in the settings.php of the gitdumper files

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fa7nhQCihDJkQjJcWXpZB%2Fimage.png?alt=media&amp;token=6ec60a03-70e1-42fa-b098-d3042570275f" alt=""><figcaption></figcaption></figure>

using the discovered credentials tried to login but they did not work. so i need o find a user who can be able to be used to use the password.

that said grepping the git repo for users revealed a user name

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fk1q3fh6O1vEA4o7EcjAP%2Fimage.png?alt=media&amp;token=2024547a-c556-4e7e-af33-a2bc3b905b13" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FziMx3TVqWfsmMtED3MGX%2Fimage.png?alt=media&amp;token=af620591-f945-4168-b502-da7711b2dbc6" alt=""><figcaption></figcaption></figure>

now that i have username, i can try the discovered password to against this user to try logging in.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FZAx7fPh1px4LVQjoXwyX%2Fimage.png?alt=media&amp;token=7c21e100-5cbb-41d6-8a88-818489a0ebb2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FCL3MhRdjNPwb38EI1aHa%2Fimage.png?alt=media&amp;token=bca72ae7-5ccb-46dc-88eb-9ebfd69dc9cf" alt=""><figcaption></figcaption></figure>

and we got successful authentication.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FGIEKyxAaSC5NoSVuiPH0%2Fimage.png?alt=media&amp;token=55af52f1-722d-4e2f-981a-61c86543fb33" alt=""><figcaption></figcaption></figure>

tiffany is a administrative user. also the version of cms being used is 1.27.1

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FpLUYVWhT6ScW0aOpe9Yf%2Fimage.png?alt=media&amp;token=67635185-d70b-4320-9cf0-25ffc525372d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FJpeFItmMVuvJMVkA4SPV%2Fimage.png?alt=media&amp;token=c23c3770-0a54-4c54-87e9-82cf65587ab1" alt=""><figcaption></figcaption></figure>

poking around google the cms is vulnerable to Authenticated RCE.

{% embed url="<https://www.exploit-db.com/exploits/52021>" %}

The above poc explains the exploitation steps.

the exploitation involves writing a php shell into a modules  directory by zip uploads.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fv4H3sMk6R9dm3NUCWims%2Fimage.png?alt=media&amp;token=d223c68b-9dc7-48c6-88f8-77905ab95597" alt=""><figcaption></figcaption></figure>

it takes tar file as upload form so i can upload a shell.tar here.

found this page which has the tar file to exploit

{% embed url="<https://github.com/V1n1v131r4/CSRF-to-RCE-on-Backdrop-CMS/releases/tag/backdrop>" %}

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fn2Z3WctVmuRYoQON1ud7%2Fimage.png?alt=media&amp;token=ec024e3e-1c11-4bf6-afc5-33f4e53e0707" alt=""><figcaption></figcaption></figure>

there is a shell.php in the tar file, that said i will upload the file to target to get shell access.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FyQQ9WTjYJLE2R5Qi9teH%2Fimage.png?alt=media&amp;token=938b6f6c-1abf-4c84-9b2a-2ba0048fddad" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FLvs2fsfCfUc3Ld01Pa0K%2Fimage.png?alt=media&amp;token=43a1a07c-741c-4c23-a6fc-ee110a7223f2" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FTU2lzsaFWqHhIZmpwDPC%2Fimage.png?alt=media&amp;token=e469e569-08c2-4d10-aad5-64b2671ef4b9" alt=""><figcaption></figcaption></figure>

the code execution is confirmed with that i will try to get a reverse shell.

## Shell as www-data

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FMeO5LgqL9HmD25863GSg%2Fimage.png?alt=media&amp;token=270f836e-9580-45c9-902e-140648af22b5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fevu9NjlwMQE3cGeEa68b%2Fimage.png?alt=media&amp;token=23828c5c-877b-4ee2-bb50-930a02410b4a" alt=""><figcaption></figcaption></figure>

next i will try to upgrade the shell

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FaAkaGyAHoNzMohKJH6Jy%2Fimage.png?alt=media&amp;token=203ef1cb-b1ed-4e96-877e-8995733c6ea3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FR4Cnt3zudMbTdPIh34al%2Fimage.png?alt=media&amp;token=bfbfdd61-8341-4d4d-883a-db7a3cd17381" alt=""><figcaption></figcaption></figure>

## Shell as Johncusack

using the same password obtained from git repo got access as john, as he is using the same password as tiffany.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FdzdI9STqZjniX9y2VbY1%2Fimage.png?alt=media&amp;token=13dfde8f-4f9f-4374-a728-ed90228edb4f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FNq9pXnNrSFOcBwm0STcT%2Fimage.png?alt=media&amp;token=a2c2a1fd-dd78-4ea7-b5ee-681333f53095" alt=""><figcaption></figcaption></figure>

johncusack can run bee as root without password.

{% embed url="<https://gtfobins.org/gtfobins/bee/>" %}

GTFObins has page on how to exploit this binary

### bee privilege escalation

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FlzU5mMO3NVAEIkV5OZ1I%2Fimage.png?alt=media&amp;token=c1970d6c-13e2-4ade-b266-9475870ed5fe" alt=""><figcaption></figcaption></figure>

root path confirmed.

now we can get shell as root

## Shell as Root

```bash
johncusack@dog:~$ sudo /usr/local/bin/bsudo /usr/local/bin/bee --root=/var/www/html eval 'system("/bin/bash -p");'
sudo /usr/local/bin/bee --root=/var/www/html eval 'system("/bin/bash -p");'
root@dog:/var/www/html# 
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Ft9la3uh5d5zu9TKTgehf%2Fimage.png?alt=media&amp;token=4c8d3568-a443-4d15-8407-9eea4c24c7f0" alt=""><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 dynamically by asking a question.

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

```
GET https://ajaykumar-kanthi.gitbook.io/write-ups/hack-the-box-oscp-machines/htb-dog.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 `build a script that syncs our docs to a CMS` 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.
