Subscribe to Blog via Email



CTF Challenges

Hack the Box: Friendzone Walkthrough

FriendZone is a recently retired CTF VM on Hack the Box with the objective – Capture the user and root flag. Hack the Box offers a wide range of VMs for practice from beginner to advanced level and it is great for penetration testers and researchers.

Level: Intermediate

Task: To find user.txt and root.txt file

Note: Since these labs are online available, therefore, they have a static IP. The IP of FriendZone is

Penetration Testing Methodologies


  • Nmap


  • SMB shared Directory
  • DNS Zone Transfer
  • MySQL creds


  • LFI to RCE
  • Capture the user flag

Privilege Escalation

  • Abusing Python Library
  • Capture the root flag


Let’s start off with scanning with the nmap to check open ports.

From nmap scan we found so many ports are opened such as 22,53,80,443, 445 and several services were available and we noted the SSL certificate is registered as


On exploring, vulnerable machine IP in the web browser, it welcomes us with following web page as shown below.

Here also I notice and this could be a clue for proceeding further. As per nmap scan result, port 53 is open for TCP which means there may be some possibilities for DNS Zone Transfer.

I didn’t find any other useful information on the home page, so I try to enumerate web directories with the help of DIRB. But this was also not worthwhile for us because the enumerated result was not valuable when further inspected.

Consequently, I switch to another enumeration service and it was a null session SMB enumeration. So, with the help of SMBmap, which is a Linux utility, we try to enumerate smb shared directories.

I found two shared directories and among those /general had read-only permissions and /Development has read/write both permissions. so, when we accessed /general directory, we obtained a text file named as “creds”.

In this file, I found the following credential which could be used later.

First, I added inside /etc/hosts file but didn’t found any valuable information, therefore I enumerated sub-domain by executing following command and fetch some sub-domains which could be useful in DNS zone transfer.

Further, I saved /  in the /etc/hosts file for accessing this domain.

On the exploring we got a login portal where I submitted the credential that we have found above.

So, we found another hint “/dashboard.php” which was a web directory.

On enumerating /dashboard.php we found following web page; here it gave a message “image_name param is missing”.

Therefore, we injected “default is image_id=a.jpg&pagename=timestamp” in the URL and obtain following web page where we notice timestamp, and this looked little suspicious towards LFI.

Exploiting LFI

To ensure that I try to call timestamp.php and by obtaining time stamp on the screen it was confirmed that it is vulnerable to LFI. Now let’s extend LFI to RCE to obtain shell of the host machine.

As we knew that /Development is the only directory that has read/write both permissions, hence we can inject our malicious file inside this directory and execute the backdoor by exploiting LFI to obtain a reverse connection.

Then I have used pentest’s monkey php reverse shell with little modification such $lhost & $lport as a backdoor that to be injected inside the host machine.

So, we connect to SMB with the help of smbclient and upload the php-reverse-shell inside /Development. Simultaneously we launched netcat listener in a new terminal to obtain a reverse connection from the host machine.

Then execute the uploaded php backdoor with the privilege of LFI as shown below:

As soon as we executed above URL in the browser, we have access netcat session and to obtain proper shell we import python pty one-liner and found our 1st flag inside /home/friend.

With little more traversing I found credential for user “friend” from inside /var/www/mysql_data.conf



Privilege Escalation

So, with the help of above-enumerated creds, we try to access ssh and luckily, we connected to ssh and try to identify weak permission file or role for escalating privileges to access root shell or root flag.

As I failed to identify any sudo rights or SUID permission files, therefore I go for pspy64s to examine the running process of the machine. Thus, I downloaded the script it inside /tmp directory and gave full permissions.

On running pspy64s, we notice that a python is executing by root which was surprising to us.

So, I decided to take a look at what is script was doing, therefore I used the cat command to read what this script is running.

Hmmm! So, I didn’t find any useful operation is being executed by this script other than import a python library “” hence I take its advantage in privilege escalation.

Taking privilege of python library, we can create a bogus python library named as to call root flag through this file.

After some time it will create write the root flag inside /tmp/flag as shown in the below image. Thus, we have obtained the root flag and finished this challenge.

Author: Aarti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

2 thoughts on “Hack the Box: Friendzone Walkthrough

  1. Your walk throughs are good to follow.
    In friendzone, I am unable to download the file using wget.
    Logged using ssh. Wget … ‘connection refused’.

    How to rectify

Leave a Reply

Your email address will not be published. Required fields are marked *