forked from BishopFox/sliver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
go-assets.sh
executable file
·116 lines (94 loc) · 3.36 KB
/
go-assets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Sliver Implant Framework
# Copyright (C) 2019 Bishop Fox
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Creates the static go asset archives
# You'll need wget, tar, and unzip commands
GO_VER="1.12.5"
BLOAT_FILES="AUTHORS CONTRIBUTORS PATENTS VERSION favicon.ico robots.txt CONTRIBUTING.md LICENSE README.md ./doc ./test"
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
WORK_DIR=`mktemp -d`
echo "-----------------------------------------------------------------"
echo $WORK_DIR
echo "-----------------------------------------------------------------"
cd $WORK_DIR
mkdir -p $REPO_DIR/assets/
# --- Darwin ---
wget https://dl.google.com/go/go$GO_VER.darwin-amd64.tar.gz
tar xvf go$GO_VER.darwin-amd64.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_amd64/doc
rm -f ./pkg/tool/darwin_amd64/tour
rm -f ./pkg/tool/darwin_amd64/test2json
cd ..
cp -vv src.zip $REPO_DIR/assets/src.zip
rm -f src.zip
zip -r darwin-go.zip ./go
mkdir -p $REPO_DIR/assets/darwin/
cp -vv darwin-go.zip $REPO_DIR/assets/darwin/go.zip
rm -rf ./go
rm -f darwin-go.zip go$GO_VER.darwin-amd64.tar.gz
# --- Linux ---
wget https://dl.google.com/go/go$GO_VER.linux-amd64.tar.gz
tar xvf go$GO_VER.linux-amd64.tar.gz
cd go
rm -rf $BLOAT_FILES
rm -rf ./src
rm -f ./pkg/tool/linux_amd64/doc
rm -f ./pkg/tool/linux_amd64/tour
rm -f ./pkg/tool/linux_amd64/test2json
cd ..
zip -r linux-go.zip ./go
mkdir -p $REPO_DIR/assets/linux/
cp -vv linux-go.zip $REPO_DIR/assets/linux/go.zip
rm -rf ./go
rm -f linux-go.zip go$GO_VER.linux-amd64.tar.gz
# --- Windows ---
wget https://dl.google.com/go/go$GO_VER.windows-amd64.zip
unzip go$GO_VER.windows-amd64.zip
cd go
rm -rf $BLOAT_FILES
rm -rf ./src
rm -f ./pkg/tool/windows_amd64/doc.exe
rm -f ./pkg/tool/windows_amd64/tour.exe
rm -f ./pkg/tool/windows_amd64/test2json.exe
cd ..
zip -r windows-go.zip ./go
mkdir -p $REPO_DIR/assets/windows/
cp -vv windows-go.zip $REPO_DIR/assets/windows/go.zip
rm -rf ./go
rm -f windows-go.zip go$GO_VER.windows-amd64.zip
echo "-----------------------------------------------------------------"
echo " 3rd Party Assets"
echo "-----------------------------------------------------------------"
cd $WORK_DIR
PROTOBUF_COMMIT=347cf4a86c1cb8d262994d8ef5924d4576c5b331
wget https://github.com/golang/protobuf/archive/$PROTOBUF_COMMIT.zip
unzip $PROTOBUF_COMMIT.zip
rm -f $PROTOBUF_COMMIT.zip
mv protobuf-$PROTOBUF_COMMIT protobuf
zip -r protobuf.zip ./protobuf
cp -vv protobuf.zip $REPO_DIR/assets/protobuf.zip
wget https://go.googlesource.com/sys/+archive/master.tar.gz
mkdir $WORK_DIR/sys
cd $WORK_DIR/sys
tar xfv ../master.tar.gz
rm -rf ../master.tar.gz
cd ..
zip -r $REPO_DIR/assets/golang_x_sys.zip sys
# end
echo -e "clean up: $WORK_DIR"
rm -rf $WORK_DIR
echo -e "\n[*] All done\n"