mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
Refactoring modules
This commit is contained in:
parent
c0d3c314fc
commit
ed652622e2
89 changed files with 186 additions and 138 deletions
27
main.go
27
main.go
|
@ -35,31 +35,8 @@ func main() {
|
||||||
|
|
||||||
fmt.Printf("%s (type '%s' for a list of commands)\n\n", tui.Bold(appName), tui.Bold("help"))
|
fmt.Printf("%s (type '%s' for a list of commands)\n\n", tui.Bold(appName), tui.Bold("help"))
|
||||||
|
|
||||||
sess.Register(modules.NewEventsStream(sess))
|
// Load all modules
|
||||||
sess.Register(modules.NewTicker(sess))
|
modules.LoadModules(sess)
|
||||||
sess.Register(modules.NewUpdateModule(sess))
|
|
||||||
sess.Register(modules.NewCapletsModule(sess))
|
|
||||||
sess.Register(modules.NewMacChanger(sess))
|
|
||||||
sess.Register(modules.NewProber(sess))
|
|
||||||
sess.Register(modules.NewDiscovery(sess))
|
|
||||||
sess.Register(modules.NewArpSpoofer(sess))
|
|
||||||
sess.Register(modules.NewDHCP6Spoofer(sess))
|
|
||||||
sess.Register(modules.NewDNSSpoofer(sess))
|
|
||||||
sess.Register(modules.NewSniffer(sess))
|
|
||||||
sess.Register(modules.NewPacketProxy(sess))
|
|
||||||
sess.Register(modules.NewAnyProxy(sess))
|
|
||||||
sess.Register(modules.NewTcpProxy(sess))
|
|
||||||
sess.Register(modules.NewHttpProxy(sess))
|
|
||||||
sess.Register(modules.NewHttpsProxy(sess))
|
|
||||||
sess.Register(modules.NewHttpServer(sess))
|
|
||||||
sess.Register(modules.NewHttpsServer(sess))
|
|
||||||
sess.Register(modules.NewRestAPI(sess))
|
|
||||||
sess.Register(modules.NewWOL(sess))
|
|
||||||
sess.Register(modules.NewWiFiModule(sess))
|
|
||||||
sess.Register(modules.NewBLERecon(sess))
|
|
||||||
sess.Register(modules.NewSynScanner(sess))
|
|
||||||
sess.Register(modules.NewGPS(sess))
|
|
||||||
sess.Register(modules.NewMySQLServer(sess))
|
|
||||||
|
|
||||||
if err = sess.Start(); err != nil {
|
if err = sess.Start(); err != nil {
|
||||||
log.Fatal("%s", err)
|
log.Fatal("%s", err)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package any_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/firewall"
|
"github.com/bettercap/bettercap/firewall"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package api_rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package api_rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/subtle"
|
"crypto/subtle"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package api_rest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package arp_spoof
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package ble
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/gatt"
|
"github.com/bettercap/gatt"
|
|
@ -1,7 +1,7 @@
|
||||||
// +build !windows
|
// +build !windows
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
|
|
||||||
package modules
|
package ble
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
|
@ -1,7 +1,7 @@
|
||||||
// +build !windows
|
// +build !windows
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
|
|
||||||
package modules
|
package ble
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
|
@ -1,7 +1,7 @@
|
||||||
// +build !windows
|
// +build !windows
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
|
|
||||||
package modules
|
package ble
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
|
@ -1,7 +1,7 @@
|
||||||
// +build !windows
|
// +build !windows
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
|
|
||||||
package modules
|
package ble
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,6 +1,6 @@
|
||||||
// +build windows darwin
|
// +build windows darwin
|
||||||
|
|
||||||
package modules
|
package ble
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package caplets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package dhcp6_spoof
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,6 +1,7 @@
|
||||||
package modules
|
package discovery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/bettercap/bettercap/modules/utils"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
|
@ -10,7 +11,7 @@ import (
|
||||||
|
|
||||||
type Discovery struct {
|
type Discovery struct {
|
||||||
session.SessionModule
|
session.SessionModule
|
||||||
selector *ViewSelector
|
selector *utils.ViewSelector
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDiscovery(s *session.Session) *Discovery {
|
func NewDiscovery(s *session.Session) *Discovery {
|
||||||
|
@ -52,7 +53,8 @@ func NewDiscovery(s *session.Session) *Discovery {
|
||||||
return d.showMeta(args[0])
|
return d.showMeta(args[0])
|
||||||
}))
|
}))
|
||||||
|
|
||||||
d.selector = ViewSelectorFor(&d.SessionModule, "net.show", []string{"ip", "mac", "seen", "sent", "rcvd"}, "ip asc")
|
d.selector = utils.ViewSelectorFor(&d.SessionModule, "net.show", []string{"ip", "mac", "seen", "sent", "rcvd"},
|
||||||
|
"ip asc")
|
||||||
|
|
||||||
return d
|
return d
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package discovery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -16,9 +16,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
aliveTimeInterval = time.Duration(10) * time.Second
|
AliveTimeInterval = time.Duration(10) * time.Second
|
||||||
presentTimeInterval = time.Duration(1) * time.Minute
|
PresentTimeInterval = time.Duration(1) * time.Minute
|
||||||
justJoinedTimeInterval = time.Duration(10) * time.Second
|
JustJoinedTimeInterval = time.Duration(10) * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProtoPair struct {
|
type ProtoPair struct {
|
||||||
|
@ -42,7 +42,7 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
// if endpoint was not found in ARP at least once
|
// if endpoint was not found in ARP at least once
|
||||||
addr = tui.Dim(addr)
|
addr = tui.Dim(addr)
|
||||||
mac = tui.Dim(mac)
|
mac = tui.Dim(mac)
|
||||||
} else if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval {
|
} else if sinceStarted > (JustJoinedTimeInterval*2) && sinceFirstSeen <= JustJoinedTimeInterval {
|
||||||
// if endpoint was first seen in the last 10 seconds
|
// if endpoint was first seen in the last 10 seconds
|
||||||
addr = tui.Bold(addr)
|
addr = tui.Bold(addr)
|
||||||
mac = tui.Bold(mac)
|
mac = tui.Bold(mac)
|
||||||
|
@ -67,10 +67,10 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
|
|
||||||
seen := e.LastSeen.Format("15:04:05")
|
seen := e.LastSeen.Format("15:04:05")
|
||||||
sinceLastSeen := time.Since(e.LastSeen)
|
sinceLastSeen := time.Since(e.LastSeen)
|
||||||
if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval {
|
if sinceStarted > AliveTimeInterval && sinceLastSeen <= AliveTimeInterval {
|
||||||
// if endpoint seen in the last 10 seconds
|
// if endpoint seen in the last 10 seconds
|
||||||
seen = tui.Bold(seen)
|
seen = tui.Bold(seen)
|
||||||
} else if sinceLastSeen <= presentTimeInterval {
|
} else if sinceLastSeen <= PresentTimeInterval {
|
||||||
// if endpoint seen in the last 60 seconds
|
// if endpoint seen in the last 60 seconds
|
||||||
} else {
|
} else {
|
||||||
// not seen in a while
|
// not seen in a while
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package discovery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package dns_spoof
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package dns_spoof
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,7 +1,8 @@
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/bettercap/bettercap/modules/net_sniff"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -9,6 +10,8 @@ import (
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
|
|
||||||
|
"github.com/bettercap/bettercap/modules/syn_scan"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/tui"
|
"github.com/evilsocket/islazy/tui"
|
||||||
|
@ -78,12 +81,12 @@ func (s *EventsStream) viewSnifferEvent(e session.Event) {
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
tui.Green(e.Tag),
|
tui.Green(e.Tag),
|
||||||
e.Data.(SnifferEvent).Message)
|
e.Data.(net_sniff.SnifferEvent).Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewSynScanEvent(e session.Event) {
|
func (s *EventsStream) viewSynScanEvent(e session.Event) {
|
||||||
se := e.Data.(SynScanEvent)
|
se := e.Data.(syn_scan.SynScanEvent)
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] found open port %d for %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] found open port %d for %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
tui.Green(e.Tag),
|
tui.Green(e.Tag),
|
|
@ -1,7 +1,7 @@
|
||||||
// +build !windows
|
// +build !windows
|
||||||
// +build !darwin
|
// +build !darwin
|
||||||
|
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,6 +1,6 @@
|
||||||
// +build windows darwin
|
// +build windows darwin
|
||||||
|
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/bettercap/bettercap/modules/net_sniff"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -19,7 +20,7 @@ var (
|
||||||
reJsonKey = regexp.MustCompile(`("[^"]+"):`)
|
reJsonKey = regexp.MustCompile(`("[^"]+"):`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *EventsStream) shouldDumpHttpRequest(req HTTPRequest) bool {
|
func (s *EventsStream) shouldDumpHttpRequest(req net_sniff.HTTPRequest) bool {
|
||||||
if s.dumpHttpReqs {
|
if s.dumpHttpReqs {
|
||||||
// dump all
|
// dump all
|
||||||
return true
|
return true
|
||||||
|
@ -37,7 +38,7 @@ func (s *EventsStream) shouldDumpHttpRequest(req HTTPRequest) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) shouldDumpHttpResponse(res HTTPResponse) bool {
|
func (s *EventsStream) shouldDumpHttpResponse(res net_sniff.HTTPResponse) bool {
|
||||||
if s.dumpHttpResp {
|
if s.dumpHttpResp {
|
||||||
return true
|
return true
|
||||||
} else if strings.Contains(res.ContentType, "text/plain") {
|
} else if strings.Contains(res.ContentType, "text/plain") {
|
||||||
|
@ -119,8 +120,8 @@ func (s *EventsStream) dumpRaw(body []byte) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewHttpRequest(e session.Event) {
|
func (s *EventsStream) viewHttpRequest(e session.Event) {
|
||||||
se := e.Data.(SnifferEvent)
|
se := e.Data.(net_sniff.SnifferEvent)
|
||||||
req := se.Data.(HTTPRequest)
|
req := se.Data.(net_sniff.HTTPRequest)
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
||||||
|
@ -157,8 +158,8 @@ func (s *EventsStream) viewHttpRequest(e session.Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewHttpResponse(e session.Event) {
|
func (s *EventsStream) viewHttpResponse(e session.Event) {
|
||||||
se := e.Data.(SnifferEvent)
|
se := e.Data.(net_sniff.SnifferEvent)
|
||||||
res := se.Data.(HTTPResponse)
|
res := se.Data.(net_sniff.HTTPResponse)
|
||||||
|
|
||||||
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
fmt.Fprintf(s.output, "[%s] [%s] %s\n",
|
||||||
e.Time.Format(eventTimeFormat),
|
e.Time.Format(eventTimeFormat),
|
|
@ -1,7 +1,8 @@
|
||||||
package modules
|
package events_stream
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/bettercap/bettercap/modules/wifi"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
||||||
|
@ -44,7 +45,7 @@ func (s *EventsStream) viewWiFiApEvent(e session.Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewWiFiClientProbeEvent(e session.Event) {
|
func (s *EventsStream) viewWiFiClientProbeEvent(e session.Event) {
|
||||||
probe := e.Data.(WiFiProbeEvent)
|
probe := e.Data.(wifi.WiFiProbeEvent)
|
||||||
desc := ""
|
desc := ""
|
||||||
if probe.FromAlias != "" {
|
if probe.FromAlias != "" {
|
||||||
desc = fmt.Sprintf(" (%s)", probe.FromAlias)
|
desc = fmt.Sprintf(" (%s)", probe.FromAlias)
|
||||||
|
@ -66,7 +67,7 @@ func (s *EventsStream) viewWiFiClientProbeEvent(e session.Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewWiFiHandshakeEvent(e session.Event) {
|
func (s *EventsStream) viewWiFiHandshakeEvent(e session.Event) {
|
||||||
hand := e.Data.(WiFiHandshakeEvent)
|
hand := e.Data.(wifi.WiFiHandshakeEvent)
|
||||||
|
|
||||||
from := hand.Station.String()
|
from := hand.Station.String()
|
||||||
to := hand.AP.String()
|
to := hand.AP.String()
|
||||||
|
@ -91,7 +92,7 @@ func (s *EventsStream) viewWiFiHandshakeEvent(e session.Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *EventsStream) viewWiFiClientEvent(e session.Event) {
|
func (s *EventsStream) viewWiFiClientEvent(e session.Event) {
|
||||||
ce := e.Data.(WiFiClientEvent)
|
ce := e.Data.(wifi.WiFiClientEvent)
|
||||||
|
|
||||||
ce.Client.Alias = s.Session.Lan.GetAlias(ce.Client.BSSID())
|
ce.Client.Alias = s.Session.Lan.GetAlias(ce.Client.BSSID())
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package gps
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package http_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,22 +1,23 @@
|
||||||
package modules
|
package https_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
||||||
"github.com/bettercap/bettercap/tls"
|
"github.com/bettercap/bettercap/tls"
|
||||||
|
"github.com/bettercap/bettercap/modules/http_proxy"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/fs"
|
"github.com/evilsocket/islazy/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpsProxy struct {
|
type HttpsProxy struct {
|
||||||
session.SessionModule
|
session.SessionModule
|
||||||
proxy *HTTPProxy
|
proxy *http_proxy.HTTPProxy
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHttpsProxy(s *session.Session) *HttpsProxy {
|
func NewHttpsProxy(s *session.Session) *HttpsProxy {
|
||||||
p := &HttpsProxy{
|
p := &HttpsProxy{
|
||||||
SessionModule: session.NewSessionModule("https.proxy", s),
|
SessionModule: session.NewSessionModule("https.proxy", s),
|
||||||
proxy: NewHTTPProxy(s),
|
proxy: http_proxy.NewHTTPProxy(s),
|
||||||
}
|
}
|
||||||
|
|
||||||
p.AddParam(session.NewIntParameter("https.port",
|
p.AddParam(session.NewIntParameter("https.port",
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package https_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package mac_changer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
61
modules/modules.go
Normal file
61
modules/modules.go
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package modules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/bettercap/bettercap/modules/any_proxy"
|
||||||
|
"github.com/bettercap/bettercap/modules/api_rest"
|
||||||
|
"github.com/bettercap/bettercap/modules/arp_spoof"
|
||||||
|
"github.com/bettercap/bettercap/modules/ble"
|
||||||
|
"github.com/bettercap/bettercap/modules/caplets"
|
||||||
|
"github.com/bettercap/bettercap/modules/dhcp6_spoof"
|
||||||
|
"github.com/bettercap/bettercap/modules/discovery"
|
||||||
|
"github.com/bettercap/bettercap/modules/dns_spoof"
|
||||||
|
"github.com/bettercap/bettercap/modules/events_stream"
|
||||||
|
"github.com/bettercap/bettercap/modules/gps"
|
||||||
|
"github.com/bettercap/bettercap/modules/http_proxy"
|
||||||
|
"github.com/bettercap/bettercap/modules/http_server"
|
||||||
|
"github.com/bettercap/bettercap/modules/https_proxy"
|
||||||
|
"github.com/bettercap/bettercap/modules/https_server"
|
||||||
|
"github.com/bettercap/bettercap/modules/mac_changer"
|
||||||
|
"github.com/bettercap/bettercap/modules/mysql_server"
|
||||||
|
"github.com/bettercap/bettercap/modules/net_sniff"
|
||||||
|
"github.com/bettercap/bettercap/modules/packet_proxy"
|
||||||
|
"github.com/bettercap/bettercap/modules/prober"
|
||||||
|
"github.com/bettercap/bettercap/modules/syn_scan"
|
||||||
|
"github.com/bettercap/bettercap/modules/tcp_proxy"
|
||||||
|
"github.com/bettercap/bettercap/modules/ticker"
|
||||||
|
"github.com/bettercap/bettercap/modules/update"
|
||||||
|
"github.com/bettercap/bettercap/modules/wifi"
|
||||||
|
"github.com/bettercap/bettercap/modules/wol"
|
||||||
|
|
||||||
|
"github.com/bettercap/bettercap/session"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LoadModules(sess *session.Session) {
|
||||||
|
|
||||||
|
sess.Register(any_proxy.NewAnyProxy(sess))
|
||||||
|
sess.Register(arp_spoof.NewArpSpoofer(sess))
|
||||||
|
sess.Register(api_rest.NewRestAPI(sess))
|
||||||
|
sess.Register(ble.NewBLERecon(sess))
|
||||||
|
sess.Register(caplets.NewCapletsModule(sess))
|
||||||
|
sess.Register(dhcp6_spoof.NewDHCP6Spoofer(sess))
|
||||||
|
sess.Register(discovery.NewDiscovery(sess))
|
||||||
|
sess.Register(dns_spoof.NewDNSSpoofer(sess))
|
||||||
|
sess.Register(events_stream.NewEventsStream(sess))
|
||||||
|
sess.Register(gps.NewGPS(sess))
|
||||||
|
sess.Register(http_proxy.NewHttpProxy(sess))
|
||||||
|
sess.Register(http_server.NewHttpServer(sess))
|
||||||
|
sess.Register(https_proxy.NewHttpsProxy(sess))
|
||||||
|
sess.Register(https_server.NewHttpsServer(sess))
|
||||||
|
sess.Register(mac_changer.NewMacChanger(sess))
|
||||||
|
sess.Register(mysql_server.NewMySQLServer(sess))
|
||||||
|
sess.Register(net_sniff.NewSniffer(sess))
|
||||||
|
sess.Register(packet_proxy.NewPacketProxy(sess))
|
||||||
|
sess.Register(prober.NewProber(sess))
|
||||||
|
sess.Register(syn_scan.NewSynScanner(sess))
|
||||||
|
sess.Register(tcp_proxy.NewTcpProxy(sess))
|
||||||
|
sess.Register(ticker.NewTicker(sess))
|
||||||
|
sess.Register(update.NewUpdateModule(sess))
|
||||||
|
sess.Register(wifi.NewWiFiModule(sess))
|
||||||
|
sess.Register(wol.NewWOL(sess))
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package mysql_server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/packets"
|
"github.com/bettercap/bettercap/packets"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package net_sniff
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package packet_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
|
@ -1,6 +1,6 @@
|
||||||
// +build !amd64
|
// +build !amd64
|
||||||
|
|
||||||
package modules
|
package packet_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package packet_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package packet_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/session"
|
"github.com/bettercap/bettercap/session"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package prober
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package prober
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package prober
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package prober
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package prober
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package syn_scan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package syn_scan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package syn_scan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package tcp_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package tcp_proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package ticker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package update
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -1,7 +1,8 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/bettercap/bettercap/modules/utils"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -47,7 +48,7 @@ type WiFiModule struct {
|
||||||
writes *sync.WaitGroup
|
writes *sync.WaitGroup
|
||||||
reads *sync.WaitGroup
|
reads *sync.WaitGroup
|
||||||
chanLock *sync.Mutex
|
chanLock *sync.Mutex
|
||||||
selector *ViewSelector
|
selector *utils.ViewSelector
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWiFiModule(s *session.Session) *WiFiModule {
|
func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
|
@ -208,7 +209,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
return w.Show()
|
return w.Show()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
w.selector = ViewSelectorFor(&w.SessionModule, "wifi.show",
|
w.selector = utils.ViewSelectorFor(&w.SessionModule, "wifi.show",
|
||||||
[]string{"rssi", "bssid", "essid", "channel", "encryption", "clients", "seen", "sent", "rcvd"}, "rssi asc")
|
[]string{"rssi", "bssid", "essid", "channel", "encryption", "clients", "seen", "sent", "rcvd"}, "rssi asc")
|
||||||
|
|
||||||
w.AddHandler(session.NewModuleHandler("wifi.recon.channel", `wifi\.recon\.channel[\s]+([0-9]+(?:[, ]+[0-9]+)*|clear)`,
|
w.AddHandler(session.NewModuleHandler("wifi.recon.channel", `wifi\.recon\.channel[\s]+([0-9]+(?:[, ]+[0-9]+)*|clear)`,
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,7 +1,8 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/bettercap/bettercap/modules/discovery"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -26,17 +27,17 @@ func (w *WiFiModule) getRow(station *network.Station) ([]string, bool) {
|
||||||
sinceFirstSeen := time.Since(station.FirstSeen)
|
sinceFirstSeen := time.Since(station.FirstSeen)
|
||||||
|
|
||||||
bssid := station.HwAddress
|
bssid := station.HwAddress
|
||||||
if sinceStarted > (justJoinedTimeInterval*2) && sinceFirstSeen <= justJoinedTimeInterval {
|
if sinceStarted > (discovery.JustJoinedTimeInterval*2) && sinceFirstSeen <= discovery.JustJoinedTimeInterval {
|
||||||
// if endpoint was first seen in the last 10 seconds
|
// if endpoint was first seen in the last 10 seconds
|
||||||
bssid = tui.Bold(bssid)
|
bssid = tui.Bold(bssid)
|
||||||
}
|
}
|
||||||
|
|
||||||
seen := station.LastSeen.Format("15:04:05")
|
seen := station.LastSeen.Format("15:04:05")
|
||||||
sinceLastSeen := time.Since(station.LastSeen)
|
sinceLastSeen := time.Since(station.LastSeen)
|
||||||
if sinceStarted > aliveTimeInterval && sinceLastSeen <= aliveTimeInterval {
|
if sinceStarted > discovery.AliveTimeInterval && sinceLastSeen <= discovery.AliveTimeInterval {
|
||||||
// if endpoint seen in the last 10 seconds
|
// if endpoint seen in the last 10 seconds
|
||||||
seen = tui.Bold(seen)
|
seen = tui.Bold(seen)
|
||||||
} else if sinceLastSeen > presentTimeInterval {
|
} else if sinceLastSeen > discovery.PresentTimeInterval {
|
||||||
// if endpoint not seen in the last 60 seconds
|
// if endpoint not seen in the last 60 seconds
|
||||||
seen = tui.Dim(seen)
|
seen = tui.Dim(seen)
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wifi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/network"
|
"github.com/bettercap/bettercap/network"
|
|
@ -1,4 +1,4 @@
|
||||||
package modules
|
package wol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
Loading…
Add table
Add a link
Reference in a new issue