mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
new: added number of captured full handshakes in wifi.show
This commit is contained in:
parent
a6cfb2413f
commit
a90f63b643
3 changed files with 50 additions and 12 deletions
|
@ -279,16 +279,32 @@ func (w *WiFiModule) Show() (err error) {
|
||||||
tui.Table(os.Stdout, w.colNames(nrows), rows)
|
tui.Table(os.Stdout, w.colNames(nrows), rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
numHandshakes := w.Session.WiFi.NumHandshakes()
|
||||||
|
|
||||||
w.Session.Queue.Stats.RLock()
|
w.Session.Queue.Stats.RLock()
|
||||||
fmt.Printf("\n%s (ch. %d) / %s %s / %s %s / %d pkts / %d errs\n\n",
|
|
||||||
w.Session.Interface.Name(),
|
if numHandshakes > 0 {
|
||||||
network.GetInterfaceChannel(w.Session.Interface.Name()),
|
fmt.Printf("\n%s (ch. %d) / %s %s / %s %s / %d pkts / %d errs / %d handshakes\n\n",
|
||||||
tui.Red("↑"),
|
w.Session.Interface.Name(),
|
||||||
humanize.Bytes(w.Session.Queue.Stats.Sent),
|
network.GetInterfaceChannel(w.Session.Interface.Name()),
|
||||||
tui.Green("↓"),
|
tui.Red("↑"),
|
||||||
humanize.Bytes(w.Session.Queue.Stats.Received),
|
humanize.Bytes(w.Session.Queue.Stats.Sent),
|
||||||
w.Session.Queue.Stats.PktReceived,
|
tui.Green("↓"),
|
||||||
w.Session.Queue.Stats.Errors)
|
humanize.Bytes(w.Session.Queue.Stats.Received),
|
||||||
|
w.Session.Queue.Stats.PktReceived,
|
||||||
|
w.Session.Queue.Stats.Errors,
|
||||||
|
numHandshakes)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("\n%s (ch. %d) / %s %s / %s %s / %d pkts / %d errs\n\n",
|
||||||
|
w.Session.Interface.Name(),
|
||||||
|
network.GetInterfaceChannel(w.Session.Interface.Name()),
|
||||||
|
tui.Red("↑"),
|
||||||
|
humanize.Bytes(w.Session.Queue.Stats.Sent),
|
||||||
|
tui.Green("↓"),
|
||||||
|
humanize.Bytes(w.Session.Queue.Stats.Received),
|
||||||
|
w.Session.Queue.Stats.PktReceived,
|
||||||
|
w.Session.Queue.Stats.Errors)
|
||||||
|
}
|
||||||
w.Session.Queue.Stats.RUnlock()
|
w.Session.Queue.Stats.RUnlock()
|
||||||
|
|
||||||
w.Session.Refresh()
|
w.Session.Refresh()
|
||||||
|
|
|
@ -182,6 +182,22 @@ func (w *WiFi) Clear() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *WiFi) NumHandshakes() int {
|
||||||
|
w.Lock()
|
||||||
|
defer w.Unlock()
|
||||||
|
|
||||||
|
sum := 0
|
||||||
|
for _, ap := range w.aps {
|
||||||
|
for _, station := range ap.Clients() {
|
||||||
|
if station.Handshake.Complete() {
|
||||||
|
sum++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum
|
||||||
|
}
|
||||||
|
|
||||||
func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error {
|
func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error {
|
||||||
w.Lock()
|
w.Lock()
|
||||||
defer w.Unlock()
|
defer w.Unlock()
|
||||||
|
|
|
@ -97,15 +97,21 @@ func (ap *AccessPoint) Clients() (list []*Station) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ap *AccessPoint) HasHandshakes() bool {
|
func (ap *AccessPoint) NumHandshakes() int {
|
||||||
ap.Lock()
|
ap.Lock()
|
||||||
defer ap.Unlock()
|
defer ap.Unlock()
|
||||||
|
|
||||||
|
sum := 0
|
||||||
|
|
||||||
for _, c := range ap.clients {
|
for _, c := range ap.clients {
|
||||||
if c.Handshake.Complete() {
|
if c.Handshake.Complete() {
|
||||||
return true
|
sum++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return sum
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ap *AccessPoint) HasHandshakes() bool {
|
||||||
|
return ap.NumHandshakes() > 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue