吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6913|回复: 38
收起左侧

[讨论] 美剧天堂终于搞定了(破网站) 视频加密解密学习(小白写的烂将就看))

[复制链接]
lihu5841314 发表于 2021-6-28 21:43
[Asm] 纯文本查看 复制代码
from selenium import  webdriver
import  time,re

start_url = "https://www.jijikb.com/play/52825-0-1.html"  #一共5集
def  get_start_m3u8(url):
#-----------------------------------------------------------------------------------------------------------------------
# chrome_options = webdriver.ChromeOptions()
# # 添加浏览器参数
# # 添加UA
# chrome_options.add_argument(
# 'User-Agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"'
# )
# # 浏览器不提供可视化页面. linux下如果系统不支持可视化不加这条会启动失败
# chrome_options.add_argument('--headless')
# # 以最高权限运行
# chrome_options.add_argument('--no-sandbox')
# chrome_options.add_argument("--disable-gpu")
# chrome_options.add_argument("--disable-dev-shm-usage")
# # 设置开发者模式启动,该模式下webdriver属性为正常值
# chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
# driver = webdriver.Chrome(chrome_options= chrome_options)
#-----------------------------------------------------------------------------------------------------------------------
    #创建浏览器对象

    driver =webdriver.Chrome()
    driver.get(start_url)
    driver.find_element_by_id("details-button").click()
    time.sleep(0.5)
    driver.find_element_by_id('proceed-link').click()
    time.sleep(1)
    response = driver .page_source  #获取首页的响应数据  首页有debuger  调试验证  用selenium  跳过
    # print(response)
    start_m3u8 = re.findall(r'id="forbaiducache">(.*?)</div>',response)[0]
    print(start_m3u8)
    time.sleep(0.5)
    print(driver.title)
    driver.quit()  #退出浏览器

    return  start_m3u8

if __name__ == '__main__':
    get_start_m3u8(start_url)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[Asm] 纯文本查看 复制代码
import timeimport  requests,os
import urllib3
import urllib.request
from  startm3u8  import get_start_m3u8
import asyncio
import aiofile
import aiohttp


# start_url = "https://www.jijikb.com/play/52825-0-1.html"   #一共5集
secend_m3u8 = "https://vod4.buycar5.cn/20210617/DmV0P4zD/1000kb/hls/index.m3u8"
headers = {
'Referer': 'https://vod4.buycar5.cn/',
'host':'vod4.buycar5.cn',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
}

def  response(url):
    rep = requests.get(url=url,headers=headers,timeout = 20,verify =False) #使用Python3 requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下InsecureRequestWarning
    rep.encoding = rep.apparent_encoding
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)  ## 禁用安全请求警告
    if rep.status_code == 200:
        return rep
    else:
        print("----没有响应----")

def get_second_m3u8_url(url):
    rep = requests.get(url)
    print(rep)
    with open('first.m3u8','w')  as f:
          f.write(rep.text)
    with open('first.m3u8',"r")  as r_f:
         for line in r_f:
             if line.startswith("#"):
                 continue
             start_m3u8_url = "https://vod4.buycar5.cn" + line
             return  start_m3u8_url
def  get_tc_url(resp):
    with open('secend.m3u8', 'wb')  as f:
        f.write(resp)
    tc_urls = []
    with open('secend.m3u8',"r")  as r_f:
         for n in r_f:
             if n.startswith("#"):
                 continue
             else:
                 print(n)
                 tc_urls.append(n)
         return tc_urls


async def mov_down(url,semaphore):
    async with semaphore:
        async with aiohttp.ClientSession()  as session:
            tc_name = url.split('/')[-1].strip()
            print(tc_name,"---正在下载-----")
            async with await session.get(url,headers=headers)  as rep:
               print(rep.status)
               async with aiofile.async_open("mov2/"+tc_name,'wb')   as p_f:
                     print("-----正在存储------")
                     rep1 = await rep.read()
                     await p_f.write(rep1)
                     print(tc_name,'----下载完成---')

"""
urllib.request.urlopen(url, data=None, [timeout, ])
传入的url就是你想抓取的地址;
data是指向服务器提交信息时传递的字典形式的信息,通常来说就是爬去需要登录的网址时传入的用户名和密码,可省略。
timeout参数指的是超时时间,也可省略。
"""
def  main():
     semaphore = asyncio.Semaphore(100)  # 限制并发量为20
     start_time = time.time()
     if not os.path.exists('mov2'):
        os.mkdir("mov2")
     start_m3u8_url = get_start_m3u8(start_url)
     secend_m3u8_url = get_second_m3u8_url(start_m3u8_url)
     print(secend_m3u8_url)
     resp = urllib.request.urlopen(secend_m3u8_url).read()
     # resp =requests.get(url=secend_m3u8_url,headers=headers)  #不知道为什么requests  请求不到
     tc_urls = get_tc_url(resp)
     tasks = []
     for url in tc_urls:
          task =asyncio.ensure_future(mov_down(url,semaphore))
          tasks.append(task)
     loop.run_until_complete(asyncio.wait(tasks))
     loop.close()
     print(time.time()-start_time)



