Skip to content

Commit

Permalink
Merged stage
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Dec 18, 2020
2 parents eef3b21 + 3fb42c0 commit 60190ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15.5
FROM golang:1.15.6

#
# IMPORTANT: This Dockerfile is used for testing, I do not recommend deploying
Expand Down
25 changes: 0 additions & 25 deletions go-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


# Creates the static go asset archives
# You'll need curl, tar, and unzip commands

GO_VER="1.16beta1"
GO_ARCH_1="amd64"
Expand All @@ -28,9 +27,7 @@ BLOAT_FILES="AUTHORS CONTRIBUTORS PATENTS VERSION favicon.ico robots.txt CONTRIB
PROTOBUF_COMMIT=347cf4a86c1cb8d262994d8ef5924d4576c5b331
GOLANG_SYS_COMMIT=669c56c373c468cbe0f0c12b7939832b26088d33


if ! [ -x "$(command -v curl)" ]; then
echo 'Error: curl is not installed.' >&2
exit 1
fi

Expand All @@ -50,7 +47,6 @@ if ! [ -x "$(command -v tar)" ]; then
fi

REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OUTPUT_DIR="$REPO_DIR/server/assets/fs"
WORK_DIR=`mktemp -d`

echo "-----------------------------------------------------------------"
Expand Down Expand Up @@ -80,27 +76,6 @@ cp -vv darwin-go.zip $OUTPUT_DIR/darwin/$GO_ARCH_1/go.zip
rm -rf ./go
rm -f darwin-go.zip go$GO_VER.darwin-$GO_ARCH_1.tar.gz

# --- Darwin (arm64) ---
curl --output go$GO_VER.darwin-$GO_ARCH_2.tar.gz https://dl.google.com/go/go$GO_VER.darwin-$GO_ARCH_2.tar.gz
tar xvf go$GO_VER.darwin-$GO_ARCH_2.tar.gz

cd go
rm -rf $BLOAT_FILES
zip -r ../src.zip ./src # Zip up /src we only need to do this once
rm -rf ./src
rm -f ./pkg/tool/darwin_$GO_ARCH_2/doc
rm -f ./pkg/tool/darwin_$GO_ARCH_2/tour
rm -f ./pkg/tool/darwin_$GO_ARCH_2/test2json
cd ..
cp -vv src.zip $OUTPUT_DIR/src.zip
rm -f src.zip

zip -r darwin-go.zip ./go
mkdir -p $OUTPUT_DIR/darwin/$GO_ARCH_2
cp -vv darwin-go.zip $OUTPUT_DIR/darwin/$GO_ARCH_2/go.zip

rm -rf ./go
rm -f darwin-go.zip go$GO_VER.darwin-$GO_ARCH_2.tar.gz

# --- Linux ---
curl --output go$GO_VER.linux-amd64.tar.gz https://dl.google.com/go/go$GO_VER.linux-$GO_ARCH_1.tar.gz
Expand Down
12 changes: 12 additions & 0 deletions server/handlers/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ package handlers
*/

import (
"sync"

"github.com/bishopfox/sliver/protobuf/sliverpb"
"github.com/bishopfox/sliver/server/core"
"github.com/bishopfox/sliver/server/log"
Expand All @@ -38,6 +40,8 @@ var (
sliverpb.MsgTunnelData: tunnelDataHandler,
sliverpb.MsgTunnelClose: tunnelCloseHandler,
}

tunnelHandlerMutex = &sync.Mutex{}
)

// GetSessionHandlers - Returns a map of server-side msg handlers
Expand Down Expand Up @@ -83,7 +87,12 @@ func registerSessionHandler(session *core.Session, data []byte) {
core.Sessions.Add(session)
}

// The handler mutex prevents a send on a closed channel, without it
// two handlers calls may race when a tunnel is quickly created and closed.
func tunnelDataHandler(session *core.Session, data []byte) {
tunnelHandlerMutex.Lock()
defer tunnelHandlerMutex.Unlock()

tunnelData := &sliverpb.TunnelData{}
proto.Unmarshal(data, tunnelData)
tunnel := core.Tunnels.Get(tunnelData.TunnelID)
Expand All @@ -99,6 +108,9 @@ func tunnelDataHandler(session *core.Session, data []byte) {
}

func tunnelCloseHandler(session *core.Session, data []byte) {
tunnelHandlerMutex.Lock()
defer tunnelHandlerMutex.Unlock()

tunnelData := &sliverpb.TunnelData{}
proto.Unmarshal(data, tunnelData)
if !tunnelData.Closed {
Expand Down

0 comments on commit 60190ea

Please sign in to comment.