mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
new: improved control over events.stream verbosity ( ref #70 )
This commit is contained in:
parent
e6170263a2
commit
9ee43b6b67
3 changed files with 179 additions and 42 deletions
|
@ -11,11 +11,12 @@ import (
|
|||
"github.com/bettercap/bettercap/session"
|
||||
)
|
||||
|
||||
const eventTimeFormat = "2006-01-02 15:04:05"
|
||||
const eventTimeFormat = "15:04:05"
|
||||
|
||||
func (s EventsStream) viewLogEvent(e session.Event) {
|
||||
fmt.Printf("[%s] [%s] %s\n",
|
||||
fmt.Printf("[%s] [%s] [%s] %s\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
e.Label(),
|
||||
e.Data.(session.LogMessage).Message)
|
||||
}
|
||||
|
@ -28,14 +29,16 @@ func (s EventsStream) viewApEvent(e session.Event) {
|
|||
}
|
||||
|
||||
if e.Tag == "wifi.ap.new" {
|
||||
fmt.Printf("[%s] WiFi access point %s detected as %s%s.\n",
|
||||
fmt.Printf("[%s] [%s] WiFi access point %s detected as %s%s.\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
core.Bold(ap.ESSID()),
|
||||
core.Green(ap.BSSID()),
|
||||
vend)
|
||||
} else if e.Tag == "wifi.ap.lost" {
|
||||
fmt.Printf("[%s] WiFi access point %s (%s) lost.\n",
|
||||
fmt.Printf("[%s] [%s] WiFi access point %s (%s) lost.\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
core.Red(ap.ESSID()),
|
||||
ap.BSSID())
|
||||
} else {
|
||||
|
@ -62,14 +65,16 @@ func (s EventsStream) viewEndpointEvent(e session.Event) {
|
|||
}
|
||||
|
||||
if e.Tag == "endpoint.new" {
|
||||
fmt.Printf("[%s] Endpoint %s detected as %s%s.\n",
|
||||
fmt.Printf("[%s] [%s] Endpoint %s detected as %s%s.\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
core.Bold(t.IpAddress),
|
||||
core.Green(t.HwAddress),
|
||||
vend)
|
||||
} else if e.Tag == "endpoint.lost" {
|
||||
fmt.Printf("[%s] Endpoint %s%s lost.\n",
|
||||
fmt.Printf("[%s] [%s] Endpoint %s%s lost.\n",
|
||||
e.Time.Format(eventTimeFormat),
|
||||
core.Green(e.Tag),
|
||||
core.Red(t.IpAddress),
|
||||
name)
|
||||
} else {
|
||||
|
@ -133,25 +138,23 @@ func (s EventsStream) viewSynScanEvent(e session.Event) {
|
|||
}
|
||||
|
||||
func (s *EventsStream) View(e session.Event, refresh bool) {
|
||||
if s.filter == "" || strings.Contains(e.Tag, s.filter) {
|
||||
if e.Tag == "sys.log" {
|
||||
s.viewLogEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "endpoint.") {
|
||||
s.viewEndpointEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "wifi.ap.") {
|
||||
s.viewApEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "mod.") {
|
||||
s.viewModuleEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "net.sniff.") {
|
||||
s.viewSnifferEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "syn.scan") {
|
||||
s.viewSynScanEvent(e)
|
||||
} else {
|
||||
fmt.Printf("[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), core.Green(e.Tag), e)
|
||||
}
|
||||
if e.Tag == "sys.log" {
|
||||
s.viewLogEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "endpoint.") {
|
||||
s.viewEndpointEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "wifi.ap.") {
|
||||
s.viewApEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "mod.") {
|
||||
s.viewModuleEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "net.sniff.") {
|
||||
s.viewSnifferEvent(e)
|
||||
} else if strings.HasPrefix(e.Tag, "syn.scan") {
|
||||
s.viewSynScanEvent(e)
|
||||
} else {
|
||||
fmt.Printf("[%s] [%s] %v\n", e.Time.Format(eventTimeFormat), core.Green(e.Tag), e)
|
||||
}
|
||||
|
||||
if refresh {
|
||||
s.Session.Refresh()
|
||||
}
|
||||
if refresh {
|
||||
s.Session.Refresh()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue