Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit 8b59d54

Browse files
committed
Trial fix for latest 403 Errors
Attempts to resolve the issue with the decipher handling the new algorithm
1 parent c3055f8 commit 8b59d54

File tree

1 file changed

+64
-11
lines changed

1 file changed

+64
-11
lines changed

YoutubeExtractor/YoutubeExtractor/Decipherer.cs

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,74 @@ public static string DecipherWithVersion(string cipher, string cipherVersion)
2424
//Match the function function_name (that has one argument)
2525
string funcPattern = string.Format(@"{0}\(\w+\){1}", funcName, funcBodyPattern);
2626
var funcBody = Regex.Match(js, funcPattern).Groups["brace"].Value;
27-
2827
var lines = funcBody.Split(';');
28+
2929
string operations = "";
30+
31+
32+
//CYNAO - 07/08/2014, Test Fix
33+
/* The previous algoritms used a.splice(), where the decipher used the method (.splice()), however it seems the new algoritm
34+
* renames the method to random but unique characters (example ab.dc() = splice). This code determines what each method code is,
35+
* as it is defined once using the original name.
36+
*/
37+
string id_Reverse = "" , id_Slice = "" , id_CharSwap = ""; //Holds the new method name for each.
38+
string functionIdentifier = "";
39+
40+
string functIDPattern = @"\w+:\bfunction\b"; //Define as "NB:function(a,b)" where nb can be the three ciphers
41+
var funcID = Regex.Match(js, functIDPattern).Groups[1].Value;
42+
43+
///CODE ADDITION: Get the three ciphers by finding the definition
44+
foreach (var line in lines.Skip(1).Take(lines.Length - 2))
45+
{
46+
string newVarName; //Previous algoritms used to be just "a." - now stores temp var name as its uneccessary
47+
int locOfDot, locOfBracket, functionIDLength;
48+
locOfDot = line.IndexOf("."); // NB.AC( - gets location of the dot.
49+
locOfBracket = line.IndexOf("("); //NB.AC( - gets location of the bracet
50+
functionIDLength = locOfBracket - (locOfDot + 1);
51+
newVarName = line.Substring(0, locOfDot);
52+
functionIdentifier = line.Substring(locOfDot + 1, functionIDLength); //leaving us with the function AC
53+
54+
//This is what the definitions currently look like, could be changed so the regex needs improving. Messy fix.
55+
string tempReverse = string.Format(@"{0}:\bfunction\b\(\w+\)", functionIdentifier); //Reverse only one that doesnt have two parameters
56+
string tempSlice = string.Format(@"{0}:\bfunction\b\([a],b\).(\breturn\b)?.?\w+\.", functionIdentifier); //Regex for slice (return or not)
57+
string tempCharSwap = string.Format(@"{0}:\bfunction\b\(\w+\,\w\).\bvar\b.\bc=a\b", functionIdentifier); //Regex for the char swap.
58+
59+
Match me;
60+
if ((me = Regex.Match(js, tempReverse)).Success)
61+
{ id_Reverse = functionIdentifier; } //If def matched the regex for reverse then the current function is a defined as the reverse cipher
62+
63+
if ((me = Regex.Match(js, tempSlice)).Success)
64+
{ id_Slice = functionIdentifier; } //If def matched the regex for slice then the current function is defined as the slice cipher.
65+
66+
if ((me = Regex.Match(js, tempCharSwap)).Success)
67+
{ id_CharSwap = functionIdentifier; } //If def matched the regex for charSwap then the current function is defined as swap cipher.
68+
69+
}
70+
71+
3072
foreach (var line in lines.Skip(1).Take(lines.Length - 2))
3173
{
3274
Match m;
33-
if ((m = Regex.Match(line, @"\(\w+,(?<index>\d+)\)")).Success)
34-
//calling a two argument function (swap)
35-
operations += "w" + m.Groups["index"].Value + " ";
36-
else if ((m = Regex.Match(line, @"slice\((?<index>\d+)\)")).Success)
37-
//calling slice
38-
operations += "s" + m.Groups["index"].Value + " ";
39-
else if ((m = Regex.Match(line, @"reverse\(\)")).Success)
40-
//calling reverse
41-
operations += "r ";
75+
///DUPLICATE CODE! Improve.
76+
int locOfDot; int locOfBracket; int functionIDLength;
77+
locOfDot = line.IndexOf(".");
78+
locOfBracket = line.IndexOf("(");
79+
functionIDLength = locOfBracket - (locOfDot + 1);
80+
functionIdentifier = line.Substring(locOfDot + 1, functionIDLength); //Just needed this (define it as a member?)
81+
82+
string newSliceIDRegex = string.Format(@"(?<index>\d+)\)+", functionIdentifier);
83+
84+
if ((m = Regex.Match(line, @"\(\w+,(?<index>\d+)\)")).Success && functionIdentifier == id_CharSwap)
85+
{ operations += "w" + m.Groups["index"].Value + " "; } //Character swap regex appears to be the same as before
86+
87+
88+
if ((m = Regex.Match(line, @"\(\w+,(?<index>\d+)\)")).Success && functionIdentifier == id_Slice)
89+
{ operations += "s" + m.Groups["index"].Value + " "; } //Slice appears to have changed the index location???
90+
//Could be wrong and the regex needs improving, seems to work on the latest algorithm though.
91+
92+
if (functionIdentifier == id_Reverse)
93+
{ operations += "r "; } //Reverse operation, no regex required
94+
4295
}
4396
operations = operations.Trim();
4497

@@ -51,7 +104,7 @@ private static string ApplyOperation(string cipher, string op)
51104
{
52105
case 'r':
53106
return new string(cipher.ToCharArray().Reverse().ToArray());
54-
107+
55108
case 'w':
56109
{
57110
int index = GetOpIndex(op);

0 commit comments

Comments
 (0)