点击此处获得更好的阅读体验
WriteUp来源
https://dunsp4rce.github.io/csictf-2020/web/2020/07/22/CCC.html
by shreyas-sriram
题目描述
You can steal a car if you steal its key.
题目考点
解题思路
We are given a complex-looking-fancy website which has numerous dummy links and only 2 useful links
The useful links are :
/adminNames/login/adminNamesredirects to/getFile=file=adminsand a file with the following contents is obtained :csivitu/authorized_users/blob/master/Going through the above GitHub repository, we realize that it contains the
usernamesof admins and script to retrieve theirssh-rsa public keys/logintakes us to a login page :On logging in, we receive a
JWTin theHTTP response headerLogging in with
admin:admin, the responseJWTdecodes to (use JWT.IO) :
1 | { |
nqzvais theROT13encoding ofadminandsnyfris theROT13encoding offalse(use Cryptii)This is a hint that we need to forge the
JWTtoken by settingadminastruealong with a validusername(inROT13encoded form)A valid username can be got from the GitHub repository obtained previously
To get the
keyto sign theJWT, we try a bunch of common file names in the path/getFile?file=<filename>There is also a filename length limit of 7, this tells us that the file name is short and could be even shorter if we are to use
directory traversalTrying
/getFile?file=../.env(becausenode.js app), we get thekeyused to sign theJWT:
1 | JWT_SECRET=Th1sSECr3TMu5TN0Tb3L43KEDEv3RRRRRR!!1 |
Using the
keyand a validusername, we forge theJWTand sign itVisiting
/admin, we get an error message :
1 | {"success": false,"message": "Invalid Token, Headers?"} |
So we need to send the
JWTto/adminto impersonate an adminSending the
JWTinAuthorization headergets us theROT13encoding of the flag
Request
1 | GET /admin HTTP/1.1 |
Response
1 | pfvpgs{1a_gu3_3aq_1g_q0rfa'g_3i3a_z4gg3e} |
- Decode the above to get the flag
Flag
1 | csictf{1n_th3_3nd_1t_d0esn't_3v3n_m4tt3r} |