/
events_view_ble.go
56 lines (49 loc) · 1.21 KB
/
events_view_ble.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build !windows
// +build !darwin
package events_stream
import (
"fmt"
"github.com/bettercap/bettercap/network"
"github.com/bettercap/bettercap/session"
"github.com/evilsocket/islazy/tui"
)
func (mod *EventsStream) viewBLEEvent(e session.Event) {
if e.Tag == "ble.device.new" {
dev := e.Data.(*network.BLEDevice)
name := dev.Device.Name()
if name != "" {
name = " " + tui.Bold(name)
}
vend := dev.Vendor
if vend != "" {
vend = fmt.Sprintf(" (%s)", tui.Yellow(vend))
}
fmt.Fprintf(mod.output, "[%s] [%s] new BLE device%s detected as %s%s %s.\n",
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
name,
dev.Device.ID(),
vend,
tui.Dim(fmt.Sprintf("%d dBm", dev.RSSI)))
} else if e.Tag == "ble.device.lost" {
dev := e.Data.(*network.BLEDevice)
name := dev.Device.Name()
if name != "" {
name = " " + tui.Bold(name)
}
vend := dev.Vendor
if vend != "" {
vend = fmt.Sprintf(" (%s)", tui.Yellow(vend))
}
fmt.Fprintf(mod.output, "[%s] [%s] BLE device%s %s%s lost.\n",
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag),
name,
dev.Device.ID(),
vend)
} /* else {
fmt.Fprintf(s.output,"[%s] [%s]\n",
e.Time.Format(mod.timeFormat),
tui.Green(e.Tag))
} */
}