Hack The Box. Passage RE. Metasploit, load in office document, Zip Slip attack, a bit about PowerSploit and tokens

image

I continue to publish solutions sent for further processing from the HackTheBox site . I hope that this will help at least someone to develop in the field of information security. In this article, we are tormented with metasloit and msfvenom loads, make an Office document with msvenom load, consider the search for ways to increase privileges with PowerSploit, and steal the token to access the encrypted file.

Connection to the laboratory is via VPN. It is recommended not to connect from a work computer or from a host where the data important to you is available, since you end up on a private network with people who know something in the field of information security :)

Organizational Information
, - , :

  • PWN;
  • (Crypto);
  • c (Network);
  • (Reverse Engineering);
  • (Stegano);
  • WEB-.

, , , .

, , Telegram . , , .

. , - , .

Intelligence service


Port scan


This machine has an IP address 10.10.10.144, which I add to / etc / hosts.

10.10.10.144    re.htb

First, we scan open ports. Since it takes a long time to scan all the ports with nmap, I will first do this with masscan. We scan all TCP and UDP ports from the tun0 interface at a speed of 500 packets per second.

masscan -e tun0 -p1-65535,U:1-65535 10.10.10.144 --rate=500

image

Next, you need to collect more information about known ports. To do this, use nmap with the -A option.
nmap -A re.htb -p80,445


image

So we have an SMB and an IIS web server. If you visit re.htb, you can find such comments on the page.

image

Check back for re.htb? I turned to the server at 10.10.10.144 and received a redirect to reblog.htb. So add this entry to / etc / hosts and go to the web server again.

image

In the first post, it becomes clear that this is a platform for analyzing OpenOffice documents, and if the downloaded document passes all the rules, it will be executed.

image

Now you need to find a way to download the file. Let's take a look at SMB.
smbclient -L 10.10.10.144

image

Entry point


Well, the name is clear where to upload. Now you need to generate an odt document containing the load. For this, you can use the openoffice_document_macro module from the metasploit framework.

image

But since we were warned that msf load of this module will be detected, we will create a template, and then insert another load.

image

Template generated. Let's check the assumption. If you download this file, it will be deleted immediately. Open it in the archive and change the following file: Basic / Standard / Module1.xml. And change the extension to ODS.

image

In this case, we just ping our car. Now open, run tcpdump, specifying the interface and protocol for the filter.

tcpdump -i tun0 icmp

Upload the file to the server.

image

And we observe ping in tcpdump'e.

image

USER


Now using msfvenom we generate the load meterpreter in exe format.

image

We will place it on a local server. In order to register the load in our document, open it in the archive and change the following file: Basic / Standard / Module1.xml.

In this case, we download the generated load from our machine and run the downloaded file.

image

After saving, change the format to ODS and upload the file to the server.

image

And after a few seconds, we see an open meterpreter session.

image

And we take away the user.

image

image

ROOT


After we had a little look around on the machine, in the Documents folder there is an interesting PS script.

image

And the next piece of code runs into a ZipSlip attack, when we can unzip the file to the right place. Let's check it out. To create the archive we use Evil-WinRAR-Generator .

image

We will load into the ods folder.

image

We use Evil WinRAR and specify the path to the folder (-p), a good file (-g) and the file that you need to unzip to the desired path (-e).

image

Now, using PowerShell, download the file to the target machine in the ods folder.

image

Now check.

image

Fine! Assumptions are correct. Let's generate an aspx load.

image

And according to the previous scenario, we’ll open the session.

image

image

image

image

image

Thus, we are already working under the IIS user. Next, we use my favorite PowerSploit , namely its PowerUp module.

image



image

Orchestrator Update Service is a service that organizes Windows updates for you. This service is responsible for downloading, installing and checking for updates for the computer. And through it we can execute commands. We generate another load in exe format and drop it on the host.

image

image

And now start using UsoSvc.

image

And we get a session.

image

But it closes very quickly, so we generate another load, load it onto the machine. Run r2.exe again from UsoSvc. And in the allotted 20-30 seconds, we call the shell and start a new generated load.

image

Thus, the session from r2.exe closes, but r3.exe will work in the same SYSTEM context.

image

But when you try to read the file, we get a denied access.

image

Most likely it is encrypted. Let's make sure of that.

image

And we see that we can open it from under coby. Then let's steal his token - an access token. Why connect the module in meterpreter.

image

Let's see the list of tokens in the system.

image

And take the coby token.

image

Now that we are reading a file in its security context.

image

The car has passed.

You can join us on Telegram . Let's put together a community in which there will be people who are versed in many areas of IT, then we can always help each other on any IT and information security issues.

Source: https://habr.com/ru/post/undefined/


All Articles