0xabsec

Stuff Related to Security.

HackTheBox POV

RECON

Nmap

Starting of with the NMAP, It shows only one port open 80/(http).

nmap

Going through Script and version scan it shows something like a hostname in http_title

nmap

Adding hostname in to our /etc/hosts file

hosts

Website

pov.htb

Going through the webpage looks like a static webpage leaking another hostname dev.pov.htb and potential user sfitz.

site

Adding the hostname dev.pov.htb

site

dev.pov.htb

Looking in to the site we can see there is a download button to Download Stephen Fitz CV

site


User Sfitz

Intercepting the Download Request through burp it looks something like this with the file parameter as cv.pdf

site

Seding the Request in to the Repeater and changing the cv.pdf in index.aspx it gives error path to /portfolio/default.aspx

site

Changing the file parameter from index.aspx to default.aspx it shows code of the page means the file parameter is vulnerable to file_disclosure vulnerablity

It also shows index.aspx.cs as a CodeFile

site

Looking in to th index.aspx.cs file we can see it is filtering ../ for possible directory traversal attacks

site

To bypass the filter we can do something like ….//web.config as it will filter out ../ and the req will be processed as ../web.config

We are looking in to web.config because sometimes it holds sensitive information.

site

Web.Config is leaking Decryption key and Machine key and since the site is using ViewState cookie There is a potential chance of RCE

There are few resources on the internet which goes over this like hacktricks, I personally liked this one here

Using ysoserial.exe in windows VM to generate a RCE payload

site

For simplicity i used powershell base64 encoded payload

powershell

Pasting the resulted payload ysoserial gave us in to the ViewState parameter on the burp

site

modifying our nishang revshell payload

site

Starting the python webserver in and nc in our box and sending the request we get the shell back

site

Using whoami we can see we go the shell as sfitz user

site


User alaading

Starting Recon of the Box as Sftiz we can see there is another user on the box as alaading

site

Looking at the current open ports in the box we can see the smb (445), winrm(5985) ports are open locally

site

Enumerating sftiz home directory we found connection.xml file in the Documents Directory

site

Looking in to the contents of the file there is what looks like a secure string pass of user alaading

site

To Decrypt the Secure string pass we put the pass in to the file.

site

Decrypting the pass we get the Password for user alaading

site

Since there is no way we can log in to the box from our box as only port 80 is open to us. But winrm is open locally so we can use Chisel to access the port

Starting chisel server in our box

site

Putting Chisel in windows and doing port forwarding of winrm

site

We can see port 5985 is opened in our box

site

Using Evil-Winrm to log in as User alaading we can login in to box

site

We can grab the user.txt

site


Privilege Escalation To System

whoami /priv shows us that the use alaading has SeDebugPrivilege Enabled

site

SeDebugPrivilege allows the holder to debug another process, this includes reading and writing to that process memory

To Use it for our advantage i used a powershell script from the GITHUB

Moving it in to the box and then importing it

site

Looking in to script it gave us the instruction on how to use it

site

We need a system process pid so i am using winlogon

site

As a command to execute i am going to execute msfvenom revshell payload for windows.

Generating msfvenom payload

site

copying payload to the Box and Starting our nc listener we can use the powershell script module

site

We Get the shell back as nt authority/system now we can grab the flag

site