ykdl icon indicating copy to clipboard operation
ykdl copied to clipboard

申请支持央视网直播源

Open toorich opened this issue 5 years ago • 20 comments

在提交前,请确保您已经检查了以下内容!

请将错误输出粘贴在下面:

ykdl -i http://tv.cctv.com/live/cctv17/ --debug DEBUG:common:video_host> tv.cctv.com DEBUG:common:short_name> cctv DEBUG:html:get_content> URL: http://tv.cctv.com/live/cctv17/ DEBUG:html:get_content> Charset: UTF-8 CRITICAL:YKDL:cant find vid

如果您有其他附言,例如问题只在某个视频发生,或者是一般性讨论或者提出新功能,请在下面添加:

如题,哪怕只能解析出m3u8也行

toorich avatar Aug 06 '19 08:08 toorich

I can share the way how they do it, I'm not sure I get time to do this myself, but for others it may be a perfect reference point:

  1. open page with mobile user agent

  2. their API base url is https://vdn.live.cntv.cn/api2/liveHtml5.do

  3. build channel param, from link http://tv.cctv.com/live/cctv17/m/ use cctv17, then at beginning add pa://cctv_p2p_hd at the end you will get pa://cctv_p2p_hdcctv17

  4. client param = html5

  5. tsp param in their page = new Date().getTime().toString().slice(0,10)

  6. vn param is hardcoded inside https://js.player.cntv.cn/creator/live_common.js and its value = 2049

  7. vc params is difficult one, as it uses function inside live_common.js and named setH5Str and it uses (tsp, client, "47899B86370B879139C08EA3B5E88267", vdn_uid), but I think they dont validate that, so any 32 char long HEX valid name in uppercase, like C7413E27B533939F5498E9D8FA2238BB should be valid

  8. uid and wlan can be empty

  9. ip param = 101.248.0.0

  10. final url looks like: https://vdn.live.cntv.cn/api2/liveHtml5.do?channel=pa://cctv_p2p_hdcctv17&client=html5&tsp=1565089293&vn=2049&vc=C7413E27B533939F5498E9D8FA2238BB&uid=&wlan=&ip=101.248.0.0

  11. after that open url and parse JSON or use regex to get those urls :)

justasmalinauskas avatar Aug 06 '19 11:08 justasmalinauskas

I can share the way how they do it, I'm not sure I get time to do this myself, but for others it may be a perfect reference point:

  1. open page with mobile user agent
  2. their API base url is https://vdn.live.cntv.cn/api2/liveHtml5.do
  3. build channel param, from link http://tv.cctv.com/live/cctv17/m/ use cctv17, then at beginning add pa://cctv_p2p_hd at the end you will get pa://cctv_p2p_hdcctv17
  4. client param = html5
  5. tsp param in their page = new Date().getTime().toString().slice(0,10)
  6. vn param is hardcoded inside https://js.player.cntv.cn/creator/live_common.js and its value = 2049
  7. vc params is difficult one, as it uses function inside live_common.js and named setH5Str and it uses (tsp, client, "47899B86370B879139C08EA3B5E88267", vdn_uid), but I think they dont validate that, so any 32 char long HEX valid name in uppercase, like C7413E27B533939F5498E9D8FA2238BB should be valid
  8. uid and wlan can be empty
  9. ip param = 101.248.0.0
  10. final url looks like: https://vdn.live.cntv.cn/api2/liveHtml5.do?channel=pa://cctv_p2p_hdcctv17&client=html5&tsp=1565089293&vn=2049&vc=C7413E27B533939F5498E9D8FA2238BB&uid=&wlan=&ip=101.248.0.0
  11. after that open url and parse JSON or use regex to get those urls :)

这样抓出来的直播源是花屏的,没法看,求破

toorich avatar Aug 06 '19 12:08 toorich

@toorich In their flash player, they use api endpoint, which looks like http://vdn.live.cntv.cn/api2/live.do?channel=pa://cctv_p2p_hdcctv17&client=flash&tsp=1565095762&vn=1543&vc=391A3078A64AEB778540A382CB035B76 Links from there work for you?

justasmalinauskas avatar Aug 06 '19 12:08 justasmalinauskas

图片

图片

用html5算法 高清源确实会花屏 低分辨率的不会

airdge avatar Aug 06 '19 13:08 airdge

@toorich In their flash player, they use api endpoint, which looks like http://vdn.live.cntv.cn/api2/live.do?channel=pa://cctv_p2p_hdcctv17&client=flash&tsp=1565095762&vn=1543&vc=391A3078A64AEB778540A382CB035B76 Links from there work for you?

