丁香园公开课视频下载脚本
本帖最后由 tree_fly 于 2019-5-9 00:37 编辑⚠️注意: 该脚本仅是解密、下载丁香园的加密m3u8流媒体。然而如何破解付费视频不在讨论范畴。本文以试看视频为例,技术讨论。
0x1 获取m3u8链接
启动Charles,手机端点击视频试看,可以获取到m3u8链接:
https://1252348479.vod2.myqcloud.com/92e0c654vodtransgzp1252348479/5bdc4ce85285890786207203137/drm/voddrm.token.......v.f230.m3u8?t=5cd44f78&us=LiKnCliT9O&sign=355c8e1e131caefd371925798a6f6129
0x2 分析m3u8文件
内容如下:
#EXTM3U#EXT-X-VERSION:3
#EXT-X-KEY:METHOD=AES-128,URI="https://class.dxy.cn/webservices/clazz/video/getDK?edk=CiBgnn44vnF5....804938636d7f6f050",IV=0x00000000000000000000000000000000
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:16
#EXT-X-KEY:METHOD=AES-128,URI="https://class.dxy.cn/webservices/clazz/video/getDK?edk=CiBgnn44vnF5....804938636d7f6f050",IV=0x00000000000000000000000000000000
#EXTINF:1.458,
v.f230.ts?start=0&end=339343&type=mpegts&t=5cd3cb96&us=M15e20LQ8Q&sign=06cc5f175661088abce73a951bdf3b57
#EXT-X-KEY:METHOD=AES-128,URI="https://class.dxy.cn/webservices/clazz/video/getDK?edk=CiBgnn44vnF5....804938636d7f6f050",IV=0x00000000000000000000000000000000
#EXTINF:3.333,
v.f230.ts?start=339344&end=655199&type=mpegts&t=5cd3cb96&us=M15e20LQ8Q&sign=06cc5f175661088abce73a951bdf3b57
#EXT-X-KEY:METHOD=AES-128,URI="https://class.dxy.cn/webservices/clazz/video/getDK?edk=CiBgnn44vnF5....804938636d7f6f050",IV=0x00000000000000000000000000000000
#EXTINF:2.000,
v.f230.ts?start=655200&end=717999&type=mpegts&t=5cd3cb96&us=M15e20LQ8Q&sign=06cc5f175661088abce73a951bdf3b57
#EXT-X-KEY:METHOD=AES-128,URI="https://class.dxy.cn/webservices/clazz/video/getDK?edk=CiBgnn44vnF5....804938636d7f6f050",IV=0x00000000000000000000000000000000
可以看出视频加解密算法:AES-128
iv=0,key=?
0x3 脚本
写个脚本,顺序下载所有加密的流文件ts,openssl解密,再用ffmpeg合并即可。
#!/bin/bash
# A dxyVideo downloader bash. For technical research only.
# tree_fly/P.Y.G
# 2019-05-07
clear
echo "* DXY FREE VIDEO DOWNLOAD TOOLS *"
if [ "$#" != "1" ]; then
echo "usage: $0 <url>"
exit 1
fi
CONCAT=CONCAT`date +"%Y%m%d-%H%M%S"`.tmp
VIDEO=VIDEO`date +"%Y%m%d-%H%M%S"`.mp4
BASEURL=`echo $1 | awk '{drmpos=index($0, "voddrm.token"); url=substr($0, 0, drmpos-1); print url }'`
echo "* BASEURL=$BASEURL"
echo "* START DOWNLOADING"
curl -s "$1" | sed "s#v.f230.ts#$BASEURL&#g" | \
awk 'BEGIN {i=0; print "#" > "'$CONCAT'" } \
$0 ~ "EXT-X-KEY" { urlpos=index($0,"URI=")+5; ivpos=index($0,"IV="); keyurl=substr($0, urlpos, ivpos-urlpos-2); iv=substr($0, ivpos+5); \
print "key=`curl -s '\''"keyurl"'\'' | hexdump -C | head -1 | sed \"s/00000000//;s/|.*//;s/ //g\"`"; print "iv="iv} \
$0 !~ "-KEY" && $0 ~ ".ts" || $0 ~ "start=" { \
printf("curl -s '\''"$0"'\'' | openssl aes-128-cbc -K $key -iv $iv -d >TF-tmp-2019-%05i.ts\n", i++); \
printf("file TF-tmp-2019-%05i.ts\n", i-1) >> "'$CONCAT'" }' | bash
echo "* CONCAT TS FILES"
# /usr/local/bin/ffmpeg
ffmpeg -y -f concat -i $CONCAT -c copy $VIDEO 2>/dev/null
rm -f TF-tmp-2019-*.ts
rm -f CONCAT*.tmp
echo "* DONE! SAVE TO $VIDEO"
下载:
赞一个,支持大婶分享。 好工具,谢楼主~ 真不错!专业视频正需要! 应该不错的,谢谢分享 感谢提供!不错! 感谢分享,技术哦 学习大神了,感谢分享 {:biggrin:}{:biggrin:}{:biggrin:}{:biggrin:}{:biggrin:} {:biggrin:}{:biggrin:}{:biggrin:}{:biggrin:}{:biggrin:}
页:
[1]
2