windowsJacko

Elevated privileges using a DLL hijacking attack

Summary

  • A vulnerable version of H2 Database was hosted on the machine vulnerable to JNI Code Execution.

  • Leveraged code injection to get a reverse shell on the box

  • Using winPEAS, found DLL hijack vulnerability resulting in priv escalation in PaperStream service.

  • Leraved this vulnerability to gain elevated shell on the box.

🧵Let's Unpack

Enumeration

sudo nmap -sC -sN -A -oN nmapFull -p- -A 192.168.216.66
>

Nmap scan report for 192.168.216.66
Host is up (0.088s latency).

PORT      STATE SERVICE       VERSION
80/tcp    open  http          Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
|_http-title: H2 Database Engine (redirect)
| http-methods: 
|_  Potentially risky methods: TRACE
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
445/tcp   open  microsoft-ds?
5040/tcp  open  unknown
8082/tcp  open  http          H2 database http console
|_http-title: H2 Console
9092/tcp  open  XmlIpcRegSvc?
49664/tcp open  msrpc         Microsoft Windows RPC
49665/tcp open  msrpc         Microsoft Windows RPC
49666/tcp open  msrpc         Microsoft Windows RPC
49667/tcp open  msrpc         Microsoft Windows RPC
49668/tcp open  msrpc         Microsoft Windows RPC
49669/tcp open  msrpc         Microsoft Windows RPC

An older version of H2 database was hosted on port 8082, which was vulnerable to JNI code injection.

Initial Foothold

We can use the following exploit to get a reverse shell in the box.

chevron-rightGot stuck here 😥hashtag

I was unable to upload the nc.exe on the same directory, on looking to the walkthrough, I understood that if payload cannot be saved in the same directory, then always save in C:\windows\Temp\nc.exe! Silly mistake I know 😅

Privilege escalation

None of the cmd commands, like Whoami, systeminfo, etc., were usable. So, the cmd prompt was fixed by running the following command.

Using winPEAS, we found a vulnerable version of PaperStream installed in the system that can be used to gain elevated privileges using a DLL hijacking attack.

Exploit used -> https://www.exploit-db.com/exploits/49384arrow-up-right

Last updated