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

[YouTube] Add JavaScript lexer to parse completely throttling decryption function #905

Merged
merged 18 commits into from
Sep 24, 2022

Conversation

Theta-Dev
Copy link
Contributor

@Theta-Dev Theta-Dev commented Aug 20, 2022

fixes #902

I added a proper javascript lexer to extract the nsig function. The old naive implementation broke because of regexes containing curly braces.

I copied the tokenizer from Rhino because it is private and removed unneeded function. On top of that I had to add logic to determine whether a slash constitutes a regex delimiter or a division operator. I have adapted that from the RESS library.

I also found an issue with the Rhino JS interpreter. Version 1.7.14 uses javax.lang.model.SourceVersion, which is not available on android. This causes the app to load indefinitely when opening a video. If you have any idea how to fix this without downgrading, please help me. I have no idea why this error did not occur before. Checked with the debugger, the error occurs when executing the (correctly extracted) javascript. Perhaps the new deobfuscation function uses a feature of the interpreter which causes it to load the class with the failing import. https://github.com/mozilla/rhino/issues/1149

For now I downgraded Rhino to v1.7.13.

(This part was done in a separate PR.)

@AudricV AudricV added bug youtube service, https://www.youtube.com/ labels Aug 20, 2022
Copy link
Member

@AudricV AudricV left a comment

Choose a reason for hiding this comment

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

Thank you for taking care of this fix! Could you please rebase your PR (and so drop the Rhino version downgrade change that you made yourself)?

Copy link
Member

@AudricV AudricV left a comment

Choose a reason for hiding this comment

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

Thank you again for all the efforts you put to fix this issue!

Your changes look good now to me.

@AudricV AudricV changed the title Add JS lexer to throttling decrypter [YouTube] Add JavaScript lexer to parse completely throttling decryption function Sep 8, 2022
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

I think this approach looks good, and if we find any better way to do this in the future we can still undo this pretty easily. Code also looks good (I obviously didn't review the copied-over code). Thank you @Theta-Dev!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[YouTube] Throttling parameter decryption is broken, decrypt function is not again fully extracted
3 participants