Skip to content

Commit

Permalink
fix: fixed signature decipher function, fixed N function.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixkk committed Jan 16, 2025
1 parent dd671ef commit 1ec4a29
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions NUXT/plugins/innertube.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class Innertube {
/\{[A-Za-z$]=[A-z0-9$]\.split\(""\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);return +[A-z0-9$]\.join\(""\)};/.exec(
baseJs.data
);
} else if (/\{a=a\.split\(""[^"]*""\)\};/i.exec(baseJs.data)) {
} else if (/\{[A-Za-z]=[A-Za-z]\.split\(""[^"]*""\)\};/i.exec(baseJs.data)) {
// 10.07.2023
isMatch = /\{a=a\.split\(""[^"]*""\)\};/i.exec(baseJs.data);
isMatch = /\{[A-Za-z]=[A-Za-z]\.split\(""[^"]*""\)\};/i.exec(baseJs.data);
} else if (/\{a=a\.split\(""\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);return a\.join\(""\)\};/.exec(
baseJs.data
)){
Expand All @@ -104,9 +104,8 @@ class Innertube {
);
}
else {
// TODO: Optimize regex patterns
// 13.01.2025
isMatch = /\{[A-Za-z$]=[A-z0-9$]\.split\(""\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);[A-z0-9$]+\.[A-Za-z0-9]+\([^)]*\);return +[A-z0-9$]\.join\(""\)};/.exec(
// 16.01.2025
isMatch = /{[A-Za-z]=[A-Za-z]\.split\(""\);.*return [A-Za-z]\.join\(""\)};/.exec(
baseJs.data
);
}
Expand Down Expand Up @@ -270,23 +269,28 @@ class Innertube {
"s"
).exec(baseJs.data)[2];
}
console.warn("NFunction - 1 error");
}else {
challenge_name = /[A-z0-9$]=String\.fromCharCode\(110\),[A-z0-9$]=[A-z0-9$]\.get\([A-z0-9$]\)\)&&\([A-z0-9$]=[A-Za-z0-9]+\[0\]\([A-z0-9$]\),[A-z0-9$]\.set\([A-z0-9$],[A-z0-9$]\)/i.exec(baseJs.data);

if (challenge_name === null) {

challenge_name = /[A-z0-9$]=[A-Za-z0-9]+\[0\]\([A-z0-9$]\)/i.exec(baseJs.data);
console.warn("NFunction - 2 error");
challenge_name = /\nvar [A-z0-9_$]+=\[[A-z0-9_$]+\];/i.exec(baseJs.data);
}
else {
console.warn("NFunction - success");
challenge_name = /[A-z0-9$]=[A-Za-z0-9]+\[0\]\([A-z0-9$]\)/i.exec(challenge_name[0]);
}

challenge_name = challenge_name[0].replace(/^.*?=\s*(\w+)\s*\[.*$/, "$1");

challenge_name = new RegExp(
`var ${challenge_name}=[[A-Za-z0-9$]+];`).exec(baseJs.data)[0];
// challenge_name = challenge_name[0].replace(/^.*?=\s*(\w+)\s*\[.*$/, "$1");
challenge_name = /^.*?=\s*\[(.*)\];/gm.exec(challenge_name[0])[1];

challenge_name = challenge_name.replace(/^[^\[]*\[|\][^\]]*$/g, '')
// challenge_name = new RegExp(
// `var ${challenge_name}=[[A-Za-z0-9$]+];`).exec(baseJs.data)[0];
// console.warn(challenge_name);
//
// challenge_name = challenge_name.replace(/^[^\[]*\[|\][^\]]*$/g, '')
// console.warn(challenge_name);

challenge_name = challenge_name.replace("$", "\\$");

Expand Down Expand Up @@ -315,9 +319,6 @@ class Innertube {
"var getN=function("+functionArg+"){" + challenge_name + "}; return getN;";

fullCode = fullCode.replace(/if\(typeof [A-Za-z0-9]+==="undefined"\)return [A-Za-z0-9]+;/g, "");
// console.warn(fullCode);
// console.warn(fullCode);
// console.warn(fullCode);
let getN = new Function(fullCode);
this.nfunction = getN();
}
Expand All @@ -338,8 +339,13 @@ class Innertube {
url: baseJsUrl,
}).catch((error) => error);
await this.makeDecipherFunction(baseJs);

console.warn("one");
await this.getNFunction(baseJs);
console.warn("two");
await this.getPOTFunction(baseJs);
console.warn("three");

try {
if (html instanceof Error && this.checkErrorCallback)
this.ErrorCallback(html.message, true);
Expand Down Expand Up @@ -385,11 +391,13 @@ class Innertube {
}
} catch (error) {
this.ErrorCallback(error, true);
console.error(error);
}
}

static async createAsync(ErrorCallback) {
const created = new Innertube(ErrorCallback);

await created.initAsync();
return created;
}
Expand Down

0 comments on commit 1ec4a29

Please sign in to comment.