diff --git a/package-lock.json b/package-lock.json index 813901da..10c7e8f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "license": "MIT", "dependencies": { "@bufbuild/protobuf": "^2.0.0", - "jintr": "^3.3.0", + "jintr": "^3.3.1", "tslib": "^2.5.0", "undici": "^5.19.1" }, @@ -6155,9 +6155,9 @@ } }, "node_modules/jintr": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/jintr/-/jintr-3.3.0.tgz", - "integrity": "sha512-ZsaajJ4Hr5XR0tSPhOZOTjFhxA0qscKNSOs41NRjx7ZOGwpfdp8NKIBEUtvUPbA37JXyv1sJlgeOOZHjr3h76Q==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jintr/-/jintr-3.3.1.tgz", + "integrity": "sha512-nnOzyhf0SLpbWuZ270Omwbj5LcXUkTcZkVnK8/veJXtSZOiATM5gMZMdmzN75FmTyj+NVgrGaPdH12zIJ24oIA==", "funding": [ "https://github.com/sponsors/LuanRT" ], diff --git a/package.json b/package.json index d006d5ac..ebd85c8a 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "license": "MIT", "dependencies": { "@bufbuild/protobuf": "^2.0.0", - "jintr": "^3.3.0", + "jintr": "^3.3.1", "tslib": "^2.5.0", "undici": "^5.19.1" }, diff --git a/src/core/Player.ts b/src/core/Player.ts index 6d3cec21..987d7a8e 100644 --- a/src/core/Player.ts +++ b/src/core/Player.ts @@ -258,7 +258,18 @@ export default class Player { } static extractSigSourceCode(data: string, global_variable?: ASTLookupResult): string | undefined { - const match = data.match(/function\(([A-Za-z_0-9]+)\)\{([A-Za-z_0-9]+=[A-Za-z_0-9]+\.split\((?:[^)]+)\)(.+?)\.join\((?:[^)]+)\))\}/); + // Classic static split/join. + const split_join_regex = /function\(([A-Za-z_0-9]+)\)\{([A-Za-z_0-9]+=[A-Za-z_0-9]+\.split\((?:[^)]+)\)(.+?)\.join\((?:[^)]+)\))\}/; + + // Using the global lookup variable. + const lookup_var = global_variable?.name?.replace(/[$^\\.*+?()[\]{}|]/g, '\\$&'); + const lookup_regex = lookup_var + ? new RegExp( + `function\\(([A-Za-z_0-9]+)\\)\\{([A-Za-z_0-9]+=[A-Za-z_0-9]+\\[${lookup_var}\\[\\d+\\]\\]\\([^)]*\\)([\\s\\S]+?)\\[${lookup_var}\\[\\d+\\]\\]\\([^)]*\\))\\}` + ) + : null; + + const match = data.match(split_join_regex) || (lookup_regex ? data.match(lookup_regex) : null); if (!match) { Log.warn(TAG, 'Failed to extract signature decipher algorithm.');