From 078268b069e7af5a28db4d9772c3063861315693 Mon Sep 17 00:00:00 2001 From: FoxRefire <155989196+FoxRefire@users.noreply.github.com> Date: Sat, 13 Apr 2024 06:20:33 +0900 Subject: [PATCH] DRMToday --- README.md | 2 -- popup.html | 2 +- popup.js | 12 ++++++- schemes/DRMToday.js | 77 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 schemes/DRMToday.js diff --git a/README.md b/README.md index 0e5f382..6d24ad8 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,6 @@ ### Todo -* Support custom payload scheme - * Improve UI ### Disclaimer diff --git a/popup.html b/popup.html index 1a74e5e..9456276 100644 --- a/popup.html +++ b/popup.html @@ -29,7 +29,7 @@
-
diff --git a/popup.js b/popup.js index 52fa309..f631dde 100644 --- a/popup.js +++ b/popup.js @@ -1,4 +1,5 @@ import CommonWV from './schemes/CommonWV.js'; +import DRMToday from './schemes/DRMToday.js'; let psshs=chrome.extension.getBackgroundPage().getPsshs(); let requests=chrome.extension.getBackgroundPage().getRequests(); @@ -30,7 +31,16 @@ function handleRadioChange(event) { } async function guess(){ - const result=await CommonWV(document.getElementById('guessr').value, + let WVScheme; + switch (document.getElementById('scheme').value) { + case "CommonWV": + WVScheme=CommonWV; + break; + case "DRMToday": + WVScheme=DRMToday; + break; + } + const result=await WVScheme(document.getElementById('guessr').value, document.getElementById('pssh').value, requests[userInputs['license']]['url'], requests[userInputs['license']]['headers']) diff --git a/schemes/DRMToday.js b/schemes/DRMToday.js new file mode 100644 index 0000000..6cafe8d --- /dev/null +++ b/schemes/DRMToday.js @@ -0,0 +1,77 @@ +export default async function(serverAddr, pssh, licUrl,_headers) { + console.group("fetch cert..."); + let certBuffer = await fetch(licUrl, { + body: new Uint8Array([0x08, 0x04]), + headers: _headers, + method: "POST", + }).then((resp) => resp.arrayBuffer()); + let certB64 = ""; + if (isValidJson(String.fromCharCode(...new Uint8Array(certBuffer)))) { + let jsonData = JSON.parse( + String.fromCharCode(...new Uint8Array(certBuffer)) + ); + if (jsonData.license) { + certB64 = jsonData.license; + } else { + console.log("JSON does not contain 'license'"); + } + } else { + certB64 = btoa(String.fromCharCode(...new Uint8Array(certBuffer))); + } + console.log(certB64); + console.groupEnd(); + + console.group("fetch challenge..."); + let jsonC = await fetch(serverAddr + "/getchallenge", { + body: JSON.stringify({ + PSSH: pssh, + CertBase64: certB64, + }), + headers: { + "Content-Type": "application/json", + }, + method: "POST", + }).then((resp) => resp.json()); + let challengeBase64 = jsonC.challengeBase64; + console.log(challengeBase64); + console.groupEnd(); + + console.group("fetch license..."); + let licBuffer = await fetch(licUrl, { + body: Uint8Array.from(atob(challengeBase64), (c) => c.charCodeAt(0)), + headers: _headers, + method: "POST", + }).then((resp) => resp.arrayBuffer()); + let licB64 = ""; + if (isValidJson(String.fromCharCode(...new Uint8Array(licBuffer)))) { + let jsonData = JSON.parse( + String.fromCharCode(...new Uint8Array(licBuffer)) + ); + if (jsonData.license) { + licB64 = jsonData.license; + } else { + console.log("JSON does not contain 'license'"); + } + } else { + licB64 = btoa(String.fromCharCode(...new Uint8Array(licBuffer))); + } + console.log(licB64); + console.groupEnd(); + + console.group("get keys..."); + let jsonK = await fetch(serverAddr + "/getkeys", { + body: JSON.stringify({ + PSSH: pssh, + ChallengeBase64: challengeBase64, + LicenseBase64: licB64, + }), + headers: { + "Content-Type": "application/json", + }, + method: "POST", + }).then((resp) => resp.json()); + let keys = jsonK.keys; + console.log(keys); + console.groupEnd(); + return keys; +};