Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mode 33400: mega.nz password-protected link (PBKDF2-HMAC-SHA512) #3907

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DCNick3
Copy link

@DCNick3 DCNick3 commented Nov 20, 2023

mega.nz is a centralized file-sharing service with some nice security features, like client-side file decryption. Apparently it is not widely known, but mega password-protected links are implemented fully on the client side using PBKDF2-HMAC-SHA512 to derive a key and an HMAC-SHA256 to verify the derived key.

This PR adds support for cracking passwords for such links.

Relevant documentation

Example hash

P!AgD________U2XVjJi1vxkJgMPf5rkQYUn1H_6WI_sKtiic69mqBKP_____________________O_PDG0Om7BSapL1QoRAgUrz9vzaZmrYnU8t-Au6hteg

It corresponds to the following link:

https://mega.nz/#P!AgD________U2XVjJi1vxkJgMPf5rkQYUn1H_6WI_sKtiic69mqBKP_____________________O_PDG0Om7BSapL1QoRAgUrz9vzaZmrYnU8t-Au6hteg

This hash follows the algorithm, but does not correspond to a real file.

Notes

I did not test this on file links (they have 01 at the second byte and a different key length), but I did try to support it.

I am unsure of some of the choices I made in the PR and would like some input from the maintainers:

  1. What should the category for such a hash should be? I've used HASH_CATEGORY_APPLICATION_DATABASE, but it's not really an application and more like a centralized service..
  2. I am not sure if the use of COMPARE_M in the kernel makes sense. Intuitively, we already know the digest we want to compare with so, probably COMPARE_S should be used instead? I was not able to figure out how to use it here though

// the base64-decoded data after the P! is either 88 or 104 bytes, depending on whether it is a folder or a file link
u8 decoded_buf[0x100];

if (line_len > 140) return (PARSER_GLOBAL_LENGTH);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 142
The base64 is ceil(104/3)*4=140 chars long, plus 2 for P!

@DCNick3
Copy link
Author

DCNick3 commented Jun 10, 2024

Rebased & fixed the length check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants