mirror of
https://github.com/bettercap/bettercap.git
synced 2025-03-12 04:36:03 -07:00
new: net.show.meta command to show meta information collected about one or more hosts
This commit is contained in:
parent
c85548dbdc
commit
62db3a0be0
modules
@ -31,7 +31,7 @@ func NewDiscovery(s *session.Session) *Discovery {
|
||||
}))
|
||||
|
||||
d.AddParam(session.NewBoolParameter("net.show.meta",
|
||||
"true",
|
||||
"false",
|
||||
"If true, the net.show command will show all metadata collected about each endpoint."))
|
||||
|
||||
d.AddHandler(session.NewModuleHandler("net.show", "",
|
||||
@ -46,6 +46,12 @@ func NewDiscovery(s *session.Session) *Discovery {
|
||||
return d.Show(args[0])
|
||||
}))
|
||||
|
||||
d.AddHandler(session.NewModuleHandler("net.show.meta ADDRESS1, ADDRESS2", `net\.show\.meta (.+)`,
|
||||
"Show meta information about a specific list of addresses (by IP or MAC).",
|
||||
func(args []string) error {
|
||||
return d.showMeta(args[0])
|
||||
}))
|
||||
|
||||
d.selector = ViewSelectorFor(&d.SessionModule, "net.show", []string{"ip", "mac", "seen", "sent", "rcvd"}, "ip asc")
|
||||
|
||||
return d
|
||||
|
@ -264,3 +264,47 @@ func (d *Discovery) Show(arg string) (err error) {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Discovery) showMeta(arg string) (err error) {
|
||||
var targets []*network.Endpoint
|
||||
if err, targets = d.doSelection(arg); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
colNames := []string{"Name", "Value"}
|
||||
any := false
|
||||
|
||||
for _, t := range targets {
|
||||
keys := []string{}
|
||||
|
||||
t.Meta.Each(func(name string, value interface{}) {
|
||||
keys = append(keys, name)
|
||||
})
|
||||
|
||||
if len(keys) > 0 {
|
||||
sort.Strings(keys)
|
||||
rows := [][]string{
|
||||
[]string{
|
||||
tui.Green("address"),
|
||||
t.IP.String(),
|
||||
},
|
||||
}
|
||||
|
||||
for _, k := range keys {
|
||||
rows = append(rows, []string{
|
||||
tui.Green(k),
|
||||
tui.Yellow(t.Meta.Get(k).(string)),
|
||||
})
|
||||
}
|
||||
|
||||
any = true
|
||||
tui.Table(os.Stdout, colNames, rows)
|
||||
}
|
||||
}
|
||||
|
||||
if any {
|
||||
d.Session.Refresh()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user