forked from Genetic-Malware/Ebowla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_x86_go.sh
executable file
·48 lines (32 loc) · 1.35 KB
/
build_x86_go.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
#!/bin/bash
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ] ; then
echo "Usage: $0 go_x86_script.go output.exe [Optional argument: --hidden]"
exit
fi
# take the first argument and build an x86 binary from go
filename=$(basename $1)
filename2=$(basename $2)
sans_extension="${filename2%.*}"
echo [*] Copy Files to tmp for building
mkdir -p /tmp/MemoryModule/build/
rsync -r ./MemoryModule/build686/ /tmp/MemoryModule/build/
cp ./MemoryModule/MemoryModule.h /tmp/MemoryModule/
cp $1 /tmp/$sans_extension.go
cd /tmp/
echo [*] Building...
if [[ $3 == --hidden ]]; then
export GOOS=windows; export GOARCH=386; export CGO_ENABLED=1; export CXX=i686-w64-mingw32-g++; export CC=i686-w64-mingw32-gcc
GOOS=windows; CXX=i686-w64-mingw32-g++; CC=i686-w64-mingw32-gcc; GCCFLAGS="-m32 -fmessage-length=0" CGO_ENABLED=1 GOOS=windows GOARCH=386 go build -ldflags -H=windowsgui $sans_extension.go
else
export GOOS=windows; export GOARCH=386; export CGO_ENABLED=1; export CXX=i686-w64-mingw32-g++; export CC=i686-w64-mingw32-gcc
GOOS=windows; CXX=i686-w64-mingw32-g++; CC=i686-w64-mingw32-gcc; GCCFLAGS="-m32 -fmessage-length=0" CGO_ENABLED=1 GOOS=windows GOARCH=386 go build $sans_extension.go
fi
echo [*] Building complete
rm -rf /tmp/MemoryModule
cd - 1> /dev/null
echo [*] Copy $2 to output
cp /tmp/$2 ./output/
echo [*] Cleaning up
rm /tmp/$2
rm /tmp/$sans_extension.go
echo [*] Done