Audio/video stream recording forums

Attention Visitor:
You may have to register or log in before you can post:
  • Click the register link to sign up.
  • Registered members please fill in the form below and click the "Log in" button.
To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Audio/video stream recording forums > Streaming media recording forum > Video stream recording
Register FAQ Members List Calendar Mark Forums Read

Reply Post New Thread
 
Thread Tools Display Modes
  #21  
Old 05-24-2014, 02:51 PM
chap chap is offline
Senior Member
 
Join Date: Feb 2011
Location: Ukraine
Posts: 1,165
chap is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Quote:
Originally Posted by Nopt View Post
The answer indeed lies in the original source page
And since you like python :
Code:
import base64
from Crypto.Cipher import Blowfish
key = "Rev3rseEngIneeringIsN0tLeGal" #~ As if ;)
aes = Blowfish.new(key, Blowfish.MODE_ECB)
d = "e2f96a0861cb381a8b52801f18bf04924c3472bc8f319930"
d = d.decode("hex")
d = aes.decrypt(d)
d = base64.b64decode(d)
return d
what it looks like in PHP?
Reply With Quote
  #22  
Old 05-24-2014, 04:07 PM
Dune Dune is offline
Member
 
Join Date: May 2014
Posts: 39
Dune is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Quote:
Originally Posted by gaaara View Post
seems to be the language ruby code was in a file. rb

you speek french Dune ?
Indeed I do, we're quite a bunch of french people being concerned by this

Quote:
Originally Posted by Nopt View Post
The answer indeed lies in the original source page
And since you like python :
Code:
import base64
from Crypto.Cipher import Blowfish
key = "Rev3rseEngIneeringIsN0tLeGal" #~ As if ;)
aes = Blowfish.new(key, Blowfish.MODE_ECB)
d = "e2f96a0861cb381a8b52801f18bf04924c3472bc8f319930"
d = d.decode("hex")
d = aes.decrypt(d)
d = base64.b64decode(d)
return d
Thank you very much for the Python port! I'm gonna try this ASAP.
Reply With Quote
  #23  
Old 05-24-2014, 04:23 PM
Nopt Nopt is offline
Member
 
Join Date: May 2014
Posts: 37
Nopt is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Quote:
Originally Posted by Dune View Post
Thank you very much for the Python port! I'm gonna try this ASAP.
I'm not sure what you mean by "port", it has nothing to do with the earlier ruby code (which only handle a classic HLS stream)
My code specifically and only address the problem of the encrypted .key file. (it even includes the secret - well not that secret anymore - key !)

If you want a python port of the ruby code (to dump a classic HLS stream like ffmpeg would do) it's more like that :
Code:
import m3u8
from Crypto.Cipher import AES
f = open('file.ts','rb')
playlist = m3u8.loads(playlist) 
key = urllib2.urlopen(playlist.key.uri).read() # <- swap that line with my earlier snippet to handle encrypted keys
iv = ('%x' % int(playlist.key.iv,16)).decode("hex")
aes = AES.new(key, AES.MODE_CBC, iv)
for x in playlist.segments :
	r = urllib2.urlopen(x.uri)
	d = r.read()
	d = aes.decrypt(d)
	f.write(d)
f.close()
Reply With Quote
  #24  
Old 05-24-2014, 04:38 PM
Spyne Spyne is offline
Junior Member
 
Join Date: May 2014
Posts: 3
Spyne is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Can you explain how you find this key ?
Reply With Quote
  #25  
Old 05-24-2014, 04:50 PM
Dune Dune is offline
Member
 
Join Date: May 2014
Posts: 39
Dune is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Quote:
Originally Posted by Nopt View Post
I'm not sure what you mean by "port", it has nothing to do with the earlier ruby code (which only handle a classic HLS stream)
My code specifically and only address the problem of the encrypted .key file. (it even includes the secret - well not that secret anymore - key !)

If you want a python port of the ruby code (to dump a classic HLS stream like ffmpeg would do) it's more like that :
Code:
import m3u8
from Crypto.Cipher import AES
f = open('file.ts','rb')
playlist = m3u8.loads(playlist) 
key = urllib2.urlopen(playlist.key.uri).read() # <- swap that line with my earlier snippet to handle encrypted keys
iv = ('%x' % int(playlist.key.iv,16)).decode("hex")
aes = AES.new(key, AES.MODE_CBC, iv)
for x in playlist.segments :
	r = urllib2.urlopen(x.uri)
	d = r.read()
	d = aes.decrypt(d)
	f.write(d)
f.close()
Oh I'm sorry I didn't look too puch into the Ruby code and thought all you did was porting.

Thank you a HUGE lot for your investment!
I just tested it, and it works!!! It is going to help a lot of us, that's for sure

Dat key though

Huge thanks again!

Edit: as Spyne said, it would help us a bunch in the future if you could give a few directions&tip as to how to get this key.
Reply With Quote
  #26  
Old 05-24-2014, 05:09 PM
CereFR CereFR is offline
Junior Member
 
Join Date: May 2014
Posts: 6
CereFR is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


You can access the key with every sniffer you can find on the net (personally I use Coojah). But take care to the banishment ! The criteria change weekly, they are still programming their system, then we never know when it changes.

I suggest to focus on the key we have to decrypt, because surrounding stuff can be solved with Google .
Reply With Quote
  #27  
Old 05-24-2014, 05:14 PM
Nopt Nopt is offline
Member
 
Join Date: May 2014
Posts: 37
Nopt is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Quote:
Originally Posted by Dune View Post
Edit: as Spyne said, it would help us a bunch in the future if you could give a few directions&tip as to how to get this key.
Well hint n°1 : the browser always know the key (or anything of that kind for that matter)
hint n°2 : everything the browser executes is basically plain text (or not so far from it)
hint n°3 : it's in the HLSProvider6.0.2.swf file
Reply With Quote
  #28  
Old 05-24-2014, 05:34 PM
Dune Dune is offline
Member
 
Join Date: May 2014
Posts: 39
Dune is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Quote:
Originally Posted by CereFR View Post
You can access the key with every sniffer you can find on the net (personally I use Coojah). But take care to the banishment ! The criteria change weekly, they are still programming their system, then we never know when it changes.

I suggest to focus on the key we have to decrypt, because surrounding stuff can be solved with Google .
Downloading the .key file really is no hard task... it's more about the way to decrypt it. You need another "key"

Quote:
Originally Posted by Nopt View Post
Well hint n°1 : the browser always know the key (or anything of that kind for that matter)
hint n°2 : everything the browser executes is basically plain text (or not so far from it)
hint n°3 : it's in the HLSProvider6.0.2.swf file
Trying that on my own atm, thanks for the hints!
Reply With Quote
  #29  
Old 05-24-2014, 05:44 PM
Dune Dune is offline
Member
 
Join Date: May 2014
Posts: 39
Dune is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


Alright, I've looked into the .swf file, but I can't find anything there; what would you use track the execution/use of that file (or of the player in general)?

Damn I'm feeling incompetent now :/
Reply With Quote
  #30  
Old 05-24-2014, 06:35 PM
gaaara gaaara is offline
Member
 
Join Date: Nov 2013
Posts: 63
gaaara is on a distinguished road
Default

Re: Decrypt AES-128 encrypted video files from a m3u8


how to use this for download video ?
Reply With Quote
Reply Post New Thread
Tags: , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 02:18 AM.


Powered by All-streaming-media.com; 2006-2011
vB forum hacked with Zoints add-ons