mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -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
2 changed files with 51 additions and 1 deletions
|
@ -31,7 +31,7 @@ func NewDiscovery(s *session.Session) *Discovery {
|
||||||
}))
|
}))
|
||||||
|
|
||||||
d.AddParam(session.NewBoolParameter("net.show.meta",
|
d.AddParam(session.NewBoolParameter("net.show.meta",
|
||||||
"true",
|
"false",
|
||||||
"If true, the net.show command will show all metadata collected about each endpoint."))
|
"If true, the net.show command will show all metadata collected about each endpoint."))
|
||||||
|
|
||||||
d.AddHandler(session.NewModuleHandler("net.show", "",
|
d.AddHandler(session.NewModuleHandler("net.show", "",
|
||||||
|
@ -46,6 +46,12 @@ func NewDiscovery(s *session.Session) *Discovery {
|
||||||
return d.Show(args[0])
|
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")
|
d.selector = ViewSelectorFor(&d.SessionModule, "net.show", []string{"ip", "mac", "seen", "sent", "rcvd"}, "ip asc")
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
|
@ -264,3 +264,47 @@ func (d *Discovery) Show(arg string) (err error) {
|
||||||
|
|
||||||
return nil
|
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…
Add table
Add a link
Reference in a new issue