-
-
Save wale/2ece221059397c24788084ef0912e8dd to your computer and use it in GitHub Desktop.
Python Proof of Concept license retrieval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Proof-of-concept Python script to retrieve DRM license strings. | |
# | |
# You will need Python 3 to run this script. | |
# | |
# I am not liable for what you do with this script. | |
import requests, random, sys, os | |
user_agents = [ | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36' | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0' | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.30' | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36 OPR/84.0.4316.31' | |
'Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0' | |
] | |
user_agent = random.choice(user_agents) | |
def get_jwt(video: str) -> str: | |
r = requests.post('https://api.iview.abc.net.au/v2/token/jwt', headers={ | |
'Content-Type': 'application/x-www-form-urlencoded', | |
'Origin': 'https://iview.abc.net.au', | |
'Referer': video, | |
'User-Agent': user_agent | |
}, data={'clientId': '1d4b5cba-42d2-403e-80e7-34565cdf772d'}) | |
return r.json()['token'] | |
def get_license(jwt: str, video: str) -> str: | |
stripped = video.replace('https://iview.abc.net.au/video/', '') | |
r = requests.get(f'https://api.iview.abc.net.au/v2/token/drm/{stripped}', headers={ | |
'Origin': 'https://iview.abc.net.au', | |
'Referer': video, | |
'Authorization': f'Bearer {jwt}', | |
'User-Agent': user_agent | |
}) | |
return r.json()['license'] | |
if __name__ == "__main__": | |
video = sys.argv[1] | |
type = sys.argv[2] | |
jwt = get_jwt(video) | |
print(f'JWT: {jwt}') | |
license = get_license(jwt, video) | |
print(f'License: {license}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment