1
0
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:
evilsocket 2019-02-10 12:44:47 +01:00
parent c85548dbdc
commit 62db3a0be0
No known key found for this signature in database
GPG Key ID: 1564D7F30393A456
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",
"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
}