πStealth - TryHackMe Walkthrough / Writeup
Shortest Path to Admin, AV Bypass using msfvenom and meterpreter and more.
Table of Contents
Recon
Using nmap scan, for initial recon. I will spare you the delay of looking for open ports :)
Ok, now as you can see a lot of open ports, but we will only focus on the 8080 port as that is the only way for initial access, unless you found something else.
Visiting the http://target:8080 presents us with the following page.

Since this is a windows server, we will upload a powershell file that will execute and download a web shell for us in C:\xampp\htdocs
You may choose any web shell, that you may like, my personal favorite is p0wny Shell.
Create a powershell script that will download the shell to htdocs directory.
Before we deliver it, start the server
Now upload our getShell.ps1 file! and wait for it to fetch our shell.php

Once done you can check the web shell at http://targetip:8080/shell.php

Weaponization
As you can see we have a local account access, now we can create a reverse shell payload, an encoded payload to avoid AV detection. But why, we already have a web shell? because....
TRUST ME BRO, TRUST THE PROCESS
Use the following command to generate a msfvenom payload. If you are using your own choice of encoder make sure it is x64.
Notice the encoder I am using with -e x64/zutto_dekiru
You may generate the commands from revshells.com, but make sure you are using encoders. This generates a rev.exe file for us. Before we deliver it to target, start the msfconsole listener.
Delivery
Once we are all done with the setup, use the web shell to deliver the payload and execute it to get the shell.

And you should receive the connection in no time.

You may check the uid first, check if its evader or not.
Then check what kind of privileges you have. Execute getprivs

Now if you notice carefully, we have a SeImpersonatePrivilege option which is enabled for us.
Exploitation ( Automatic )
I will divide the exploitation part, into 2 categories, one is automated with msfconsole and other one is manually exploiting the system.
Let's get started. The first is very simple, just execute : getsystem
And you should have admin access.
Disclaimer : Note that some users have reported, that this might be patched, it may or may not work for you but its worth at-least a try. π

Theory on why this one worked in the first place
I think since we are using an encoded agent, this avoids detection by AV, the payload might not be touching the disk at all but running in memory, to avoid getting flagged.
Exploitation ( Manual Method )
Once you have a web shell, enumerate the box to check if there is a .NET SDK compiler for us or not.

The next prerequisite is to check if you have SeImpersonatePrivilege enabled or not. use the following command.

Ok now for the final showdown, we don't need a reverse shell, we will compile an exploit, locally on the system, and also another C sharp file that will execute the registry query to dump SAM/SYSTEM hive.
First lets download the exploit code on our machine.
Create another program like backup.cs, use the code below.
Now upload both of the code on our target system using the web shell.

Now finally compile them using the following commands.
Once done, execute them like following.

If you see backup successful, then all is well.

If you see the bak files being generated, lets get them.
Dump the hashes

Now use Evil-Winrm to access the box as admin, via pass the hash technique

Get User Flag

The user flag is encoded in base64. Use the following command to decode.


Remove the following log file

And then reload the endpoint again, to get the flag!

Get Admin Flag

Theory on why the manual method works
Few years ago, I wrote a simple c program to print hello world, I thought to myself, how can I publish it and share it with others. So I compiled it on my windows machine, and executed it. It worked without any issues. But as soon as I ran it on a different computer or even a VM. Defender/UAC kicked in and flagged it as malicious as it did not have any valid digital certificate. Imagine a simple hello world getting flagged by the AV.
It was not the same with a java program, I wrote a simple hello world, created a jar file, and executed on different machine, it worked without any issues. Since it ran via Java, a trusted binary it did not have any issues.
So in this room, when we are compiling an actual exploit and defender does not find it suspicious, because it thinks the user is not mad to break the system. Same with the backup.cs file as well. But if you compile the program without signing it with a valid digital certificate it might get flagged on a different machine. Even if its running a Windows 10 Home Edition. Now if you think there might be a different reason, please feel free to share with me.
Credits to my friends for helping me research on this room
1st Person
Check out 0xb0b's writeup : https://0xb0b.gitbook.io/writeups/tryhackme/2023/stealth
2nd Person
Thank you for reading my article β€οΈ Happy Hunting π, feel free to connect with me on Linkedin
Last updated
Was this helpful?

