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

Error in Decryption Test (youtube_genalgo.py) #1441

Closed
JamesRickman4 opened this issue Sep 16, 2013 · 6 comments
Closed

Error in Decryption Test (youtube_genalgo.py) #1441

JamesRickman4 opened this issue Sep 16, 2013 · 6 comments

Comments

@JamesRickman4
Copy link

@JamesRickman4 JamesRickman4 commented 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

@phihag
Copy link
Contributor

@phihag phihag commented 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 phihag closed this Sep 16, 2013
@JamesRickman4
Copy link
Author

@JamesRickman4 JamesRickman4 commented Sep 17, 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

@Nothing4You
Copy link

@Nothing4You Nothing4You commented Sep 17, 2013

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

@JamesRickman4
Copy link
Author

@JamesRickman4 JamesRickman4 commented 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

@phihag
Copy link
Contributor

@phihag phihag commented 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.

@JamesRickman4
Copy link
Author

@JamesRickman4 JamesRickman4 commented Sep 17, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.