VideoHelp Forum


Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!


Try StreamFab Downloader and download streaming video from Youtube, Netflix, Amazon! Download free trial.


+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. Member
    Join Date
    Oct 2017
    Location
    Philippines
    Search Comp PM
    This video not playing when i add to my player online
    Quote Quote  
  2. Hi Bryan_122!

    Lately I've been trying to download VoD from Movistar without luck. Both URLs you post are perfectly valid, but they're encrypted in a way I struggle to understand.
    In this post I'll to explain what I've found so far, so anyone interested could solve this once and for all


    1. Getting stream data

    Ok, let's take your first link as an starting point for this example: http://XXXXX.vod.cdn.telefonica.com/.../index-02-spa.m3u8

    This M3U8 file contains all SD qualities available for that digital content. But, and here's the trick, if we request index-01-spa.m3u8 instead, we get all available streams (both SD and HD):

    Code:
    #EXTM3U
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5895680,RESOLUTION=1280x720,CODECS="avc1.4d4020,mp4a.40.2"
    01.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4355584,RESOLUTION=1280x720,CODECS="avc1.4d4020,mp4a.40.2"
    03.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2815488,RESOLUTION=1024x576,CODECS="avc1.4d401f,mp4a.40.2"
    05.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2200352,RESOLUTION=1024x576,CODECS="avc1.4d401e,mp4a.40.2"
    07.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2200352,RESOLUTION=640x360,CODECS="avc1.4d4015,mp4a.40.2"
    09.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1481440,RESOLUTION=640x360,CODECS="avc1.4d401f,mp4a.40.2"
    11.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1173120,RESOLUTION=480x270,CODECS="avc1.4d401f,mp4a.40.2"
    13.m3u8
    Next, we target the first stream (http://XXXXX.vod.cdn.telefonica.com/.../01.m3u8) as is the one with the better quality:

    Code:
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:11
    #EXT-X-MEDIA-SEQUENCE:0
    #EXT-X-KEY:METHOD=AES-128,URI="http://www.nagra.com/key=268327&prm=eyJjb250ZW50SWQiOiIyNjgzMjciLCJrZXlJZCI6ImFhZTk5NzhjLWJkZGUtNDMyZi1hMDg3LTYxNTI4MjVkZjVlZCJ9",IV=0x00000000000000000000000000000000
    #EXTINF:10,
    01-0.ts
    #EXTINF:10,
    01-1.ts
    [...]
    #EXTINF:5.6,
    01-326.ts
    #EXT-X-ENDLIST

    2. Extracting the key

    Now, this is when this gets tricky. Due to the stream being encrypted we need a way to decrypt it before merging all TS files. This is usually achieved by using FFMPEG:

    Code:
    ffmpeg -protocol_whitelist "file,http,https,tcp,tls,crypto"
    -allowed_extensions ALL
    -i "http://XXXXX.vod.cdn.telefonica.com/.../01.m3u8"
    -c copy "output.ts"
    But, unfortunately, this results in a "Unable to open key" error. So, what's hapenning?

    FFMPEG is trying to download the key specified in the M3U8, which is supposed to be located at http://www.nagra.com/key=268327&prm=a_really_long_base64_string. But that URL doesn't exists, and the Movistar player has to be taking the decryption key from somewhere.

    After doing some traffic captures, I came to the conclusion that the key has to be hidden inside the M3U8 file.


    3. Understanding the key

    Let's take that long string from the fake key URL: eyJjb250ZW50SWQiOiIyNjgzMjciLCJrZXlJZCI6ImFhZTk5Nz hjLWJkZGUtNDMyZi1hMDg3LTYxNTI4MjVkZjVlZCJ9.

    If we Base64-decode it, we get this JSON object:

    Code:
    {"contentId":"268327","keyId":"aae9978c-bdde-432f-a087-6152825df5ed"}
    The keyId field seems to be a hexadecimal representation of binary data. Removing the hyphens we get a 16 bytes chuck of data, which equals to 128 bits, the length that an AES-128 cypher key should have.

    We seem to have found the decryption key: 0xaae9978cbdde432fa0876152825df5ed. But... that doesn't work either, as FFMPEG returns this error message:

    Code:
    Error when loading first segment 'http://b38545.1.vod.cdn.telefonica.com/38545/prod/hls/cplus-1422250_cplus-1422250-hls_20170921_083550/01-0.ts'
    D:\ConsoleProjects\tmp\stream.m3u8: Invalid data found when processing input

    Conclusion

    This is what I've got so far. I've have no idea why this doesn't work, so any help will be appreciated. I attach three files if you want to test this for yourself:
    • stream.m3u8: contains the parsed stream file with the key path fixed
    • stream.key: the 16 bytes decryption key
    • command.bat: the FFMPEG command
    Image Attached Files
    Quote Quote  
  3. Member Emeritus
    Join Date
    May 2014
    Search PM
    Originally Posted by geronimo007 View Post
    FFMPEG is trying to download the key specified in the M3U8, which is supposed to be located at http://www.nagra.com/key=268327&prm=a_really_long_base64_string. But that URL doesn't exists, ...
    The URL exists, but is does not return the key value - probably because of missing cookie(s) or other header data.

    Originally Posted by geronimo007 View Post
    After doing some traffic captures, I came to the conclusion that the key has to be hidden inside the M3U8 file.

    Let's take that long string from the fake key URL: eyJjb250ZW50SWQiOiIyNjgzMjciLCJrZXlJZCI6ImFhZTk5Nz hjLWJkZGUtNDMyZi1hMDg3LTYxNTI4MjVkZjVlZCJ9.

    If we Base64-decode it, we get this JSON object:
    Code:
    {"contentId":"268327","keyId":"aae9978c-bdde-432f-a087-6152825df5ed"}
    The keyId field seems to be a hexadecimal representation of binary data. Removing the hyphens we get a 16 bytes chuck of data, which equals to 128 bits, the length that an AES-128 cypher key should have.

    We seem to have found the decryption key: 0xaae9978cbdde432fa0876152825df5ed.
    That's not the (decryption) key. It's a key value parameter passed to nagra.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!