26th January 2022
Write-up Advent of CTF challenge 10

Write-Up Advent of CTF 10

The NOVI University Of Applied Sciences is offering an Advent CTF challenge for December 2020. The CTF is created by our community member of the Hackdewereld.nl and Chief Lecturer for Cyber Security at the NOVI University, Arjen Wiersma. If you want to participate in these CTF challenges, you can create an account on the website https://www.adventofctf.com/.

Challenge 10

  • When files are included things can get real messy. The flag is in flag.php.
  • 1000 Points

This challenge was a hard one for me. It had taken me quite some time to solve this challenge. Let’s start with this challenge! There are actually two ways to solve this challenge. I will explain both of the solutions in this write-up.

I visited the URL of this challenge https://10.adventofctf.com. The webpage shows the message Currently there is only one person on the naughty list..... It’s our job to find who is on this list.

Advent of CTF Challenge 10

The description of the challenge is talking about included files. I think we are handling a webpage with a Local File Inclusion (LFI) vulnerability.

Local File Inclusion (LFI)

Local File Inclusion (LFI) allows an attacker to include files on a server through the web browser. This vulnerability exists when a web application includes a file without correctly sanitizing the input. This allows an attacker to manipulate the input and inject path traversal characters, and include other files from the webserver.

An example of a piece of PHP code that is vulnerable to LFI.

$file = $_GET['file'];
if (isset($file)) {
    include('pages / $file');
} else {
    include('flag . php');

As the description says, the flag is in the flag.php file. Let’s try to access that file by adding it to our URL, the URL will be https://10.adventofctf.com/flag.php.

Advent of CTF Challenge 10 flag php file

This page is giving the hint for the next step Go get promoted! We need to get promoted. Maybe we are now logged in as a user or something. Let’s check our cookie. The cookie has the name zeroten with the value eyJwYWdlIjoibWFpbiIsInJvbGUiOiIxMmRlYTk2ZmVjMjA1OTM1NjZhYjc1NjkyYzk5NDk1OTY4MzNhZGM5In0%3D. After decoding this Base64 encoded value, we got the following JSON value.


The role parameter is SHA1-encoded. Let’s decode this value and see what we got. After decoding, our cookie is human readable.


Solution 1

The flag.php already tells us, we have to promote ourselves to admin to be able to read the flag. The cookie also shows that the “page”:”main” is called, it needs to be changed to "page":"flag", so we can access the flag. If we put the things together we got this as our new cookie: {"page":"flag","role":"admin"}. The user needs to be encoded to a SHA1-format.

Normally, I’m using hashes.com to generate a hash from a string, but this time I’ve written a small Python program for this purpose. I’m teaching myself to get more familiar with Python, so I try to script as much as possible with Python.

My small Python script for the SHA1 encoding:

import hashlib
import argparse

parser = argparse.ArgumentParser()

    '-s', '--string', help='Specify string for encoding to SHA1.', type=str, required=True)

args = parser.parse_args()

def Sha1encode(string):
        sha1 = hashlib.sha1(args.string.encode())
    except ValueError:
        print(f'Error could not encode {args.string}')


Ok, now we can pass the string admin to the Python script.

~$ python3 Sha1Encoder.py --string admin

Now, we are ending up with this cookie:


The last what we have to do is to encode this cookie to Base64 with CyberChef.


Replace the current cookie in our browser with the new cookie and we can read the flag: NOVI{LFI_1s_ask1ng_f0r_tr0bl3}.

Advent of CTF Challenge 10 flag

Solution 2

There is another solution to capture the flag by using the php://filter. With this solution, there is no need to promote ourselves to admin. Without further redo, let’s walk through the second solution.

For this solution, we are using the php://filter. allows us to include local files and base64 encodes the output. Therefore, we need any base64 output to be decoded to reveal the contents of the included file. To read the flag, we only need to change the page parameter in the cookie to this value.


Decode this cookie to the Base64 and we got this cookie.


We can replace the current Base64 cookie with the new one, and after refreshing the page, we have included the flag.php file in base64 encoded format.

Advent of CTF Challenge 10 base64 flag

After decoding this flag with CyberChef, we can read the flag.

Advent of CTF Challenge 10 decoded flag

In the end, I got a little bit stuck in this challenge. I thought in the first place, that it will be a classic LFI, which can be attacked by using parameters in the browser. After getting stuck, I’ve switched to the cookie and managed through the cookie to find my way to get to the flag. I’ve learned something new, I wasn’t aware in the first place that LFI through a cookie was possible.

Thanks for reading!


I'm a cybersecurity enthusiast! I'm working as an IT Security Engineer for a company in The Netherlands. I love writing scripts and doing research and pentesting. As a big fan of Hack The Box, I share my write-ups on this blog. I'm blogging because I like to summarize my thoughts and share them with you.

View all posts by T13nn3s →

Leave a Reply

Your email address will not be published.