-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.sh
90 lines (72 loc) · 2.83 KB
/
builder.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
#!/bin/bash
set -e
ascii_art="
_ _ ___
| | __ _ __ _ _ | |_ / _ \ __ __
| |/ / | '__| | | | | | __| | | | | \ \/ /
| < | | | |_| | | |_ | |_| | > <
|_|\_\ |_| \__, | \__| \___/ /_/\_\
|___/
"
desc="\tkryt0x - Utility to Mutate or Encrypt files using AES-256."
banner="$ascii_art \r\n $desc \r \n"
if ! command -v lolcat &>/dev/null; then
echo "lolcat could not be found"
echo "Installing lolcat"
sudo apt-get install lolcat
fi
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <path-to-go-code>" | lolcat -a -d 5
exit 1
fi
if [[ ! -f "$1" ]]; then
echo "Error: File not found: $1" | lolcat -a -d 5
exit 1
fi
echo -e "$banner" | lolcat -a -d 5
echo -e "\r\n [+] Building kryt0x \r\n" | lolcat -a -d 5
echo -e "\r\n [+] Checking for Go installation \r\n" | lolcat -a -d 5
# check for go installation
if ! command -v go &>/dev/null; then
echo "go could not be found"
echo "Installing go"
sudo apt-get install golang
fi
echo -e "\r\n [+] Go installation found \r\n" | lolcat -a -d 5
echo -e "\r\n [+] Installing dependencies \r\n" | lolcat -a -d 5
# install go dependencies
go get . && go mod tidy &>/dev/null || handle_error "Failed to install dependencies. Please check your Go installation."
echo -e "\r\n [+] Dependencies installed \r\n" | lolcat -a -d 5
echo -e "----------------------------------------------------------------------------------------------------\r\n" | lolcat -a -d 5
platforms=("windows" "linux")
architectures=("386" "amd64")
output_dir="bin"
if [[ ! -d "$output_dir" ]]; then
mkdir "$output_dir"
fi
function handle_error {
echo "Error: $1"
exit 1
}
trap 'handle_error "An error occurred on line $LINENO: $BASH_COMMAND"' ERR
for platform in "${platforms[@]}"; do
for arch in "${architectures[@]}"; do
echo -e "[+] Building for $platform-$arch\r\n" | lolcat -a -d 5
if [[ "$platform" == "windows" ]]; then
output="$output_dir/kryt0x-$platform-$arch.exe"
else
output="$output_dir/kryt0x-$platform-$arch"
fi
env GOOS=$platform GOARCH=$arch go build -a -ldflags '-s -w -extldflags "-static"' -o "$output" "$1" || handle_error "Failed to build $platform-$arch binary. Please check your Go installation."
echo -e "\t[+] Stripping $platform-$arch binary" | lolcat -a -d 5
strip "$output" || handle_error "Failed to strip $platform-$arch binary."
if ! command -v upx &>/dev/null; then
echo "upx could not be found"
echo "Installing upx"
sudo apt-get install upx
fi
echo -e "\t[+] Compressing $platform-$arch binary" | lolcat -a -d 5
upx -9 "$output" &>/dev/null || handle_error "Failed to compress $platform-$arch binary."
echo -e "\r\n\t[!] Binary created: $output\r\n" | lolcat -a -d 5
done
done