Hack the Gemini inc:2 (CTF Challenge)

Hello Friends!! Today we are going to breach a new VM lab “Gemini inc:2” of the vulnhub series and before moving ahead you can also take a  look over Gemini inc:1 which we had solved earlier.

Gemini Inc has contacted you to perform a penetration testing on one of their internal system. This system has a web application that is meant for employees to export their profile to a PDF. Identify any vulnerabilities possible with the goal of complete system compromise with root privilege. To demonstrate the level of access obtained, please provide the content of flag.txt located in the root directory as proof.

Penetration Methodologies:

  • Network Scanning (Netdiscover, Nmap)
  • Obtaining Activation Code (Bash script)
  • Web Directory Enumeration (Dirb)
  • Bypass WAF (Burp Suite)
  • Exploit Remote Code Execution
  • Upload Reverse_ shell
  • Obtain Reverse connection (Netcat)
  • Abusing Redis for privilege escalation
  • Capture the flag


First step is as always, running netdiscover on the VM to grab the IP address. In my case the IP was

Once the IP was found, we ran nmap aggressive scan to enumerate all the open ports.


From the nmap scan result, we found port 80 is open for http service, let’s navigate to port 80 in the browser. It put up the Welcome Guest page for login into web application.

When we didn’t found any remarkable clue from its home page, then without wasting much time, I use dirb for web directory enumeration and ran the following command for php extension related files:

Hmmm! I fetched some interesting URL, let’s inspect each one-by-one.

So further, we navigate to URL: and here observe the Activation Form that requires User ID and Activation Code to activate the account.

Next, we navigate to URL: and here observe the Register Form to register new account. So I registered for an account as “raaj”.

By registering as raaj, a new profile has been generated with User ID-14 as highlighted in the below image but still we need 6-digit activation code to activate the user “raaj” account.

To obtain activation code, I try all possible Hit-Try method but all were proof waste and at last I found this link where I found a bash script for activation code.


I copied the following code in a text file and save as act.sh on the Desktop. Script Source here

And at last ran the bash script through following command with user_id “14” to obtain the 6-digit activation code for user “raaj”.

Awesome!! So we cracked the activation code “000511” for user “raaj”

Now, submit your User_id and activated code to activate the account. In my case my user_id is 14 and activation code is 000511 for user “raaj”.

Great, I got login of raaz and then further I explored User List where I found all activated account of other users.

Then I check profile of 9emin1 which was actually name as Gemini and here I found it is an administrator account.


Then I check its source code where luckily I found the password hashes. I copied the hash value for its decryption.

Then I use the online MD5 decryption for decrypting the hash value ‘edbd1887e772e13c251f688a5f10c1ffbb67960d’ and finally we obtain the plain text password “secretpassword”.

Then we login into admin panel with the following credential:

Then navigate to Admin Panel -> Execute Command. But its shows nothing.

At that moment I used Burp suit for intercepting Http request and then further sent the intercepted request into repeater to assured what kind of Response it is generating.

Here I look at the HTTP traffic and perceive a 403 IP NOT ALLOWED response. Hence proved the web application is running behind some kind of firewall.

Then I Google to bypass WAF through burp suite extension and found a link for “Bypass WAF”

This extension add headers to all Burp requests to bypass some WAF products. The following headers are automatically added to all requests:

  1. X-Originating-IP:
  2. X-Forwarded-For:
  3. X-Remote-IP:
  4. X-Remote-Addr:

In our case I use “X-Forwarded-For:” and then forward the intercepted HTTP request.

Execute Command

Finally, we got the Execute Command page, and it appears to be vulnerable to RCE where we can run system arbitrary command. Therefore, we try some malicious code such as “;ls” but again its shows nothing.

Here we need to fix X-Forwarded-For: header for each page and to do so follow below steps:

  1. Intercept the HTTP request of Execute Command page and go to Options.
  2. Explore Match and Replace setting then click to edit option to modify the request header.
  3. A small window will pop-up for Edit match/replace rule, here paste “X-Forwarded-For:” in the replace text filed.
  4. Click on Ok and forward the intercepted request.