Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

parse_token returns wrong ajax token #85

Open
Lohorunk opened this issue Jun 21, 2023 · 11 comments
Open

parse_token returns wrong ajax token #85

Lohorunk opened this issue Jun 21, 2023 · 11 comments
Labels
bug Something isn't working update Aternos API or security methods were changed

Comments

@Lohorunk
Copy link
Contributor

may be related to #75 (comment)

(i dont think ajax tokens are sensitive info but will censor them anyway)

I noticed in the dev console that the ajax token used by aternos did not match the one given by the library
LGuu**************** < used by aternos website
TBsn**************** < used by the library

I deobfuscated the js function by hand to try and understand how it works

(() => /*window["AJAX_TOKEN"]="TBsn****************"}*/{window[["XAJA","OT_","K","NE"].map(s => s.split('').reverse().join('')).join('')]=!(window[["Map"].reverse().join('')]["prototype"]&&window[["cod","emu","tn"].map(s => s.split('').reverse().join('')).join('')]&&window[["nemucod","t"].map(s => s.split('').reverse().join('')).join('')][("getEleme" + "ntB" + "yId")]&&window[["oemiTtes","tu"].map(s => s.split('').reverse().join('')).join('')])?"TBsn****************":"LGuu****************";})();

// -->
(() => {
    window['AJAX_TOKEN'] = !(window["Map"]["prototype"] && window["document"] 
    && window["document"]["getElementById"] 
    && window["setTimeout"]) ? "TBsn****************" : "LGuu****************";
})();

// -->
(() => {
    window['AJAX_TOKEN'] = !true ? "TBsn****************" : "LGuu****************";
})();

And yeah it just sets the AJAX_TOKEN to LGuu**************** its all determined by the !

i tested and the to_ecma5 dosent seem to be the thing causing the error.
If a had to guess its probably the ctx.execute('window.document = { };') and the others that are causing the problem.

@DarkCat09
Copy link
Owner

@hiikion,

Thank you very much!
I think that's how Aternos detects library requests.

Fix: execute document.getElementById = function(_a) { }; before executing the code.

@DarkCat09 DarkCat09 pinned this issue Jun 22, 2023
@DarkCat09 DarkCat09 mentioned this issue Jun 20, 2023
15 tasks
@DarkCat09 DarkCat09 added bug Something isn't working update Aternos API or security methods were changed labels Jun 22, 2023
@Lohorunk
Copy link
Contributor Author

Lohorunk commented Jun 22, 2023

#86 I tested the fix works

DarkCat09 added a commit that referenced this issue Jun 22, 2023
@DarkCat09 DarkCat09 unpinned this issue Jun 27, 2023
@DarkCat09 DarkCat09 reopened this Jun 30, 2023
@DarkCat09
Copy link
Owner

I've checked token parser using tests/js_samples.py now. Every sample was processed incorrectly.

@DarkCat09
Copy link
Owner

Oh, that's because of document.doctype property.

@DarkCat09
Copy link
Owner

DarkCat09 commented Jun 30, 2023

I think the most efficient solution is to create the accurate copy of window and document objects from Firefox DevTools, but there are too many properties and methods.
Maybe I'll write a script for checking AJAX_TOKEN every day and finding usage of properties not implemented in python-aternos.

DarkCat09 added a commit that referenced this issue Jun 30, 2023
@DarkCat09
Copy link
Owner

Temporarily fixed

@DarkCat09
Copy link
Owner

That happened again: Aternos added document.currentScript. Fixed in v3.0.3

@DarkCat09
Copy link
Owner

document.prepend, fixed in 3.0.4

@pythoncat1
Copy link

Is the cause known?

@DarkCat09
Copy link
Owner

@pythoncat1, yes. Please, read the conversation above.

@pythoncat1
Copy link

So I imagine #85 (comment) must be done?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working update Aternos API or security methods were changed
Projects
None yet
Development

No branches or pull requests

3 participants