From d272e8f2e6f4527e8f3236ca9423fd7dc9d65373 Mon Sep 17 00:00:00 2001 From: FoxRefire <155989196+FoxRefire@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:59:34 +0900 Subject: [PATCH] Attempt for RedBee --- content.js | 18 ++++++++++++++++++ popup.html | 1 + popup.js | 6 ++++++ python/schemes/RedBee.py | 14 ++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 python/schemes/RedBee.py diff --git a/content.js b/content.js index a9a8cca..a27b513 100644 --- a/content.js +++ b/content.js @@ -17,3 +17,21 @@ document.addEventListener('pssh', (e) => { pageURL: document.URL },null); }); + +//Fetch from original origin +chrome.runtime.onMessage.addListener( + async function (request, sender, sendResponse) { + if(request.type=="FETCH"){ + console.log("DEBUG") + let res = await fetch(request.u, { + method: request.m, + headers: request.h, + body: request.b + }).then((r)=>r.json()).then((r)=>{ + btoa(String.fromCharCode(...new Uint8Array(r))) + }) + sendResponse({res: res}); + return true + } + } +); diff --git a/popup.html b/popup.html index b108403..6fb5f05 100644 --- a/popup.html +++ b/popup.html @@ -27,6 +27,7 @@

diff --git a/popup.js b/popup.js index f3280e7..7535d69 100644 --- a/popup.js +++ b/popup.js @@ -33,6 +33,12 @@ function copyResult(){ navigator.clipboard.writeText(this.value); } +window.corsFetch = (u, m, h, b) => { + chrome.runtime.sendMessage({type:"FETCH", u:u, m:m, h:h, b:b}, function(response) { + console.log(response) + }); +} + if(psshs.length!=0){ document.addEventListener('DOMContentLoaded', function() { document.getElementById('noEME').style.display='none'; diff --git a/python/schemes/RedBee.py b/python/schemes/RedBee.py new file mode 100644 index 0000000..3a3e00a --- /dev/null +++ b/python/schemes/RedBee.py @@ -0,0 +1,14 @@ +import base64 +import re +import js +req = base64.b64decode(licBody.encode()).decode() +b64challenge = base64.b64encode(challenge).decode() +req = re.sub(r'(?<=\"message\":\").*(?=\"})', b64challenge, req) +print(req) +# res = await (await pyfetch(licUrl, +# method="POST", +# headers=licHeaders, +# body=req +# )).json() +res = js.window.corsFetch(licUrl, "POST", licHeaders, req) +licence = base64.b64decode(res['license'].encode())