Update upstream source from tag 'upstream/2.32.0'
Update to upstream version '2.32.0'
with Debian dir d53c8e5bb680feeb3b5595ab474b06d86b30a711
Sophie Brun
2 years ago
1 | 1 | PACKAGES ?= core firewall log modules network packets session tls |
2 | 2 | PREFIX ?= /usr/local |
3 | 3 | GO ?= go |
4 | GOFLAGS ?= | |
5 | 4 | |
6 | 5 | all: build |
7 | 6 | |
8 | 7 | build: resources |
9 | $(GO) $(GOFLAGS) build -o $(TARGET) . | |
8 | $(GOFLAGS) $(GO) build -o $(TARGET) . | |
10 | 9 | |
11 | 10 | build_with_race_detector: resources |
12 | $(GO) $(GOFLAGS) build -race -o $(TARGET) . | |
11 | $(GOFLAGS) $(GO) build -race -o $(TARGET) . | |
13 | 12 | |
14 | 13 | resources: network/manuf.go |
15 | 14 | |
17 | 16 | @python3 ./network/make_manuf.py |
18 | 17 | |
19 | 18 | install: |
20 | @mkdir -p $(PREFIX)/share/bettercap/caplets | |
21 | @cp bettercap $(PREFIX)/bin/ | |
19 | @mkdir -p $(DESTDIR)$(PREFIX)/share/bettercap/caplets | |
20 | @cp bettercap $(DESTDIR)$(PREFIX)/bin/ | |
22 | 21 | |
23 | 22 | docker: |
24 | 23 | @docker build -t bettercap:latest . |
25 | 24 | |
26 | 25 | test: |
27 | $(GO) $(GOFLAGS) test -covermode=atomic -coverprofile=cover.out ./... | |
26 | $(GOFLAGS) $(GO) test -covermode=atomic -coverprofile=cover.out ./... | |
28 | 27 | |
29 | 28 | html_coverage: test |
30 | $(GO) $(GOFLAGS) tool cover -html=cover.out -o cover.out.html | |
29 | $(GOFLAGS) $(GO) tool cover -html=cover.out -o cover.out.html | |
31 | 30 | |
32 | 31 | benchmark: server_deps |
33 | $(GO) $(GOFLAGS) test -v -run=doNotRunTests -bench=. -benchmem ./... | |
32 | $(GOFLAGS) $(GO) test -v -run=doNotRunTests -bench=. -benchmem ./... | |
34 | 33 | |
35 | 34 | fmt: |
36 | 35 | $(GO) fmt -s -w $(PACKAGES) |
39 | 38 | $(RM) $(TARGET) |
40 | 39 | $(RM) -r build |
41 | 40 | |
42 | .PHONY: all build build_with_race_detector resources install docker test html_coverage benchmark fmt clean⏎ | |
41 | .PHONY: all build build_with_race_detector resources install docker test html_coverage benchmark fmt clean |
1 | 1 | |
2 | 2 | const ( |
3 | 3 | Name = "bettercap" |
4 | Version = "2.31.1" | |
4 | Version = "2.32.0" | |
5 | 5 | Author = "Simone 'evilsocket' Margaritelli" |
6 | 6 | Website = "https://bettercap.org/" |
7 | 7 | ) |
0 | 0 | package core |
1 | 1 | |
2 | import "flag" | |
2 | import ( | |
3 | "flag" | |
4 | ) | |
3 | 5 | |
4 | 6 | type Options struct { |
5 | 7 | InterfaceName *string |
17 | 19 | MemProfile *string |
18 | 20 | CapletsPath *string |
19 | 21 | Script *string |
22 | PcapBufSize *int | |
20 | 23 | } |
21 | 24 | |
22 | 25 | func ParseOptions() (Options, error) { |
36 | 39 | MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."), |
37 | 40 | CapletsPath: flag.String("caplets-path", "", "Specify an alternative base path for caplets."), |
38 | 41 | Script: flag.String("script", "", "Load a session script."), |
42 | PcapBufSize: flag.Int("pcap-buf-size", -1, "PCAP buffer size, leave to 0 for the default value."), | |
39 | 43 | } |
40 | 44 | |
41 | 45 | flag.Parse() |
0 | 0 | module github.com/bettercap/bettercap |
1 | 1 | |
2 | go 1.12 | |
2 | go 1.16 | |
3 | 3 | |
4 | 4 | require ( |
5 | 5 | github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d |
6 | 6 | github.com/adrianmo/go-nmea v1.3.0 |
7 | 7 | github.com/antchfx/jsonquery v1.1.4 |
8 | github.com/antchfx/xpath v1.1.11 // indirect | |
8 | github.com/antchfx/xpath v1.2.0 // indirect | |
9 | 9 | github.com/bettercap/gatt v0.0.0-20210514133428-df6e615f2f67 |
10 | 10 | github.com/bettercap/nrf24 v0.0.0-20190219153547-aa37e6d0e0eb |
11 | 11 | github.com/bettercap/readline v0.0.0-20210228151553-655e48bcb7bf |
14 | 14 | github.com/chzyer/logex v1.1.10 // indirect |
15 | 15 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect |
16 | 16 | github.com/dustin/go-humanize v1.0.0 |
17 | github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e | |
17 | github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 | |
18 | 18 | github.com/elazarl/goproxy/ext v0.0.0-20210110162100-a92cc753f88e // indirect |
19 | 19 | github.com/evilsocket/islazy v1.10.6 |
20 | 20 | github.com/gobwas/glob v0.0.0-20181002190808-e7a84e9525fe |
26 | 26 | github.com/google/gousb v2.1.0+incompatible |
27 | 27 | github.com/gorilla/mux v1.8.0 |
28 | 28 | github.com/gorilla/websocket v1.4.2 |
29 | github.com/hashicorp/mdns v1.0.3 | |
29 | github.com/hashicorp/mdns v1.0.4 | |
30 | 30 | github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b |
31 | 31 | github.com/jpillora/go-tld v1.1.1 |
32 | 32 | github.com/koppacetic/go-gpsd v0.4.0 |
33 | 33 | github.com/kr/binarydist v0.1.0 // indirect |
34 | 34 | github.com/malfunkt/iprange v0.9.0 |
35 | github.com/mattn/go-isatty v0.0.13 // indirect | |
35 | 36 | github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b |
36 | github.com/miekg/dns v1.1.41 | |
37 | github.com/miekg/dns v1.1.43 | |
37 | 38 | github.com/mitchellh/go-homedir v1.1.0 |
38 | 39 | github.com/pkg/errors v0.9.1 // indirect |
39 | github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac | |
40 | github.com/robertkrimen/otto v0.0.0-20210614181706-373ff5438452 | |
40 | 41 | github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 |
41 | github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb | |
42 | golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 | |
43 | golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect | |
42 | github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64 | |
43 | golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d | |
44 | golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect | |
45 | golang.org/x/text v0.3.7 // indirect | |
44 | 46 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect |
45 | 47 | gopkg.in/sourcemap.v1 v1.0.5 // indirect |
46 | 48 | ) |
6 | 6 | github.com/antchfx/xpath v1.1.7/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= |
7 | 7 | github.com/antchfx/xpath v1.1.11 h1:WOFtK8TVAjLm3lbgqeP0arlHpvCEeTANeWZ/csPpJkQ= |
8 | 8 | github.com/antchfx/xpath v1.1.11/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= |
9 | github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8= | |
10 | github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= | |
9 | 11 | github.com/bettercap/gatt v0.0.0-20210514133428-df6e615f2f67 h1:xzN6806c01hWTz8gjGsRjhOPlYj5/dNoZIR8CN9+O1c= |
10 | 12 | github.com/bettercap/gatt v0.0.0-20210514133428-df6e615f2f67/go.mod h1:oafnPgaBI4gqJiYkueCyR4dqygiWGXTGOE0gmmAVeeQ= |
11 | 13 | github.com/bettercap/nrf24 v0.0.0-20190219153547-aa37e6d0e0eb h1:JWAAJk4ny+bT3VrtcX+e7mcmWtWUeUM0xVcocSAUuWc= |
28 | 30 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= |
29 | 31 | github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e h1:/cwV7t2xezilMljIftb7WlFtzGANRCnoOhPjtl2ifcs= |
30 | 32 | github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= |
33 | github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4 h1:lS3P5Nw3oPO05Lk2gFiYUOL3QPaH+fRoI1wFOc4G1UY= | |
34 | github.com/elazarl/goproxy v0.0.0-20210801061803-8e322dfb79c4/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= | |
31 | 35 | github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= |
32 | 36 | github.com/elazarl/goproxy/ext v0.0.0-20210110162100-a92cc753f88e h1:CQn2/8fi3kmpT9BTiHEELgdxAOQNVZc9GoPA4qnQzrs= |
33 | 37 | github.com/elazarl/goproxy/ext v0.0.0-20210110162100-a92cc753f88e/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= |
55 | 59 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |
56 | 60 | github.com/hashicorp/mdns v1.0.3 h1:hPneYJlzSjxFBmUlnDGXRykxBZ++dQAJhU57gCO7TzI= |
57 | 61 | github.com/hashicorp/mdns v1.0.3/go.mod h1:P9sIDVQGUBr2GtS4qS2QCBdtgqP7TBt6d8looU5l5r4= |
62 | github.com/hashicorp/mdns v1.0.4 h1:sY0CMhFmjIPDMlTB+HfymFHCaYLhgifZ0QhjaYKD/UQ= | |
63 | github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= | |
58 | 64 | github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b h1:IpLPmn6Re21F0MaV6Zsc5RdSE6KuoFpWmHiUSEs3PrE= |
59 | 65 | github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b/go.mod h1:aA6DnFhALT3zH0y+A39we+zbrdMC2N0X/q21e6FI0LU= |
60 | 66 | github.com/jpillora/go-tld v1.1.1 h1:P1ZwtKDHBYYUl235R/D64cdBARfGYzEy1Hg2Ikir3FQ= |
75 | 81 | github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= |
76 | 82 | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= |
77 | 83 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= |
84 | github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= | |
85 | github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | |
78 | 86 | github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b h1:r12blE3QRYlW1WBiBEe007O6NrTb/P54OjR5d4WLEGk= |
79 | 87 | github.com/mdlayher/dhcp6 v0.0.0-20190311162359-2a67805d7d0b/go.mod h1:p4K2+UAoap8Jzsadsxc0KG0OZjmmCthTPUyZqAVkjBY= |
80 | 88 | github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= |
84 | 92 | github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= |
85 | 93 | github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= |
86 | 94 | github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= |
95 | github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= | |
96 | github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= | |
87 | 97 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= |
88 | 98 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= |
89 | 99 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= |
92 | 102 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
93 | 103 | github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac h1:kYPjbEN6YPYWWHI6ky1J813KzIq/8+Wg4TO4xU7A/KU= |
94 | 104 | github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= |
105 | github.com/robertkrimen/otto v0.0.0-20210614181706-373ff5438452 h1:ewTtJ72GFy2e0e8uyiDwMG3pKCS5mBh+hdSTYsPKEP8= | |
106 | github.com/robertkrimen/otto v0.0.0-20210614181706-373ff5438452/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= | |
95 | 107 | github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= |
96 | 108 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
97 | 109 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= |
101 | 113 | github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= |
102 | 114 | github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb h1:EavwSqheIJl3nb91HhkL73DwnT2Fk8W3yM7T7TuLZvA= |
103 | 115 | github.com/thoj/go-ircevent v0.0.0-20190807115034-8e7ce4b5a1eb/go.mod h1:I0ZT9x8wStY6VOxtNOrLpnDURFs7HS0z1e1vhuKUEVc= |
116 | github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64 h1:l/T7dYuJEQZOwVOpjIXr1180aM9PZL/d1MnMVIxefX4= | |
117 | github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64/go.mod h1:Q1NAJOuRdQCqN/VIWdnaaEhV8LpeO2rtlBP7/iDJNII= | |
104 | 118 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
105 | 119 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= |
106 | 120 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= |
113 | 127 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
114 | 128 | golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 h1:4qWs8cYYH6PoEFy4dfhDFgoMGkwAcETd+MmPdCPMzUc= |
115 | 129 | golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= |
130 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |
131 | golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= | |
132 | golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | |
116 | 133 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
117 | 134 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= |
118 | 135 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
126 | 143 | golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
127 | 144 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
128 | 145 | golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
146 | golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | |
129 | 147 | golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= |
130 | 148 | golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
149 | golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 h1:rw6UNGRMfarCepjI8qOepea/SXwIBVfTKjztZ5gBbq4= | |
150 | golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
131 | 151 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |
132 | 152 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
133 | 153 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
134 | 154 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
135 | 155 | golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= |
136 | 156 | golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
157 | golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | |
158 | golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | |
137 | 159 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
138 | 160 | golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= |
139 | 161 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= |
3 | 3 | "bytes" |
4 | 4 | "compress/gzip" |
5 | 5 | "encoding/base64" |
6 | ||
6 | 7 | "github.com/robertkrimen/otto" |
7 | 8 | ) |
8 | 9 | |
12 | 13 | if err != nil { |
13 | 14 | return ReportError("Could not convert to string: %s", varValue) |
14 | 15 | } |
16 | ||
15 | 17 | return v |
16 | 18 | } |
17 | 19 | |
20 | 22 | if err != nil { |
21 | 23 | return ReportError("Could not decode string: %s", call.Argument(0).String()) |
22 | 24 | } |
25 | ||
23 | 26 | v, err := otto.ToValue(string(varValue)) |
24 | 27 | if err != nil { |
25 | 28 | return ReportError("Could not convert to string: %s", varValue) |
26 | 29 | } |
30 | ||
27 | 31 | return v |
28 | 32 | } |
29 | 33 |
2 | 2 | import ( |
3 | 3 | "bytes" |
4 | 4 | "fmt" |
5 | "github.com/robertkrimen/otto" | |
6 | 5 | "io" |
7 | 6 | "io/ioutil" |
8 | 7 | "net/http" |
9 | 8 | "net/url" |
10 | 9 | "strings" |
10 | ||
11 | "github.com/robertkrimen/otto" | |
11 | 12 | ) |
12 | 13 | |
13 | 14 | type httpPackage struct { |
25 | 26 | return url.QueryEscape(s) |
26 | 27 | } |
27 | 28 | |
28 | func (c httpPackage) Request(method string, uri string, headers map[string]string, form map[string]string, json string) httpResponse { | |
29 | func (c httpPackage) Request(method string, uri string, | |
30 | headers map[string]string, | |
31 | form map[string]string, | |
32 | json string) httpResponse { | |
29 | 33 | var reader io.Reader |
30 | 34 | |
31 | 35 | if form != nil { |
2 | 2 | import ( |
3 | 3 | "github.com/evilsocket/islazy/log" |
4 | 4 | "github.com/evilsocket/islazy/plugin" |
5 | ||
6 | 5 | "github.com/robertkrimen/otto" |
7 | 6 | ) |
8 | 7 |
174 | 174 | gwIP := mod.Session.Gateway.IP |
175 | 175 | myMAC := mod.Session.Interface.HW |
176 | 176 | for mod.Running() { |
177 | mod.arpSpoofTargets(gwIP, myMAC, true, true) | |
177 | mod.arpSpoofTargets(gwIP, myMAC, true, false) | |
178 | 178 | for _, address := range neighbours { |
179 | 179 | if !mod.Session.Skip(address) { |
180 | 180 | mod.arpSpoofTargets(address, myMAC, true, false) |
8 | 8 | "sync" |
9 | 9 | "time" |
10 | 10 | |
11 | "github.com/bettercap/bettercap/network" | |
11 | 12 | "github.com/bettercap/bettercap/packets" |
12 | 13 | "github.com/bettercap/bettercap/session" |
13 | 14 | |
82 | 83 | return session.ErrAlreadyStarted(mod.Name()) |
83 | 84 | } |
84 | 85 | |
85 | if mod.Handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { | |
86 | if mod.Handle, err = network.Capture(mod.Session.Interface.Name()); err != nil { | |
86 | 87 | return err |
87 | 88 | } |
88 | 89 |
7 | 7 | "sync" |
8 | 8 | |
9 | 9 | "github.com/bettercap/bettercap/log" |
10 | "github.com/bettercap/bettercap/network" | |
10 | 11 | "github.com/bettercap/bettercap/packets" |
11 | 12 | "github.com/bettercap/bettercap/session" |
12 | 13 | |
99 | 100 | |
100 | 101 | if mod.Running() { |
101 | 102 | return session.ErrAlreadyStarted(mod.Name()) |
102 | } else if mod.Handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { | |
103 | } else if mod.Handle, err = network.Capture(mod.Session.Interface.Name()); err != nil { | |
103 | 104 | return err |
104 | 105 | } else if err = mod.Handle.SetBPFFilter("udp"); err != nil { |
105 | 106 | return err |
4 | 4 | "net/http" |
5 | 5 | "net/url" |
6 | 6 | "regexp" |
7 | "strconv" | |
7 | 8 | "strings" |
8 | "strconv" | |
9 | 9 | |
10 | 10 | "github.com/bettercap/bettercap/log" |
11 | "github.com/bettercap/bettercap/modules/dns_spoof" | |
12 | "github.com/bettercap/bettercap/network" | |
11 | 13 | "github.com/bettercap/bettercap/session" |
12 | "github.com/bettercap/bettercap/modules/dns_spoof" | |
13 | 14 | |
14 | 15 | "github.com/elazarl/goproxy" |
15 | 16 | "github.com/google/gopacket" |
22 | 23 | ) |
23 | 24 | |
24 | 25 | var ( |
25 | httpsLinksParser = regexp.MustCompile(`https://[^"'/]+`) | |
26 | httpsLinksParser = regexp.MustCompile(`https://[^"'/]+`) | |
26 | 27 | domainCookieParser = regexp.MustCompile(`; ?(?i)domain=.*(;|$)`) |
27 | flagsCookieParser = regexp.MustCompile(`; ?(?i)(secure|httponly)`) | |
28 | flagsCookieParser = regexp.MustCompile(`; ?(?i)(secure|httponly)`) | |
28 | 29 | ) |
29 | 30 | |
30 | 31 | type SSLStripper struct { |
82 | 83 | if enabled && s.handle == nil { |
83 | 84 | var err error |
84 | 85 | |
85 | if s.handle, err = pcap.OpenLive(s.session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { | |
86 | if s.handle, err = network.Capture(s.session.Interface.Name()); err != nil { | |
86 | 87 | panic(err) |
87 | 88 | } |
88 | 89 | |
167 | 168 | origDomain := origParts[len(origParts)-2] + "." + origParts[len(origParts)-1] |
168 | 169 | strippedDomain := strippedParts[len(strippedParts)-2] + "." + strippedParts[len(strippedParts)-1] |
169 | 170 | |
170 | log.Info("[%s] Fixing cookies on %s", tui.Green("sslstrip"),tui.Bold(strippedHost.Hostname)) | |
171 | log.Info("[%s] Fixing cookies on %s", tui.Green("sslstrip"), tui.Bold(strippedHost.Hostname)) | |
171 | 172 | cookies := make([]string, len(res.Header["Set-Cookie"])) |
172 | 173 | // replace domain and strip "secure" flag for each cookie |
173 | 174 | for i, cookie := range res.Header["Set-Cookie"] { |
5 | 5 | "time" |
6 | 6 | |
7 | 7 | "github.com/bettercap/bettercap/log" |
8 | "github.com/bettercap/bettercap/network" | |
8 | 9 | "github.com/bettercap/bettercap/session" |
9 | 10 | |
10 | 11 | "github.com/google/gopacket/pcap" |
41 | 42 | * could hang waiting for a timeout to expire ... |
42 | 43 | */ |
43 | 44 | readTimeout := 500 * time.Millisecond |
44 | if ctx.Handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, readTimeout); err != nil { | |
45 | if ctx.Handle, err = network.CaptureWithTimeout(mod.Session.Interface.Name(), readTimeout); err != nil { | |
45 | 46 | return err, ctx |
46 | 47 | } |
47 | 48 | } else { |
6 | 6 | "sync/atomic" |
7 | 7 | "time" |
8 | 8 | |
9 | "github.com/bettercap/bettercap/network" | |
9 | 10 | "github.com/bettercap/bettercap/packets" |
10 | 11 | "github.com/bettercap/bettercap/session" |
11 | 12 | |
114 | 115 | return session.ErrAlreadyStarted(mod.Name()) |
115 | 116 | } |
116 | 117 | if mod.handle == nil { |
117 | if mod.handle, err = pcap.OpenLive(mod.Session.Interface.Name(), 65536, true, pcap.BlockForever); err != nil { | |
118 | if mod.handle, err = network.Capture(mod.Session.Interface.Name()); err != nil { | |
118 | 119 | return err |
119 | 120 | } else if err = mod.handle.SetBPFFilter(fmt.Sprintf("tcp dst port %d", synSourcePort)); err != nil { |
120 | 121 | return err |
8 | 8 | "os" |
9 | 9 | "path/filepath" |
10 | 10 | "regexp" |
11 | "runtime" | |
11 | 12 | |
12 | 13 | "github.com/bettercap/bettercap/session" |
13 | 14 | |
28 | 29 | uiPath string |
29 | 30 | } |
30 | 31 | |
32 | func getDefaultInstallBase() string { | |
33 | if runtime.GOOS == "windows" { | |
34 | return filepath.Join(os.Getenv("ALLUSERSPROFILE"), "bettercap") | |
35 | } | |
36 | return "/usr/local/share/bettercap/" | |
37 | } | |
38 | ||
31 | 39 | func NewUIModule(s *session.Session) *UIModule { |
32 | 40 | mod := &UIModule{ |
33 | 41 | SessionModule: session.NewSessionModule("ui", s), |
35 | 43 | } |
36 | 44 | |
37 | 45 | mod.AddParam(session.NewStringParameter("ui.basepath", |
38 | "/usr/local/share/bettercap/", | |
46 | getDefaultInstallBase(), | |
39 | 47 | "", |
40 | 48 | "UI base installation path.")) |
41 | 49 |
53 | 53 | assocSilent bool |
54 | 54 | assocOpen bool |
55 | 55 | assocAcquired bool |
56 | csaSilent bool | |
57 | fakeAuthSilent bool | |
56 | 58 | filterProbeSTA *regexp.Regexp |
57 | 59 | filterProbeAP *regexp.Regexp |
58 | 60 | apRunning bool |
87 | 89 | assocSilent: false, |
88 | 90 | assocOpen: false, |
89 | 91 | assocAcquired: false, |
92 | csaSilent: false, | |
93 | fakeAuthSilent: false, | |
90 | 94 | showManuf: false, |
91 | 95 | shakesAggregate: true, |
92 | 96 | writes: &sync.WaitGroup{}, |
213 | 217 | probe.Complete("wifi.probe", s.WiFiCompleterFull) |
214 | 218 | |
215 | 219 | mod.AddHandler(probe) |
220 | ||
221 | channelSwitchAnnounce := session.NewModuleHandler("wifi.channel_switch_announce bssid channel ", `wifi\.channel_switch_announce ((?:[a-fA-F0-9:]{11,}))\s+((?:[0-9]+))`, | |
222 | "Start a 802.11 channel hop attack, all client will be force to change the channel lead to connection down.", | |
223 | func(args []string) error { | |
224 | bssid, err := net.ParseMAC(args[0]) | |
225 | if err != nil { | |
226 | return err | |
227 | } | |
228 | channel, _ := strconv.Atoi(args[1]) | |
229 | if channel > 180 || channel < 1 { | |
230 | return fmt.Errorf("%d is not a valid channel number", channel) | |
231 | } | |
232 | return mod.startCSA(bssid, int8(channel)) | |
233 | }) | |
234 | ||
235 | channelSwitchAnnounce.Complete("wifi.channel_switch_announce", s.WiFiCompleterFull) | |
236 | ||
237 | mod.AddHandler(channelSwitchAnnounce) | |
238 | ||
239 | fakeAuth := session.NewModuleHandler("wifi.fake_auth bssid client", `wifi\.fake_auth ((?:[a-fA-F0-9:]{11,}))\s+((?:[a-fA-F0-9:]{11,}))`, | |
240 | "send an fake authentication with client mac to ap lead to client disconnect", | |
241 | func(args []string) error { | |
242 | bssid, err := net.ParseMAC(args[0]) | |
243 | if err != nil { | |
244 | return err | |
245 | } | |
246 | client, err := net.ParseMAC(args[1]) | |
247 | if err != nil { | |
248 | return err | |
249 | } | |
250 | return mod.startFakeAuth(bssid, client) | |
251 | }) | |
252 | ||
253 | fakeAuth.Complete("wifi.fake_auth", s.WiFiCompleterFull) | |
254 | ||
255 | mod.AddHandler(fakeAuth) | |
256 | ||
257 | mod.AddParam(session.NewBoolParameter("wifi.channel_switch_announce.silent", | |
258 | "false", | |
259 | "If true, messages from wifi.channel_switch_announce will be suppressed.")) | |
260 | ||
261 | mod.AddParam(session.NewBoolParameter("wifi.fake_auth.silent", | |
262 | "false", | |
263 | "If true, messages from wifi.fake_auth will be suppressed.")) | |
216 | 264 | |
217 | 265 | mod.AddParam(session.NewStringParameter("wifi.deauth.skip", |
218 | 266 | "", |
507 | 555 | } |
508 | 556 | } |
509 | 557 | |
510 | setRFMonMaybeFatal := false | |
558 | /* | |
559 | * We don't want to pcap.BlockForever otherwise pcap_close(handle) | |
560 | * could hang waiting for a timeout to expire ... | |
561 | */ | |
562 | opts := network.CAPTURE_DEFAULTS | |
563 | opts.Timeout = 500 * time.Millisecond | |
564 | opts.Monitor = true | |
565 | ||
511 | 566 | for retry := 0; ; retry++ { |
512 | ihandle, err := pcap.NewInactiveHandle(ifName) | |
513 | if err != nil { | |
514 | return fmt.Errorf("error while opening interface %s: %s", ifName, err) | |
515 | } | |
516 | defer ihandle.CleanUp() | |
517 | ||
518 | /* | |
519 | * Calling SetRFMon is fatal when the interface is already in monitor mode. | |
520 | * gopacket has no GetRFMon analogue to SetRFMon with which we could check this, however ... | |
521 | */ | |
522 | if !setRFMonMaybeFatal { | |
523 | if err = ihandle.SetRFMon(true); err != nil { | |
524 | return fmt.Errorf("error while setting interface %s in monitor mode: %s", tui.Bold(ifName), err) | |
567 | if mod.handle, err = network.CaptureWithOptions(ifName, opts); err == nil { | |
568 | // we're done | |
569 | break | |
570 | } else if retry == 0 && err.Error() == ErrIfaceNotUp { | |
571 | // try to bring interface up and try again | |
572 | mod.Info("interface %s is down, bringing it up ...", ifName) | |
573 | if err := network.ActivateInterface(ifName); err != nil { | |
574 | return err | |
525 | 575 | } |
576 | continue | |
577 | } else if !opts.Monitor { | |
578 | // second fatal error, just bail | |
579 | return fmt.Errorf("error while activating handle: %s", err) | |
526 | 580 | } else { |
527 | mod.Debug("SetRFMon on interface %s might be fatal, skipping this time", tui.Bold(ifName)) | |
528 | } | |
529 | if err = ihandle.SetSnapLen(65536); err != nil { | |
530 | return fmt.Errorf("error while settng snapshot length: %s", err) | |
531 | } | |
532 | /* | |
533 | * We don't want to pcap.BlockForever otherwise pcap_close(handle) | |
534 | * could hang waiting for a timeout to expire ... | |
535 | */ | |
536 | readTimeout := 500 * time.Millisecond | |
537 | if err = ihandle.SetTimeout(readTimeout); err != nil { | |
538 | return fmt.Errorf("error while setting timeout: %s", err) | |
539 | } else if mod.handle, err = ihandle.Activate(); err != nil { | |
540 | if retry == 0 && err.Error() == ErrIfaceNotUp { | |
541 | mod.Debug("interface %s is down, bringing it up ...", ifName) | |
542 | if err := network.ActivateInterface(ifName); err != nil { | |
543 | return err | |
544 | } | |
545 | continue | |
546 | } | |
547 | if setRFMonMaybeFatal { | |
548 | return fmt.Errorf("error while activating handle: %s", err) | |
549 | } else { | |
550 | mod.Warning("error while activating handle: %s, %s", err, tui.Bold("interface might already be monitoring. retrying!")) | |
551 | setRFMonMaybeFatal = true | |
552 | continue | |
553 | } | |
554 | } | |
555 | ||
556 | break | |
581 | // first fatal error, try again without setting the interface in monitor mode | |
582 | mod.Warning("error while activating handle: %s, %s", err, tui.Bold("interface might already be monitoring. retrying!")) | |
583 | opts.Monitor = false | |
584 | } | |
557 | 585 | } |
558 | 586 | } |
559 | 587 |
0 | package wifi | |
1 | ||
2 | import ( | |
3 | "bytes" | |
4 | "fmt" | |
5 | "github.com/bettercap/bettercap/network" | |
6 | "github.com/bettercap/bettercap/packets" | |
7 | "github.com/google/gopacket/layers" | |
8 | "net" | |
9 | ) | |
10 | ||
11 | func (mod *WiFiModule) isCSASilent() bool { | |
12 | if err, is := mod.BoolParam("wifi.channel_switch_announce.silent"); err != nil { | |
13 | mod.Warning("%v", err) | |
14 | } else { | |
15 | mod.csaSilent = is | |
16 | } | |
17 | return mod.csaSilent | |
18 | } | |
19 | ||
20 | func (mod *WiFiModule) sendBeaconWithCSAPacket(ap *network.AccessPoint, toChan int8) { | |
21 | ssid := ap.ESSID() | |
22 | if ssid == "<hidden>" { | |
23 | ssid = "" | |
24 | } | |
25 | hw, _ := net.ParseMAC(ap.BSSID()) | |
26 | ||
27 | for seq := uint16(0); seq < 256 && mod.Running(); seq++ { | |
28 | if err, pkt := packets.NewDot11Beacon(packets.Dot11ApConfig{ | |
29 | SSID: ssid, | |
30 | BSSID: hw, | |
31 | Channel: ap.Channel, | |
32 | Encryption: false, | |
33 | SpectrumManagement: true, | |
34 | }, 0, packets.Dot11Info(layers.Dot11InformationElementIDSwitchChannelAnnounce, []byte{0, byte(toChan), 1})); err != nil { | |
35 | mod.Error("could not create beacon packet: %s", err) | |
36 | continue | |
37 | } else { | |
38 | mod.injectPacket(pkt) | |
39 | } | |
40 | } | |
41 | } | |
42 | ||
43 | func (mod *WiFiModule) startCSA(to net.HardwareAddr, toChan int8) error { | |
44 | // if not already running, temporarily enable the pcap handle | |
45 | // for packet injection | |
46 | if !mod.Running() { | |
47 | if err := mod.Configure(); err != nil { | |
48 | return err | |
49 | } | |
50 | defer mod.handle.Close() | |
51 | } | |
52 | ||
53 | var ap *network.AccessPoint = nil | |
54 | ||
55 | for _, _ap := range mod.Session.WiFi.List() { | |
56 | if bytes.Equal(_ap.HW, to) { | |
57 | ap = _ap | |
58 | } | |
59 | ||
60 | } | |
61 | ||
62 | if ap == nil { | |
63 | return fmt.Errorf("%s is an unknown BSSID", to.String()) | |
64 | } | |
65 | ||
66 | mod.writes.Add(1) | |
67 | go func() { | |
68 | defer mod.writes.Done() | |
69 | ||
70 | if mod.Running() { | |
71 | logger := mod.Info | |
72 | if mod.isCSASilent() { | |
73 | logger = mod.Debug | |
74 | } | |
75 | logger("channel hop attack in AP %s (channel:%d encryption:%s), hop to channel %d ", ap.ESSID(), ap.Channel, ap.Encryption, toChan) | |
76 | // send the beacon frame with channel switch announce element id | |
77 | mod.onChannel(ap.Channel, func() { | |
78 | mod.sendBeaconWithCSAPacket(ap, toChan) | |
79 | }) | |
80 | } | |
81 | ||
82 | }() | |
83 | ||
84 | return nil | |
85 | } |
0 | package wifi | |
1 | ||
2 | import ( | |
3 | "bytes" | |
4 | "fmt" | |
5 | "github.com/bettercap/bettercap/network" | |
6 | "github.com/bettercap/bettercap/packets" | |
7 | "net" | |
8 | ) | |
9 | ||
10 | ||
11 | func (mod *WiFiModule) isFakeAuthSilent() bool { | |
12 | if err, is := mod.BoolParam("wifi.fake_auth.silent"); err != nil { | |
13 | mod.Warning("%v", err) | |
14 | } else { | |
15 | mod.csaSilent = is | |
16 | } | |
17 | return mod.csaSilent | |
18 | } | |
19 | ||
20 | func(mod *WiFiModule)sendFakeAuthPacket(bssid,client net.HardwareAddr){ | |
21 | err,pkt:=packets.NewDot11Auth(client,bssid,0) | |
22 | if err!=nil{ | |
23 | mod.Error("could not create authentication packet: %s", err) | |
24 | return | |
25 | } | |
26 | for i:=0;i<32;i++{ | |
27 | mod.injectPacket(pkt) | |
28 | } | |
29 | } | |
30 | ||
31 | func (mod *WiFiModule) startFakeAuth(bssid,client net.HardwareAddr) error { | |
32 | // if not already running, temporarily enable the pcap handle | |
33 | // for packet injection | |
34 | if !mod.Running() { | |
35 | if err := mod.Configure(); err != nil { | |
36 | return err | |
37 | } | |
38 | defer mod.handle.Close() | |
39 | } | |
40 | ||
41 | var ap *network.AccessPoint = nil | |
42 | ||
43 | for _, _ap := range mod.Session.WiFi.List() { | |
44 | if bytes.Equal(_ap.HW, bssid) { | |
45 | ap = _ap | |
46 | } | |
47 | } | |
48 | ||
49 | if ap == nil { | |
50 | return fmt.Errorf("%s is an unknown BSSID", bssid.String()) | |
51 | } | |
52 | ||
53 | mod.writes.Add(1) | |
54 | go func() { | |
55 | defer mod.writes.Done() | |
56 | ||
57 | if mod.Running() { | |
58 | logger := mod.Info | |
59 | if mod.isFakeAuthSilent() { | |
60 | logger = mod.Debug | |
61 | } | |
62 | logger("fake authentication attack in AP: %s client: %s", ap.ESSID(), client.String()) | |
63 | // send the beacon frame with channel switch announce element id | |
64 | mod.onChannel(ap.Channel, func() { | |
65 | mod.sendFakeAuthPacket(bssid,client) | |
66 | }) | |
67 | } | |
68 | }() | |
69 | return nil | |
70 | }⏎ |
0 | package network | |
1 | ||
2 | import ( | |
3 | "fmt" | |
4 | "time" | |
5 | ||
6 | "github.com/evilsocket/islazy/tui" | |
7 | "github.com/google/gopacket/pcap" | |
8 | ) | |
9 | ||
10 | const ( | |
11 | PCAP_DEFAULT_SETRF = false | |
12 | PCAP_DEFAULT_SNAPLEN = 65536 | |
13 | PCAP_DEFAULT_BUFSIZE = 2_097_152 | |
14 | PCAP_DEFAULT_PROMISC = true | |
15 | PCAP_DEFAULT_TIMEOUT = pcap.BlockForever | |
16 | ) | |
17 | ||
18 | var CAPTURE_DEFAULTS = CaptureOptions{ | |
19 | Monitor: PCAP_DEFAULT_SETRF, | |
20 | Snaplen: PCAP_DEFAULT_SNAPLEN, | |
21 | Bufsize: PCAP_DEFAULT_BUFSIZE, | |
22 | Promisc: PCAP_DEFAULT_PROMISC, | |
23 | Timeout: PCAP_DEFAULT_TIMEOUT, | |
24 | } | |
25 | ||
26 | type CaptureOptions struct { | |
27 | Monitor bool | |
28 | Snaplen int | |
29 | Bufsize int | |
30 | Promisc bool | |
31 | Timeout time.Duration | |
32 | } | |
33 | ||
34 | func CaptureWithOptions(ifName string, options CaptureOptions) (*pcap.Handle, error) { | |
35 | Debug("creating capture for '%s' with options: %+v", ifName, options) | |
36 | ||
37 | ihandle, err := pcap.NewInactiveHandle(ifName) | |
38 | if err != nil { | |
39 | return nil, fmt.Errorf("error while opening interface %s: %s", ifName, err) | |
40 | } | |
41 | defer ihandle.CleanUp() | |
42 | ||
43 | if options.Monitor { | |
44 | if err = ihandle.SetRFMon(true); err != nil { | |
45 | return nil, fmt.Errorf("error while setting interface %s in monitor mode: %s", tui.Bold(ifName), err) | |
46 | } | |
47 | } | |
48 | ||
49 | if err = ihandle.SetSnapLen(options.Snaplen); err != nil { | |
50 | return nil, fmt.Errorf("error while settng snapshot length: %s", err) | |
51 | } else if err = ihandle.SetBufferSize(options.Bufsize); err != nil { | |
52 | return nil, fmt.Errorf("error while settng buffer size: %s", err) | |
53 | } else if err = ihandle.SetPromisc(options.Promisc); err != nil { | |
54 | return nil, fmt.Errorf("error while settng promiscuous mode to %v: %s", options.Promisc, err) | |
55 | } else if err = ihandle.SetTimeout(options.Timeout); err != nil { | |
56 | return nil, fmt.Errorf("error while settng snapshot length: %s", err) | |
57 | } | |
58 | ||
59 | return ihandle.Activate() | |
60 | } | |
61 | ||
62 | func Capture(ifName string) (*pcap.Handle, error) { | |
63 | return CaptureWithOptions(ifName, CAPTURE_DEFAULTS) | |
64 | } | |
65 | ||
66 | func CaptureWithTimeout(ifName string, timeout time.Duration) (*pcap.Handle, error) { | |
67 | var opts = CAPTURE_DEFAULTS | |
68 | opts.Timeout = timeout | |
69 | return CaptureWithOptions(ifName, opts) | |
70 | } |
22 | 22 | return 14 |
23 | 23 | } else if freq >= 5035 && freq <= 5865 { |
24 | 24 | return ((freq - 5035) / 5) + 7 |
25 | } else if freq >= 5875 && freq <= 5895 { | |
26 | return 177 | |
25 | 27 | } |
26 | 28 | return 0 |
27 | 29 | } |
33 | 35 | return 2484 |
34 | 36 | } else if channel <= 173 { |
35 | 37 | return ((channel - 7) * 5) + 5035 |
38 | } else if channel == 177 { | |
39 | return 5885 | |
36 | 40 | } |
37 | 41 | |
38 | 42 | return 0 |
5 | 5 | "github.com/evilsocket/islazy/data" |
6 | 6 | ) |
7 | 7 | |
8 | // Define test data for dot11 frequency <-> channel tests | |
9 | type dot11pair struct { | |
10 | frequency int | |
11 | channel int | |
12 | } | |
13 | ||
14 | var dot11TestVector = []dot11pair{ | |
15 | {2472, 13}, | |
16 | {2484, 14}, | |
17 | {5825, 165}, | |
18 | {5885, 177}, | |
19 | } | |
20 | ||
8 | 21 | func buildExampleWiFi() *WiFi { |
9 | 22 | aliases := &data.UnsortedKV{} |
10 | 23 | return NewWiFi(buildExampleEndpoint(), aliases, func(ap *AccessPoint) {}, func(ap *AccessPoint) {}) |
11 | 24 | } |
12 | 25 | |
13 | 26 | func TestDot11Freq2Chan(t *testing.T) { |
14 | exampleFreq := 2472 | |
15 | exp := 13 | |
16 | got := Dot11Freq2Chan(exampleFreq) | |
17 | if got != exp { | |
18 | t.Fatalf("expected '%v', got '%v'", exp, got) | |
27 | for _, entry := range dot11TestVector { | |
28 | gotChannel := Dot11Freq2Chan(entry.frequency) | |
29 | if gotChannel != entry.channel { | |
30 | t.Fatalf("expected '%v', got '%v'", entry.channel, gotChannel) | |
31 | } | |
19 | 32 | } |
20 | 33 | } |
21 | 34 | |
22 | 35 | func TestDot11Chan2Freq(t *testing.T) { |
23 | exampleChan := 13 | |
24 | exp := 2472 | |
25 | got := Dot11Chan2Freq(exampleChan) | |
26 | if got != exp { | |
27 | t.Fatalf("expected '%v', got '%v'", exp, got) | |
36 | for _, entry := range dot11TestVector { | |
37 | gotFrequency := Dot11Chan2Freq(entry.channel) | |
38 | if gotFrequency != entry.frequency { | |
39 | t.Fatalf("expected '%v', got '%v'", entry.frequency, gotFrequency) | |
40 | } | |
28 | 41 | } |
29 | 42 | } |
30 | 43 |
12 | 12 | var ( |
13 | 13 | openFlags = 1057 |
14 | 14 | wpaFlags = 1041 |
15 | specManFlag = 1<<8 | |
15 | 16 | durationID = uint16(0x013a) |
16 | 17 | capabilityInfo = uint16(0x0411) |
17 | 18 | listenInterval = uint16(3) |
36 | 37 | ) |
37 | 38 | |
38 | 39 | type Dot11ApConfig struct { |
39 | SSID string | |
40 | BSSID net.HardwareAddr | |
41 | Channel int | |
42 | Encryption bool | |
40 | SSID string | |
41 | BSSID net.HardwareAddr | |
42 | Channel int | |
43 | Encryption bool | |
44 | SpectrumManagement bool | |
43 | 45 | } |
44 | 46 | |
45 | 47 | func Dot11Info(id layers.Dot11InformationElementID, info []byte) *layers.Dot11InformationElement { |
50 | 52 | } |
51 | 53 | } |
52 | 54 | |
53 | func NewDot11Beacon(conf Dot11ApConfig, seq uint16) (error, []byte) { | |
55 | func NewDot11Beacon(conf Dot11ApConfig, seq uint16, extendDot11Info ...*layers.Dot11InformationElement) (error, []byte) { | |
54 | 56 | flags := openFlags |
55 | 57 | if conf.Encryption { |
56 | 58 | flags = wpaFlags |
57 | 59 | } |
58 | ||
60 | if conf.SpectrumManagement { | |
61 | flags |= specManFlag | |
62 | } | |
59 | 63 | stack := []gopacket.SerializableLayer{ |
60 | 64 | &layers.RadioTap{ |
61 | 65 | DBMAntennaSignal: int8(-10), |
76 | 80 | Dot11Info(layers.Dot11InformationElementIDRates, fakeApRates), |
77 | 81 | Dot11Info(layers.Dot11InformationElementIDDSSet, []byte{byte(conf.Channel & 0xff)}), |
78 | 82 | } |
79 | ||
83 | for _, v := range extendDot11Info { | |
84 | stack = append(stack, v) | |
85 | } | |
80 | 86 | if conf.Encryption { |
81 | 87 | stack = append(stack, &layers.Dot11InformationElement{ |
82 | 88 | ID: layers.Dot11InformationElementIDRSNInfo, |
176 | 176 | size := len(data) |
177 | 177 | for offset := 3; offset < size; { |
178 | 178 | idByte := uint8(data[offset]) |
179 | sizeByte := uint8(data[offset+1]) | |
180 | if idByte == wpsVersion2ID { | |
181 | verByte := fmt.Sprintf("%x", data[offset+2]) | |
182 | (*info)["Version"] = wpsVersionDesc[verByte] | |
183 | data = data[offset+3:] | |
179 | if next := offset + 1; next < size { | |
180 | sizeByte := uint8(data[next]) | |
181 | if idByte == wpsVersion2ID { | |
182 | if next = offset + 2; next < size { | |
183 | verByte := fmt.Sprintf("%x", data[next]) | |
184 | (*info)["Version"] = wpsVersionDesc[verByte] | |
185 | if next = offset + 3; next < size { | |
186 | data = data[next:] | |
187 | } | |
188 | break | |
189 | } | |
190 | } | |
191 | offset += int(sizeByte) + 2 | |
192 | } else { | |
184 | 193 | break |
185 | 194 | } |
186 | offset += int(sizeByte) + 2 | |
187 | 195 | } |
188 | 196 | } |
189 | 197 | return hex.EncodeToString(data) |
4 | 4 | "strings" |
5 | 5 | |
6 | 6 | "github.com/evilsocket/islazy/str" |
7 | ||
8 | 7 | "github.com/google/gopacket" |
9 | 8 | "github.com/google/gopacket/layers" |
10 | 9 | ) |
68 | 68 | } |
69 | 69 | |
70 | 70 | if q.active { |
71 | if q.handle, err = pcap.OpenLive(iface.Name(), 1024, true, pcap.BlockForever); err != nil { | |
71 | if q.handle, err = network.Capture(iface.Name()); err != nil { | |
72 | 72 | return |
73 | 73 | } |
74 | 74 |
0 | 0 | package routing |
1 | 1 | |
2 | 2 | import ( |
3 | "regexp" | |
4 | "strings" | |
5 | ||
3 | 6 | "github.com/bettercap/bettercap/core" |
4 | 7 | "github.com/evilsocket/islazy/str" |
5 | "regexp" | |
6 | "strings" | |
7 | 8 | ) |
8 | 9 | |
9 | 10 | var parser = regexp.MustCompile(`^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+).*$`) |
1 | 1 | |
2 | 2 | import ( |
3 | 3 | "fmt" |
4 | "github.com/bettercap/bettercap/caplets" | |
5 | _ "github.com/bettercap/bettercap/js" | |
6 | "github.com/evilsocket/islazy/fs" | |
7 | "github.com/evilsocket/islazy/plugin" | |
8 | "github.com/evilsocket/islazy/str" | |
9 | 4 | "io/ioutil" |
10 | 5 | "path/filepath" |
11 | 6 | "regexp" |
12 | 7 | "strings" |
8 | ||
9 | "github.com/bettercap/bettercap/caplets" | |
10 | _ "github.com/bettercap/bettercap/js" | |
11 | ||
12 | "github.com/evilsocket/islazy/fs" | |
13 | "github.com/evilsocket/islazy/plugin" | |
14 | "github.com/evilsocket/islazy/str" | |
13 | 15 | ) |
14 | 16 | |
15 | 17 | // require("telegram.js") |
36 | 38 | filepath.Join(caplets.InstallBase, fileName), |
37 | 39 | } |
38 | 40 | |
39 | if strings.Contains(fileName, ".js") == false { | |
41 | if !strings.Contains(fileName, ".js") { | |
40 | 42 | searchPaths = append(searchPaths, []string{ |
41 | 43 | filepath.Join(basePath, fileName) + ".js", |
42 | 44 | filepath.Join(caplets.InstallBase, fileName) + ".js", |