diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..0353da08 --- /dev/null +++ b/build.sh @@ -0,0 +1,96 @@ +#!/bin/bash +VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2) + +clean() { + rm -rf build + mkdir build +} + +bin_dep() { + BIN=$1 + which $BIN > /dev/null || { echo "@ Dependency $BIN not found !"; exit 1; } +} + +vm_dep() { + HOST=$1 + ping -c 1 $HOST > /dev/null || { echo "@ Virtual machine host $HOST not visible !"; exit 1; } +} + +build_linux_amd64() { + OUTPUT=$1 + echo "@ Building $OUTPUT ..." + go build -o "$OUTPUT" .. +} + +build_linux_arm7() { + bin_dep 'arm-linux-gnueabi-gcc' + + OUTPUT=$1 + OLD=$(pwd) + echo "@ Building $OUTPUT ..." + cd /tmp + rm -rf libpcap-1.8.1 + if [ ! -f /tmp/libpcap-1.8.1.tar.gz ]; then + echo "@ Downloading http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz ..." + wget -q http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz -O /tmp/libpcap-1.8.1.tar.gz + fi + echo "@ Cross compiling libpcap for ARM ..." + tar xf libpcap-1.8.1.tar.gz + cd libpcap-1.8.1 + export CC=arm-linux-gnueabi-gcc + ./configure --host=arm-linux-gnueabi --with-pcap=linux > /dev/null + make CFLAGS='-w' -j4 > /dev/null + echo "@ Compiling $OUTPUT ..." + cd "$OLD" + env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="-L/tmp/libpcap-1.8.1" go build -o "$OUTPUT" .. + rm -rf /tmp/libpcap-1.8.1 +} + +build_macos_amd64() { + vm_dep 'osxvm' + + DIR=/Users/evilsocket/gocode/src/github.com/evilsocket/bettercap-ng + OUTPUT=$1 + + echo "@ Updating repo on MacOS VM ..." + ssh osxvm "cd $DIR && rm -rf '$OUTPUT' && git checkout . && git pull" > /dev/null + + echo "@ Building $OUTPUT ..." + ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd '$DIR' && PATH=$PATH:/usr/local/bin && go build -o $OUTPUT ." > /dev/null + + echo "@ Downloading $OUTPUT ..." + scp -C osxvm:$DIR/$OUTPUT . > /dev/null +} + +build_windows_amd64() { + vm_dep 'winvm' + + DIR=c:/Users/evilsocket/gopath/src/github.com/evilsocket/bettercap-ng + OUTPUT=$1 + + echo "@ Updating repo on Windows VM ..." + ssh winvm "cd $DIR && del *.exe && git pull" > /dev/null + + echo "@ Building $OUTPUT ..." + ssh winvm "cd $DIR && go build -o $OUTPUT ." > /dev/null + + echo "@ Downloading $OUTPUT ..." + scp -C winvm:$DIR/$OUTPUT . > /dev/null +} + +clean +cd build + +build_linux_amd64 bettercap-ng_linux_amd64_$VERSION +build_linux_arm7 bettercap-ng_linux_arm7_$VERSION +build_macos_amd64 bettercap-ng_macos_amd64_$VERSION +build_windows_amd64 bettercap-ng_windows_amd64_$VERSION.exe + +echo +echo +du -sh * + +cd -- + + + diff --git a/build_arm.sh b/build_arm.sh deleted file mode 100755 index a79188be..00000000 --- a/build_arm.sh +++ /dev/null @@ -1,21 +0,0 @@ -# nothing to see here, just what i use to cross compile for ARM -DIR=/Users/evilsocket/gocode/src/github.com/evilsocket/bettercap-ng -EXE=bettercap-ng_linux_arm7 - -echo "@ Updating repo ..." -rm -rf $EXE && git pull - -echo "@ Configuring libpcap ..." -rm -rf libpcap-*.* -rm -rf libpcap* -wget http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz -tar xvf libpcap-1.8.1.tar.gz -cd libpcap-1.8.1 -export CC=arm-linux-gnueabi-gcc -./configure --host=arm-linux --with-pcap=linux -make - -echo "@ Building $EXE ..." -cd .. -env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="-Llibpcap-1.8.1" go build -o $EXE . -rm -rf libpcap-1.8.1 diff --git a/build_linux.sh b/build_linux.sh deleted file mode 100755 index 42bc9750..00000000 --- a/build_linux.sh +++ /dev/null @@ -1,3 +0,0 @@ -# nothing to see here, quite literally ... -go build -o bettercap-ng_linux_amd64 - diff --git a/build_macos.sh b/build_macos.sh deleted file mode 100755 index 6fe56d99..00000000 --- a/build_macos.sh +++ /dev/null @@ -1,11 +0,0 @@ -# nothing to see here, just what i use to build for OS X -DIR=/Users/evilsocket/gocode/src/github.com/evilsocket/bettercap-ng -AMD64_EXE=bettercap-ng_macos_amd64 - -echo "@ Updating repo ..." -ssh osxvm "cd $DIR && rm -rf $AMD64_EXE && git pull" - -echo "@ Building $AMD64_EXE ..." -ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd $DIR && PATH=$PATH:/usr/local/bin && go build -o $AMD64_EXE ." - -scp osxvm:$DIR/$AMD64_EXE . diff --git a/build_win.sh b/build_win.sh deleted file mode 100755 index c3aa9ed2..00000000 --- a/build_win.sh +++ /dev/null @@ -1,18 +0,0 @@ -# nothing to see here, just what i use to build for Windows -# -# -> https://stackoverflow.com/questions/38047858/compile-gopacket-on-windows-64bit -DIR=c:/Users/evilsocket/gopath/src/github.com/evilsocket/bettercap-ng -AMD64_EXE=bettercap-ng_win32_amd64.exe -I386_EXE=bettercap-ng_win32_i386.exe - -echo "@ Updating repo ..." -ssh winvm "cd $DIR && del *.exe && git pull" - -echo "@ Building $AMD64_EXE ..." -ssh winvm "cd $DIR && go build -o $AMD64_EXE ." - -# not worth the effort of installing the 32bit toolchain to be honest ... -# echo "@ Building $I386_EXE ..." -# ssh winvm "cd $DIR && set GOARCH=386 && go build -o $I386_EXE . && dir *.exe" - -scp winvm:$DIR/$AMD64_EXE . diff --git a/core/banner.go b/core/banner.go index ef549d45..96a55650 100644 --- a/core/banner.go +++ b/core/banner.go @@ -2,7 +2,7 @@ package core const ( Name = "bettercap-ng" - Version = "0.9.0" + Version = "2.0.0" Author = "Simone 'evilsocket' Margaritelli" Website = "https://bettercap.org/" )