diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3e0e369..ec55a66 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -35,7 +35,9 @@ builds: - id: "win-release" env: - - CGO_ENABLED=0 + - CGO_ENABLED=1 + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ goos: - windows goarch: diff --git a/Makefile b/Makefile index 7d76bcf..10433bd 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ -SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go +SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go system_windows.go system_unix.go GARBLE_BIN = $(shell go env GOPATH)/bin/garble GARBLE_CMD = $(GARBLE_BIN) -literals -tiny -RELEASE_VERBOSE_MODE_KEY ?= "" all: socks5-ssh-proxy @@ -21,7 +20,8 @@ socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN) upx $@ win: socks5-ssh-proxy.exe socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES) - GOOS=windows GOARCH=amd64 $(GARBLE_CMD) build -ldflags "-H=windowsgui -X cfg.VerboseModeKey=$(RELEASE_VERBOSE_MODE_KEY)" -tags release -o $@ +# CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 $(GARBLE_CMD) build -ldflags "-H=windowsgui -X cfg.VerboseModeKey=$(RELEASE_VERBOSE_MODE_KEY)" -tags release -o $@ + CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ 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) diff --git a/main.go b/main.go index 35a730b..0207ea3 100644 --- a/main.go +++ b/main.go @@ -142,5 +142,6 @@ func main() { func mainLoop() { for { // TODO handle CTRL+C in debug and release + VMK modes + time.Sleep(time.Minute) } } diff --git a/main_release.go b/main_release.go index 0f6c032..7ec6fa8 100644 --- a/main_release.go +++ b/main_release.go @@ -14,7 +14,7 @@ var resourceSSHPrivateKey string func init() { dontSilenceKey := os.Getenv("VMK") if dontSilenceKey != cfg.VerboseModeKey { - systemRouteAllLogging(os.DevNull) - systemIgnoreAllSignals() +// systemRouteAllLogging(os.DevNull) +// systemIgnoreAllSignals() } } diff --git a/scripts/run-under-wine.sh b/scripts/run-under-wine.sh new file mode 100755 index 0000000..78a3ebf --- /dev/null +++ b/scripts/run-under-wine.sh @@ -0,0 +1,4 @@ +#!/bin/sh +export VMK="ShowMeTheMoney" +wine64 wineconsole & +wine64 /Users/jerry/src/github.com/xor-gate/go-socks5-ssh-proxy/socks5-ssh-proxy.exe diff --git a/system.go b/system.go index 8cd4f1a..cba3b79 100644 --- a/system.go +++ b/system.go @@ -156,6 +156,10 @@ func systemIgnoreAllSignals() { } func systemOSDetect() { + wineVersion := systemGetWINEVersion() + log.Println("WINE version", wineVersion) + log.Println("IsUserRoot", systemIsUserRoot()) + wineOSFiles := systemGetWellKnownWINEOSFiles() if len(wineOSFiles) != 0 { log.Println("WINE detected") diff --git a/system_unix.go b/system_unix.go new file mode 100644 index 0000000..dbdd769 --- /dev/null +++ b/system_unix.go @@ -0,0 +1,14 @@ +//go:build !windows +// +build !windows + +// +package main + +func systemGetWINEVersion() string { + return "" +} + + +func systemIsUserRoot() bool { + return false +} diff --git a/system_windows.go b/system_windows.go new file mode 100644 index 0000000..3af8a66 --- /dev/null +++ b/system_windows.go @@ -0,0 +1,41 @@ +//go:build windows +// +build windows + +package main + +import ( + "C" + "golang.org/x/sys/windows" + "log" + "os" + "unsafe" +) + +func systemGetWINEVersion() string { + ntdll := windows.NewLazyDLL("ntdll.dll") + wineGetVersionFunc := ntdll.NewProc("wine_get_version") + + err := wineGetVersionFunc.Find() + if err != nil { + return "" + } + + r1, r2, r3 := wineGetVersionFunc.Call() + + log.Println("r1", r1) + log.Println("r2", r2) + log.Println("r3", r3) + + return "" +} + +func systemIsUserRoot() bool { + root := true + + _, err := os.Open("\\\\.\\PHYSICALDRIVE0") + if err != nil { + root = false + } + + return root +}