不行,也是花屏

toorich avatar Aug 08 '19 16:08 toorich

他这个是音视频编码改了吧,最早的时候是不花屏的。

DysaniazzZ avatar Nov 27 '19 02:11 DysaniazzZ

看了下,貌似是对I帧进行了加密,加密的操作在liveplayer_controls.js下面的一坨(应该是魔改版本的hls.js),原本的逻辑

捕获

Module里的函数是h5.worker提供的,貌似用了wasm,暂时没啥好办法

hr3lxphr6j avatar Jan 20 '20 15:01 hr3lxphr6j

看了下,貌似是对I帧进行了加密,加密的操作在liveplayer_controls.js下面的一坨(应该是魔改版本的hls.js),原本的逻辑

捕获

Module里的函数是h5.worker提供的,貌似用了wasm,暂时没啥好办法

应该是用JS解密吧……

toorich avatar Jan 25 '20 19:01 toorich

看了下,貌似是对I帧进行了加密,加密的操作在liveplayer_controls.js下面的一坨(应该是魔改版本的hls.js),原本的逻辑 捕获 Module里的函数是h5.worker提供的,貌似用了wasm,暂时没啥好办法

应该是用JS解密吧……

h5.worker最开始的字符串就是base64过的wasm

hr3lxphr6j avatar Jan 26 '20 06:01 hr3lxphr6j

看了下,貌似是对I帧进行了加密,加密的操作在liveplayer_controls.js下面的一坨(应该是魔改版本的hls.js),原本的逻辑 捕获 Module里的函数是h5.worker提供的,貌似用了wasm,暂时没啥好办法

应该是用JS解密吧……

h5.worker最开始的字符串就是base64过的wasm

WABT: The WebAssembly Binary Toolkit 无论用哪个工具转换出来的东西都不少,看着头晕。

mengmo avatar Feb 03 '20 06:02 mengmo

@hr3lxphr6j decryptkey 和 iv 必须搞定 wasm 才能算出来吗?

mengmo avatar Feb 03 '20 09:02 mengmo

@hr3lxphr6j decryptkey 和 iv 必须搞定 wasm 才能算出来吗?

能直接调wasm里的这几个函数应该就可以,我试了几个python上跑wasm的库都不行,不知道是不是我姿势不对的原因

hr3lxphr6j avatar Feb 03 '20 09:02 hr3lxphr6j

这搞法,和我想法一样啊。处理I祯的前面若干字节的二进制数据,使用aes加密。主要是 iv 和key做好秘密传输就可以了。

wnpllrzodiac avatar Feb 04 '20 10:02 wnpllrzodiac

都放弃破解了?

ifnfn avatar Aug 08 '21 13:08 ifnfn

Any news about this problem?

joaopa00 avatar Jul 07 '22 19:07 joaopa00

看了下,貌似是对I帧进行了加密,加密的操作在liveplayer_controls.js下面的一坨(应该是魔改版本的hls.js),原本的逻辑 捕获 Module里的函数是h5.worker提供的,貌似用了wasm,暂时没啥好办法

应该是用JS解密吧……

h5.worker最开始的字符串就是base64过的wasm

WABT: The WebAssembly Binary Toolkit 无论用哪个工具转换出来的东西都不少,看着头晕。

但是目前最新的网页,貌似没有运行这个地方的代码,断点断不到这个位置。目前发现这个加密是跟url地址有关系

zc16607 avatar Sep 19 '22 09:09 zc16607

看了下,貌似是对I帧进行了加密,加密的操作在liveplayer_controls.js下面的一坨(应该是魔改版本的hls.js),原本的逻辑 捕获 Module里的函数是h5.worker提供的,貌似用了wasm,暂时没啥好办法

应该是用JS解密吧……

h5.worker最开始的字符串就是base64过的wasm

WABT: The WebAssembly Binary Toolkit 无论用哪个工具转换出来的东西都不少,看着头晕。

但是目前最新的网页,貌似没有运行这个地方的代码,断点断不到这个位置。目前发现这个加密是跟url地址有关系

我是用python还原了一下算法,主要是es流的一些异或操作,还原出来的基本可以播放,但是对于解密后的数据长度变短的问题还没处理好

592767809 avatar Sep 19 '22 09:09 592767809

現在還有研究嘛?

ghost avatar Jan 14 '23 03:01 ghost

目前wasm已经进行了更新,增加了中等程度的控制流混淆。使用jsrpc方式可以完成解密【https://www.52pojie.cn/thread-1708807-1-1.html】。后面准备使用ast进行反混淆进行算法分析

592767809 avatar Jan 15 '23 11:01 592767809