misc: improve consistency and add rssi to logs

This commit is contained in:
Neal Patel 2018-02-26 14:40:58 -08:00
parent b8e48e7f8a
commit b9cf32573f
4 changed files with 40 additions and 11 deletions

View file

@ -29,14 +29,19 @@ func (s EventsStream) viewWiFiEvent(e session.Event) {
if ap.Vendor != "" { if ap.Vendor != "" {
vend = fmt.Sprintf(" (%s)", ap.Vendor) vend = fmt.Sprintf(" (%s)", ap.Vendor)
} }
rssi := ""
if ap.RSSI != 0 {
rssi = fmt.Sprintf(" (%d dBm)", ap.RSSI)
}
if e.Tag == "wifi.ap.new" { if e.Tag == "wifi.ap.new" {
fmt.Printf("[%s] [%s] WiFi access point %s detected as %s%s.\n", fmt.Printf("[%s] [%s] WiFi access point %s%s detected as %s%s.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
core.Bold(ap.ESSID()), core.Bold(ap.ESSID()),
core.Dim(core.Yellow(rssi)),
core.Green(ap.BSSID()), core.Green(ap.BSSID()),
vend) core.Dim(vend))
} else if e.Tag == "wifi.ap.lost" { } else if e.Tag == "wifi.ap.lost" {
fmt.Printf("[%s] [%s] WiFi access point %s (%s) lost.\n", fmt.Printf("[%s] [%s] WiFi access point %s (%s) lost.\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
@ -51,11 +56,24 @@ func (s EventsStream) viewWiFiEvent(e session.Event) {
} }
} else if e.Tag == "wifi.client.probe" { } else if e.Tag == "wifi.client.probe" {
probe := e.Data.(WiFiProbe) probe := e.Data.(WiFiProbe)
fmt.Printf("[%s] [%s] Station %s is probing for SSID %s\n", desc := ""
if probe.FromAlias != "" {
desc = fmt.Sprintf(" (%s)", probe.FromAlias)
} else if probe.FromVendor != "" {
desc = fmt.Sprintf(" (%s)", probe.FromVendor)
}
rssi := ""
if probe.RSSI != 0 {
rssi = fmt.Sprintf(" (%d dBm)", probe.RSSI)
}
fmt.Printf("[%s] [%s] Station %s%s is probing for SSID %s%s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
probe.From.String(), probe.FromAddr.String(),
core.Bold(probe.SSID)) core.Dim(desc),
core.Bold(probe.SSID),
core.Yellow(rssi))
} }
} }
@ -87,7 +105,7 @@ func (s EventsStream) viewEndpointEvent(e session.Event) {
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),
core.Green(e.Tag), core.Green(e.Tag),
core.Red(t.IpAddress), core.Red(t.IpAddress),
name) core.Dim(vend))
} else { } else {
fmt.Printf("[%s] [%s] %s\n", fmt.Printf("[%s] [%s] %s\n",
e.Time.Format(eventTimeFormat), e.Time.Format(eventTimeFormat),

View file

@ -25,8 +25,11 @@ import (
var maxStationTTL = 5 * time.Minute var maxStationTTL = 5 * time.Minute
type WiFiProbe struct { type WiFiProbe struct {
From net.HardwareAddr FromAddr net.HardwareAddr
FromVendor string
FromAlias string
SSID string SSID string
RSSI int8
} }
type WiFiRecon struct { type WiFiRecon struct {
@ -481,8 +484,11 @@ func (w *WiFiRecon) discoverProbes(radiotap *layers.RadioTap, dot11 *layers.Dot1
} }
w.Session.Events.Add("wifi.client.probe", WiFiProbe{ w.Session.Events.Add("wifi.client.probe", WiFiProbe{
From: dot11.Address2, FromAddr: dot11.Address2,
FromVendor: network.OuiLookup(dot11.Address2.String()),
FromAlias: w.Session.Lan.GetAlias(dot11.Address2.String()),
SSID: string(req.Contents[2 : 2+size]), SSID: string(req.Contents[2 : 2+size]),
RSSI: radiotap.DBMAntennaSignal,
}) })
} }

View file

@ -204,3 +204,7 @@ func (lan *LAN) AddIfNew(ip, mac string) *Endpoint {
return nil return nil
} }
func (lan *LAN) GetAlias(mac string) string {
return lan.aliases.Get(mac)
}

View file

@ -85,10 +85,11 @@ func (s *Session) helpHandler(args []string, sess *Session) error {
for _, h := range handlers { for _, h := range handlers {
fmt.Printf(h.Help(maxLen)) fmt.Printf(h.Help(maxLen))
} }
fmt.Println()
params := m.Parameters() params := m.Parameters()
if len(params) > 0 { if len(params) > 0 {
fmt.Printf("\n Parameters\n\n") fmt.Printf(" Parameters\n\n")
maxLen := 0 maxLen := 0
for _, h := range params { for _, h := range params {
len := len(h.Name) len := len(h.Name)