Documentation ¶
Overview ¶
Package network contains network specific code ... lol.
Index ¶
- Constants
- Variables
- func ArpInverseLookup(iface string, mac string, refresh bool) (string, error)
- func ArpLookup(iface string, address string, refresh bool) (string, error)
- func ArpParsed() bool
- func Dot11Chan2Freq(channel int) int
- func Dot11Freq2Chan(freq int) int
- func GetSupportedFrequencies(iface string) ([]int, error)
- func IsBroadcastMac(mac net.HardwareAddr) bool
- func IsZeroMac(mac net.HardwareAddr) bool
- func NormalizeMac(mac string) string
- func OuiLookup(mac string) string
- func SetInterfaceChannel(iface string, channel int) error
- type APLostCallback
- type APNewCallback
- type AccessPoint
- type Aliases
- type ArpTable
- type BLE
- type BLEDevLostCallback
- type BLEDevNewCallback
- type BLEDevice
- type Endpoint
- func FindGateway(iface *Endpoint) (*Endpoint, error)
- func FindInterface(name string) (*Endpoint, error)
- func IPv4RouteIsGateway(ifname string, tokens []string, f func(gateway string) (*Endpoint, error)) (*Endpoint, error)
- func NewEndpoint(ip, mac string) *Endpoint
- func NewEndpointNoResolve(ip, mac, name string, bits uint32) *Endpoint
- func NewEndpointWithAlias(ip, mac, alias string) *Endpoint
- type EndpointLostCallback
- type EndpointNewCallback
- type LAN
- func (lan *LAN) AddIfNew(ip, mac string) *Endpoint
- func (lan *LAN) EachHost(cb func(mac string, e *Endpoint))
- func (lan *LAN) Get(mac string) (*Endpoint, bool)
- func (lan *LAN) GetAlias(mac string) string
- func (lan *LAN) GetByIp(ip string) *Endpoint
- func (lan *LAN) Has(ip string) bool
- func (lan *LAN) List() (list []*Endpoint)
- func (l *LAN) MarshalJSON() ([]byte, error)
- func (lan *LAN) Remove(ip, mac string)
- func (lan *LAN) SetAliasFor(mac, alias string) bool
- func (lan *LAN) WasMissed(mac string) bool
- type Meta
- func (m *Meta) Each(cb func(name string, value interface{}))
- func (m *Meta) Empty() bool
- func (m *Meta) Get(name string) interface{}
- func (m *Meta) GetIntsWith(name string, with int, sorted bool) []int
- func (m *Meta) GetOr(name string, dflt interface{}) interface{}
- func (m *Meta) MarshalJSON() ([]byte, error)
- func (m *Meta) Set(name string, value interface{})
- func (m *Meta) SetInts(name string, ints []int)
- type OnHostResolvedCallback
- type Station
- type WiFi
- func (w *WiFi) AddIfNew(ssid, mac string, frequency int, rssi int8) *AccessPoint
- func (w *WiFi) Clear() error
- func (w *WiFi) EachAccessPoint(cb func(mac string, ap *AccessPoint))
- func (w *WiFi) Get(mac string) (*AccessPoint, bool)
- func (w *WiFi) GetClient(mac string) (*Station, bool)
- func (w *WiFi) List() (list []*AccessPoint)
- func (w *WiFi) MarshalJSON() ([]byte, error)
- func (w *WiFi) Remove(mac string)
- func (w *WiFi) Stations() (list []*Station)
Constants ¶
View Source
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" )
View Source
const LANAliasesFile = "~/bettercap.aliases"
View Source
const LANDefaultttl = 10
Variables ¶
View Source
var ( BroadcastHw = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff} IPv4Validator = regexp.MustCompile("^[0-9\\.]+/?\\d*$") )
View Source
var ArpCmd = "ip"
View Source
var ArpCmdOpts = []string{"neigh"}
View Source
var ArpTableParser = regexp.MustCompile("^([\\d\\.]+)\\s+dev\\s+(\\w+)\\s+\\w+\\s+([a-f0-9:]{17})\\s+\\w+$")
View Source
var ArpTableTokenIndex = []int{1, 3, 2}
View Source
var ArpTableTokens = 4
View Source
var ErrNoGateway = errors.New("Could not detect gateway.")
View Source
var ErrNoIfaces = errors.New("No active interfaces found.")
View Source
var IPv4RouteCmd = "ip"
View Source
var IPv4RouteCmdOpts = []string{"route"}
View Source
var IPv4RouteParser = regexp.MustCompile("^(default|[0-9\\.]+)\\svia\\s([0-9\\.]+)\\sdev\\s(\\w+)\\s.*$")
only matches gateway lines
View Source
var IPv4RouteTokens = 4
View Source
var WiFiFreqParser = regexp.MustCompile("^\\s+Channel.([0-9]+)\\s+:\\s+([0-9\\.]+)\\s+GHz.*$")
Functions ¶
func ArpInverseLookup ¶
func Dot11Chan2Freq ¶
func Dot11Freq2Chan ¶
func GetSupportedFrequencies ¶
func IsBroadcastMac ¶
func IsBroadcastMac(mac net.HardwareAddr) bool
func IsZeroMac ¶
func IsZeroMac(mac net.HardwareAddr) bool
func NormalizeMac ¶
func SetInterfaceChannel ¶
Types ¶
type APLostCallback ¶
type APLostCallback func(ap *AccessPoint)
type APNewCallback ¶
type APNewCallback func(ap *AccessPoint)
type AccessPoint ¶
func NewAccessPoint ¶
func NewAccessPoint(essid, bssid string, frequency int, rssi int8) *AccessPoint
func (*AccessPoint) AddClient ¶
func (ap *AccessPoint) AddClient(bssid string, frequency int, rssi int8) *Station
func (*AccessPoint) Clients ¶
func (ap *AccessPoint) Clients() (list []*Station)
func (*AccessPoint) MarshalJSON ¶
func (ap *AccessPoint) MarshalJSON() ([]byte, error)
func (*AccessPoint) NumClients ¶
func (ap *AccessPoint) NumClients() int
type Aliases ¶
func LoadAliases ¶
type BLE ¶
func NewBLE ¶
func NewBLE(newcb BLEDevNewCallback, lostcb BLEDevLostCallback) *BLE
func (*BLE) AddIfNew ¶
func (b *BLE) AddIfNew(id string, p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice
func (*BLE) MarshalJSON ¶
type BLEDevLostCallback ¶
type BLEDevLostCallback func(dev *BLEDevice)
type BLEDevNewCallback ¶
type BLEDevNewCallback func(dev *BLEDevice)
type BLEDevice ¶
type BLEDevice struct { LastSeen time.Time Vendor string RSSI int Device gatt.Peripheral Advertisement *gatt.Advertisement }
func NewBLEDevice ¶
func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice
func (*BLEDevice) MarshalJSON ¶
type Endpoint ¶
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 ¶
func FindInterface ¶
func IPv4RouteIsGateway ¶
func NewEndpoint ¶
func NewEndpointNoResolve ¶
func NewEndpointWithAlias ¶
func (*Endpoint) SetNetwork ¶
type EndpointLostCallback ¶
type EndpointLostCallback func(e *Endpoint)
type EndpointNewCallback ¶
type EndpointNewCallback func(e *Endpoint)
type LAN ¶
func NewLAN ¶
func NewLAN(iface, gateway *Endpoint, newcb EndpointNewCallback, lostcb EndpointLostCallback) *LAN
func (*LAN) MarshalJSON ¶
func (*LAN) SetAliasFor ¶
type Meta ¶
func (*Meta) MarshalJSON ¶
type OnHostResolvedCallback ¶
type OnHostResolvedCallback func(e *Endpoint)
type Station ¶
type WiFi ¶
func NewWiFi ¶
func NewWiFi(iface *Endpoint, newcb APNewCallback, lostcb APLostCallback) *WiFi
func (*WiFi) AddIfNew ¶
func (w *WiFi) AddIfNew(ssid, mac string, frequency int, rssi int8) *AccessPoint
func (*WiFi) EachAccessPoint ¶
func (w *WiFi) EachAccessPoint(cb func(mac string, ap *AccessPoint))
func (*WiFi) List ¶
func (w *WiFi) List() (list []*AccessPoint)
func (*WiFi) MarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.