Investigating the Source Code
In this challenge, we are provided with the source code of the script directly.
Here are the interesting snippets of the source code:
|
|
It looks like the entrypoint for the server uses a helper function, filter()
, to determine if the user is trying to call the win()
function.
The important thing to note is that the code assumes any input past the filter()
function is valid, so it does not perform any additional checks.
So, we just need to get the user_input
variable to evaluate to the string “win” when the server executes our Python code.
The Nested Eval Approach
Intuition
We know that we need the user_input
variable to evaluate to “win” after the server executes our code. So, we can provide as input an eval()
function that evaluates to “win”.
Implementation
In this case, I just had a short line of code that converted the ASCII values of “w”, “i”, “n” to their respective characters, and added them into the single word “win”.
|
|
On the server, this essentially gets represented like below:
|
|
After the nested eval()
call, the server essentially executes the below code, which outputs the flag:
|
|
Cleaning Up the Flag
Similar to Picker I, the output of the flag is a space separated string of hex codes:
|
|
So, we can write a tiny Python script to clean up this text and output the flag:
|
|