if __name__ == '__main__':
     loop = asyncio.get_event_loop()  #建立事件循环
     main()

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[Asm] 纯文本查看 复制代码
import asyncioimport os,re
import requests
import aiofiles
from  Crypto.Cipher import  AES

#pycryptodome模块

# key_url = "https://ts4.chinalincoln.com:9999/20210617/DmV0P4zD/1000kb/hls/key.key"
headers = {
    'Referer': 'https://vod4.buycar5.cn/',
    'host': 'vod4.buycar5.cn',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
}
def get_key_url():
    with open('secend.m3u8','r')  as f:
          ke = f.read()
          key_url = re.findall(r'#EXT-X-KEY:METHOD=AES-128,URI="(?P<key>.*?)"',str(ke))[0]
          print(key_url)
          return key_url


async def aio_dec(key):  # METHOD=AES-128
      #解密
      tasks = []
      print("-------1------")
      with open("secend.m3u8",'r') as f:
         for  line  in f:
               if line.startswith("#"):
                   continue
               line = line.split('/')[-1].strip()
               #开始创建异步任务
               print(line)
               task = asyncio.ensure_future(dec_ts(line,key))
               tasks.append(task)
         await  asyncio.wait(tasks)
      # loop.run_until_complete(asyncio.wait(tasks))
      # loop.close()

async  def  dec_ts(name,key):  #解密
        aes = AES.new(key=key,IV=b"0000000000000000",mode=AES.MODE_CBC)  #IV偏移量  key多少位就是多少位前面写b
        # print(aes)
        async  with  aiofiles.open(f'mov2/{name}','rb') as f1:
                bs= await f1.read()  # 从原文件读取内容
                print("-----2----")
        async with aiofiles.open(f'mov2/temp_{name}','wb') as f2:
                await f2.write(aes.decrypt(bs))  #解密好的内容用存入文件
                os.remove(f'mov2/{name}')
                print("-----3----")
        print(f'{name}处理完毕')


def  merge_ts():  #合并
    #mac:  cat 1.ts 2.ts 3.ts > xxx.mp4
    #windows:  copy/b  1.ts +2.ts +3.ts ...  xxx.mp4
    #copy /b 命令格式:copy /b 文件1+文件2+......文件N 合并后的文件名<BR>命令讲解:使用"+"将多个相同或不同格式的文件合并为一个文件。
     lst = []
     with open('secend.m3u8',mode="r",encoding='utf-8') as p_f:
         for  line in  p_f:
             if line.startswith("#"):
                 continue
             line = line.split('/')[-1].strip()
             lst.append(line)
     s = "".join(lst)
     os.system(f"copy /b {s} movie.mp4")
     print("")



if __name__ == '__main__':
    # loop = asyncio.get_event_loop()
    key_url = get_key_url()
    key = requests.get(url=key_url, headers=headers).text
    # key ='39f98d719dbdfbde'
    key = key.encode("utf-8")
    print(key)
    asyncio.run(aio_dec(key))

免费评分

参与人数 7吾爱币 +13 热心值 +5 收起 理由
wangxiaohong888 + 1 谢谢@Thanks!
君不器 + 1 + 1 谢谢@Thanks!
seeyoubug + 1 + 1 我很赞同!
三滑稽甲苯 + 1 + 1 谢谢@Thanks!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
ofo + 1 用心讨论,共获提升!
5151diy + 1 + 1 我很赞同!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

君不器 发表于 2021-6-28 21:46
这东西能生成程序吗   
bling 发表于 2021-6-28 21:50
我爱你若能倒着 发表于 2021-6-28 21:53
 楼主| lihu5841314 发表于 2021-6-28 21:54

这网站烂的很   没有打包的价值
红蓝黄 发表于 2021-6-28 21:55
程序和教程发一份
 楼主| lihu5841314 发表于 2021-6-28 21:56
红蓝黄 发表于 2021-6-28 21:55
程序和教程发一份

教程B站看的  爬91 模式差不多  
fangben518 发表于 2021-6-28 22:25
这个好,牛逼PLUS
hshcompass 发表于 2021-6-28 22:42
先收藏,慢慢学习
wilson_lws82 发表于 2021-6-28 22:53
支持楼主,辛苦了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-3 23:31

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表