带key视频解密(爬虫)
·
初级会计实务视频课程(爬虫)
有key值ts视频破解
1.观察网站
https://www.chinaacc.com/demo/h5/2/198/cware-39252/video-901.html
视频大多为m3u8文件,直接搜索
2.爬虫基本操作:请求获取此m3u8文件并下载ts文件
3.获取后发现ts无法播放,发现有加密,加密方式AES-128,key文件也有

4.再爬虫基操,获取此key二进制文件,拖入windows hex得到16进制文件

5.命令行解密:out文件名字iv值发现不需要,随便一个128位值就行,新生成文件可播放,只能单独ts可播放,需要获取一个解密一个,最后用格式工厂合并文件

6.完整代码
import os
import re
import json
import requests_html
session = requests_html.HTMLSession()
class Kuaiji(object):
def __init__(self):
self.hebings = 'copy *.ts video.ts'
self.cmd = 'openssl aes-128-cbc -d -in {}.ts -out {}.ts -nosalt -iv 00000000000000000000000000000000 -K 722B6E0F3Ec6937C17BAFEE31A84684D'
self.url = 'https://www.chinaacc.com/demo/h5/2/198/cware-39252/video-901.html'
self.head = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Cookie': 'tpjv2_0=""; hd_uid=CjsAJmBlMzNVrxANA0fbAg==; BIGipServerwww.chinaacc.com=637549322.20480.0000; trackerSdkVisitor_isNew=true; bdp_uuid=25a7880035-3f40238f-2941b61adf; zg_did=%7B%22did%22%3A%20%221788b500221c5-0567f92c23244e-3e604802-2a3000-1788b500222176%22%7D; Hm_lvt_f1ca44b62370e4b7dc11d5937e51c2d6=1617244980; client_ucToken=E2B10812FE13243A16D3B76B02099042-fd0e60a7055425f72028d7f12e7505ad-01; clientID=PsE7CI4Ct8uccPjeodDIvoN8yU7y8-FEsGRYg9Q6sBhf2IsFHa-ZB72ePeXUOqlF1ALL08UOnJoU%0D%0AbvnprVAvV7tYFOUxqI9C0Lnk4VnNsYk%0D%0A; _pk_ses.www.chinaacc.com.6c33=*; _pk_id.www.chinaacc.com.eab1=9dff4dc4e2916c1b.1617247903.3.1617257305.1617257305.; _pk_ses.www.chinaacc.com.eab1=*; _pk_id.www.chinaacc.com.6c33=fc496df8c5584b71.1617244980.3.1617257351.1617256689.; Hm_lpvt_f1ca44b62370e4b7dc11d5937e51c2d6=1617257351; trackerSdkData={%22uid%22:%22%22%2C%22platform_source%22:%22web%22%2C%22time%22:1617257351553%2C%22bdp_uuid%22:%2225a7880035-3f40238f-2941b61adf%22}; zg_9b4551cf447148b0845f31f91e8a524d=%7B%22sid%22%3A%201617256688405%2C%22updated%22%3A%201617257889655%2C%22info%22%3A%201617244979751%2C%22superProperty%22%3A%20%22%7B%7D%22%2C%22platform%22%3A%20%22%7B%7D%22%2C%22utm%22%3A%20%22%7B%7D%22%2C%22referrerDomain%22%3A%20%22%22%7D',
'Host': 'www.chinaacc.com',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36',
}
self.m3u8_url = self.getm3u8()
def getdata(self):
print(self.m3u8_url)
ts_data = session.get(self.m3u8_url)
ts_url_datas = re.findall('(//ssec4.chinaacc.com/.*)\n', ts_data.text)
i = 0
for ts_url_data in ts_url_datas:
i += 1
ts_url = 'https:' + ts_url_data
print(ts_url)
ts_rous = session.get(ts_url)
Path = str(i) + '.ts'
with open(Path, 'wb') as f:
f.write(ts_rous.content)
self.new_cmd = self.cmd.format(str(i), 'video2/' + str(i))
# print(ts_url)
self.video()
# self.hebing()
def getm3u8(self):
rous = session.get(self.url, headers=self.head)
json_data = re.findall("JSON.parse\('(.*)'\);", rous.text)[0].replace('\\', '')
m3u8_url_data = json.loads(json_data)['videoPath']
m3u8_url = 'https:' + m3u8_url_data
return m3u8_url
def video(self):
os.system(self.new_cmd)
def hebing(self):
os.system(self.hebings)
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)