metasploit

All posts tagged metasploit

Walkthrough of a Windows machine exploitation with account credential bruteforce.

Deploying the machine

After deploying the VM a quick Google Lens reverse image search comes up with the origin of the clown.

Using Hydra to brute-force the login page

First of all let’s start Burp to check the response from the login page.

What request type is the Windows website login form using?

We could use the default Hydra http-post-form bruteforce method, but that would take way too long, around 90 hours in my case and obviously success is also not guaranteed.

Instead we can further adjust the command with the response from BurpSuite which delivers the result much faster.

Compromising the machine

Now, that we know the password we are able to login to the website as admin and do some further information gathering.

What is the version of the BlogEngine?

Let’s check the local exploit database for any potential options for this version, copy the first one from the top and open it.

What is the CVE?

As mentioned in the exploit code first we need to change the IP-address and the port number to the ones of our attacker machine and then also have to rename the file to “PostView.ascx”.

The modified and renamed file to be uploaded via modifying the existing “Welcome to Hackpark” post.

After that all we have to do is just setting up our usual Netcat listener on the same IP-address and port which we configured in the exploit and then visit the link where the file is located on the webserver.

We should receive a reverse shell on our listener.

Who is the webserver running as?

Windows Privilege Escalation

For privesc purposes an upgraded shell is needed which should be achieved by generating an msfvenom reverse shell payload first and then pivoting from the existing Netcat session to a Meterpreter session.

Let’s place the created Metasploit venom payload into the same directory from which we are running our  simple HTTP webserver and download it from via our existing low-level shell. First let’s navigate to the temp directory of the Windows machine to have writing permissions and then download the executable. All we need to do afterwards just running the file.

Then receiving a Meterpreter shell on our previously set up listener.

We can gather the necessary information for the privesc process by uploading a winPEAS executable to do the enumeration for us.

What is the OS version of this windows machine?

What is the name of the abnormal service running?

What is the name of the binary you’re supposed to exploit?

Due to the fact that the “WindowsScheduler” service runs periodically and it calls the “Message.exe” with root privileges all we have to do is to create another msfvenom reverse shell payload, rename it to “Message.exe” and upload it to the machine.

Let’s upload the file to our working directory on the Windows machine, then copy it from there to our target directory overwriting the original file. Then exit from the shell, background the Meterpreter session and setting up another reverse_tcp listener using the port with which the msfvenom payload was configured. All we have to do afterwards is just waiting for our system shell.

What is the user flag on Jeffs Desktop?

What is the root flag?

Thanks for reading and as always, any feedback is most welcome.

Walkthrough of a Windows machine exploiting Jenkins, privilege escalation via Windows authentication tokens.

Initial Access

This room is mainly about misconfigurations of the Jenkins devops automation server. Let us start with a usual Nmap scan.

How many TCP ports are open?

Next, we may want to investigate the Jenkins login page a bit further. Let’s fire up Burp to see a more detailed client-server data exchange and the POST request link on the top to tamper with.

Let’s feed that into Hydra and crack the creds with some very simple wordlists.

What is the username and password for the login panel?

We can login now and the plan is to exploit one of the vulnerabilities of Jenkins resulting a remote code execution. Let’s download the Invoke-PowerShellTcp.ps1 script from the Nishang GitHub page. We need to serve this script on our usual HTTP server.

Let’s login to Jenkins to create a new project and download and invoke the Powershell script from our Kali by saving and building the project in Jenkins.

We should receive a reverse shell on our Netcat listener from the Jenkins server.

What is the user.txt flag?

Switching Shells

To make the privilege escalation easier, let’s switch to a meterpreter shell with a first step of creating an msfvenom Meterpreter reverse shell payload.

What is the final size of the payload we generated?

Like before we need to place this executable into the directory from which our python HTTP server runs and also a Metasploit listener should be booted up. So, let’s upload the payload first using the same method than before creating another project and building it afterwards.

Then starting the listener.

Now, let us get back to our previous shell and find the msfvenom payload to be run.

We should receive a Meterpreter shell as a result.

Despite the fact that we have a higher privileged token, we might not have the permissions of a privileged user thanks to the permission handling of Windows. Let us check the availability of tokens loading the incognito module and then listing out the tokens anyways. We can see that the BUILTIN\Administrators token is available.

Let’s try to impersonate that token shall we.

What is the output when you run the getuid command?

So, what we have to do is the usual process migration to a full system process to circumvent the lack of the full permissions of a privileged user. After that we are able to find those files as well which belong to a higher privileged user.

What is the content of the root.txt file?

Thanks for reading and as always, any feedback is most welcome.

Walkthrough of a Windows machine exploitation leveraging common misconfigurations.

Introduction

This is a very basic and simple to work on machine clearly just for educational purposes. Let us initate a comprehesive vulnerability Nmap script scan against the machine.

How many ports are open with a port number under 1000?

What is this machine vulnerable to?

Gaining Access

We are going to leverage this vulnerability which is also known as Eternal Blue. This exploits a weakness in the Microsoft implementation of SMBv1 allowing the attacker to run arbitrary code on the victim systems. Let’s spin up Metasploit and initiate an attack against the system.

Escalation

Let us background the existing shell with CTRL+Z and upgrade it to a Meterpreter shell as follows. Use the “post/multi/manage/shell_to_meterpreter” post module, add the IP-address of the localhost again, associate the existing session with the module and run it against the victim. As you can see below, another session is created, so all we need to do afterwards is just switching over to that session.

Let’s list out all the processes in order to migrate our current process to an elevated one which is running as NT AUTHORITY\SYSTEM. The reason behind this is even if we are system it does not necessarily mean that our current process is also at system level. Good choices of processes would be Powershell or for example cmd but we chose the Console Host process below as it houses applications that use the command line.

Cracking

We do have full control of the victim machine now, so let us dump the hashes from the SAM database from our elevated Meterpreter  shell.

What is the name of the non-default user?

Let’s copy this password hash to a file and crack it. What is the cracked password?

Finding the flags

Three flags planted on this machine, let’s find them, shall we.

Thanks for reading and as always, any feedback is most welcome.