fix: getting rid of forked gopacket, static build ftw!

This commit is contained in:
evilsocket 2018-03-01 10:40:49 +01:00
parent cc179f20b4
commit 1a67c82fbd
25 changed files with 55 additions and 53 deletions

View file

@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
BUILD_FOLDER=build BUILD_FOLDER=build
VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2) VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2)
GO_BUILD_FLAGS=--ldflags '-linkmode external -extldflags "-static -s -w"' -v
CROSS_LIB=/tmp/libpcap-1.8.1/libpcap.a CROSS_LIB=/tmp/libpcap-1.8.1/libpcap.a
bin_dep() { bin_dep() {
@ -45,7 +47,7 @@ xcompile_pcap() {
build_linux_amd64() { build_linux_amd64() {
echo "@ Building linux/amd64 ..." echo "@ Building linux/amd64 ..."
go build -o bettercap .. go build $GO_BUILD_FLAGS -o bettercap ..
} }
build_linux_arm7() { build_linux_arm7() {
@ -56,7 +58,7 @@ build_linux_arm7() {
echo "@ Building linux/arm7 ..." echo "@ Building linux/arm7 ..."
cd "$OLD" cd "$OLD"
env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap .. env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="$CROSS_LIB" go build $GO_BUILD_FLAGS -o bettercap ..
} }
build_linux_mips() { build_linux_mips() {
@ -67,7 +69,7 @@ build_linux_mips() {
echo "@ Building linux/mips ..." echo "@ Building linux/mips ..."
cd "$OLD" cd "$OLD"
env CC=mips-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap .. env CC=mips-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips CGO_LDFLAGS="$CROSS_LIB" go build $GO_BUILD_FLAGS -o bettercap ..
} }
build_linux_mipsle() { build_linux_mipsle() {
@ -78,7 +80,7 @@ build_linux_mipsle() {
echo "@ Building linux/mipsle ..." echo "@ Building linux/mipsle ..."
cd "$OLD" cd "$OLD"
env CC=mipsel-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mipsle CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap .. env CC=mipsel-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mipsle CGO_LDFLAGS="$CROSS_LIB" go build $GO_BUILD_FLAGS -o bettercap ..
} }
build_linux_mips64() { build_linux_mips64() {
@ -89,7 +91,7 @@ build_linux_mips64() {
echo "@ Building linux/mips64 ..." echo "@ Building linux/mips64 ..."
cd "$OLD" cd "$OLD"
env CC=mips64-linux-gnuabi64-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips64 CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap .. env CC=mips64-linux-gnuabi64-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips64 CGO_LDFLAGS="$CROSS_LIB" go build $GO_BUILD_FLAGS -o bettercap ..
} }
build_linux_mips64le() { build_linux_mips64le() {
@ -100,7 +102,7 @@ build_linux_mips64le() {
echo "@ Building linux/mips64le ..." echo "@ Building linux/mips64le ..."
cd "$OLD" cd "$OLD"
env CC=mips64el-linux-gnuabi64-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips64le CGO_LDFLAGS="$CROSS_LIB" go build -o bettercap .. env CC=mips64el-linux-gnuabi64-gcc CGO_ENABLED=1 GOOS=linux GOARCH=mips64le CGO_LDFLAGS="$CROSS_LIB" go build $GO_BUILD_FLAGS -o bettercap ..
} }
build_macos_amd64() { build_macos_amd64() {
@ -112,7 +114,7 @@ build_macos_amd64() {
ssh osxvm "cd $DIR && rm -rf '$OUTPUT' && git pull" > /dev/null ssh osxvm "cd $DIR && rm -rf '$OUTPUT' && git pull" > /dev/null
echo "@ Building darwin/amd64 ..." echo "@ Building darwin/amd64 ..."
ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd '$DIR' && PATH=$PATH:/usr/local/bin && go get ./... && go build -o bettercap ." > /dev/null ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd '$DIR' && PATH=$PATH:/usr/local/bin && go get ./... && go build $GO_BUILD_FLAGS -o bettercap ." > /dev/null
scp -C osxvm:$DIR/bettercap . > /dev/null scp -C osxvm:$DIR/bettercap . > /dev/null
} }
@ -126,7 +128,7 @@ build_windows_amd64() {
ssh winvm "cd $DIR && git pull && go get ./..." > /dev/null ssh winvm "cd $DIR && git pull && go get ./..." > /dev/null
echo "@ Building windows/amd64 ..." echo "@ Building windows/amd64 ..."
ssh winvm "cd $DIR && go build -o bettercap.exe ." > /dev/null ssh winvm "cd $DIR && go build $GO_BUILD_FLAGS -o bettercap.exe ." > /dev/null
scp -C winvm:$DIR/bettercap.exe . > /dev/null scp -C winvm:$DIR/bettercap.exe . > /dev/null
} }
@ -140,7 +142,7 @@ build_android_arm() {
ssh -p 8022 root@shield "cd "$DIR" && rm -rf bettercap* && git pull && go get ./..." ssh -p 8022 root@shield "cd "$DIR" && rm -rf bettercap* && git pull && go get ./..."
echo "@ Building android/arm ..." echo "@ Building android/arm ..."
ssh -p 8022 root@shield "cd $DIR && go build -o bettercap ." ssh -p 8022 root@shield "cd $DIR && go build $GO_BUILD_FLAGS -o bettercap ."
echo "@ Downloading bettercap ..." echo "@ Downloading bettercap ..."
scp -C -P 8022 root@shield:$DIR/bettercap . scp -C -P 8022 root@shield:$DIR/bettercap .

View file

@ -14,12 +14,12 @@ import (
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/bettercap/gopacket/pcap" "github.com/google/gopacket/pcap"
// TODO: refactor to use gopacket when gopacket folks // TODO: refactor to use gopacket when gopacket folks
// will fix this > https://github.com/bettercap/gopacket/issues/334 // will fix this > https://github.com/google/gopacket/issues/334
"github.com/mdlayher/dhcp6" "github.com/mdlayher/dhcp6"
"github.com/mdlayher/dhcp6/dhcp6opts" "github.com/mdlayher/dhcp6/dhcp6opts"
) )

View file

@ -12,9 +12,9 @@ import (
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/bettercap/gopacket/pcap" "github.com/google/gopacket/pcap"
) )
type DNSSpoofer struct { type DNSSpoofer struct {

View file

@ -8,8 +8,8 @@ import (
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
type Sniffer struct { type Sniffer struct {

View file

@ -8,8 +8,8 @@ import (
"github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket/pcap" "github.com/google/gopacket/pcap"
"github.com/bettercap/gopacket/pcapgo" "github.com/google/gopacket/pcapgo"
) )
type SnifferContext struct { type SnifferContext struct {

View file

@ -5,8 +5,8 @@ import (
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { func dnsParser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {

View file

@ -1,8 +1,8 @@
package modules package modules
import ( import (
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
func dot11Parser(radiotap *layers.RadioTap, dot11 *layers.Dot11, pkt gopacket.Packet, verbose bool) { func dot11Parser(radiotap *layers.RadioTap, dot11 *layers.Dot11, pkt gopacket.Packet, verbose bool) {

View file

@ -7,8 +7,8 @@ import (
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool { func httpParser(ip *layers.IPv4, pkt gopacket.Packet, tcp *layers.TCP) bool {

View file

@ -6,8 +6,8 @@ import (
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool { func krb5Parser(ip *layers.IPv4, pkt gopacket.Packet, udp *layers.UDP) bool {

View file

@ -7,8 +7,8 @@ import (
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
var ( var (

View file

@ -7,8 +7,8 @@ import (
"github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) { func tcpParser(ip *layers.IPv4, pkt gopacket.Packet, verbose bool) {

View file

@ -6,8 +6,8 @@ import (
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"regexp" "regexp"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
// poor man's TLS Client Hello with SNI extension parser :P // poor man's TLS Client Hello with SNI extension parser :P

View file

@ -5,7 +5,7 @@ import (
"net" "net"
"time" "time"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/core"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"

View file

@ -13,8 +13,8 @@ import (
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/malfunkt/iprange" "github.com/malfunkt/iprange"
) )

View file

@ -15,9 +15,9 @@ import (
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/bettercap/gopacket/pcap" "github.com/google/gopacket/pcap"
"github.com/dustin/go-humanize" "github.com/dustin/go-humanize"
) )

View file

@ -10,7 +10,7 @@ import (
"github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/packets"
"github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/session"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
var ( var (

View file

@ -6,7 +6,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/bettercap/gopacket/pcap" "github.com/google/gopacket/pcap"
) )
// only matches gateway lines // only matches gateway lines

View file

@ -3,7 +3,7 @@ package packets
import ( import (
"net" "net"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
func NewARPTo(from net.IP, from_hw net.HardwareAddr, to net.IP, to_hw net.HardwareAddr, req uint16) (layers.Ethernet, layers.ARP) { func NewARPTo(from net.IP, from_hw net.HardwareAddr, to net.IP, to_hw net.HardwareAddr, req uint16) (layers.Ethernet, layers.ARP) {

View file

@ -3,7 +3,7 @@ package packets
import ( import (
"errors" "errors"
// TODO: refactor to use gopacket when gopacket folks // TODO: refactor to use gopacket when gopacket folks
// will fix this > https://github.com/bettercap/gopacket/issues/334 // will fix this > https://github.com/google/gopacket/issues/334
"github.com/mdlayher/dhcp6" "github.com/mdlayher/dhcp6"
) )

View file

@ -1,7 +1,7 @@
package packets package packets
import ( import (
"github.com/bettercap/gopacket" "github.com/google/gopacket"
) )
type DHCPv6Layer struct { type DHCPv6Layer struct {

View file

@ -6,8 +6,8 @@ import (
"fmt" "fmt"
"net" "net"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
) )
type Dot11CipherType uint8 type Dot11CipherType uint8

View file

@ -8,9 +8,9 @@ import (
"github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/network"
"github.com/bettercap/gopacket" "github.com/google/gopacket"
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/bettercap/gopacket/pcap" "github.com/google/gopacket/pcap"
) )
type Activity struct { type Activity struct {

View file

@ -1,7 +1,7 @@
package packets package packets
import ( import (
"github.com/bettercap/gopacket" "github.com/google/gopacket"
) )
var SerializationOptions = gopacket.SerializeOptions{ var SerializationOptions = gopacket.SerializeOptions{

View file

@ -1,7 +1,7 @@
package packets package packets
import ( import (
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"net" "net"
) )

View file

@ -1,7 +1,7 @@
package packets package packets
import ( import (
"github.com/bettercap/gopacket/layers" "github.com/google/gopacket/layers"
"net" "net"
) )