rooCookie & SSTI golf
rooCookie
According to the description, it seems that the author set the flag as the password. And he said 'I fed my website some cookies so it would remember me' => Maybe flag in cookies
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
View source code
- We get a function createToken(text) ,it performs the function of encrypting a text and then assign it to document.cookie
- Notice there is a predefined document.cookie => This is flag ???
- If so we just reverse the createToken() function to get the flag
Analysis of the coding process
- First each character in text will go through the charCodeAt() function => the function will return the Unicode value of that character
- That unicode value will continue to do the calculation (-43+1337)
- '>>' is right shift operator but '>> 0' so the result does not change
- And finally convert it to binary
Decryption script
Flag : ictf{h0p3_7ha7_wa5n7_t00_b4d}
SSTI golf
Check source code
- The function '/' will show source code
- The function '/ssti' is mapped with the '/ssti' path and takes the query parameter => /ssti?query=
- The input query will be checked for length if it exceeds 48 then return "To long"
- If less than 48 characters will return render_template_string(query)
Note : The page uses render_template_string for rendering the HTML response.The function renders the template directly from a string which can trigger a potential Server-Side Template Injection (SSTI) if the string has been modified to include a valid python code.
Exploit
- Challenge is written in Python and runs the Jinja2 template.I found a basic payload of {{7*7}}. I injected the inputs query with the payload and analyzed the responses. => Successful !!!
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- I use this payload to list all file names :
{{lipsum.__globals__['os'].popen('ls').read()}}
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- Because the file name is too long I used the command
cat *
to read all the files in the current folder
{{lipsum.__globals__.os.popen('cat *').read()}}
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Flag : ictf{F!1+3r5s!?}
Refer to the connection
https://chowdera.com/2020/12/20201221231521371q.html
https://workshops.devax.academy/security-for-developers/module9/fix_ssti_vulnerability.html
https://hackmd.io/@Chivato/HyWsJ31dI#What-is-a-SSTI