Documentation ¶
Overview ¶
Package network contains network specific code ... lol.
Index ¶
- Constants
- Variables
- func ActivateInterface(name string) error
- func ArpInverseLookup(iface string, mac string, refresh bool) (string, error)
- func ArpLookup(iface string, address string, refresh bool) (string, error)
- func ArpParsed() bool
- func ColorRSSI(n int) string
- func Dot11Chan2Freq(channel int) int
- func Dot11Freq2Chan(freq int) int
- func GetInterfaceChannel(iface string) int
- func GetServiceByPort(port int, proto string) string
- func GetSupportedFrequencies(iface string) ([]int, error)
- func HIDAddress(address []byte) string
- func IsBroadcastMac(mac net.HardwareAddr) bool
- func IsZeroMac(mac net.HardwareAddr) bool
- func ManufLookup(mac string) string
- func NormalizeHIDAddress(address string) string
- func NormalizeMac(mac string) string
- func ParseMACs(targets string) (macs []net.HardwareAddr, err error)
- func ParseTargets(targets string, aliasMap *data.UnsortedKV) (ips []net.IP, macs []net.HardwareAddr, err error)
- func SetInterfaceChannel(iface string, channel int) error
- func SetInterfaceCurrentChannel(iface string, channel int)
- func SetInterfaceTxPower(name string, txpower int) error
- func SetWiFiRegion(region string) error
- type APLostCallback
- type APNewCallback
- type AccessPoint
- func (ap *AccessPoint) AddClientIfNew(bssid string, frequency int, rssi int8) (*Station, bool)
- func (ap *AccessPoint) Clients() (list []*Station)
- func (ap *AccessPoint) EachClient(cb func(mac string, station *Station))
- func (ap *AccessPoint) Get(bssid string) (*Station, bool)
- func (ap *AccessPoint) HasHandshakes() bool
- func (ap *AccessPoint) HasKeyMaterial() bool
- func (ap *AccessPoint) HasPMKID() bool
- func (ap *AccessPoint) MarshalJSON() ([]byte, error)
- func (ap *AccessPoint) NumClients() int
- func (ap *AccessPoint) NumHandshakes() int
- func (ap *AccessPoint) RemoveClient(mac string)
- func (ap *AccessPoint) WithKeyMaterial(state bool)
- type ArpTable
- type BLE
- func (b *BLE) AddIfNew(id string, p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice
- func (b *BLE) Clear()
- func (b *BLE) Devices() (devices []*BLEDevice)
- func (b *BLE) EachDevice(cb func(mac string, d *BLEDevice))
- func (b *BLE) Get(id string) (dev *BLEDevice, found bool)
- func (b *BLE) MarshalJSON() ([]byte, error)
- func (b *BLE) Remove(id string)
- type BLECharacteristic
- type BLEDevLostCallback
- type BLEDevNewCallback
- type BLEDevice
- type BLEService
- type DebugFunc
- type Endpoint
- func FindGateway(iface *Endpoint) (*Endpoint, error)
- func FindInterface(name string) (*Endpoint, error)
- func GatewayProvidedByUser(iface *Endpoint, gateway 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
- func ParseEndpoints(targets string, lan *LAN) ([]*Endpoint, error)
- func (t *Endpoint) CIDR() string
- func (t *Endpoint) IsMonitor() bool
- func (t *Endpoint) Name() string
- func (t *Endpoint) OnMeta(meta map[string]string)
- func (t *Endpoint) SetBits(bits uint32)
- func (t *Endpoint) SetIP(ip string)
- func (t *Endpoint) SetIPv6(netw string)
- func (t *Endpoint) SetNetwork(netw string)
- func (t *Endpoint) String() string
- type EndpointLostCallback
- type EndpointNewCallback
- type HID
- func (b *HID) AddIfNew(address []byte, channel int, payload []byte) (bool, *HIDDevice)
- func (b *HID) Clear()
- func (b *HID) Devices() (devices []*HIDDevice)
- func (b *HID) EachDevice(cb func(mac string, d *HIDDevice))
- func (b *HID) Get(id string) (dev *HIDDevice, found bool)
- func (h *HID) MarshalJSON() ([]byte, error)
- func (b *HID) Remove(id string)
- type HIDDevLostCallback
- type HIDDevNewCallback
- type HIDDevice
- func (dev *HIDDevice) AddChannel(ch int)
- func (dev *HIDDevice) AddPayload(payload []byte)
- func (dev *HIDDevice) Channels() string
- func (dev *HIDDevice) ChannelsList() []string
- func (dev *HIDDevice) EachPayload(cb func([]byte) bool)
- func (dev *HIDDevice) MarshalJSON() ([]byte, error)
- func (dev *HIDDevice) NumPayloads() int
- func (dev *HIDDevice) PayloadsSize() uint64
- type HIDPayload
- type HIDType
- type Handshake
- func (h *Handshake) AddAndGetPMKID(pkt gopacket.Packet) []byte
- func (h *Handshake) AddFrame(n int, pkt gopacket.Packet)
- func (h *Handshake) Complete() bool
- func (h *Handshake) EachUnsavedPacket(cb func(gopacket.Packet))
- func (h *Handshake) Half() bool
- func (h *Handshake) HasPMKID() bool
- func (h *Handshake) NumUnsaved() int
- func (h *Handshake) SetBeacon(pkt gopacket.Packet)
- type LAN
- func (lan *LAN) AddIfNew(ip, mac string) *Endpoint
- func (lan *LAN) Aliases() *data.UnsortedKV
- func (lan *LAN) Clear()
- 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) 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, bool)
- func (w *WiFi) Clear()
- 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) NumHandshakes() int
- func (w *WiFi) Remove(mac string)
- func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error
- 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 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})"
View Source
const LANDefaultttl = 10
View Source
const NO_CHANNEL = -1
Variables ¶
View Source
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}$`) )
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 Debug = func(format string, args ...interface{}) {
}
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]+\.[0-9]+\.[0-9]+\.[0-9]+)\svia\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\sdev\s(\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 ActivateInterface ¶
func ArpInverseLookup ¶
func Dot11Chan2Freq ¶
func Dot11Freq2Chan ¶
func GetInterfaceChannel ¶
func GetServiceByPort ¶
func GetSupportedFrequencies ¶
func HIDAddress ¶
func IsBroadcastMac ¶
func IsBroadcastMac(mac net.HardwareAddr) bool
func IsZeroMac ¶
func IsZeroMac(mac net.HardwareAddr) bool
func ManufLookup ¶
func NormalizeHIDAddress ¶
func NormalizeMac ¶
func ParseTargets ¶
func ParseTargets(targets string, aliasMap *data.UnsortedKV) (ips []net.IP, macs []net.HardwareAddr, err error)
func SetInterfaceChannel ¶
func SetInterfaceTxPower ¶
func SetWiFiRegion ¶
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, aliases *data.UnsortedKV) *AccessPoint
func (*AccessPoint) AddClientIfNew ¶
func (*AccessPoint) Clients ¶
func (ap *AccessPoint) Clients() (list []*Station)
func (*AccessPoint) EachClient ¶
func (ap *AccessPoint) EachClient(cb func(mac string, station *Station))
func (*AccessPoint) HasHandshakes ¶
func (ap *AccessPoint) HasHandshakes() bool
func (*AccessPoint) HasKeyMaterial ¶
func (ap *AccessPoint) HasKeyMaterial() bool
func (*AccessPoint) HasPMKID ¶
func (ap *AccessPoint) HasPMKID() bool
func (*AccessPoint) MarshalJSON ¶
func (ap *AccessPoint) MarshalJSON() ([]byte, error)
func (*AccessPoint) NumClients ¶
func (ap *AccessPoint) NumClients() int
func (*AccessPoint) NumHandshakes ¶
func (ap *AccessPoint) NumHandshakes() int
func (*AccessPoint) RemoveClient ¶
func (ap *AccessPoint) RemoveClient(mac string)
func (*AccessPoint) WithKeyMaterial ¶
func (ap *AccessPoint) WithKeyMaterial(state bool)
type BLE ¶
func NewBLE ¶
func NewBLE(aliases *data.UnsortedKV, 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) EachDevice ¶
func (*BLE) MarshalJSON ¶
type BLECharacteristic ¶
type BLEDevLostCallback ¶
type BLEDevLostCallback func(dev *BLEDevice)
type BLEDevNewCallback ¶
type BLEDevNewCallback func(dev *BLEDevice)
type BLEDevice ¶
type BLEDevice struct { Alias string LastSeen time.Time DeviceName string Vendor string RSSI int Device gatt.Peripheral Advertisement *gatt.Advertisement Services []BLEService }
func NewBLEDevice ¶
func NewBLEDevice(p gatt.Peripheral, a *gatt.Advertisement, rssi int) *BLEDevice
func (*BLEDevice) MarshalJSON ¶
type BLEService ¶
type BLEService struct { UUID string `json:"uuid"` Name string `json:"name"` Handle uint16 `json:"handle"` EndHandle uint16 `json:"end_handle"` Characteristics []BLECharacteristic `json:"characteristics"` }
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 GatewayProvidedByUser ¶
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 HID ¶
func NewHID ¶
func NewHID(aliases *data.UnsortedKV, newcb HIDDevNewCallback, lostcb HIDDevLostCallback) *HID
func (*HID) EachDevice ¶
func (*HID) MarshalJSON ¶
type HIDDevLostCallback ¶
type HIDDevLostCallback func(dev *HIDDevice)
type HIDDevNewCallback ¶
type HIDDevNewCallback func(dev *HIDDevice)
type HIDDevice ¶
type HIDDevice struct { sync.Mutex LastSeen time.Time Type HIDType Alias string Address string RawAddress []byte // contains filtered or unexported fields }
func (*HIDDevice) AddChannel ¶
func (*HIDDevice) AddPayload ¶
func (*HIDDevice) ChannelsList ¶
func (*HIDDevice) EachPayload ¶
func (*HIDDevice) MarshalJSON ¶
func (*HIDDevice) NumPayloads ¶
func (*HIDDevice) PayloadsSize ¶
type HIDPayload ¶
type HIDPayload []byte
type Handshake ¶
type Handshake struct { sync.Mutex Beacon gopacket.Packet Challenges []gopacket.Packet Responses []gopacket.Packet Confirmations []gopacket.Packet // contains filtered or unexported fields }
func NewHandshake ¶
func NewHandshake() *Handshake
func (*Handshake) EachUnsavedPacket ¶
func (*Handshake) NumUnsaved ¶
type LAN ¶
func NewLAN ¶
func NewLAN(iface, gateway *Endpoint, aliases *data.UnsortedKV, newcb EndpointNewCallback, lostcb EndpointLostCallback) *LAN
func (*LAN) Aliases ¶
func (lan *LAN) Aliases() *data.UnsortedKV
func (*LAN) MarshalJSON ¶
type Meta ¶
func (*Meta) MarshalJSON ¶
type OnHostResolvedCallback ¶
type OnHostResolvedCallback func(e *Endpoint)
type Station ¶
type Station struct { *Endpoint Frequency int `json:"frequency"` Channel int `json:"channel"` RSSI int8 `json:"rssi"` Sent uint64 `json:"sent"` Received uint64 `json:"received"` Encryption string `json:"encryption"` Cipher string `json:"cipher"` Authentication string `json:"authentication"` WPS map[string]string `json:"wps"` Handshake *Handshake `json:"-"` }
func (*Station) PathFriendlyName ¶
type WiFi ¶
func NewWiFi ¶
func NewWiFi(iface *Endpoint, aliases *data.UnsortedKV, newcb APNewCallback, lostcb APLostCallback) *WiFi
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 ¶
func (*WiFi) NumHandshakes ¶
func (*WiFi) SaveHandshakesTo ¶
Click to show internal directories.
Click to hide internal directories.