From d76cc2c7e540cb9f6ddcb89a7c2d68455d56e69e Mon Sep 17 00:00:00 2001 From: VHSgunzo Date: Thu, 8 Feb 2024 10:31:49 +0300 Subject: [PATCH] Update tls usage, build.sh, add tls LICENSE --- build.sh | 8 +++--- tls/LICENSE | 21 +++++++++++++++ tls/README.md | 2 +- tls/build.sh | 70 ++++++++++++++++++++++++++++++++++++++++++++++++- tls/go.mod | 12 ++++++++- tls/go.sum | 9 ++++++- tls/shellsrv.go | 2 +- 7 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 tls/LICENSE mode change 120000 => 100755 tls/build.sh mode change 120000 => 100644 tls/go.mod mode change 120000 => 100644 tls/go.sum diff --git a/build.sh b/build.sh index f74d29c..b9e34fb 100755 --- a/build.sh +++ b/build.sh @@ -29,15 +29,14 @@ cd "$SRC_DIR" export CGO_ENABLED=0 for ARCH in "${ARCHS[@]}" do - mkdir -p "build/$ARCH" - case "$ARCH" in source) echo "Create archive with source code..." git clean -fdx -e build go mod vendor - tar -I 'zstd -T0 --ultra -22 --progress' --exclude build -cf \ - "$SRC_DIR/shellsrv-src-v${VERSION}.tar.zst" -C "$SRC_DIR" . + tar -I 'zstd -T0 --ultra -22 --progress' --exclude build -l \ + --exclude tls --exclude .git --exclude .github --exclude .gitignore \ + -cf "$SRC_DIR/shellsrv-src-v${VERSION}.tar.zst" -C "$SRC_DIR" . continue ;; i386|i686) GOARCH='386' ;; x86_64) GOARCH='amd64' ;; @@ -48,6 +47,7 @@ for ARCH in "${ARCHS[@]}" export GOARCH echo "Build for ${ARCH}..." + mkdir -p "build/$ARCH" go build -trimpath -o "build/$ARCH/shellsrv" \ -ldflags "-X main.VERSION=$VERSION -s -w -buildid=" diff --git a/tls/LICENSE b/tls/LICENSE new file mode 100644 index 0000000..2721e2f --- /dev/null +++ b/tls/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 VHSgunzo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tls/README.md b/tls/README.md index 465cdd6..df869f5 100644 --- a/tls/README.md +++ b/tls/README.md @@ -23,7 +23,7 @@ go install github.com/VHSgunzo/shellsrv@latest ## **Usage**: ``` ┌──[user@linux]─[~] - Server: -└──╼ $ shellsrv -server [-tls-key key.pem] [-tls-key cert.pem] [-socket tcp:1337] +└──╼ $ shellsrv -server [-tls-key key.pem] [-tls-cert cert.pem] [-socket tcp:1337] ┌──[user@linux]─[~] - Client: └──╼ $ shellsrv -tls [options] [ COMMAND [ arguments... ] ] diff --git a/tls/build.sh b/tls/build.sh deleted file mode 120000 index 669ce2a..0000000 --- a/tls/build.sh +++ /dev/null @@ -1 +0,0 @@ -../build.sh \ No newline at end of file diff --git a/tls/build.sh b/tls/build.sh new file mode 100755 index 0000000..b9e34fb --- /dev/null +++ b/tls/build.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -o pipefail + +# WITH_UPX=1 +# VERSION=0.0.1 +# ARCHS=(source i386 x86_64 armv7 aarch64) +# CREATE_RELEASE_ARCHIVES=1 + +SRC_DIR="$(dirname "$BASH_SOURCE")" + +if [ ! -n "$ARCHS" ] + then + [ -n "$1" ] && \ + ARCHS=("$@")||\ + ARCHS="$(uname -m)" +fi +[ "$ARCHS" == 'all' ] && \ +ARCHS=(source i386 x86_64 armv7 aarch64) + +GIT_VERSION="$(git describe --long --tags 2>/dev/null|sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')" +[ -n "$GIT_VERSION" ] && \ +VERSION="$GIT_VERSION"||\ +VERSION="${VERSION:-HEAD}" +[ "$(basename "$(realpath "$SRC_DIR")")" == 'tls' ] && \ + VERSION="${VERSION}-tls" + +cd "$SRC_DIR" + +export CGO_ENABLED=0 +for ARCH in "${ARCHS[@]}" + do + case "$ARCH" in + source) + echo "Create archive with source code..." + git clean -fdx -e build + go mod vendor + tar -I 'zstd -T0 --ultra -22 --progress' --exclude build -l \ + --exclude tls --exclude .git --exclude .github --exclude .gitignore \ + -cf "$SRC_DIR/shellsrv-src-v${VERSION}.tar.zst" -C "$SRC_DIR" . + continue ;; + i386|i686) GOARCH='386' ;; + x86_64) GOARCH='amd64' ;; + armv7) GOARCH='arm' ;; + aarch64) GOARCH='arm64' ;; + *) GOARCH="$ARCH" ;; + esac + export GOARCH + + echo "Build for ${ARCH}..." + mkdir -p "build/$ARCH" + go build -trimpath -o "build/$ARCH/shellsrv" \ + -ldflags "-X main.VERSION=$VERSION -s -w -buildid=" + + if [ "$WITH_UPX" == 1 ] && command -v upx &>/dev/null + then + echo "UPXing ${ARCH}..." + upxdir="build/$ARCH/upx" + mkdir -p "$upxdir" + upx --force-overwrite -9 --best \ + "build/$ARCH/shellsrv" -o "$upxdir/shellsrv" + fi + + if [ "$CREATE_RELEASE_ARCHIVES" == 1 ] + then + echo "Archiving release ${ARCH}..." + tar -I 'zstd -T0 --ultra -22 --progress' -cf \ + "$SRC_DIR/shellsrv-${ARCH}-v${VERSION}.tar.zst" -C "build/$ARCH" . + fi +done diff --git a/tls/go.mod b/tls/go.mod deleted file mode 120000 index a7e4d37..0000000 --- a/tls/go.mod +++ /dev/null @@ -1 +0,0 @@ -../go.mod \ No newline at end of file diff --git a/tls/go.mod b/tls/go.mod new file mode 100644 index 0000000..f92f701 --- /dev/null +++ b/tls/go.mod @@ -0,0 +1,11 @@ +module github.com/VHSgunzo/shellsrv/tls + +go 1.21.6 + +require ( + github.com/creack/pty v1.1.21 + github.com/hashicorp/yamux v0.1.1 + golang.org/x/term v0.16.0 +) + +require golang.org/x/sys v0.16.0 // indirect diff --git a/tls/go.sum b/tls/go.sum deleted file mode 120000 index a3a4a98..0000000 --- a/tls/go.sum +++ /dev/null @@ -1 +0,0 @@ -../go.sum \ No newline at end of file diff --git a/tls/go.sum b/tls/go.sum new file mode 100644 index 0000000..ae26a4a --- /dev/null +++ b/tls/go.sum @@ -0,0 +1,8 @@ +github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= +github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= diff --git a/tls/shellsrv.go b/tls/shellsrv.go index 7f5b4f9..2afe907 100644 --- a/tls/shellsrv.go +++ b/tls/shellsrv.go @@ -28,7 +28,7 @@ var VERSION string = "HEAD" const BINARY_NAME = "shellsrv" const UNIX_SOCKET = "unix:@shellsrv" -const USAGE_PREAMBLE = `Server usage: %[1]s -server [-tls-key key.pem] [-tls-key cert.pem] [-socket tcp:1337] +const USAGE_PREAMBLE = `Server usage: %[1]s -server [-tls-key key.pem] [-tls-cert cert.pem] [-socket tcp:1337] Client usage: %[1]s -tls [options] [ COMMAND [ arguments... ] ] If COMMAND is not passed, spawn a $SHELL on the server side.