点击此处获得更好的阅读体验
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
/adminNames
redirects to/getFile=file=admins
and 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
usernames
of admins and script to retrieve theirssh-rsa public keys
/login
takes us to a login page :On logging in, we receive a
JWT
in theHTTP response header
Logging in with
admin:admin
, the responseJWT
decodes to (use JWT.IO) :
1 | { |
nqzva
is theROT13
encoding ofadmin
andsnyfr
is theROT13
encoding offalse
(use Cryptii)This is a hint that we need to forge the
JWT
token by settingadmin
astrue
along with a validusername
(inROT13
encoded form)A valid username can be got from the GitHub repository obtained previously
To get the
key
to 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 traversal
Trying
/getFile?file=../.env
(becausenode.js app
), we get thekey
used to sign theJWT
:
1 | JWT_SECRET=Th1sSECr3TMu5TN0Tb3L43KEDEv3RRRRRR!!1 |
Using the
key
and a validusername
, we forge theJWT
and sign itVisiting
/admin
, we get an error message :
1 | {"success": false,"message": "Invalid Token, Headers?"} |
So we need to send the
JWT
to/admin
to impersonate an adminSending the
JWT
inAuthorization header
gets us theROT13
encoding 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} |