THM Machine Relevant
Here I solve The THM Machine Relevant. There I exploit PrintSpoofer Vulnerability to gain higher privileged account.

Pre-Engagement Briefing
You have been assigned to a client that wants a penetration test conducted on an environment due to be released to production in seven days.
Scope of Work
The client requests that an engineer conducts an assessment of the provided virtual environment. The client has asked that minimal information be provided about the assessment, wanting the engagement conducted from the eyes of a malicious actor (black box penetration test). The client has asked that you secure two flags (no location provided) as proof of exploitation:
User.txtRoot.txt
Additionally, the client has provided the following scope allowances:
Any tools or techniques are permitted in this engagement, however we ask that you attempt manual exploitation first
Locate and note all vulnerabilities found
Submit the flags discovered to the dashboard
Only the IP address assigned to your machine is in scope
Find and report ALL vulnerabilities.
Information Gathering
IP Address
Scanning
Running the nmap scan to find open ports and the result is like the following.
From the above scan result, we see the system has the following open ports and services running on it.
Port
80that is running anhttpservice and possibly running a Windows IIS web server.Port
135running Microsoft RPC (Remote procedural Call) service is a basic thing when the system is runningsmbandNetBIOSservice.Port
139is running thenetbiosservicePort
445is running thesmbservice andnmapshowed it asmicrosoft-dsin its result.Port
3389is an RDP (Remote Desktop Protocol) service that shows some useful information i.e Computer Name, Domain Name, etc.Port
49663is also running anhttpservice.Port
49667service is unknown tonmapthey weren't able to guess what type of service is running on it.
Besides all that they also find some other information that we can read in the scan results. Now let's move on to do some information on the running ports.
Enumeration
We saw there is an smb service running so we can start from it and see if they give us any access with a guest or anonymous account (Login without giving him any credentials). We can use the Linux command line utility smbclient to access it using the following command.
Above we try to list all the shares that are present in the smb server and we see there is a share that is not come by default i.e nt4wrksv. The nt4wrksv share also allowed anonymous login, because I can able to connect to it using the following.
In the share, there is a passwords.txt file that has the following content.
It looks like the password was encoded with base64, So I decode it with the following command.
They give me the following output.
They are some kind of credentials so I tried it on RDP but It doesn't work. I just keep that in my notes for now and let's move into enumerating some other services.
HTTP
There is more than one http server running on the machine and they just have a default Windows IIS page.
Content-Discovery
I use ffuf to discover some hidden directories and files but didn't find any useful directory, where we can use the above credentials or do any other things.
I try the nt4wrksv share name on the web server and luckily it shows status 200. That means that directory exits and when I request for passwords.txt it shows me its content. I try to upload files from smb and I was successfully able to do that.
Knowing this we can upload any reverse shell file and execute it by visiting the page. As it's a Windows IIS server that uses aspx or asp files as its backend language so we have to use the reverse shell in that language. We can make a reverse shell using msfvenom but I use /usr/share/webshells/aspx/cmdasp.aspx and upload it using the following command.
After that I visit the page on this link http://$ip/nt4wrks/cmdasp.aspx, and they show me the command execution box where I can submit any command and they show me its output.
Initial Access
Now I try to get a reverse shell by uploading reverse shell binary(.exe) generated by msfvenom but AntiVirus deletes it, Also I cannot able to execute the powershell reverse shell command because the antivirus marks that malicious. So I search on Google and got the following command that downloads a text file that contains powershell reverse shell code and after downloading that they execute it without alerting antivirus software. This is a staged payload in which they execute the first payload that requests the other payload part and executes it to give us a reverse shell.
The Powershell code is the following.
There we have to change the $address variable with the attacker machine IP and the $port variable with the port we want to use and then save it with the name powershell.reverse.txt or any filename you like and host it, I use a python http server for this.
After hosting that Powershell file executes the following command in your command shell.
This will call to your powershell.reverse.txt file, download it and then execute it, and eventually, you will receive a connection back.
Note: Start your netcat listener first before executing the above command. For Windows, I prefer using the following command to start a listener.
$ rlwarp nc -lvnp 4444
Privilege Escalation
After gaining initial access to the system the next thing we try to achieve is to gain a higher privileged account or access. To do that we enumerate the system to find some misconfiguration or plain text passwords that we can use to get higher access.
We can use a tool name winpeas that automate all the basic enumeration for us and highlight some ways that can be used to get higher privileges.
I host winpeas.bat and transfer it using a Python http server, We can also upload that using smb.
After running winpeas.bat we see our user has some permission that is used in privilege escalation.
There we can see SeImpersonatePrivilege is enabled and in Windows OS there is a vulnerability or a misconfiguration that is used to get privilege escalation. If a user has this permission enabled then we can use a tool name printspoofer that can be downloaded from the following link.
Download that binary and host it using a Python server or some other way and then download it to the target system using the following command.
After that use the following command to exploit the vulnerability to get a higher privileged account.
This opens a command prompt with the nt authority\system account that has all the permissions in the system. Secure both user.txt and root.txt flags and submit it.
Last updated
Was this helpful?
