Error in Decryption Test (youtube_genalgo.py) #1099

Closed
opened 2026-02-20 23:20:29 -05:00 by deekerman · 6 comments
Owner

Originally created by @JamesRickman4 on GitHub (Sep 16, 2013).

I think there is an error in the line...

tests = [
#92 - vflQw-fB4 2013/07/17
("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&()-+={[]}|:;?/>.<'`~"",
"mrtyuioplkjhgfdsazxcvbnq1234567890QWERTY}IOPLKJHGFDSAZXCVBNM!@#$%^&()-+={[]"|:;"),

The input test string is actually 93 characters if you count them and I don't think you wanted to include quotes as a test character in the string like you did at the end of the input string (the test has "" at the end).

I am interested in how you derive the algorithms to decrypt the signature. Are those published somewhere?

Thanks,
James

Originally created by @JamesRickman4 on GitHub (Sep 16, 2013). I think there is an error in the line... tests = [ #92 - vflQw-fB4 2013/07/17 ("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&_()_-+={[]}|:;?/>.<'`~\"", "mrtyuioplkjhgfdsazxcvbnq1234567890QWERTY}IOPLKJHGFDSAZXCVBNM!@#$%^&_()_-+={[]\"|:;"), The input test string is actually 93 characters if you count them and I don't think you wanted to include quotes as a test character in the string like you did at the end of the input string (the test has "" at the end). I am interested in how you derive the algorithms to decrypt the signature. Are those published somewhere? Thanks, James
Author
Owner

@phihag commented on GitHub (Sep 16, 2013):

You're mistaken; the input string is 92 characters:

>>> len("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'`~\"")
92

The signatures come from the HTML5 player code. I'm working on adding automated extraction. It works fine for HTML5, but alas is not finished for the Flash player.

@phihag commented on GitHub (Sep 16, 2013): You're mistaken; the input string _is_ 92 characters: ``` >>> len("qwertyuioplkjhgfdsazxcvbnm1234567890QWERTYUIOPLKJHGFDSAZXCVBNM!@#$%^&*()_-+={[]}|:;?/>.<'`~\"") 92 ``` The signatures come from the HTML5 player code. I'm working on adding automated extraction. It works fine for HTML5, but alas is not finished for the Flash player.
Author
Owner

@JamesRickman4 commented on GitHub (Sep 16, 2013):

LOL...Interesting. But I think not. Looks like your Len function is lying to you. Try physically counting the characters. I assume we're talking from the 'q' character to the quote character (leaving off the first quote and the last quote....and that means the last character inside the quotes is a quote character). There are 93 characters.

Anyway, do your really want to use the quote character as a test character? I would think this would cause issues like this.

Thanks,
James

@JamesRickman4 commented on GitHub (Sep 16, 2013): LOL...Interesting. But I think not. Looks like your Len function is lying to you. Try physically counting the characters. I assume we're talking from the 'q' character to the quote character (leaving off the first quote and the last quote....and that means the last character inside the quotes is a quote character). There are 93 characters. Anyway, do your really want to use the quote character as a test character? I would think this would cause issues like this. Thanks, James
Author
Owner

@Nothing4You commented on GitHub (Sep 16, 2013):

\" is a single character... it means a " which is escaped because it's inside a quoted string with " as delimiter

@Nothing4You commented on GitHub (Sep 16, 2013): `\"` is a single character... it means a `"` which is escaped because it's inside a quoted string with `"` as delimiter
Author
Owner

@JamesRickman4 commented on GitHub (Sep 17, 2013):

Thanks for the insight. I don't know python syntax but I know how to count and the count added up to 93. But it seems my ignorance in python makes me wrong in the end. LOL Is there a reason for the test cast to go out of its way to use a character that you have to escape with the ""? Just curious now.

On a related note, I didn't fully understand phihag's comment above about the signatures coming from the HTML5 player code. Is that the video.js player or is he talking about something else? I ran across some interesting code from the youtube5 project that had a more formula based approach to the decryption algorithm. However, I could not get it to match the test cases results from the youtube-dl project. The code is below. Are you aware of the youtube5 approach? What is your take on it? I am looking for an algorithm description document (ADD) on how to decrypt the youtube URL download signatures. If you have any insight on that process I'm all ears.

self.signatureDecipher = {
    timestamp: 15902,

    clone: function(a, b) {
        return (a.slice(b));
    },

    decipher: function(s) {
        var t = s.split("");
        t = this.clone(t, 2);
        t = this.reverse(t);
        t = this.clone(t, 3);
        t = this.swap(t, 9);
        t = this.clone(t, 3);
        t = this.swap(t, 43);
        t = this.clone(t, 3);
        t = this.reverse(t);
        t = this.swap(t, 23);
        return (t.join(""));
    },

    swap: function(a, b) {
        var t1 = a[0];
        var t2 = a[(b % a.length)];
        a[0] = t2;
        a[b] = t1;
        return (a);
    },

    reverse: function(a) {
        a.reverse();
        return (a);
    }
};

Thanks,
James

@JamesRickman4 commented on GitHub (Sep 17, 2013): Thanks for the insight. I don't know python syntax but I know how to count and the count added up to 93. But it seems my ignorance in python makes me wrong in the end. LOL Is there a reason for the test cast to go out of its way to use a character that you have to escape with the "\"? Just curious now. On a related note, I didn't fully understand phihag's comment above about the signatures coming from the HTML5 player code. Is that the video.js player or is he talking about something else? I ran across some interesting code from the youtube5 project that had a more formula based approach to the decryption algorithm. However, I could not get it to match the test cases results from the youtube-dl project. The code is below. Are you aware of the youtube5 approach? What is your take on it? I am looking for an algorithm description document (ADD) on how to decrypt the youtube URL download signatures. If you have any insight on that process I'm all ears. ``` self.signatureDecipher = { timestamp: 15902, clone: function(a, b) { return (a.slice(b)); }, decipher: function(s) { var t = s.split(""); t = this.clone(t, 2); t = this.reverse(t); t = this.clone(t, 3); t = this.swap(t, 9); t = this.clone(t, 3); t = this.swap(t, 43); t = this.clone(t, 3); t = this.reverse(t); t = this.swap(t, 23); return (t.join("")); }, swap: function(a, b) { var t1 = a[0]; var t2 = a[(b % a.length)]; a[0] = t2; a[b] = t1; return (a); }, reverse: function(a) { a.reverse(); return (a); } }; ``` Thanks, James
Author
Owner

@phihag commented on GitHub (Sep 17, 2013):

@JamesRickman4 This code is equivalent to one of the lines in our code that look like

return s[5:34] + s[0] + s[35:38] + s[3] + s[39:45] + s[38] + s[46:53] + s[73] + s[54:73] + s[85] + s[74:85] + s[53]

Please bear in mind that this is an issue tracker about issues with youtube-dl. If your copy of youtube-dl doesn't work in some way or you want to suggest an improvement, feel free to do so.

@phihag commented on GitHub (Sep 17, 2013): @JamesRickman4 This code is equivalent to one of the lines in our code that look like ``` return s[5:34] + s[0] + s[35:38] + s[3] + s[39:45] + s[38] + s[46:53] + s[73] + s[54:73] + s[85] + s[74:85] + s[53] ``` Please bear in mind that this is an issue tracker about issues with youtube-dl. If your copy of youtube-dl doesn't work in some way or you want to suggest an improvement, feel free to do so.
Author
Owner

@JamesRickman4 commented on GitHub (Sep 17, 2013):

Ok. Fair enough. Thanks for the quick replies. I'll look elsewhere for answers to my questions. :-)

@JamesRickman4 commented on GitHub (Sep 17, 2013): Ok. Fair enough. Thanks for the quick replies. I'll look elsewhere for answers to my questions. :-)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#1099
No description provided.