VideoHelp Forum




+ Reply to Thread
Results 1 to 15 of 15
  1. Hi there

    I need help understanding how to decrypt a video. (all URLs at the end)

    My original question was here, but larley (thanks) suggested in his answer that this was a (I quote) "rare occurence of AES-128 encryption using a DASH manifest file", and I should start a new thread.

    I updated the steps and details below according to some additional things I tried out after his answer. But I still can't figure out how to finalise this.

    What I've done so far :

    - found the MPD url and downloaded the manifest XML.

    - Also downloaded the desired (encrypted) audio and video streams using yt-dlp (also tried dash-mpd-cli, both worked).
    These are already sitting on my disk now and need to be decrypted.
    Or maybe they need to be decrypted as chunks while being downloaded, I don't know (and wouldn't know how to do that).

    - didn't find any PSSH nor explicit licence url, so I just tried out some random things :
    I went to cdrm-project.com and entered the url found at "keyUriTemplate" in the manifest XML (first one for audio, along with its kid param.) and some headers that I could make out, leaving the PSSH field blank.

    Upon "Send" it returned :
    Code:
    Cached PSSH
    
    PSSH:
    
    Time:Wed Jan 3 17:08:02 2024
    
        b8d35746ec9e9f5c3ebfc5ec945ebf42:78531faef00ddfcf9dfe029812c9f40f
    First I tried to use this as a decryption id:key pair with mp4decrypt it didn't work (didn't get any error, but a 0 byte output file).

    Then, since larley pointed out that it could be AES-128, I searched the forum a bit and found a thread explaining how to find the key in browser's dev tools (it was about a HLS stream but I just followed the key part).

    So I looked for requests to the "key delivery" URL and their responses.
    This is what I found (sorry french UI) :
    Image
    [Attachment 78373 - Click to enlarge]


    Converted to HEX :
    Code:
    Base64: 9CrjgG+fUx2fsUlmCQ7gTQ==
    HEX: f42ae3806f9f531d9fb14966090ee04d
    I then tried different id:key combinations with mp4decrypt, to no avail. (again, either "wrong id (or key)" error, or no error but 0 byte output file)

    If someone could just give the last hint(s) I'm missing that would be greatly appreciated.


    Video URL (public access) :
    https://community.claris.com/en/s/engage/claris-engage-recordings?vtui__catalogId=a5NV...y0000000EB3MAM

    MPD URL :
    https://appiniummediacentralusa-usct.streaming.media.azure.net/02f4acb1-7193-422d-8d0f...ncryption=cbc)

    Headers I used on cdrm-project :
    Code:
    accept: "*/*"
    Accept-Language: "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"
    Accept-Encoding: "gzip, deflate, br"
    Origin: "https://community.claris.com"
    Connection: keep-alive
    Referer: "https://community.claris.com"
    Sec-Fetch-Dest: empty
    Sec-Fetch-Mode: cors
    Sec-Fetch-Site: cross-site
    Last edited by StanP; 15th Apr 2024 at 02:47.
    Quote Quote  
  2. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    This has nothing to do with DRM. It's just plain old AES-128 only disguised as a mpd manifest. It surprised me that N_m3u8 fails at this just because it's not m3u8. Here's your video, subtitles included:
    https://www.transfernow.net/dl/20240414SWWWir6A
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  3. OK thousand thanks for that but could you please explain what you did, exactly ?

    I realise I stated in my original post that "I was a complete newb to this" but didn't repeat it here.

    I have no idea how to grab "plain old AES-128 only disguised as a mpd manifest" as you put it.
    If you could just direct me to where I could find the info here, that would be great.

    Firslty because there's a few other videos I want to grab from that source, and I'd rather do it by myself and second because I'm very much interested in understanding the process.
    Quote Quote  
  4. Feels Good Man 2nHxWW6GkN1l916N3ayz8HQoi's Avatar
    Join Date
    Jan 2024
    Location
    Pepe Island
    Search Comp PM
    Originally Posted by StanP View Post
    could you please explain what you did
    Well, as I told you: "N_m3u8 fails at this just because it's not m3u8". So why not build your own local m3u8? Keep in mind, I dunno if there is some hidden m3u8 provided by them already. I tried editing some variables in that mpd path of yours with no luck.

    First, download the encrypted content using their manifest. You do not want to decrypt them using N_m3u8 or merge them. Make sure you grab your wanted quality for both audio/video since we'll be working with that.
    Code:
    N_m3u8DL-RE.exe https://appiniummediacentralusa-usct.streaming.media.azure.net/02f4acb1-7193-422d-8d0f-a8b2f5cd36d2/9f891697-3e16-4a91-8e3a-73392daf.ism/manifest(format=mpd-time-csf,encryption=cbc) --skip-merge
    In the N_m3u8 output folder you're gonna have 2 folders containing the fragments for video and audio separated. Rename the 2 folders with their long names to simply audio or video. In the new video folder rename _init.mp4 to 0000a.mp4 and 0000.m4s to 0000b.m4s . Do the same for audio.

    Before we move on we're gonna need 2 important things to decrypt hls aes 128: the key and the iv. The key you already found and we'll be using the hex value:

    Originally Posted by StanP View Post
    So I looked for requests to the "key delivery" URL and their responses.
    This is what I found (sorry french UI) :
    Image
    [Attachment 78373 - Click to enlarge]


    Converted to HEX :
    Code:
    Base64: 9CrjgG+fUx2fsUlmCQ7gTQ==
    HEX: f42ae3806f9f531d9fb14966090ee04d
    For the iv, download the mpd and save it as xml. Use VS Code or any other formatting tool to make it look neat. Then in it, you'll find:
    Code:
    <sea:CryptoPeriod keyUriTemplate="https://appiniummediacentralusa.keydelivery.centralus.media.azure.net/?kid=f7f79bd5-91a2-4747-a61d-cee302b17c1b" IV="0x40E9F39B386D74F22185F092C7836FDE"/>
    So the iv is 0x40E9F39B386D74F22185F092C7836FDE . Now we have the wanted content (but encrypted), the key, and the iv. Time to generate the most basic m3u8. I don't think you can even play it in VLC or any other media player, however, you only need it to be valid enough so that it can be parsed by N_m3u8. I coded a short script that does that. Put the script outside the video and audio folders and run it.

    Code:
    import os
    
    
    def generate_m3u8(directory, iv_value):
        fragments = sorted([f for f in os.listdir(directory)])
        with open(f"{directory}.m3u8", "w") as f:
            f.write("#EXTM3U\n")
            f.write("#EXT-X-VERSION:3\n")
            f.write("#EXT-X-MEDIA-SEQUENCE:1\n")
    
            f.write(f'#EXT-X-KEY:METHOD=AES-128,URI="random_irrelevant_path",IV={iv_value}\n')
            for fragment in fragments:
                f.write(f"#EXTINF:0,\n")
                f.write(f"{directory}/{fragment}\n")
            f.write("#EXT-X-ENDLIST")
    
    
    def generate_master_m3u8(video_dir, audio_dir):
        with open("master.m3u8", "w") as f:
            f.write(f"#EXTM3U\n")
            f.write(f"#EXT-X-STREAM-INF:BANDWIDTH=2\n{video_dir}.m3u8\n")
            f.write(f"#EXT-X-STREAM-INF:BANDWIDTH=1\n{audio_dir}.m3u8\n")
    
    
    v_dir = "video"
    a_dir = "audio"
    iv_val = "0x40E9F39B386D74F22185F092C7836FDE"
    
    generate_master_m3u8(v_dir, a_dir)
    generate_m3u8(v_dir, iv_val)
    generate_m3u8(a_dir, iv_val)
    If you notice, the variable iv_val was initialized using the iv extracted from the MPD. Now, all it takes is running this final command. Make sure you check both boxes for video/audio tracks.
    Code:
    N_m3u8DL-RE.exe master.m3u8 --custom-hls-key f42ae3806f9f531d9fb14966090ee04d -M format=mkv
    You can now delete the previously encrypted fragments and the generated m3u8s. The solution is boring, cheap, and very tedious. But I don't know any other way. I didn't care that much to actually search for a smarter way but I know there is definitely one. You should search for tools that can convert mpd manifests to m3u8s either locally or from a URL. Or N_m3u8 has some specific parameters that I don't know. Or if other tools can actually decrypt hls aes 128 if it's in an MPD manifest.
    Last edited by 2nHxWW6GkN1l916N3ayz8HQoi; 14th Apr 2024 at 08:29.
    --[----->+<]>.++++++++++++.---.--------.
    [*drm mass downloader: widefrog*]~~~~~~~~~~~[*how to make your own mass downloader: guide*]
    Quote Quote  
  5. https://github.com/Tontonnow/N_m3u8DL-RE/actions/runs/8680287173

    download this

    key must set

    Code:
    N_m3u8DL-RE.exe https://appiniummediacentralusa-usct.streaming.media.azure.net/02f4acb1-7193-422d-8d0f-a8b2f5cd36d2/9f891697-3e16-4a91-8e3a-73392daf.ism/manifest(format=mpd-time-csf,encryption=cbc)  --custom-hls-key 9CrjgG+fUx2fsUlmCQ7gTQ== -M format=mkv
    Image
    [Attachment 78378 - Click to enlarge]


    Image
    [Attachment 78377 - Click to enlarge]
    Last edited by Novia; 14th Apr 2024 at 10:42.
    Quote Quote  
  6. Originally Posted by 2nHxWW6GkN1l916N3ayz8HQoi View Post
    Well, as I told you: "N_m3u8 fails at this just because it's not m3u8". So why not build your own local m3u8? Keep in mind, I dunno if there is some hidden m3u8 provided by them already. I tried editing some variables in that mpd path of yours with no luck.
    Great write-up, as usual.

    Following command worked perfectly, well done.
    Code:
    N_m3u8DL-RE.exe https://appiniummediacentralusa-usct.streaming.media.azure.net/02f4acb1-7193-422d-8d0f-a8b2f5cd36d2/9f891697-3e16-4a91-8e3a-73392daf.ism/manifest(format=mpd-time-csf,encryption=cbc) -M format=mkv --custom-hls-key f42ae3806f9f531d9fb14966090ee04d --custom-range 0-10
    Quote Quote  
  7. Please tell me how to get N_m3u8DL-RE.exe
    I can't find the link
    Quote Quote  
  8. Originally Posted by mister_ nex View Post
    Please tell me how to get N_m3u8DL-RE.exe
    I can't find the link
    Check in this Repo
    1. https://github.com/nilaoda/N_m3u8DL-RE
    2. https://github.com/Tontonnow/N_m3u8DL-RE/

    Or Direct File
    N_m3u8DL-RE.zip
    Quote Quote  
  9. LittleSoldier
    Thank you for the tip
    Everything was found, I just didn’t look carefully

    2nHxWW6GkN1l916N3ayz8HQoi
    Му gratitude to you for, as always, an informative theoretical guide.

    Novia
    many thanks for the fork which can recognize AES-128 in DASH manifest file
    Last edited by mister_ nex; 14th Apr 2024 at 15:04.
    Quote Quote  
  10. Originally Posted by Novia View Post
    https://github.com/Tontonnow/N_m3u8DL-RE/actions/runs/8680287173

    download this

    key must set

    Code:
    N_m3u8DL-RE.exe https://appiniummediacentralusa-usct.streaming.media.azure.net/02f4acb1-7193-422d-8d0f-a8b2f5cd36d2/9f891697-3e16-4a91-8e3a-73392daf.ism/manifest(format=mpd-time-csf,encryption=cbc)  --custom-hls-key 9CrjgG+fUx2fsUlmCQ7gTQ== -M format=mkv
    Well, this doesn't work on my side, and actually I already tried it before. (not sure what you mean by "key must set" though)

    Image
    [Attachment 78380 - Click to enlarge]


    I'll try the method that doesn't merge the fragments asap and let you know.

    Thanks to you all in the meantime.
    Quote Quote  
  11. Originally Posted by StanP View Post

    Well, this doesn't work on my side, and actually I already tried it before.

    Use only this version of the program

    Code:
    https://github.com/Tontonnow/N_m3u8DL-RE/actions/runs/8680287173
    you did it

    Code:
    INFO : Extracted, there are 5 streams, with 4 basic streams, 1 audio streams, 0 subtitle streams
    INFO : Vid *CENC 1920x1080 | 3947 Kbps | 1_V_video_1 | avc1.640028 | 1898 Segments | ~01h03m14s
    INFO : Vid *CENC 1280x720 | 3092 Kbps | 1_V_video_2 | avc1.64001F | 1898 Segments | ~01h03m14s
    INFO : Vid *CENC 960x540 | 1392 Kbps | 1_V_video_3 | avc1.64001F | 1898 Segments | ~01h03m14s
    INFO : Vid *CENC 640x360 | 937 Kbps | 1_V_video_4 | avc1.64001E | 1898 Segments | ~01h03m14s
    but the program should recognize AES-128 instead of CENC

    Code:
    INFO : Extracted, there are 5 streams, with 4 basic streams, 1 audio streams, 0 subtitle streams
    INFO : Vid *AES_128 1920x1080 | 3947 Kbps | 1_V_video_1 | avc1.640028 | 1898 Segments | ~01h03m14s
    INFO : Vid *AES_128 1280x720 | 3092 Kbps | 1_V_video_2 | avc1.64001F | 1898 Segments | ~01h03m14s
    INFO : Vid *AES_128 960x540 | 1392 Kbps | 1_V_video_3 | avc1.64001F | 1898 Segments | ~01h03m14s
    INFO : Vid *AES_128 640x360 | 937 Kbps | 1_V_video_4 | avc1.64001E | 1898 Segments | ~01h03m14s
    Last edited by mister_ nex; 14th Apr 2024 at 15:58.
    Quote Quote  
  12. Originally Posted by mister_ nex View Post
    Originally Posted by StanP View Post

    Well, this doesn't work on my side, and actually I already tried it before.

    Use only this version of the program

    Code:
    https://github.com/Tontonnow/N_m3u8DL-RE/actions/runs/8680287173
    Sorry if I'm being stupid here, but your link doesn't show any downloadable resource.

    So I went for the latest release for that repo, that is N_m3u8DL-RE_Beta_win-x64_20240319.zip (found here )

    If that's not the same version you're using, then I don't know where to find it.

    I also tried with the 3 links provided by LittleSoldier.

    No matter which version I try, the console shows
    Code:
    INFO : Vid *CENC 1920x1080 | 3947 Kbps...
    (still didn't have time to try 2nHxWW6GkN1l916N3ayz8HQoi's solution, but I'm puzzled by the fact that mister_nex manages to do it with a plain N_m3u8DL-RE command and I can't...)
    Quote Quote  
  13. Originally Posted by mister_ nex View Post
    Originally Posted by StanP View Post

    Well, this doesn't work on my side, and actually I already tried it before.

    Use only this version of the program

    Code:
    https://github.com/Tontonnow/N_m3u8DL-RE/actions/runs/8680287173
    never mind, I got the right exe, I wasn't logged in to github and the "artifacts" section at the bottom wasn't showing links...
    I didn't know this behaviour !

    Now with the right exe, AES-128 is correctly detected and the decryption / muxing works !

    Thanks again to you all for your help, I was very close since the beginning, but was going in circles because not using the right versions of the tools...
    Quote Quote  
  14. Originally Posted by 2nHxWW6GkN1l916N3ayz8HQoi View Post
    Well, as I told you: "N_m3u8 fails at this just because it's not m3u8". So why not build your own local m3u8? Keep in mind, I dunno if there is some hidden m3u8 provided by them already. I tried editing some variables in that mpd path of yours with no luck.

    [...]
    I didn't thank you specifically for your very detailed answer and efforts, that was some brilliant workaround.

    I guess I won't need it now though, with that version of N_m3u8DL-RE detecting AES-128 ...
    Quote Quote  
  15. Member
    Join Date
    Jun 2024
    Location
    australia
    Search PM
    Can anyone help me, how to play mpd dash to ott player.. Any format to playlist. Please
    Quote Quote  



Similar Threads

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