
Introduction
In this room, we will enumerate a Windows machine, gain initial access with Metasploit, use Powershell to further enumerate the machine and escalate your privileges to Administrator.
Target IP: 10.10.240.218
Scanning & Enumeration
Nmap Scan
We notice the following services:
- HTTP and
- Samba
Enumerate the Services

HTTP Enumeration

The landing page shows ‘Employee of the month’. I actually love the Mr. Robot series, so I know his name is Bill Harper. He was a victim of Elliot’s social engineering plan :P
To those who do not know who he is, do not worry

The next step in enumerating a web server is using gobuster. That did not find anything on the server. The next step is going on the other port i.e. 8080.

The highlighted part is important because it tells us what software a particular server is running. On clicking ‘HttpFileServer 2.3’ we find that the server is using Rejetto HTTP File Server.

Now before enumerating more, since this looks like a service that is not custom, we can jump to analyzing if this Rejetto thing is vulnerable or not.
Vulnerability Analysis
A quick searchsploit suggests that we have multiple vulnerabilities for Rejetto.

We are more interested in remote code execution.


Before we start exploitation, let us read the comments in the exploit

Important note: we need to host nc.exe, essentially a netcat binary, on our attacker machine, honestly, I missed this the first time.
I took a break, and when I came back with a fresh approach, I saw this.
Exploitation
Let us first get ‘nc.exe’
A quick search provided me with a repo — ‘https://github.com/int0x33/nc.exe?files=1’
We follow the following steps:
- Download ‘nc.exe’
- Run an HTTP server using python,
sudo python3 -m http.server 80
Note: we use sudo here because port 80 is usually used by apache, and a normal user can not start the server on port 80. - Next, we set up our netcat listener ‘nc -nlvp 4445’
- Edit the code to add attacker’s IP address and the port our netcat listener is listening on
- After that, we can run our ‘exploit.py’ using
python exploit.py <target-ip>several times until our shell pops up!


Once we get access to the base user, we can go ahead and grab our user.txt

Privesc
Privesc on Windows is something I am not at all aware of. I do not know how it is done, or which direction to look into. So I am going to follow the method that TryHackMe points me into.
So they go on ahead and say that we need to put winPEAS.exe on the victim machine.
WinPEAS? What is that?

https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite.git

I cloned this to get the WinPEAS executable, we could also compile it on our own, but in this part, let us use the pre-compiled version.
Get the executable, and then start an HTTP server using - sudo python3 -m http.server 80
Make sure you start the python server where the executable is available.
Let us take a moment here and try to understand what we are going to do next.
When we run WinPEAS, it is just like LinEnum, and it would enumerate all the services and permissions and information that we will be able to use to escalate our access.
According to TryHackMe,

running winPEAS will point us towards unquoted paths. Once again, what is UNQUOTED PATHS

I googled the same and came across a nice blog by Orhan YILDIRIM which talks about Unquoted Paths on windows here and another one by Sumit Verma which can be found here.
Now that we have some clarity, let us continue where we stopped, drop our winPEAS on to the target, and get some juicy stuff!


Once we have our winPEAS on the target machine, let us run the executable and notice the output.

This suggests that ‘Red’ is the color we are going to be looking out for. Well, let’s do this

We see a couple of services that are running that have this two important highlights:
1. No quotes and space detected
2. File Permissions: Bill. We can read as well as write data.
Services
1. Advanced SystemCare
2. IObit Uninstaller Service
3. LiveUpdate
We also notice that the path for all three services is the same i.e. ‘C:\Program Files (x86)\IObit’, let us change our working directory to this path.
Three services highlight the same characteristics. Now that we know this, all we need to know is if we can start, stop and restart any of these 3 services.
We can check that using ‘icacls’

Now that we know we have all the permissions, we can create a payload using msfvenom

Let us upload it to the directory, ‘C:\Program Files (x86)\IObit\’, thus the path for Advanced.exe would be ‘C:\Program Files (x86)\IObit\Advanced.exe’ and when the service restarts this will help us because, there is a space in the path provided by the service, and instead of going in inside the ‘Advanced SystemCare’ folder, it will directly execute Advanced.exe.
Let us set up the listener on port 5555.
Then we stop the service using sc stop AdvancedSystemCareService9
And then we start it again using sc start AdvancedSystemCareService9
And bam! We have our admin shell!

We can now get our root.txt

Parting Thoughts
We learned a new concept in this room for privesc. Also, I have not added the metasploit part here but just in case you are interested, here’s another blog that has that part covered here.
The main vulnerability was UNQUOTED PATHS.