Sniper

Sniper box was easy box. It falls under windows and medium category. Here I will explain my path for Sniper box from Hack The Box.
HTB:Sniper
Sniper box was easy box. It falls under windows and medium category. Here, everything was all about enumeration and webshell upload. I’ll approach this write-up how I solved it, along with the problems that I had to face during this box. At first I obtained the user flag by exploiting RFI using SMB and I got the unprivelege user shell to privelege by using powershell commands and with .chm exploit I got root.txt. I’ll show all my payload (including that didn’t work in initial deployment to get root).
Box Details
In the above it’s ip was 10.10.14.151
, I added it to /etc/hosts
as sniper.htb. Let’s solve this box.
Recon
Let’s start with universal port scanner, nmap
to see the open ports and port 80
and smb
service was opened.
|
|
Web Enumeration
sniper.htb
After I noticed port 80
was opened I visited that site and got this as output.
From above, it was a good delivery website. So I checked everypart of the website and found this directory as interesting http://sniper.htb/blog/index.php
. Here I found language where I was able to change the language http://sniper.htb/blog/?lang=blog-en.php
. This happens due to the RFI (Remote File Inclusion) vulnerability in the webservices.
Webshell
Since Sniper
had SMB(Server Mail Box)
service. So I combined with RFI to get a webshell. For that you can follow this link here.
Above you can see the webshell. So, now I used nc to get the actually shell. For that I had to upload nc.exe
to the webshell.
If you don’t have then you can download from here.
Now before uploading that I made a dir named gr4n173
you can see the pic below.
then uploaded nc
tool to that directory as:
Unprivileged shell
Now I setup a listener on and used the command of nc
as:
Listener:
|
|
Here I was unable to run any commands, so I switched to powershell as:
Power shell
|
|
Then I found the Chris
user. Since I m unprivelege user so no any permission was granted.
|
|
Now I had to change the user from unprivileged to privileged for that I searched everypart of the dir and found the creds of user chris
as Chris:36mEAhz/B8xQ~2VM
.
|
|
By combining creds and Invoke-Command
I got the user shell. Before that I created the folder files
and downloaded the nc
tool inside. Since it’s 2020 as python2 died so I used python3 server as
|
|
|
|
Finally downloaded nc.exe
. Now I used creds
and Invoke-Command
to know the if I can run the command as
Privilege User
|
|
In above command, at first I defined a variable $pass
which store the password and another variable cred
for passing the user
and pass
to Powershell
and last one gaves the output of command whoami
in Powershell
. Hence I can run the command
.
Reverse shell
So I used the nc reverse shell
as with a listener on.
|
|
Listener:
|
|
This way I got the user.
|
|
User to Root
For root I searched every part of the user shell and uncomplete .chm
file was found inside Chris’s Downloads directory:
|
|
Poisoning .chm
In order to poison, I used Out-CHM.ps1
while from Nishang which is quite Interesting git repo especially related to window.
I used nishand tool and opened it in powershell.
|
|
Now I used the powershell to bypasss the Antivirus security.
|
|
Then I download the nc64.exe
to the Chris’s Documents folder as
|
|
Here, I defined the dir of nc64.exe
and used this to exploit. File name doc.chm
was created and you can get here file. This way I created the poison of .chm
file.
Now I downloaded the created file to user shell Chris
with a listener on along with the python3 server
in /var/www/html/pub
|
|
Root Shell
|
|
This way I can read the root.txt
file.
|
|
This way I got the root of Sniper box and learned alot from this box. So I would like to thank creators of this box MinatoTW & felamos
for such an awesome box. Especially poisoning .chm
was awesome.
I will be posting writeup of next box after box retired. I would like to Thank readers for being with me through out this writeup.
Feedback are really appreciated !!
Tweet about this writeup if you like.
You can see more blog at my medium here: gr4n173.