diff --git a/Makefile b/Makefile index b321e54..65a2e91 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,14 @@ PACKAGES ?= core firewall log modules network packets session tls PREFIX ?= /usr/local GO ?= go -GOFLAGS ?= all: build build: resources - $(GO) $(GOFLAGS) build -o $(TARGET) . + $(GOFLAGS) $(GO) build -o $(TARGET) . build_with_race_detector: resources - $(GO) $(GOFLAGS) build -race -o $(TARGET) . + $(GOFLAGS) $(GO) build -race -o $(TARGET) . resources: network/manuf.go @@ -18,20 +17,20 @@ @python3 ./network/make_manuf.py install: - @mkdir -p $(PREFIX)/share/bettercap/caplets - @cp bettercap $(PREFIX)/bin/ + @mkdir -p $(DESTDIR)$(PREFIX)/share/bettercap/caplets + @cp bettercap $(DESTDIR)$(PREFIX)/bin/ docker: @docker build -t bettercap:latest . test: - $(GO) $(GOFLAGS) test -covermode=atomic -coverprofile=cover.out ./... + $(GOFLAGS) $(GO) test -covermode=atomic -coverprofile=cover.out ./... html_coverage: test - $(GO) $(GOFLAGS) tool cover -html=cover.out -o cover.out.html + $(GOFLAGS) $(GO) tool cover -html=cover.out -o cover.out.html benchmark: server_deps - $(GO) $(GOFLAGS) test -v -run=doNotRunTests -bench=. -benchmem ./... + $(GOFLAGS) $(GO) test -v -run=doNotRunTests -bench=. -benchmem ./... fmt: $(GO) fmt -s -w $(PACKAGES) @@ -40,4 +39,4 @@ $(RM) $(TARGET) $(RM) -r build -.PHONY: all build build_with_race_detector resources install docker test html_coverage benchmark fmt clean \ No newline at end of file +.PHONY: all build build_with_race_detector resources install docker test html_coverage benchmark fmt clean diff --git a/core/banner.go b/core/banner.go index 7f4545e..cea0f93 100644 --- a/core/banner.go +++ b/core/banner.go @@ -2,7 +2,7 @@ const ( Name = "bettercap" - Version = "2.31.1" + Version = "2.32.0" Author = "Simone 'evilsocket' Margaritelli" Website = "https://bettercap.org/" ) diff --git a/core/options.go b/core/options.go index c596a6b..d19001e 100644 --- a/core/options.go +++ b/core/options.go @@ -1,6 +1,8 @@ package core -import "flag" +import ( + "flag" +) type Options struct { InterfaceName *string @@ -18,6 +20,7 @@ MemProfile *string CapletsPath *string Script *string + PcapBufSize *int } func ParseOptions() (Options, error) { @@ -37,6 +40,7 @@ MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."), CapletsPath: flag.String("caplets-path", "", "Specify an alternative base path for caplets."), Script: flag.String("script", "", "Load a session script."), + PcapBufSize: flag.Int("pcap-buf-size", -1, "PCAP buffer size, leave to 0 for the default value."), } flag.Parse() diff --git a/go.mod b/go.mod index 0b75d74..71e738a 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/bettercap/bettercap -go 1.12 +go 1.16 require ( github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/adrianmo/go-nmea v1.3.0 github.com/antchfx/jsonquery v1.1.4 - github.com/antchfx/xpath v1.1.11 // indirect + github.com/antchfx/xpath v1.2.0 // indirect github.com/bettercap/gatt v0.0.0-20210514133428-df6e615f2f67 github.com/bettercap/nrf24 v0.0.0-20190219153547-aa37e6d0e0eb github.com/bettercap/readline v0.0.0-20210228151553-655e48bcb7bf @@ -15,7 +15,7 @@ github.com/chzyer/logex v1.1.10 // indirect github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect github.com/dustin/go-humanize v1.0.0 - github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e + github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 github.com/elazarl/goproxy/ext v0.0.0-20210110162100-a92cc753f88e // indirect github.com/evilsocket/islazy v1.10.6 github.com/gobwas/glob v0.0.0-20181002190808-e7a84e9525fe @@ -27,21 +27,23 @@ github.com/google/gousb v2.1.0+incompatible github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.4.2 - github.com/hashicorp/mdns v1.0.3 + github.com/hashicorp/mdns v1.0.4 github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b github.com/jpillora/go-tld v1.1.1 github.com/koppacetic/go-gpsd v0.4.0 github.com/kr/binarydist v0.1.0 // indirect github.com/malfunkt/iprange v0.9.0 + github.com/mattn/go-isatty v0.0.13 // indirect github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b - github.com/miekg/dns v1.1.41 + github.com/miekg/dns v1.1.43 github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/errors v0.9.1 // indirect - github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac + github.com/robertkrimen/otto v0.0.0-20210614181706-373ff5438452 github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 - github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb - golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 - golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect + github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64 + golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d + golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect + golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index 06c811d..0eb433c 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/antchfx/xpath v1.1.7/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= github.com/antchfx/xpath v1.1.11 h1:WOFtK8TVAjLm3lbgqeP0arlHpvCEeTANeWZ/csPpJkQ= github.com/antchfx/xpath v1.1.11/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= +github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8= +github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= github.com/bettercap/gatt v0.0.0-20210514133428-df6e615f2f67 h1:xzN6806c01hWTz8gjGsRjhOPlYj5/dNoZIR8CN9+O1c= github.com/bettercap/gatt v0.0.0-20210514133428-df6e615f2f67/go.mod h1:oafnPgaBI4gqJiYkueCyR4dqygiWGXTGOE0gmmAVeeQ= github.com/bettercap/nrf24 v0.0.0-20190219153547-aa37e6d0e0eb h1:JWAAJk4ny+bT3VrtcX+e7mcmWtWUeUM0xVcocSAUuWc= @@ -29,6 +31,8 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e h1:/cwV7t2xezilMljIftb7WlFtzGANRCnoOhPjtl2ifcs= github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 h1:lS3P5Nw3oPO05Lk2gFiYUOL3QPaH+fRoI1wFOc4G1UY= +github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= github.com/elazarl/goproxy/ext v0.0.0-20210110162100-a92cc753f88e h1:CQn2/8fi3kmpT9BTiHEELgdxAOQNVZc9GoPA4qnQzrs= github.com/elazarl/goproxy/ext v0.0.0-20210110162100-a92cc753f88e/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= @@ -56,6 +60,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/mdns v1.0.3 h1:hPneYJlzSjxFBmUlnDGXRykxBZ++dQAJhU57gCO7TzI= github.com/hashicorp/mdns v1.0.3/go.mod h1:P9sIDVQGUBr2GtS4qS2QCBdtgqP7TBt6d8looU5l5r4= +github.com/hashicorp/mdns v1.0.4 h1:sY0CMhFmjIPDMlTB+HfymFHCaYLhgifZ0QhjaYKD/UQ= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b h1:IpLPmn6Re21F0MaV6Zsc5RdSE6KuoFpWmHiUSEs3PrE= github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b/go.mod h1:aA6DnFhALT3zH0y+A39we+zbrdMC2N0X/q21e6FI0LU= github.com/jpillora/go-tld v1.1.1 h1:P1ZwtKDHBYYUl235R/D64cdBARfGYzEy1Hg2Ikir3FQ= @@ -76,6 +82,8 @@ github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b h1:r12blE3QRYlW1WBiBEe007O6NrTb/P54OjR5d4WLEGk= github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b/go.mod h1:p4K2+UAoap8Jzsadsxc0KG0OZjmmCthTPUyZqAVkjBY= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= @@ -85,6 +93,8 @@ github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= +github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -93,6 +103,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac h1:kYPjbEN6YPYWWHI6ky1J813KzIq/8+Wg4TO4xU7A/KU= github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= +github.com/robertkrimen/otto v0.0.0-20210614181706-373ff5438452 h1:ewTtJ72GFy2e0e8uyiDwMG3pKCS5mBh+hdSTYsPKEP8= +github.com/robertkrimen/otto v0.0.0-20210614181706-373ff5438452/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -102,6 +114,8 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb h1:EavwSqheIJl3nb91HhkL73DwnT2Fk8W3yM7T7TuLZvA= github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb/go.mod h1:I0ZT9x8wStY6VOxtNOrLpnDURFs7HS0z1e1vhuKUEVc= +github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64 h1:l/T7dYuJEQZOwVOpjIXr1180aM9PZL/d1MnMVIxefX4= +github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64/go.mod h1:Q1NAJOuRdQCqN/VIWdnaaEhV8LpeO2rtlBP7/iDJNII= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= @@ -114,6 +128,9 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 h1:4qWs8cYYH6PoEFy4dfhDFgoMGkwAcETd+MmPdCPMzUc= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -127,14 +144,19 @@ golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 h1:rw6UNGRMfarCepjI8qOepea/SXwIBVfTKjztZ5gBbq4= +golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= diff --git a/js/data.go b/js/data.go index d6975c3..e2bfe5b 100644 --- a/js/data.go +++ b/js/data.go @@ -4,6 +4,7 @@ "bytes" "compress/gzip" "encoding/base64" + "github.com/robertkrimen/otto" ) @@ -13,6 +14,7 @@ if err != nil { return ReportError("Could not convert to string: %s", varValue) } + return v } @@ -21,10 +23,12 @@ if err != nil { return ReportError("Could not decode string: %s", call.Argument(0).String()) } + v, err := otto.ToValue(string(varValue)) if err != nil { return ReportError("Could not convert to string: %s", varValue) } + return v } diff --git a/js/fs.go b/js/fs.go index fbe02cc..52443ec 100644 --- a/js/fs.go +++ b/js/fs.go @@ -67,4 +67,4 @@ } return otto.NullValue() -} \ No newline at end of file +} diff --git a/js/http.go b/js/http.go index 1adbcc2..615928c 100644 --- a/js/http.go +++ b/js/http.go @@ -3,12 +3,13 @@ import ( "bytes" "fmt" - "github.com/robertkrimen/otto" "io" "io/ioutil" "net/http" "net/url" "strings" + + "github.com/robertkrimen/otto" ) type httpPackage struct { @@ -26,7 +27,10 @@ return url.QueryEscape(s) } -func (c httpPackage) Request(method string, uri string, headers map[string]string, form map[string]string, json string) httpResponse { +func (c httpPackage) Request(method string, uri string, + headers map[string]string, + form map[string]string, + json string) httpResponse { var reader io.Reader if form != nil { diff --git a/js/init.go b/js/init.go index 1b49fee..6415dd8 100644 --- a/js/init.go +++ b/js/init.go @@ -3,7 +3,6 @@ import ( "github.com/evilsocket/islazy/log" "github.com/evilsocket/islazy/plugin" - "github.com/robertkrimen/otto" ) diff --git a/modules/arp_spoof/arp_spoof.go b/modules/arp_spoof/arp_spoof.go index 49be7a6..94aa775 100644 --- a/modules/arp_spoof/arp_spoof.go +++ b/modules/arp_spoof/arp_spoof.go @@ -175,7 +175,7 @@ gwIP := mod.Session.Gateway.IP myMAC := mod.Session.Interface.HW for mod.Running() { - mod.arpSpoofTargets(gwIP, myMAC, true, true) + mod.arpSpoofTargets(gwIP, myMAC, true, false) for _, address := range neighbours { if !mod.Session.Skip(address) { mod.arpSpoofTargets(address, myMAC, true, false) diff --git a/modules/dhcp6_spoof/dhcp6_spoof.go b/modules/dhcp6_spoof/dhcp6_spoof.go index 56d8838..9c4fefd 100644 --- a/modules/dhcp6_spoof/dhcp6_spoof.go +++ b/modules/dhcp6_spoof/dhcp6_spoof.go @@ -9,6 +9,7 @@ "sync" "time" + "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" @@ -83,7 +84,7 @@ return session.ErrAlreadyStarted(mod.Name()) } - if mod.Handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { + if mod.Handle, err = network.Capture(mod.Session.Interface.Name()); err != nil { return err } diff --git a/modules/dns_spoof/dns_spoof.go b/modules/dns_spoof/dns_spoof.go index ab9a350..03a42f2 100644 --- a/modules/dns_spoof/dns_spoof.go +++ b/modules/dns_spoof/dns_spoof.go @@ -8,6 +8,7 @@ "sync" "github.com/bettercap/bettercap/log" + "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" @@ -100,7 +101,7 @@ if mod.Running() { return session.ErrAlreadyStarted(mod.Name()) - } else if mod.Handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { + } else if mod.Handle, err = network.Capture(mod.Session.Interface.Name()); err != nil { return err } else if err = mod.Handle.SetBPFFilter("udp"); err != nil { return err diff --git a/modules/http_proxy/http_proxy_base_sslstriper.go b/modules/http_proxy/http_proxy_base_sslstriper.go index 2a99ac0..3c029eb 100644 --- a/modules/http_proxy/http_proxy_base_sslstriper.go +++ b/modules/http_proxy/http_proxy_base_sslstriper.go @@ -5,12 +5,13 @@ "net/http" "net/url" "regexp" + "strconv" "strings" - "strconv" "github.com/bettercap/bettercap/log" + "github.com/bettercap/bettercap/modules/dns_spoof" + "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" - "github.com/bettercap/bettercap/modules/dns_spoof" "github.com/elazarl/goproxy" "github.com/google/gopacket" @@ -23,9 +24,9 @@ ) var ( - httpsLinksParser = regexp.MustCompile(`https://[^"'/]+`) + httpsLinksParser = regexp.MustCompile(`https://[^"'/]+`) domainCookieParser = regexp.MustCompile(`; ?(?i)domain=.*(;|$)`) - flagsCookieParser = regexp.MustCompile(`; ?(?i)(secure|httponly)`) + flagsCookieParser = regexp.MustCompile(`; ?(?i)(secure|httponly)`) ) type SSLStripper struct { @@ -83,7 +84,7 @@ if enabled && s.handle == nil { var err error - if s.handle, err = pcap.OpenLive(s.session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { + if s.handle, err = network.Capture(s.session.Interface.Name()); err != nil { panic(err) } @@ -168,7 +169,7 @@ origDomain := origParts[len(origParts)-2] + "." + origParts[len(origParts)-1] strippedDomain := strippedParts[len(strippedParts)-2] + "." + strippedParts[len(strippedParts)-1] - log.Info("[%s] Fixing cookies on %s", tui.Green("sslstrip"),tui.Bold(strippedHost.Hostname)) + log.Info("[%s] Fixing cookies on %s", tui.Green("sslstrip"), tui.Bold(strippedHost.Hostname)) cookies := make([]string, len(res.Header["Set-Cookie"])) // replace domain and strip "secure" flag for each cookie for i, cookie := range res.Header["Set-Cookie"] { diff --git a/modules/net_sniff/net_sniff_context.go b/modules/net_sniff/net_sniff_context.go index 3ebcd9f..bb21afb 100644 --- a/modules/net_sniff/net_sniff_context.go +++ b/modules/net_sniff/net_sniff_context.go @@ -6,6 +6,7 @@ "time" "github.com/bettercap/bettercap/log" + "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/google/gopacket/pcap" @@ -42,7 +43,7 @@ * could hang waiting for a timeout to expire ... */ readTimeout := 500 * time.Millisecond - if ctx.Handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, readTimeout); err != nil { + if ctx.Handle, err = network.CaptureWithTimeout(mod.Session.Interface.Name(), readTimeout); err != nil { return err, ctx } } else { diff --git a/modules/syn_scan/syn_scan.go b/modules/syn_scan/syn_scan.go index b03b79a..0ce8995 100644 --- a/modules/syn_scan/syn_scan.go +++ b/modules/syn_scan/syn_scan.go @@ -7,6 +7,7 @@ "sync/atomic" "time" + "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" @@ -115,7 +116,7 @@ return session.ErrAlreadyStarted(mod.Name()) } if mod.handle == nil { - if mod.handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { + if mod.handle, err = network.Capture(mod.Session.Interface.Name()); err != nil { return err } else if err = mod.handle.SetBPFFilter(fmt.Sprintf("tcp dst port %d", synSourcePort)); err != nil { return err diff --git a/modules/ui/ui.go b/modules/ui/ui.go index f5d6950..7bc5270 100644 --- a/modules/ui/ui.go +++ b/modules/ui/ui.go @@ -9,6 +9,7 @@ "os" "path/filepath" "regexp" + "runtime" "github.com/bettercap/bettercap/session" @@ -29,6 +30,13 @@ uiPath string } +func getDefaultInstallBase() string { + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("ALLUSERSPROFILE"), "bettercap") + } + return "/usr/local/share/bettercap/" +} + func NewUIModule(s *session.Session) *UIModule { mod := &UIModule{ SessionModule: session.NewSessionModule("ui", s), @@ -36,7 +44,7 @@ } mod.AddParam(session.NewStringParameter("ui.basepath", - "/usr/local/share/bettercap/", + getDefaultInstallBase(), "", "UI base installation path.")) diff --git a/modules/wifi/wifi.go b/modules/wifi/wifi.go index 775dd87..148e349 100644 --- a/modules/wifi/wifi.go +++ b/modules/wifi/wifi.go @@ -54,6 +54,8 @@ assocSilent bool assocOpen bool assocAcquired bool + csaSilent bool + fakeAuthSilent bool filterProbeSTA *regexp.Regexp filterProbeAP *regexp.Regexp apRunning bool @@ -88,6 +90,8 @@ assocSilent: false, assocOpen: false, assocAcquired: false, + csaSilent: false, + fakeAuthSilent: false, showManuf: false, shakesAggregate: true, writes: &sync.WaitGroup{}, @@ -214,6 +218,50 @@ probe.Complete("wifi.probe", s.WiFiCompleterFull) mod.AddHandler(probe) + + channelSwitchAnnounce := session.NewModuleHandler("wifi.channel_switch_announce bssid channel ", `wifi\.channel_switch_announce ((?:[a-fA-F0-9:]{11,}))\s+((?:[0-9]+))`, + "Start a 802.11 channel hop attack, all client will be force to change the channel lead to connection down.", + func(args []string) error { + bssid, err := net.ParseMAC(args[0]) + if err != nil { + return err + } + channel, _ := strconv.Atoi(args[1]) + if channel > 180 || channel < 1 { + return fmt.Errorf("%d is not a valid channel number", channel) + } + return mod.startCSA(bssid, int8(channel)) + }) + + channelSwitchAnnounce.Complete("wifi.channel_switch_announce", s.WiFiCompleterFull) + + mod.AddHandler(channelSwitchAnnounce) + + fakeAuth := session.NewModuleHandler("wifi.fake_auth bssid client", `wifi\.fake_auth ((?:[a-fA-F0-9:]{11,}))\s+((?:[a-fA-F0-9:]{11,}))`, + "send an fake authentication with client mac to ap lead to client disconnect", + func(args []string) error { + bssid, err := net.ParseMAC(args[0]) + if err != nil { + return err + } + client, err := net.ParseMAC(args[1]) + if err != nil { + return err + } + return mod.startFakeAuth(bssid, client) + }) + + fakeAuth.Complete("wifi.fake_auth", s.WiFiCompleterFull) + + mod.AddHandler(fakeAuth) + + mod.AddParam(session.NewBoolParameter("wifi.channel_switch_announce.silent", + "false", + "If true, messages from wifi.channel_switch_announce will be suppressed.")) + + mod.AddParam(session.NewBoolParameter("wifi.fake_auth.silent", + "false", + "If true, messages from wifi.fake_auth will be suppressed.")) mod.AddParam(session.NewStringParameter("wifi.deauth.skip", "", @@ -508,53 +556,33 @@ } } - setRFMonMaybeFatal := false + /* + * We don't want to pcap.BlockForever otherwise pcap_close(handle) + * could hang waiting for a timeout to expire ... + */ + opts := network.CAPTURE_DEFAULTS + opts.Timeout = 500 * time.Millisecond + opts.Monitor = true + for retry := 0; ; retry++ { - ihandle, err := pcap.NewInactiveHandle(ifName) - if err != nil { - return fmt.Errorf("error while opening interface %s: %s", ifName, err) - } - defer ihandle.CleanUp() - - /* - * Calling SetRFMon is fatal when the interface is already in monitor mode. - * gopacket has no GetRFMon analogue to SetRFMon with which we could check this, however ... - */ - if !setRFMonMaybeFatal { - if err = ihandle.SetRFMon(true); err != nil { - return fmt.Errorf("error while setting interface %s in monitor mode: %s", tui.Bold(ifName), err) + if mod.handle, err = network.CaptureWithOptions(ifName, opts); err == nil { + // we're done + break + } else if retry == 0 && err.Error() == ErrIfaceNotUp { + // try to bring interface up and try again + mod.Info("interface %s is down, bringing it up ...", ifName) + if err := network.ActivateInterface(ifName); err != nil { + return err } + continue + } else if !opts.Monitor { + // second fatal error, just bail + return fmt.Errorf("error while activating handle: %s", err) } else { - mod.Debug("SetRFMon on interface %s might be fatal, skipping this time", tui.Bold(ifName)) - } - if err = ihandle.SetSnapLen(65536); err != nil { - return fmt.Errorf("error while settng snapshot length: %s", err) - } - /* - * We don't want to pcap.BlockForever otherwise pcap_close(handle) - * could hang waiting for a timeout to expire ... - */ - readTimeout := 500 * time.Millisecond - if err = ihandle.SetTimeout(readTimeout); err != nil { - return fmt.Errorf("error while setting timeout: %s", err) - } else if mod.handle, err = ihandle.Activate(); err != nil { - if retry == 0 && err.Error() == ErrIfaceNotUp { - mod.Debug("interface %s is down, bringing it up ...", ifName) - if err := network.ActivateInterface(ifName); err != nil { - return err - } - continue - } - if setRFMonMaybeFatal { - return fmt.Errorf("error while activating handle: %s", err) - } else { - mod.Warning("error while activating handle: %s, %s", err, tui.Bold("interface might already be monitoring. retrying!")) - setRFMonMaybeFatal = true - continue - } - } - - break + // first fatal error, try again without setting the interface in monitor mode + mod.Warning("error while activating handle: %s, %s", err, tui.Bold("interface might already be monitoring. retrying!")) + opts.Monitor = false + } } } diff --git a/modules/wifi/wifi_csa.go b/modules/wifi/wifi_csa.go new file mode 100644 index 0000000..20fb359 --- /dev/null +++ b/modules/wifi/wifi_csa.go @@ -0,0 +1,86 @@ +package wifi + +import ( + "bytes" + "fmt" + "github.com/bettercap/bettercap/network" + "github.com/bettercap/bettercap/packets" + "github.com/google/gopacket/layers" + "net" +) + +func (mod *WiFiModule) isCSASilent() bool { + if err, is := mod.BoolParam("wifi.channel_switch_announce.silent"); err != nil { + mod.Warning("%v", err) + } else { + mod.csaSilent = is + } + return mod.csaSilent +} + +func (mod *WiFiModule) sendBeaconWithCSAPacket(ap *network.AccessPoint, toChan int8) { + ssid := ap.ESSID() + if ssid == "" { + ssid = "" + } + hw, _ := net.ParseMAC(ap.BSSID()) + + for seq := uint16(0); seq < 256 && mod.Running(); seq++ { + if err, pkt := packets.NewDot11Beacon(packets.Dot11ApConfig{ + SSID: ssid, + BSSID: hw, + Channel: ap.Channel, + Encryption: false, + SpectrumManagement: true, + }, 0, packets.Dot11Info(layers.Dot11InformationElementIDSwitchChannelAnnounce, []byte{0, byte(toChan), 1})); err != nil { + mod.Error("could not create beacon packet: %s", err) + continue + } else { + mod.injectPacket(pkt) + } + } +} + +func (mod *WiFiModule) startCSA(to net.HardwareAddr, toChan int8) error { + // if not already running, temporarily enable the pcap handle + // for packet injection + if !mod.Running() { + if err := mod.Configure(); err != nil { + return err + } + defer mod.handle.Close() + } + + var ap *network.AccessPoint = nil + + for _, _ap := range mod.Session.WiFi.List() { + if bytes.Equal(_ap.HW, to) { + ap = _ap + } + + } + + if ap == nil { + return fmt.Errorf("%s is an unknown BSSID", to.String()) + } + + mod.writes.Add(1) + go func() { + defer mod.writes.Done() + + if mod.Running() { + logger := mod.Info + if mod.isCSASilent() { + logger = mod.Debug + } + logger("channel hop attack in AP %s (channel:%d encryption:%s), hop to channel %d ", ap.ESSID(), ap.Channel, ap.Encryption, toChan) + // send the beacon frame with channel switch announce element id + mod.onChannel(ap.Channel, func() { + mod.sendBeaconWithCSAPacket(ap, toChan) + }) + } + + }() + + return nil +} diff --git a/modules/wifi/wifi_fake_auth.go b/modules/wifi/wifi_fake_auth.go new file mode 100644 index 0000000..bafb88d --- /dev/null +++ b/modules/wifi/wifi_fake_auth.go @@ -0,0 +1,71 @@ +package wifi + +import ( + "bytes" + "fmt" + "github.com/bettercap/bettercap/network" + "github.com/bettercap/bettercap/packets" + "net" +) + + +func (mod *WiFiModule) isFakeAuthSilent() bool { + if err, is := mod.BoolParam("wifi.fake_auth.silent"); err != nil { + mod.Warning("%v", err) + } else { + mod.csaSilent = is + } + return mod.csaSilent +} + +func(mod *WiFiModule)sendFakeAuthPacket(bssid,client net.HardwareAddr){ + err,pkt:=packets.NewDot11Auth(client,bssid,0) + if err!=nil{ + mod.Error("could not create authentication packet: %s", err) + return + } + for i:=0;i<32;i++{ + mod.injectPacket(pkt) + } +} + +func (mod *WiFiModule) startFakeAuth(bssid,client net.HardwareAddr) error { + // if not already running, temporarily enable the pcap handle + // for packet injection + if !mod.Running() { + if err := mod.Configure(); err != nil { + return err + } + defer mod.handle.Close() + } + + var ap *network.AccessPoint = nil + + for _, _ap := range mod.Session.WiFi.List() { + if bytes.Equal(_ap.HW, bssid) { + ap = _ap + } + } + + if ap == nil { + return fmt.Errorf("%s is an unknown BSSID", bssid.String()) + } + + mod.writes.Add(1) + go func() { + defer mod.writes.Done() + + if mod.Running() { + logger := mod.Info + if mod.isFakeAuthSilent() { + logger = mod.Debug + } + logger("fake authentication attack in AP: %s client: %s", ap.ESSID(), client.String()) + // send the beacon frame with channel switch announce element id + mod.onChannel(ap.Channel, func() { + mod.sendFakeAuthPacket(bssid,client) + }) + } + }() + return nil +} \ No newline at end of file diff --git a/network/pcap.go b/network/pcap.go new file mode 100644 index 0000000..62ec565 --- /dev/null +++ b/network/pcap.go @@ -0,0 +1,71 @@ +package network + +import ( + "fmt" + "time" + + "github.com/evilsocket/islazy/tui" + "github.com/google/gopacket/pcap" +) + +const ( + PCAP_DEFAULT_SETRF = false + PCAP_DEFAULT_SNAPLEN = 65536 + PCAP_DEFAULT_BUFSIZE = 2_097_152 + PCAP_DEFAULT_PROMISC = true + PCAP_DEFAULT_TIMEOUT = pcap.BlockForever +) + +var CAPTURE_DEFAULTS = CaptureOptions{ + Monitor: PCAP_DEFAULT_SETRF, + Snaplen: PCAP_DEFAULT_SNAPLEN, + Bufsize: PCAP_DEFAULT_BUFSIZE, + Promisc: PCAP_DEFAULT_PROMISC, + Timeout: PCAP_DEFAULT_TIMEOUT, +} + +type CaptureOptions struct { + Monitor bool + Snaplen int + Bufsize int + Promisc bool + Timeout time.Duration +} + +func CaptureWithOptions(ifName string, options CaptureOptions) (*pcap.Handle, error) { + Debug("creating capture for '%s' with options: %+v", ifName, options) + + ihandle, err := pcap.NewInactiveHandle(ifName) + if err != nil { + return nil, fmt.Errorf("error while opening interface %s: %s", ifName, err) + } + defer ihandle.CleanUp() + + if options.Monitor { + if err = ihandle.SetRFMon(true); err != nil { + return nil, fmt.Errorf("error while setting interface %s in monitor mode: %s", tui.Bold(ifName), err) + } + } + + if err = ihandle.SetSnapLen(options.Snaplen); err != nil { + return nil, fmt.Errorf("error while settng snapshot length: %s", err) + } else if err = ihandle.SetBufferSize(options.Bufsize); err != nil { + return nil, fmt.Errorf("error while settng buffer size: %s", err) + } else if err = ihandle.SetPromisc(options.Promisc); err != nil { + return nil, fmt.Errorf("error while settng promiscuous mode to %v: %s", options.Promisc, err) + } else if err = ihandle.SetTimeout(options.Timeout); err != nil { + return nil, fmt.Errorf("error while settng snapshot length: %s", err) + } + + return ihandle.Activate() +} + +func Capture(ifName string) (*pcap.Handle, error) { + return CaptureWithOptions(ifName, CAPTURE_DEFAULTS) +} + +func CaptureWithTimeout(ifName string, timeout time.Duration) (*pcap.Handle, error) { + var opts = CAPTURE_DEFAULTS + opts.Timeout = timeout + return CaptureWithOptions(ifName, opts) +} diff --git a/network/wifi.go b/network/wifi.go index f6c6e1c..2ec4b43 100644 --- a/network/wifi.go +++ b/network/wifi.go @@ -23,6 +23,8 @@ return 14 } else if freq >= 5035 && freq <= 5865 { return ((freq - 5035) / 5) + 7 + } else if freq >= 5875 && freq <= 5895 { + return 177 } return 0 } @@ -34,6 +36,8 @@ return 2484 } else if channel <= 173 { return ((channel - 7) * 5) + 5035 + } else if channel == 177 { + return 5885 } return 0 diff --git a/network/wifi_test.go b/network/wifi_test.go index a8bfe42..9631838 100644 --- a/network/wifi_test.go +++ b/network/wifi_test.go @@ -6,26 +6,39 @@ "github.com/evilsocket/islazy/data" ) +// Define test data for dot11 frequency <-> channel tests +type dot11pair struct { + frequency int + channel int +} + +var dot11TestVector = []dot11pair{ + {2472, 13}, + {2484, 14}, + {5825, 165}, + {5885, 177}, +} + func buildExampleWiFi() *WiFi { aliases := &data.UnsortedKV{} return NewWiFi(buildExampleEndpoint(), aliases, func(ap *AccessPoint) {}, func(ap *AccessPoint) {}) } func TestDot11Freq2Chan(t *testing.T) { - exampleFreq := 2472 - exp := 13 - got := Dot11Freq2Chan(exampleFreq) - if got != exp { - t.Fatalf("expected '%v', got '%v'", exp, got) + for _, entry := range dot11TestVector { + gotChannel := Dot11Freq2Chan(entry.frequency) + if gotChannel != entry.channel { + t.Fatalf("expected '%v', got '%v'", entry.channel, gotChannel) + } } } func TestDot11Chan2Freq(t *testing.T) { - exampleChan := 13 - exp := 2472 - got := Dot11Chan2Freq(exampleChan) - if got != exp { - t.Fatalf("expected '%v', got '%v'", exp, got) + for _, entry := range dot11TestVector { + gotFrequency := Dot11Chan2Freq(entry.channel) + if gotFrequency != entry.frequency { + t.Fatalf("expected '%v', got '%v'", entry.frequency, gotFrequency) + } } } diff --git a/packets/dot11.go b/packets/dot11.go index c6e5c83..b1ae89e 100644 --- a/packets/dot11.go +++ b/packets/dot11.go @@ -13,6 +13,7 @@ var ( openFlags = 1057 wpaFlags = 1041 + specManFlag = 1<<8 durationID = uint16(0x013a) capabilityInfo = uint16(0x0411) listenInterval = uint16(3) @@ -37,10 +38,11 @@ ) type Dot11ApConfig struct { - SSID string - BSSID net.HardwareAddr - Channel int - Encryption bool + SSID string + BSSID net.HardwareAddr + Channel int + Encryption bool + SpectrumManagement bool } func Dot11Info(id layers.Dot11InformationElementID, info []byte) *layers.Dot11InformationElement { @@ -51,12 +53,14 @@ } } -func NewDot11Beacon(conf Dot11ApConfig, seq uint16) (error, []byte) { +func NewDot11Beacon(conf Dot11ApConfig, seq uint16, extendDot11Info ...*layers.Dot11InformationElement) (error, []byte) { flags := openFlags if conf.Encryption { flags = wpaFlags } - + if conf.SpectrumManagement { + flags |= specManFlag + } stack := []gopacket.SerializableLayer{ &layers.RadioTap{ DBMAntennaSignal: int8(-10), @@ -77,7 +81,9 @@ Dot11Info(layers.Dot11InformationElementIDRates, fakeApRates), Dot11Info(layers.Dot11InformationElementIDDSSet, []byte{byte(conf.Channel & 0xff)}), } - + for _, v := range extendDot11Info { + stack = append(stack, v) + } if conf.Encryption { stack = append(stack, &layers.Dot11InformationElement{ ID: layers.Dot11InformationElementIDRSNInfo, diff --git a/packets/dot11_wps_attrs.go b/packets/dot11_wps_attrs.go index 0bab99c..508fcdf 100644 --- a/packets/dot11_wps_attrs.go +++ b/packets/dot11_wps_attrs.go @@ -177,14 +177,22 @@ size := len(data) for offset := 3; offset < size; { idByte := uint8(data[offset]) - sizeByte := uint8(data[offset+1]) - if idByte == wpsVersion2ID { - verByte := fmt.Sprintf("%x", data[offset+2]) - (*info)["Version"] = wpsVersionDesc[verByte] - data = data[offset+3:] + if next := offset + 1; next < size { + sizeByte := uint8(data[next]) + if idByte == wpsVersion2ID { + if next = offset + 2; next < size { + verByte := fmt.Sprintf("%x", data[next]) + (*info)["Version"] = wpsVersionDesc[verByte] + if next = offset + 3; next < size { + data = data[next:] + } + break + } + } + offset += int(sizeByte) + 2 + } else { break } - offset += int(sizeByte) + 2 } } return hex.EncodeToString(data) diff --git a/packets/mdns.go b/packets/mdns.go index e3610a2..2de3a38 100644 --- a/packets/mdns.go +++ b/packets/mdns.go @@ -5,7 +5,6 @@ "strings" "github.com/evilsocket/islazy/str" - "github.com/google/gopacket" "github.com/google/gopacket/layers" ) diff --git a/packets/queue.go b/packets/queue.go index 7bca284..b8242ea 100644 --- a/packets/queue.go +++ b/packets/queue.go @@ -69,7 +69,7 @@ } if q.active { - if q.handle, err = pcap.OpenLive(iface.Name(), 1024, true, pcap.BlockForever); err != nil { + if q.handle, err = network.Capture(iface.Name()); err != nil { return } diff --git a/routing/update_darwin.go b/routing/update_darwin.go index e5f507d..9417f7a 100644 --- a/routing/update_darwin.go +++ b/routing/update_darwin.go @@ -1,10 +1,11 @@ package routing import ( + "regexp" + "strings" + "github.com/bettercap/bettercap/core" "github.com/evilsocket/islazy/str" - "regexp" - "strings" ) var parser = regexp.MustCompile(`^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+).*$`) diff --git a/session/script.go b/session/script.go index 7306bef..15efcfd 100644 --- a/session/script.go +++ b/session/script.go @@ -2,15 +2,17 @@ import ( "fmt" - "github.com/bettercap/bettercap/caplets" - _ "github.com/bettercap/bettercap/js" - "github.com/evilsocket/islazy/fs" - "github.com/evilsocket/islazy/plugin" - "github.com/evilsocket/islazy/str" "io/ioutil" "path/filepath" "regexp" "strings" + + "github.com/bettercap/bettercap/caplets" + _ "github.com/bettercap/bettercap/js" + + "github.com/evilsocket/islazy/fs" + "github.com/evilsocket/islazy/plugin" + "github.com/evilsocket/islazy/str" ) // require("telegram.js") @@ -37,7 +39,7 @@ filepath.Join(caplets.InstallBase, fileName), } - if strings.Contains(fileName, ".js") == false { + if !strings.Contains(fileName, ".js") { searchPaths = append(searchPaths, []string{ filepath.Join(basePath, fileName) + ".js", filepath.Join(caplets.InstallBase, fileName) + ".js", diff --git a/session/session.go b/session/session.go index fc921d1..dc0a6f3 100644 --- a/session/session.go +++ b/session/session.go @@ -127,6 +127,10 @@ } } + if bufSize := *s.Options.PcapBufSize; bufSize != -1 { + network.CAPTURE_DEFAULTS.Bufsize = bufSize + } + if s.Env, err = NewEnvironment(*s.Options.EnvFile); err != nil { return nil, err }