From 579bc4bb84f850769e0d6aabe8cf67c47364694f Mon Sep 17 00:00:00 2001 From: Jerry Jacobs Date: Fri, 26 Jul 2024 13:56:53 +0200 Subject: [PATCH] Add DLL target for windows loading in Python --- .github/workflows/build.yml | 52 +++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ .goreleaser.yaml | 55 +++++++++++++++++++++++++++++++++++++ Makefile | 4 ++- README.md | 11 +++++++- main_dll.go | 13 +++++++++ 6 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 .goreleaser.yaml create mode 100644 main_dll.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 844ef71..16a79f6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,3 +50,55 @@ jobs: name: dist-folder path: | dist + + build-release-dll: + name: Build release DLL + environment: prod + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + check-latest: true + + - name: Set up MinGW + uses: egor-tensin/setup-mingw@v2 + with: + platform: x64 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + # 'latest', 'nightly', or a semver + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Use config_release.go from action secrets + uses: mobiledevops/secret-to-file-action@v1 # TODO native in Makefile, can be unsafe... + with: + base64-encoded-secret: ${{ secrets.CONFIG_RELEASE_GO_FILE }} + filename: "config_release.go" + + - 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" + working-directory: "./resources" + + - run: make dll + + - name: Store release artifacts + uses: actions/upload-artifact@v4 + with: + name: dist-dll + path: | + dist diff --git a/.gitignore b/.gitignore index 2a1cd6e..07d1f0b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ socks5-ssh-proxy.release *.base64 *.exe *.zip + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..bcfb401 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,55 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - id: "dll" + env: + - CGO_ENABLED=1 + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + goos: + - windows + goarch: + - amd64 + ldflags: + - -s -w -H=windowsgui + buildmode: c-shared + tags: + - release + - dll + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/Makefile b/Makefile index 7b60608..405db1a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ SOURCES=Makefile main.go main_release.go main_debug.go config.go config_release.go config_template.go GARBLE_BIN = $(shell go env GOPATH)/bin/garble -GO_ENV_VARS = CGO_ENABLED=0 all: socks5-ssh-proxy @@ -21,6 +20,9 @@ socks5-ssh-proxy.release: resources $(SOURCES) win: socks5-ssh-proxy.exe socks5-ssh-proxy.exe: resources $(GARBLE_BIN) $(SOURCES) GOOS=windows GOARCH=amd64 $(GARBLE_BIN) build -ldflags -H=windowsgui -tags release -o $@ +dll: resources + rm -Rf dist + goreleaser build --snapshot win-package: ChromeProxyHelperPlugin.zip ChromeProxyHelperPlugin.zip: socks5-ssh-proxy.exe cp socks5-ssh-proxy.exe chrome_proxy.exe diff --git a/README.md b/README.md index 67dfb27..3993b36 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # socks5-ssh-proxy -If HTTP(s) is filtered and outbound SSH is allowed, just create a SOCKS5 proxy. Beat the sensorship, and be free! +If HTTP(s) is filtered and outbound SSH is allowed, just create a SOCKS5 proxy over SSH using a [Jump server](https://en.wikipedia.org/wiki/Jump_server). Beat the (corporate) sensorship, and be free! ## Background information @@ -54,8 +54,17 @@ Following detections have been tested: * Microsoft Defender: [Trojan](https://en.wikipedia.org/wiki/Trojan_horse_(computing)):Win32/Gracing.I - Severe. Probably fixed because of packing with UPX * Palo Alto Networks, Inc. - Cortex [XDR](https://en.wikipedia.org/wiki/Extended_detection_and_response): detected as Suspicious (no fix yet) +## Build time dependencies + +## macOS + +* go +* go-releaser +* mingw-w64 (for building the windows dll) + ## Related information +* * * diff --git a/main_dll.go b/main_dll.go new file mode 100644 index 0000000..87ab160 --- /dev/null +++ b/main_dll.go @@ -0,0 +1,13 @@ +//go:build dll +// +build dll + +package main + +import ( + "C" +) + +//export executeMain +func executeMain() { + main() +}