bettercap: github.com/bettercap/bettercap/network Index | Files

package network

import "github.com/bettercap/bettercap/network"

Package network contains network specific code ... lol.

Index

Package Files

arp.go arp_parser_linux.go ble.go ble_device.go debug.go doc.go lan.go lan_endpoint.go manuf.go meta.go net.go net_gateway.go net_linux.go wifi.go wifi_ap.go wifi_station.go

Constants

const (
    MonitorModeAddress = "0.0.0.0"
    BroadcastSuffix    = ".255"
    BroadcastMac       = "ff:ff:ff:ff:ff:ff"
    IPv4MulticastStart = "01:00:5e:00:00:00"
    IPv4MulticastEnd   = "01:00:5e:7f:ff:ff"
)
const BLEMacValidator = "([a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2})"
const LANAliasesFile = "~/bettercap.aliases"
const LANDefaultttl = 10

Variables

var (
    BroadcastHw        = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
    IPv4Validator      = regexp.MustCompile(`^[0-9\.]+/?\d*$`)
    IPv4RangeValidator = regexp.MustCompile(`^[0-9\.\-]+/?\d*$`)
    MACValidator       = regexp.MustCompile(`(?i)^[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}$`)
)
var ArpCmd = "ip"
var ArpCmdOpts = []string{"neigh"}
var ArpTableParser = regexp.MustCompile(`^([\d\.]+)\s+dev\s+(\w+)\s+\w+\s+([a-f0-9:]{17})\s+\w+$`)
var ArpTableTokenIndex = []int{1, 3, 2}
var ArpTableTokens = 4
var Debug = func(format string, args ...interface{}) {

}
var ErrNoGateway = errors.New("Could not detect gateway.")
var ErrNoIfaces = errors.New("No active interfaces found.")
var IPv4RouteCmd = "ip"
var IPv4RouteCmdOpts = []string{"route"}
var IPv4RouteParser = regexp.MustCompile(`^(default|[0-9\.]+)\svia\s([0-9\.]+)\sdev\s(\w+)(?:\s.*|)$`)

only matches gateway lines

var IPv4RouteTokens = 4
var WiFiFreqParser = regexp.MustCompile(`^\s+Channel.([0-9]+)\s+:\s+([0-9\.]+)\s+GHz.*$`)

func ArpInverseLookup Uses

func ArpInverseLookup(iface string, mac string, refresh bool) (string, error)

func ArpLookup Uses

func ArpLookup(iface string, address string, refresh bool) (string, error)

func ArpParsed Uses

func ArpParsed() bool

func Dot11Chan2Freq Uses

func Dot11Chan2Freq(channel int) int

func Dot11Freq2Chan Uses

func Dot11Freq2Chan(freq int) int

func GetSupportedFrequencies Uses

func GetSupportedFrequencies(iface string) ([]int, error)

func IsBroadcastMac Uses

func IsBroadcastMac(mac net.HardwareAddr) bool

func IsZeroMac Uses

func IsZeroMac(mac net.HardwareAddr) bool

func ManufLookup Uses

func ManufLookup(mac string) string

func NormalizeMac Uses

func NormalizeMac(mac string) string

func ParseTargets Uses

func ParseTargets(targets string, aliasMap *data.UnsortedKV) (ips []net.IP, macs []net.HardwareAddr, err error)

func SetInterfaceChannel Uses

func SetInterfaceChannel(iface string, channel int) error

type APLostCallback Uses

type APLostCallback func(ap *AccessPoint)

type APNewCallback Uses

type APNewCallback func(ap *AccessPoint)

type AccessPoint Uses

type AccessPoint struct {
    *Station
    sync.Mutex
    // contains filtered or unexported fields
}

func NewAccessPoint Uses

func NewAccessPoint(essid, bssid string, frequency int, rssi int8) *AccessPoint

func (*AccessPoint) AddClient Uses

func (ap *AccessPoint) AddClient(bssid string, frequency int, rssi int8) *Station

func (*AccessPoint) Clients Uses

func (ap *AccessPoint) Clients() (list []*Station)

func (*AccessPoint) Get Uses

func (ap *AccessPoint) Get(bssid string) (*Station, bool)

func (*AccessPoint) MarshalJSON Uses

func (ap *AccessPoint) MarshalJSON() ([]byte, error)

func (*AccessPoint) NumClients Uses

