From f9489a8d4e6965f480ff2dcd55e9ab41b2a634a6 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Sun, 25 Feb 2018 06:50:31 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- build.sh | 23 ++++++++++++++++++++--- network/net_gateway.go | 3 +-- network/net_gateway_android.go | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 23f56396..9a3f2199 100755 --- a/build.sh +++ b/build.sh @@ -7,7 +7,7 @@ bin_dep() { which $BIN > /dev/null || { echo "@ Dependency $BIN not found !"; exit 1; } } -vm_dep() { +host_dep() { HOST=$1 ping -c 1 $HOST > /dev/null || { echo "@ Virtual machine host $HOST not visible !"; exit 1; } } @@ -114,7 +114,7 @@ build_linux_mips64le() { } build_macos_amd64() { - vm_dep 'osxvm' + host_dep 'osxvm' DIR=/Users/evilsocket/gocode/src/github.com/bettercap/bettercap OUTPUT=$1 @@ -130,7 +130,7 @@ build_macos_amd64() { } build_windows_amd64() { - vm_dep 'winvm' + host_dep 'winvm' DIR=c:/Users/evilsocket/gopath/src/github.com/bettercap/bettercap OUTPUT=$1 @@ -145,10 +145,27 @@ build_windows_amd64() { scp -C winvm:$DIR/$OUTPUT . > /dev/null } +build_android_arm() { + host_dep 'shield' + + DIR=/data/data/com.termux/files/home/go/src/github.com/bettercap/bettercap + OUTPUT=$1 + + echo "@ Updating repo on Android host ..." + ssh -p 8022 root@shield "cd $DIR && rm bettercap && git pull" > /dev/null + + echo "@ Building $OUTPUT ..." + ssh -p 8022 root@shield "cd $DIR && go build -o $OUTPUT ." > /dev/null + + echo "@ Downloading $OUTPUT ..." + scp -C -P 8022 root@shield:$DIR/$OUTPUT . > /dev/null +} + rm -rf $BUILD_FOLDER mkdir $BUILD_FOLDER cd $BUILD_FOLDER +build_android_arm bettercap_android_arm_$VERSION build_linux_amd64 bettercap_linux_amd64_$VERSION build_linux_arm7 bettercap_linux_arm7_$VERSION build_linux_mips bettercap_linux_mips_$VERSION diff --git a/network/net_gateway.go b/network/net_gateway.go index 46577c65..4a47698b 100644 --- a/network/net_gateway.go +++ b/network/net_gateway.go @@ -3,7 +3,6 @@ package network import ( - "fmt" "strings" "github.com/bettercap/bettercap/core" @@ -25,7 +24,7 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) { // we have the address, now we need its mac mac, err := ArpLookup(iface.Name(), gateway, false) if err != nil { - fmt.Printf("%s\n", err) + return nil, err } return NewEndpoint(gateway, mac), nil } diff --git a/network/net_gateway_android.go b/network/net_gateway_android.go index dcdc7633..d24e2d43 100644 --- a/network/net_gateway_android.go +++ b/network/net_gateway_android.go @@ -4,6 +4,7 @@ import ( "github.com/bettercap/bettercap/core" ) +// Hi, i'm Android and my mum said I'm special. func FindGateway(iface *Endpoint) (*Endpoint, error) { output, err := core.Exec("getprop", []string{"net.dns1"}) if err != nil {