code
# -*- coding: utf-8 -*- from subprocess import call import subprocess import re import xmltodict import json import re import requests import base64 import time import os import argparse import binascii import configparser import sys from requests import Request, Session currentFile = __file__ realPath = os.path.realpath(currentFile) dirPath = os.path.dirname(realPath) dirName = os.path.basename(dirPath) wvDecrypterexe = dirPath + "/binaries/wvDecrypter.exe" challengeBIN = dirPath + "/binaries/challenge.bin" licenceBIN = dirPath + "/binaries/licence.bin" mp4dump = dirPath + "/binaries/mp4dump.exe" if os.path.isfile(challengeBIN) : os.remove (challengeBIN) if os.path.isfile(licenceBIN) : os.remove (licenceBIN) WV_SYSTEM_ID = 'ed ef 8b a9 79 d6 4a ce a3 c8 27 dc d5 1d 21 ed' FInput = "encryptedvideo.mp4" FOutput = "decryptedvideo.mp4" KID = "a4c1cdo8-39eb-58el-b646-8bfdf427e60a" pssh = None mp4_data = subprocess.check_output ([mp4dump, '--format', 'json', '--verbosity', '3', FInput]) mp4_data = json.loads(mp4_data) for atom in mp4_data: if atom['name'] == 'moov': for child in atom['children']: if child['name'] == 'pssh' and child['system_id'] == f'[(WV_SYSTEM_ID)]': pssh = re.sub(r'^\[08 01 ([a-f0-9 ]+)\]$', r'\1', child['data']) pssh = re.sub(r'\8+', '', pssh) pssh = pssh.strip('[]') pssh = base64.b64encode (binascii.unhexlify(pssh)).decode('utf-8') print(f'PSSH: (pssh)') break if not pssh: print('unable to extract PSSSH') sys.exit(1) PSSH = pssh CERTIFICATE = "" cookies = "" token = "" licurl = "https://www.sunnxt.com/content/license/?content_id=70994=" wvdecrypt_video = subprocess.Popen([wvDecrypterexe, '--kid',KID, '--pssh', PSSH, '--certificate', CERTIFICATE, '--input', FInput, '--output', FOutput, '--debug']) time.sleep(5) with open(challengeBIN,"rb") as fd: challenge_decoded =fd.read() data = challenge_decoded headers = { 'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8', 'content-length': '4623', 'cookie': '_ga=GA1.2.975246051.1552289966; _fbp=fb.1.1552290075724.1403904187; _gid=GA1.2.396418812.1554157407; laravel_session=FjoUcOZyhVfX6dc39N85kGddMKV0DROVRS7wZLbU; _gat=1; mp_8417b02dcd9f6d45a5d3a0a7eadb1c4b_mixpanel=%7B%22distinct_id%22%3A%209176320%2C%22%24device_id%22%3A%20%221696bb128e0163-0af1f5159fe13b-3e3d5200-15f900-1696bb128e1f9%22%2C%22%24initial_referrer%22%3A%20%22https%3A%2F%2Fwww.google.com%2F%22%2C%22%24initial_referring_domain%22%3A%20%22www.google.com%22%2C%22__mps%22%3A%20%7B%7D%2C%22__mpso%22%3A%20%7B%7D%2C%22__mpus%22%3A%20%7B%7D%2C%22__mpa%22%3A%20%7B%7D%2C%22__mpu%22%3A%20%7B%7D%2C%22__mpr%22%3A%20%5B%5D%2C%22__mpap%22%3A%20%5B%5D%2C%22%24search_engine%22%3A%20%22google%22%2C%22data%20Connection%22%3A%20%22NULL%22%2C%22city%22%3A%20%22%22%2C%22country%22%3A%20%22India%22%2C%22gps%22%3A%20%22NULL%22%2C%22session%20id%22%3A%20%22NULL%22%2C%22email%20id%22%3A%20%22ambadysuresh9745%40gmail.com%22%2C%22mobile%20no%22%3A%20%22NULL%22%2C%22Device-ID%22%3A%20%22NULL%22%2C%22%24user_id%22%3A%209176320%2C%22user%20id%22%3A%209176320%7D; XSRF-TOKEN=eyJpdiI6IlRaY2J6dm5tTHJuY0pNV3NrV0hqYnc9PSIsInZhbHVlIjoiRENlMzdEQ1VpTWxnMXhGWHRhdHhcL0VZc3ZQM016QnNVR2tRZ1QwM3psQm02MnhRMFk1Q1hMWUs4ZXFDeWk2ZU9oSGI1clE2cnp3aERjSWNcL3hOUHNUdz09IiwibWFjIjoiNWY2ZjM2MDc3ZmMyNWU1ODUxMDY4YmNjZThkN2FhMGMzYjAwYWQ4ZjljYzY3MDhmNTNjMjg0MmE0MDU0MmY1MiJ9', 'origin':'https://www.sunnxt.com', 'referer': 'https://www.sunnxt.com/movie/detail/6604/Nela-Ticket/', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', } print("\nSending POST request to license url...\n") resp = requests.post(url=licurl, data=data, headers=headers) license_decoded = resp.content print(license_decoded) licenseb64 = base64.b64encode(license_decoded) with open(licenceBIN, "wb") as ld: ld.write(license_b64) stdoutdata, stderrdata = wvdecrypt_video.communicate() if str(wvdecrypt_video.returncode) == "0": os.remove(challengeBIN) os.remove(licenceBIN)