Page cover

HTB - Sniper

Machine Info

Sniper is a medium difficulty Windows machine which features a PHP server. The server hosts a file that is found vulnerable to local and remote file inclusion. Command execution is gained on the server in the context of NT AUTHORITY\iUSR via local inclusion of maliciously crafted PHP Session files. Exposed database credentials are used to gain access as the user Chris, who has the same password. Enumeration reveals that the administrator is reviewing CHM (Compiled HTML Help) files, which can be used the leak the administrators NetNTLM-v2 hash. This can be captured, cracked and used to get a reverse shell as administrator using a PowerShell credential object.

Enumeration


Scope

IP Address: 10.10.10.151

Nmap Scan

┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Cascade]
└─$ nmap -p- --min-rate 10000 $ip -Pn 

PORT    STATE SERVICE      REASON
80/tcp  open  http         syn-ack
135/tcp open  msrpc        syn-ack
139/tcp open  netbios-ssn  syn-ack
445/tcp open  microsoft-ds syn-ack

┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Cascade]
└─$ nmap -p -sCV $ip -Pn -oN Nmap/script-scan

PORT    STATE SERVICE       VERSION
80/tcp  open  http          Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-title: Sniper Co.
|_http-server-header: Microsoft-IIS/10.0
135/tcp open  msrpc         Microsoft Windows RPC
139/tcp open  netbios-ssn   Microsoft Windows netbios-ssn
445/tcp open  microsoft-ds?
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
| smb2-time: 
|   date: 2024-07-11T12:18:29
|_  start_date: N/A
|_clock-skew: 7h00m01s

RPC & SMB Enumeration

Nothing found from rpcclient

smb anonymous login failed

HTTP Enumeration

Looking at wapplayzer

http://10.10.10.151/user/login.php

I registered an account and try to login with it, but the site didn't have any thing

Initial Access


Shell as iusr

Under http://10.10.10.151/blog/ there is a parameter ?lang which include blog-en.php

When I tried to include local file such as /etc/hosts located at C:windows\system32\drivers, It returned the file content

Since, this is windows machine I will try LFI to my smb server

Craft the url to call our server and we got a hit

I tried then to get RCE via download a reverse_shell.ps1 and execute it on the fly

shell.php content

start nc listener and include the remote shell

We are in a web server folder which can contain database connection string or credentials for login

It's database credentials, I looked at open ports listening locally and found that mysql default port 3306 is there

To connect to the database, I need fully interactive shell, So I will map mysql port to my local machine using chisel

run Nmap against the port locally to verify

Shell as Chris

I found two users, one I created when registering in webapp and admin user, but when I tried to crack the hash of admin, I failed

Looking at users on the system. Chris user has a profile, Let's try the password we found of the dbuser with him instead

And we got a hit, but I need a shell with that user as I we don't have remote access with him

So, I download RunasCs.exe from my kali to the machine

Execute it as Chris user to have a shell as that use

start nc listener and wait for a shell

Get the flag

User Flag: 44d27619bef1f819476fxxxxxxxxxxxxxxxxx


Privilege Escalation

When I typed tree /F to explore the folder content, I found weird file extension I didn't seen before .chm

I searched at google for it and found that it's a compiled HTML Help file

I found this useful post:

triangle-exclamation

Shell as SYSTEM

I found that iusr has SeImpersonatePrivilege which can be abused to escalate to SYSTEM account

I need PrintSpoofer.exe tool, So I will download it to the box and execute it to get a reverse shell as SYSTEM

Get root flag

Root Flag: f65247f419e1087df1fxxxxxxxxxxxxx

Last updated