func (ap *AccessPoint) NumClients() int

func (*AccessPoint) RemoveClient Uses

func (ap *AccessPoint) RemoveClient(mac string)

type ArpTable Uses

type ArpTable map[string]string

func ArpUpdate Uses

func ArpUpdate(iface string) (ArpTable, error)

type BLE Uses

type BLE struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewBLE Uses

func NewBLE(newcb BLEDevNewCallback, lostcb BLEDevLostCallback) *BLE

func (*BLE) AddIfNew Uses

func (b *BLE) AddIfNew(id string, p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice

func (*BLE) Devices Uses

func (b *BLE) Devices() (devices []*BLEDevice)

func (*BLE) Get Uses

func (b *BLE) Get(id string) (dev *BLEDevice, found bool)

func (*BLE) MarshalJSON Uses

func (b *BLE) MarshalJSON() ([]byte, error)

func (*BLE) Remove Uses

func (b *BLE) Remove(id string)

type BLEDevLostCallback Uses

type BLEDevLostCallback func(dev *BLEDevice)

type BLEDevNewCallback Uses

type BLEDevNewCallback func(dev *BLEDevice)

type BLEDevice Uses

type BLEDevice struct {
    LastSeen      time.Time
    Vendor        string
    RSSI          int
    Device        gatt.Peripheral
    Advertisement *gatt.Advertisement
}

func NewBLEDevice Uses

func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice

func (*BLEDevice) MarshalJSON Uses

func (d *BLEDevice) MarshalJSON() ([]byte, error)

type DebugFunc Uses

type DebugFunc func(format string, args ...interface{})

type Endpoint Uses

type Endpoint struct {
    Index            int                    `json:"-"`
    IP               net.IP                 `json:"-"`
    Net              *net.IPNet             `json:"-"`
    IPv6             net.IP                 `json:"-"`
    HW               net.HardwareAddr       `json:"-"`
    IpAddress        string                 `json:"ipv4"`
    Ip6Address       string                 `json:"ipv6"`
    SubnetBits       uint32                 `json:"-"`
    IpAddressUint32  uint32                 `json:"-"`
    HwAddress        string                 `json:"mac"`
    Hostname         string                 `json:"hostname"`
    Alias            string                 `json:"alias"`
    Vendor           string                 `json:"vendor"`
    ResolvedCallback OnHostResolvedCallback `json:"-"`
    FirstSeen        time.Time              `json:"first_seen"`
    LastSeen         time.Time              `json:"last_seen"`
    Meta             *Meta                  `json:"meta"`
}

func FindGateway Uses

func FindGateway(iface *Endpoint) (*Endpoint, error)

func FindInterface Uses

func FindInterface(name string) (*Endpoint, error)

func IPv4RouteIsGateway Uses

func IPv4RouteIsGateway(ifname string, tokens []string, f func(gateway string) (*Endpoint, error)) (*Endpoint, error)

func NewEndpoint Uses

func NewEndpoint(ip, mac string) *Endpoint

func NewEndpointNoResolve Uses

func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint

func NewEndpointWithAlias Uses

func NewEndpointWithAlias(ip, mac, alias string) *Endpoint

func ParseEndpoints Uses

func ParseEndpoints(targets string, lan *LAN) ([]*Endpoint, error)

func (*Endpoint) CIDR Uses

func (t *Endpoint) CIDR() string

func (*Endpoint) IsMonitor Uses

func (t *Endpoint) IsMonitor() bool

func (*Endpoint) Name Uses

func (t *Endpoint) Name() string

func (*Endpoint) OnMeta Uses

func (t *Endpoint) OnMeta(meta map[string]string)

func (*Endpoint) SetBits Uses

func (t *Endpoint) SetBits(bits uint32)

func (*Endpoint) SetIP Uses

func (t *Endpoint) SetIP(ip string)

func (*Endpoint) SetIPv6 Uses

func (t *Endpoint) SetIPv6(netw string)

func (*Endpoint) SetNetwork Uses

func (t *Endpoint) SetNetwork(netw string)

func (*Endpoint) String Uses

func (t *Endpoint) String() string

type EndpointLostCallback Uses

type EndpointLostCallback func(e *Endpoint)

type EndpointNewCallback Uses

type EndpointNewCallback func(e *Endpoint)

type LAN Uses

type LAN struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewLAN Uses

func NewLAN(iface, gateway *Endpoint, newcb EndpointNewCallback, lostcb EndpointLostCallback) *LAN

func (*LAN) AddIfNew Uses

func (lan *LAN) AddIfNew(ip, mac string) *Endpoint

func (*LAN) Aliases Uses

func (lan *LAN) Aliases() *data.UnsortedKV

func (*LAN) EachHost Uses

func (lan *LAN) EachHost(cb func(mac string, e *Endpoint))

func (*LAN) Get Uses

func (lan *LAN) Get(mac string) (*Endpoint, bool)

func (*LAN) GetAlias Uses

func (lan *LAN) GetAlias(mac string) string

func (*LAN) GetByIp Uses

func (lan *LAN) GetByIp(ip string) *Endpoint

func (*LAN) Has Uses

func (lan *LAN) Has(ip string) bool

func (*LAN) List Uses

func (lan *LAN) List() (list []*Endpoint)

func (*LAN) MarshalJSON Uses

func (l *LAN) MarshalJSON() ([]byte, error)

func (*LAN) Remove Uses

func (lan *LAN) Remove(ip, mac string)

func (*LAN) SetAliasFor Uses

func (lan *LAN) SetAliasFor(mac, alias string) bool

func (*LAN) WasMissed Uses

func (lan *LAN) WasMissed(mac string) bool

type Meta Uses

type Meta struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewMeta Uses

func NewMeta() *Meta

func (*Meta) Each Uses

func (m *Meta) Each(cb func(name string, value interface{}))

func (*Meta) Empty Uses

func (m *Meta) Empty() bool

func (*Meta) Get Uses

func (m *Meta) Get(name string) interface{}

func (*Meta) GetIntsWith Uses

func (m *Meta) GetIntsWith(name string, with int, sorted bool) []int

func (*Meta) GetOr Uses

func (m *Meta) GetOr(name string, dflt interface{}) interface{}

func (*Meta) MarshalJSON Uses

func (m *Meta) MarshalJSON() ([]byte, error)

func (*Meta) Set Uses

func (m *Meta) Set(name string, value interface{})

func (*Meta) SetInts Uses

func (m *Meta) SetInts(name string, ints []int)

type OnHostResolvedCallback Uses

type OnHostResolvedCallback func(e *Endpoint)

type Station Uses

type Station struct {
    *Endpoint
    Frequency      int    `json:"frequency"`
    RSSI           int8   `json:"rssi"`
    Sent           uint64 `json:"sent"`
    Received       uint64 `json:"received"`
    Encryption     string `json:"encryption"`
    Cipher         string `json:"cipher"`
    Authentication string `json:"authentication"`
}

func NewStation Uses

func NewStation(essid, bssid string, frequency int, rssi int8) *Station

func (Station) BSSID Uses

func (s Station) BSSID() string

func (*Station) Channel Uses

func (s *Station) Channel() int

func (*Station) ESSID Uses

func (s *Station) ESSID() string

type WiFi Uses

type WiFi struct {
    sync.Mutex
    // contains filtered or unexported fields
}

func NewWiFi Uses

func NewWiFi(iface *Endpoint, newcb APNewCallback, lostcb APLostCallback) *WiFi

func (*WiFi) AddIfNew Uses

func (w *WiFi) AddIfNew(ssid, mac string, frequency int, rssi int8) *AccessPoint

func (*WiFi) Clear Uses

func (w *WiFi) Clear() error

func (*WiFi) EachAccessPoint Uses

func (w *WiFi) EachAccessPoint(cb func(mac string, ap *AccessPoint))

func (*WiFi) Get Uses

func (w *WiFi) Get(mac string) (*AccessPoint, bool)

func (*WiFi) GetClient Uses

func (w *WiFi) GetClient(mac string) (*Station, bool)

func (*WiFi) List Uses

func (w *WiFi) List() (list []*AccessPoint)

func (*WiFi) MarshalJSON Uses

func (w *WiFi) MarshalJSON() ([]byte, error)

func (*WiFi) Remove Uses

func (w *WiFi) Remove(mac string)

func (*WiFi) Stations Uses

func (w *WiFi) Stations() (list []*Station)

Package network imports 19 packages (graph) and is imported by 12 packages. Updated 2018-11-25. Refresh now. Tools for package owners.