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

fix(Player): Fix extracting the n-token decipher algorithm #682

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
},
"license": "MIT",
"dependencies": {
"jintr": "^1.1.0",
"jintr": "^2.0.0",
"tslib": "^2.5.0",
"undici": "^5.19.1"
},
Expand Down
16 changes: 12 additions & 4 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,20 @@ export default class Player {
}

static extractNSigSourceCode(data: string): string {
const sc = `function descramble_nsig(a) { let b=a.split("")${getStringBetweenStrings(data, 'b=a.split("")', '}return b.join("")}')}} return b.join(""); } descramble_nsig(nsig)`;
let sc = getStringBetweenStrings(data, 'b=a.split("")', '}return b.join("")}');

if (!sc)
Log.warn(TAG, 'Failed to extract n-token decipher algorithm');
if (sc)
return `function descramble_nsig(a) { let b=a.split("")${sc}} return b.join(""); } descramble_nsig(nsig)`;

return sc;
sc = getStringBetweenStrings(data, 'b=String.prototype.split.call(a,"")', '}return Array.prototype.join.call(b,"")}');

if (sc)
return `function descramble_nsig(a) { let b=String.prototype.split.call(a, "")${sc}} return Array.prototype.join.call(b, ""); } descramble_nsig(nsig)`;

// We really should throw an error here to avoid errors later, returning a pass-through function for backwards-compatibility
Log.warn(TAG, 'Failed to extract n-token decipher algorithm');

return 'function descramble_nsig(a) { return a; } descramble_nsig(nsig)';
}

get url(): string {
Expand Down
4 changes: 2 additions & 2 deletions src/platform/jsruntime/jinter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const TAG = 'JsRuntime';
export default function evaluate(code: string, env: Record<string, VMPrimative>) {
Log.debug(TAG, 'Evaluating JavaScript:\n', code);

const runtime = new Jinter(code);
const runtime = new Jinter();

for (const [ key, value ] of Object.entries(env)) {
runtime.scope.set(key, value);
}

const result = runtime.interpret();
const result = runtime.evaluate(code);

Log.debug(TAG, 'Done. Result:', result);

Expand Down
Loading