language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
Go
bettercap/modules/ble/ble_options_darwin.go
package ble import ( "github.com/bettercap/gatt" ) var defaultBLEClientOptions = []gatt.Option{ gatt.MacDeviceRole(gatt.CentralManager), } /* var defaultBLEServerOptions = []gatt.Option{ gatt.MacDeviceRole(gatt.PeripheralManager), } */
Go
bettercap/modules/ble/ble_options_linux.go
package ble import ( "github.com/bettercap/gatt" // "github.com/bettercap/gatt/linux/cmd" ) var defaultBLEClientOptions = []gatt.Option{ gatt.LnxMaxConnections(255), gatt.LnxDeviceID(-1, true), } /* var defaultBLEServerOptions = []gatt.Option{ gatt.LnxMaxConnections(255), gatt.LnxDeviceID(-1, true), gatt.Lnx...
Go
bettercap/modules/ble/ble_recon.go
// +build !windows package ble import ( "encoding/hex" "fmt" golog "log" "time" "github.com/bettercap/bettercap/modules/utils" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/bettercap/gatt" "github.com/evilsocket/islazy/str" ) type BLERecon struct { session...
Go
bettercap/modules/ble/ble_recon_events.go
// +build !windows package ble import ( "github.com/bettercap/gatt" ) func (mod *BLERecon) onStateChanged(dev gatt.Device, s gatt.State) { mod.Debug("state changed to %v", s) switch s { case gatt.StatePoweredOn: if mod.currDevice == nil { mod.Debug("starting discovery ...") dev.Scan([]gatt.UUID{}, true)...
Go
bettercap/modules/ble/ble_show.go
// +build !windows package ble import ( "sort" "time" "github.com/bettercap/bettercap/network" "github.com/evilsocket/islazy/ops" "github.com/evilsocket/islazy/tui" ) var ( bleAliveInterval = time.Duration(5) * time.Second ) func (mod *BLERecon) getRow(dev *network.BLEDevice, withName bool) []string { rssi...
Go
bettercap/modules/ble/ble_show_services.go
// +build !windows package ble import ( "encoding/binary" "fmt" "strconv" "strings" "github.com/bettercap/bettercap/network" "github.com/bettercap/gatt" "github.com/evilsocket/islazy/tui" ) var appearances = map[uint16]string{ 0: "Unknown", 64: "Generic Phone", 128: "Generic Computer", 192: "Gene...
Go
bettercap/modules/ble/ble_show_sort.go
// +build !windows package ble import ( "github.com/bettercap/bettercap/network" ) type ByBLERSSISorter []*network.BLEDevice func (a ByBLERSSISorter) Len() int { return len(a) } func (a ByBLERSSISorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByBLERSSISorter) Less(i, j int) bool { if a[i].RSSI == ...
Go
bettercap/modules/ble/ble_unsupported.go
// +build windows package ble import ( "github.com/bettercap/bettercap/session" ) type BLERecon struct { session.SessionModule } func NewBLERecon(s *session.Session) *BLERecon { mod := &BLERecon{ SessionModule: session.NewSessionModule("ble.recon", s), } mod.AddHandler(session.NewModuleHandler("ble.recon on...
Go
bettercap/modules/c2/c2.go
package c2 import ( "bytes" "crypto/tls" "fmt" "github.com/acarl005/stripansi" "github.com/bettercap/bettercap/modules/events_stream" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/log" "github.com/evilsocket/islazy/str" irc "github.com/thoj/go-ircevent" "strings" "text/template" ) ...
Go
bettercap/modules/caplets/caplets.go
package caplets import ( "fmt" "io" "net/http" "os" "github.com/bettercap/bettercap/caplets" "github.com/bettercap/bettercap/session" "github.com/dustin/go-humanize" "github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/tui" "github.com/evilsocket/islazy/zip" ) type CapletsModule struct { sess...
Go
bettercap/modules/dhcp6_spoof/dhcp6_spoof.go
package dhcp6_spoof import ( "bytes" "crypto/rand" "fmt" "net" "strings" "sync" "time" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/google/gopacket/p...
Go
bettercap/modules/dns_spoof/dns_spoof.go
package dns_spoof import ( "bytes" "fmt" "net" "strconv" "sync" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/goog...
Go
bettercap/modules/dns_spoof/dns_spoof_hosts.go
package dns_spoof import ( "bufio" "net" "os" "regexp" "strings" "github.com/gobwas/glob" "github.com/evilsocket/islazy/str" ) var hostsSplitter = regexp.MustCompile(`\s+`) type HostEntry struct { Host string Suffix string Expr glob.Glob Address net.IP } func (e HostEntry) Matches(host string) b...
Go
bettercap/modules/events_stream/events_rotation.go
package events_stream import ( "fmt" "github.com/evilsocket/islazy/zip" "os" "time" ) func (mod *EventsStream) doRotation() { if mod.output == os.Stdout { return } else if !mod.rotation.Enabled { return } output, isFile := mod.output.(*os.File) if !isFile { return } mod.rotation.Lock() defer mod.r...
Go
bettercap/modules/events_stream/events_stream.go
package events_stream import ( "fmt" "io" "os" "strconv" "sync" "time" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/tui" ) type rotation struct { sync.Mutex Enabled bool Compress bool Format string How ...
Go
bettercap/modules/events_stream/events_triggers.go
package events_stream import ( "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) func (mod *EventsStream) addTrigger(tag string, command string) error { if err, id := mod.triggerList.Add(tag, command); err != nil { return err } else { mod.Info("trigger for event %s added with iden...
Go
bettercap/modules/events_stream/events_view.go
package events_stream import ( "fmt" "io" "os" "strings" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/modules/net_sniff" "github.com/bettercap/bettercap/modules/syn_scan" "github.com/google/go-github/github" "github.com/evilsocket/islaz...
Go
bettercap/modules/events_stream/events_view_ble.go
// +build !windows package events_stream import ( "fmt" "io" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) func (mod *EventsStream) viewBLEEvent(output io.Writer, e session.Event) { if e.Tag == "ble.device.new" { dev := e.Data.(*netwo...
Go
bettercap/modules/events_stream/events_view_ble_unsupported.go
// +build windows package events_stream import ( "io" "github.com/bettercap/bettercap/session" ) func (mod *EventsStream) viewBLEEvent(output io.Writer, e session.Event) { }
Go
bettercap/modules/events_stream/events_view_gateway.go
package events_stream import ( "fmt" "io" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) func (mod *EventsStream) viewGatewayEvent(output io.Writer, e session.Event) { change := e.Data.(session.GatewayChange) fmt.Fprintf(output, "[%s] [%s] %s gateway changed: '%s' (%s) -> '%s' ...
Go
bettercap/modules/events_stream/events_view_gps.go
package events_stream import ( "fmt" "io" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) func (mod *EventsStream) viewGPSEvent(output io.Writer, e session.Event) { if e.Tag == "gps.new" { gps := e.Data.(session.GPS) fmt.Fprintf(output, "[%s] [%s] latitude:%f longitude:%f qual...
Go
bettercap/modules/events_stream/events_view_hid.go
package events_stream import ( "fmt" "io" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) func (mod *EventsStream) viewHIDEvent(output io.Writer, e session.Event) { dev := e.Data.(*network.HIDDevice) if e.Tag == "hid.device.new" { fmt.F...
Go
bettercap/modules/events_stream/events_view_http.go
package events_stream import ( "bytes" "compress/gzip" "encoding/hex" "encoding/json" "fmt" "io" "net/url" "regexp" "strings" "github.com/bettercap/bettercap/modules/net_sniff" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) var ( reJsonKey = regexp.MustCompile(`("[^"]+"):...
Go
bettercap/modules/events_stream/events_view_wifi.go
package events_stream import ( "fmt" "github.com/bettercap/bettercap/modules/wifi" "io" "strings" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) func (mod *EventsStream) viewWiFiApEvent(output io.Writer, e session.Event) { ap := e.Data....
Go
bettercap/modules/events_stream/trigger_list.go
package events_stream import ( "encoding/json" "fmt" "regexp" "strings" "sync" "github.com/bettercap/bettercap/session" "github.com/antchfx/jsonquery" "github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/tui" ) var reQueryCapture = regexp.MustCompile(`{{([^}]+)}}`) type Trigger struct { For ...
Go
bettercap/modules/gps/gps.go
package gps import ( "fmt" "io" "time" "github.com/bettercap/bettercap/session" "github.com/adrianmo/go-nmea" "github.com/stratoberry/go-gpsd" "github.com/tarm/serial" "github.com/evilsocket/islazy/str" ) type GPS struct { session.SessionModule serialPort string baudRate int serial *serial.Port gp...
Go
bettercap/modules/hid/builders.go
package hid import ( "github.com/bettercap/bettercap/network" ) type FrameBuilder interface { BuildFrames(*network.HIDDevice, []*Command) error } var FrameBuilders = map[network.HIDType]FrameBuilder{ network.HIDTypeLogitech: LogitechBuilder{}, network.HIDTypeAmazon: AmazonBuilder{}, network.HIDTypeMicrosoft...
Go
bettercap/modules/hid/build_amazon.go
package hid import ( "github.com/bettercap/bettercap/network" ) const ( amzFrameDelay = 5 ) type AmazonBuilder struct { } func (b AmazonBuilder) frameFor(cmd *Command) []byte { return []byte{0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0,...
Go
bettercap/modules/hid/build_logitech.go
package hid import ( "github.com/bettercap/bettercap/network" ) const ( ltFrameDelay = 12 ) var ( helloData = []byte{0x00, 0x4F, 0x00, 0x04, 0xB0, 0x10, 0x00, 0x00, 0x00, 0xED} keepAliveData = []byte{0x00, 0x40, 0x04, 0xB0, 0x0C} ) type LogitechBuilder struct { } func (b LogitechBuilder) frameFor(cmd *Comm...
Go
bettercap/modules/hid/build_microsoft.go
package hid import ( "fmt" "github.com/bettercap/bettercap/network" ) type MicrosoftBuilder struct { seqn uint16 } func (b MicrosoftBuilder) frameFor(template []byte, cmd *Command) []byte { data := make([]byte, len(template)) copy(data, template) data[4] = byte(b.seqn & 0xff) data[5] = byte((b.seqn >> 8) & ...
Go
bettercap/modules/hid/command.go
package hid import ( "time" ) type Frame struct { Data []byte Delay time.Duration } func NewFrame(buf []byte, delay int) Frame { return Frame{ Data: buf, Delay: time.Millisecond * time.Duration(delay), } } type Command struct { Mode byte HID byte Sleep int Frames []Frame } func (cmd *Command) ...
Go
bettercap/modules/hid/duckyparser.go
package hid import ( "fmt" "strconv" "strings" "github.com/evilsocket/islazy/fs" ) type DuckyParser struct { mod *HIDRecon } func (p DuckyParser) parseLiteral(what string, kmap KeyMap) (*Command, error) { // get reference command from the layout ref, found := kmap[what] if found == false { return nil, fmt...
Go
bettercap/modules/hid/hid.go
package hid import ( "fmt" "strings" "sync" "time" "github.com/bettercap/bettercap/modules/utils" "github.com/bettercap/bettercap/session" "github.com/bettercap/nrf24" ) type HIDRecon struct { session.SessionModule dongle *nrf24.Dongle waitGroup *sync.WaitGroup channel int devTTL int...
Go
bettercap/modules/hid/hid_inject.go
package hid import ( "fmt" "time" "github.com/bettercap/bettercap/network" "github.com/evilsocket/islazy/tui" "github.com/dustin/go-humanize" ) func (mod *HIDRecon) isInjecting() bool { return mod.inInjectMode } func (mod *HIDRecon) setInjectionMode(address string) error { if err := mod.setSniffMode(addres...
Go
bettercap/modules/hid/hid_recon.go
package hid import ( "time" "github.com/bettercap/nrf24" "github.com/google/gousb" ) func (mod *HIDRecon) doHopping() { mod.writeLock.Lock() defer mod.writeLock.Unlock() if mod.inPromMode == false { if err := mod.dongle.EnterPromiscMode(); err != nil { mod.Error("error entering promiscuous mode: %v", err...
Go
bettercap/modules/hid/hid_show.go
package hid import ( "sort" "time" "github.com/bettercap/bettercap/network" "github.com/dustin/go-humanize" "github.com/evilsocket/islazy/tui" ) var ( AliveTimeInterval = time.Duration(5) * time.Minute PresentTimeInterval = time.Duration(1) * time.Minute JustJoinedTimeInterval = time.Duration(10) *...
Go
bettercap/modules/hid/hid_show_sort.go
package hid import ( "github.com/bettercap/bettercap/network" ) type ByHIDMacSorter []*network.HIDDevice func (a ByHIDMacSorter) Len() int { return len(a) } func (a ByHIDMacSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByHIDMacSorter) Less(i, j int) bool { return a[i].Address < a[j].Address } ty...
Go
bettercap/modules/hid/hid_sniff.go
package hid import ( "encoding/hex" "fmt" "time" "github.com/bettercap/bettercap/network" "github.com/bettercap/nrf24" "github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/tui" ) func (mod *HIDRecon) isSniffing() bool { return mod.sniffAddrRaw != nil } func (mod *HIDRecon) setSniffMode(mode st...
Go
bettercap/modules/hid/keymaps.go
package hid import ( "sort" ) type KeyMap map[string]Command var BaseMap = KeyMap{ "": Command{}, "CTRL": Command{Mode: 1}, "SHIFT": Command{Mode: 2}, "ALT": Command{Mode: 4}, "GUI": Command{Mode: 8}, "ENTER": Command{HID: 40}, "ESCAPE": Command{HID: 41}, "...
Go
bettercap/modules/https_proxy/https_proxy.go
package https_proxy import ( "github.com/bettercap/bettercap/modules/http_proxy" "github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/tls" "github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/str" ) type HttpsProxy struct { session.SessionModule proxy *http_proxy.HTTPProxy } fu...
Go
bettercap/modules/https_server/https_server.go
package https_server import ( "context" "fmt" "net/http" "strings" "time" "github.com/bettercap/bettercap/session" "github.com/bettercap/bettercap/tls" "github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/tui" ) type HttpsServer struct { session.SessionModule server *http.Server certFile st...
Go
bettercap/modules/http_proxy/http_proxy.go
package http_proxy import ( "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/str" ) type HttpProxy struct { session.SessionModule proxy *HTTPProxy } func NewHttpProxy(s *session.Session) *HttpProxy { mod := &HttpProxy{ SessionModule: session.NewSessionModule("http.proxy", s), proxy: ...
Go
bettercap/modules/http_proxy/http_proxy_base.go
package http_proxy import ( "bufio" "bytes" "context" "crypto/tls" "crypto/x509" "fmt" "io/ioutil" "net" "net/http" "net/url" "path/filepath" "strconv" "strings" "time" "github.com/bettercap/bettercap/firewall" "github.com/bettercap/bettercap/session" btls "github.com/bettercap/bettercap/tls" "gith...
Go
bettercap/modules/http_proxy/http_proxy_base_cookietracker.go
package http_proxy import ( "fmt" "net/http" "strings" "sync" "github.com/elazarl/goproxy" "github.com/jpillora/go-tld" ) type CookieTracker struct { sync.RWMutex set map[string]bool } func NewCookieTracker() *CookieTracker { return &CookieTracker{ set: make(map[string]bool), } } func (t *CookieTracker...
Go
bettercap/modules/http_proxy/http_proxy_base_filters.go
package http_proxy import ( "io/ioutil" "net/http" "strings" "strconv" "github.com/elazarl/goproxy" "github.com/evilsocket/islazy/tui" ) func (p *HTTPProxy) fixRequestHeaders(req *http.Request) { req.Header.Del("Accept-Encoding") req.Header.Del("If-None-Match") req.Header.Del("If-Modified-Since") req.Head...
Go
bettercap/modules/http_proxy/http_proxy_base_hosttracker.go
package http_proxy import ( "net" "sync" ) type Host struct { Hostname string Address net.IP Resolved sync.WaitGroup } func NewHost(name string) *Host { h := &Host{ Hostname: name, Address: nil, Resolved: sync.WaitGroup{}, } h.Resolved.Add(1) go func(ph *Host) { defer ph.Resolved.Done() if addr...
Go
bettercap/modules/http_proxy/http_proxy_base_sslstriper.go
package http_proxy import ( "io/ioutil" "net/http" "net/url" "regexp" "strconv" "strings" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/modules/dns_spoof" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/elazarl/goproxy" "github.com/goog...
Go
bettercap/modules/http_proxy/http_proxy_cert_cache.go
package http_proxy import ( "crypto/tls" "fmt" "sync" ) var ( certCache = make(map[string]*tls.Certificate) certLock = &sync.Mutex{} ) func keyFor(domain string, port int) string { return fmt.Sprintf("%s:%d", domain, port) } func getCachedCert(domain string, port int) *tls.Certificate { certLock.Lock() def...
Go
bettercap/modules/http_proxy/http_proxy_js_request.go
package http_proxy import ( "bytes" "fmt" "io/ioutil" "net/http" "net/url" "regexp" "strings" "github.com/bettercap/bettercap/session" ) type JSRequest struct { Client map[string]string Method string Version string Scheme string Path string Query string Hostname stri...
Go
bettercap/modules/http_proxy/http_proxy_js_response.go
package http_proxy import ( "bytes" "fmt" "io/ioutil" "net/http" "strings" "github.com/elazarl/goproxy" ) type JSResponse struct { Status int ContentType string Headers string Body string refHash string resp *http.Response bodyRead bool bodyClear bool } func NewJSResponse(res ...
Go
bettercap/modules/http_proxy/http_proxy_script.go
package http_proxy import ( "net/http" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/robertkrimen/otto" "github.com/evilsocket/islazy/plugin" ) type HttpProxyScript struct { *plugin.Plugin doOnRequest bool doOnResponse bool doOnCommand bool } func LoadHttpPr...
Go
bettercap/modules/http_server/http_server.go
package http_server import ( "context" "fmt" "net/http" "strings" "time" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) type HttpServer struct { session.SessionModule server *http.Server } func NewHttpServer(s *session.Session) *HttpServer { mod := &HttpServer{ SessionMod...
Go
bettercap/modules/mac_changer/mac_changer.go
package mac_changer import ( "fmt" "net" "runtime" "strings" "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) type MacChanger struct { session.SessionModule iface string originalMac net.Hardw...
Go
bettercap/modules/mdns_server/mdns_server.go
package mdns_server import ( "fmt" "io/ioutil" "log" "net" "os" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/tui" "github.com/hashicorp/mdns" ) type MDNSServer struct { session.SessionModule hostname string instance string service *mdns.MDN...
Go
bettercap/modules/mysql_server/mysql_server.go
package mysql_server import ( "bufio" "bytes" "fmt" "io/ioutil" "net" "strings" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) type MySQLServer struct { session.SessionModule address *net.TCPAddr listener *net.TCPListener infile ...
Go
bettercap/modules/ndp_spoof/ndp_spoof.go
package ndp_spoof import ( "fmt" "github.com/bettercap/bettercap/packets" "github.com/evilsocket/islazy/str" "net" "sync" "time" "github.com/bettercap/bettercap/session" ) type NDPSpoofer struct { session.SessionModule neighbour net.IP prefix string prefixLength int addresses []net.IP ban ...
Go
bettercap/modules/net_probe/net_probe.go
package net_probe import ( "sync" "time" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/malfunkt/iprange" ) type Probes struct { NBNS bool MDNS bool UPNP bool WSD bool } type Prober struct { session.SessionModule throttle int probes Probes waitGroup ...
Go
bettercap/modules/net_probe/net_probe_mdns.go
package net_probe import ( "fmt" "io/ioutil" "log" "net" "github.com/bettercap/bettercap/packets" "github.com/hashicorp/mdns" ) var services = []string{ "_hap._tcp.local", "_homekit._tcp.local", "_airplay._tcp.local", "_raop._tcp.local", "_sleep-proxy._udp.local", "_companion-link._tcp.local", "_google...
Go
bettercap/modules/net_probe/net_probe_nbns.go
package net_probe import ( "fmt" "net" "github.com/bettercap/bettercap/packets" ) func (mod *Prober) sendProbeNBNS(from net.IP, from_hw net.HardwareAddr, ip net.IP) { name := fmt.Sprintf("%s:%d", ip, packets.NBNSPort) if addr, err := net.ResolveUDPAddr("udp", name); err != nil { mod.Debug("could not resolve %...
Go
bettercap/modules/net_probe/net_probe_upnp.go
package net_probe import ( "fmt" "net" "github.com/bettercap/bettercap/packets" ) func (mod *Prober) sendProbeUPNP(from net.IP, from_hw net.HardwareAddr) { name := fmt.Sprintf("%s:%d", packets.UPNPDestIP, packets.UPNPPort) if addr, err := net.ResolveUDPAddr("udp", name); err != nil { mod.Debug("could not reso...
Go
bettercap/modules/net_probe/net_probe_wsd.go
package net_probe import ( "fmt" "net" "github.com/bettercap/bettercap/packets" ) func (mod *Prober) sendProbeWSD(from net.IP, from_hw net.HardwareAddr) { name := fmt.Sprintf("%s:%d", packets.WSDDestIP, packets.WSDPort) if addr, err := net.ResolveUDPAddr("udp", name); err != nil { mod.Debug("could not resolve...
Go
bettercap/modules/net_recon/net_recon.go
package net_recon import ( "github.com/bettercap/bettercap/modules/utils" "time" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" ) type Discovery struct { session.SessionModule selector *utils.ViewSelector } func NewDiscovery(s *session.Session) *Discovery { mod := &Discover...
Go
bettercap/modules/net_recon/net_show.go
package net_recon import ( "fmt" "github.com/bettercap/bettercap/modules/syn_scan" "sort" "strings" "time" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/dustin/go-humanize" "github.com/evilsocket/islazy/tui" "github.com/evilsocket/islazy/str" ) const ( Ali...
Go
bettercap/modules/net_recon/net_show_sort.go
package net_recon import ( "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" ) type ByAddressSorter []*network.Endpoint func (a ByAddressSorter) Len() int { return len(a) } func (a ByAddressSorter) Swap(i, j int) { a[i], a[j] = a[j], a[...
Go
bettercap/modules/net_sniff/net_sniff.go
package net_sniff import ( "fmt" "time" "github.com/bettercap/bettercap/session" "github.com/google/gopacket" "github.com/google/gopacket/layers" ) type Sniffer struct { session.SessionModule Stats *SnifferStats Ctx *SnifferContext pktSourceChan chan gopacket.Packet fuzzActive bool fuz...
Go
bettercap/modules/net_sniff/net_sniff_context.go
package net_sniff import ( "os" "regexp" "time" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" "github.com/google/gopacket/pcap" "github.com/google/gopacket/pcapgo" "github.com/evilsocket/islazy/tui" ) type SnifferContext struct { Ha...
Go
bettercap/modules/net_sniff/net_sniff_dns.go
package net_sniff import ( "github.com/google/gopacket" "github.com/google/gopacket/layers" "net" "strings" "github.com/evilsocket/islazy/tui" ) func dnsParser(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, udp *layers.UDP) bool { dns, parsed := pkt.Layer(layers.LayerTypeDNS).(*layers.DNS) if !pars...
Go
bettercap/modules/net_sniff/net_sniff_dot11.go
package net_sniff import ( "github.com/google/gopacket" "github.com/google/gopacket/layers" ) func onDOT11(radiotap *layers.RadioTap, dot11 *layers.Dot11, pkt gopacket.Packet, verbose bool) { NewSnifferEvent( pkt.Metadata().Timestamp, "802.11", "-", "-", len(pkt.Data()), "%s %s proto=%d a1=%s a2=%s a3=...
Go
bettercap/modules/net_sniff/net_sniff_event.go
package net_sniff import ( "fmt" "time" "github.com/bettercap/bettercap/session" ) type SniffData map[string]interface{} type SnifferEvent struct { PacketTime time.Time `json:"time"` Protocol string `json:"protocol"` Source string `json:"from"` Destination string `json:"to"` Messag...
Go
bettercap/modules/net_sniff/net_sniff_ftp.go
package net_sniff import ( "net" "regexp" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/tui" ) var ( ftpRe = regexp.MustCompile(`^(USER|PASS) (.+)[\n\r]+$`) ) func ftpParser(srcIP, dstIP net.IP, payload []byte, pkt gopacket....
Go
bettercap/modules/net_sniff/net_sniff_fuzz.go
package net_sniff import ( "math/rand" "strings" "github.com/google/gopacket" "github.com/evilsocket/islazy/str" ) var mutators = []func(byte) byte{ func(b byte) byte { return byte(rand.Intn(256) & 0xff) }, func(b byte) byte { return byte(b << uint(rand.Intn(9))) }, func(b byte) byte { return byte(b ...
Go
bettercap/modules/net_sniff/net_sniff_http.go
package net_sniff import ( "bufio" "bytes" "compress/gzip" "io/ioutil" "net" "net/http" "strings" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/dustin/go-humanize" "github.com/evilsocket/islazy/tui" ) type HTTPRequest struct { Method string `json:"method"` Prot...
Go
bettercap/modules/net_sniff/net_sniff_krb5.go
package net_sniff import ( "encoding/asn1" "net" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) func krb5Parser(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, udp *layers.UDP) bool { if udp.DstPort != ...
Go
bettercap/modules/net_sniff/net_sniff_mdns.go
package net_sniff import ( "net" "strings" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) func mdnsParser(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, udp *la...
Go
bettercap/modules/net_sniff/net_sniff_ntlm.go
package net_sniff import ( "net" "regexp" "strings" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) var ( ntlmRe = regexp.MustCompile("(WWW-|Proxy-|)(Authenticate|Authorization): (NTLM|Negotiate)") challRe = re...
Go
bettercap/modules/net_sniff/net_sniff_parsers.go
package net_sniff import ( "fmt" "net" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) func onUNK(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, verbose bool) { if ...
Go
bettercap/modules/net_sniff/net_sniff_sni.go
package net_sniff import ( "fmt" "net" "regexp" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) // poor man's TLS Client Hello with SNI extension parser :P var sniRe = regexp.MustCompile("\x00\x00.{4}\x00.{2}([a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,6})...
Go
bettercap/modules/net_sniff/net_sniff_stats.go
package net_sniff import ( "github.com/bettercap/bettercap/log" "time" ) type SnifferStats struct { NumLocal uint64 NumMatched uint64 NumDumped uint64 NumWrote uint64 Started time.Time FirstPacket time.Time LastPacket time.Time } func NewSnifferStats() *SnifferStats { return &SnifferStats{ ...
Go
bettercap/modules/net_sniff/net_sniff_tcp.go
package net_sniff import ( "fmt" "net" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) var tcpParsers = []func(net.IP, net.IP, []byte, gopacket.Packet, *layers.TCP) bool{ sniParser, ntlmParser, httpParser, ftpParser, teamViewerParser, } func onTCP(src...
Go
bettercap/modules/net_sniff/net_sniff_teamviewer.go
package net_sniff import ( "github.com/bettercap/bettercap/packets" "net" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) func teamViewerParser(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, tcp *layers.TCP) bool { if tcp.SrcPort == packets.Team...
Go
bettercap/modules/net_sniff/net_sniff_udp.go
package net_sniff import ( "fmt" "net" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/tui" ) var udpParsers = []func(net.IP, net.IP, []byte, gopacket.Packet, *layers.UDP) bool{ dnsParser, mdnsParser, krb5Parser, upnpParser, } func onUDP(srcIP, dstIP net.IP, ...
Go
bettercap/modules/net_sniff/net_sniff_upnp.go
package net_sniff import ( "fmt" "net" "github.com/bettercap/bettercap/packets" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/str" "github.com/evilsocket/islazy/tui" ) func upnpParser(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, udp *layers.UDP) ...
Go
bettercap/modules/net_sniff/net_sniff_views.go
package net_sniff import ( "fmt" "net" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" "github.com/google/gopacket/layers" ) func vIP(ip net.IP) string { if session.I.Interface.IP.Equal(ip) { return tui.Dim("local") } else if session.I.Gateway.IP.Equal(ip) { return "gateway" ...
Go
bettercap/modules/packet_proxy/packet_proxy_darwin.go
package packet_proxy import ( "github.com/bettercap/bettercap/session" ) type PacketProxy struct { session.SessionModule } func NewPacketProxy(s *session.Session) *PacketProxy { return &PacketProxy{ SessionModule: session.NewSessionModule("packet.proxy", s), } } func (mod PacketProxy) Name() string { return ...
Go
bettercap/modules/packet_proxy/packet_proxy_linux.go
package packet_proxy import ( "fmt" "io/ioutil" golog "log" "plugin" "strings" "syscall" "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/session" "github.com/chifflier/nfqueue-go/nfqueue" "github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/tui" ) type PacketProxy struct...
Go
bettercap/modules/packet_proxy/packet_proxy_windows.go
package packet_proxy import ( "github.com/bettercap/bettercap/session" ) type PacketProxy struct { session.SessionModule } func NewPacketProxy(s *session.Session) *PacketProxy { return &PacketProxy{ SessionModule: session.NewSessionModule("packet.proxy", s), } } func (mod PacketProxy) Name() string { return ...
Go
bettercap/modules/syn_scan/banner_grabbing.go
package syn_scan import ( "fmt" "time" "github.com/evilsocket/islazy/async" ) const bannerGrabTimeout = time.Duration(5) * time.Second type bannerGrabberFn func(mod *SynScanner, ip string, port int) string type grabberJob struct { IP string Port *OpenPort } func (mod *SynScanner) bannerGrabber(arg async.Jo...
Go
bettercap/modules/syn_scan/dns_grabber.go
package syn_scan import ( "fmt" "regexp" "github.com/miekg/dns" ) var chaosParser = regexp.MustCompile(`.*"([^"]+)".*`) func grabChaos(addr string, q string) string { c := new(dns.Client) m := new(dns.Msg) m.Question = make([]dns.Question, 1) m.Question[0] = dns.Question{Name: q, Qtype: dns.TypeTXT, Qclass: ...
Go
bettercap/modules/syn_scan/http_grabber.go
package syn_scan import ( "crypto/tls" "crypto/x509" "fmt" "golang.org/x/net/html" "net/http" "strings" ) func isTitleElement(n *html.Node) bool { return n.Type == html.ElementNode && strings.ToLower(n.Data) == "title" } func searchForTitle(n *html.Node) string { if isTitleElement(n) && n.FirstChild != nil {...
Go
bettercap/modules/syn_scan/syn_scan.go
package syn_scan import ( "fmt" "net" "sync" "sync/atomic" "time" "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/packets" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/async" "github.com/google/gopacket" "github.com/google/gopacket/pcap" ) const synSour...
Go
bettercap/modules/syn_scan/syn_scan_event.go
package syn_scan import ( "github.com/bettercap/bettercap/network" "github.com/bettercap/bettercap/session" ) type SynScanEvent struct { Address string Host *network.Endpoint Port int } func NewSynScanEvent(address string, h *network.Endpoint, port int) SynScanEvent { return SynScanEvent{ Address: addr...
Go
bettercap/modules/syn_scan/syn_scan_parsers.go
package syn_scan import ( "fmt" "net" "strconv" "strings" "github.com/evilsocket/islazy/str" "github.com/malfunkt/iprange" ) func (mod *SynScanner) parseTargets(arg string) error { if strings.Contains(arg, ":") { // parse as IPv6 address if ip := net.ParseIP(arg); ip == nil { return fmt.Errorf("error w...
Go
bettercap/modules/syn_scan/syn_scan_reader.go
package syn_scan import ( "sync/atomic" "github.com/bettercap/bettercap/network" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/evilsocket/islazy/async" ) type OpenPort struct { Proto string `json:"proto"` Banner string `json:"banner"` Service string `json:"service"` Port ...
Go
bettercap/modules/syn_scan/tcp_grabber.go
package syn_scan import ( "bufio" "fmt" "net" "strconv" "strings" ) func cleanBanner(banner string) string { clean := "" for _, c := range banner { if strconv.IsPrint(c) { clean += string(c) } } return clean } func tcpGrabber(mod *SynScanner, ip string, port int) string { dialer := net.Dialer{ Tim...
Go
bettercap/modules/tcp_proxy/tcp_proxy.go
package tcp_proxy import ( "fmt" "io" "net" "sync" "github.com/bettercap/bettercap/firewall" "github.com/bettercap/bettercap/session" "github.com/robertkrimen/otto" ) type TcpProxy struct { session.SessionModule Redirection *firewall.Redirection localAddr *net.TCPAddr remoteAddr *net.TCPAddr tunnelAd...
Go
bettercap/modules/tcp_proxy/tcp_proxy_script.go
package tcp_proxy import ( "net" "strings" "github.com/bettercap/bettercap/log" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/plugin" "github.com/robertkrimen/otto" ) type TcpProxyScript struct { *plugin.Plugin doOnData bool } func LoadTcpProxyScript(path string, sess *session.Ses...
Go
bettercap/modules/ticker/ticker.go
package ticker import ( "time" "github.com/bettercap/bettercap/session" ) type Ticker struct { session.SessionModule Period time.Duration Commands []string } func NewTicker(s *session.Session) *Ticker { mod := &Ticker{ SessionModule: session.NewSessionModule("ticker", s), } mod.AddParam(session.NewStri...
Go
bettercap/modules/ui/ui.go
package ui import ( "context" "fmt" "io" "io/ioutil" "net/http" "os" "path/filepath" "regexp" "runtime" "github.com/bettercap/bettercap/session" "github.com/google/go-github/github" "github.com/evilsocket/islazy/fs" "github.com/evilsocket/islazy/tui" "github.com/evilsocket/islazy/zip" ) var versionPa...
Go
bettercap/modules/update/update.go
package update import ( "context" "math" "strconv" "strings" "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/session" "github.com/google/go-github/github" "github.com/evilsocket/islazy/tui" ) type UpdateModule struct { session.SessionModule client *github.Client } func NewUpdateMod...
Go
bettercap/modules/utils/view_selector.go
package utils import ( "fmt" "regexp" "strings" "github.com/bettercap/bettercap/session" "github.com/evilsocket/islazy/tui" ) type ViewSelector struct { owner *session.SessionModule Filter string filterName string filterPrev string Expression *regexp.Regexp SortField string Sort string So...