new: new by sent and by rcvd net.show sorting methods

This commit is contained in:
evilsocket 2018-01-23 18:06:33 +01:00
parent b331ca81a2
commit 857c0c7261
2 changed files with 59 additions and 1 deletions

View file

@ -48,7 +48,7 @@ func NewDiscovery(s *session.Session) *Discovery {
}))
d.AddHandler(session.NewModuleHandler("net.show", "",
"Show current hosts list.",
"Show current hosts list (default sorting by ip).",
func(args []string) error {
return d.Show("address")
}))
@ -59,6 +59,18 @@ func NewDiscovery(s *session.Session) *Discovery {
return d.Show("seen")
}))
d.AddHandler(session.NewModuleHandler("net.show by sent", "",
"Show current hosts list (sort by sent packets).",
func(args []string) error {
return d.Show("sent")
}))
d.AddHandler(session.NewModuleHandler("net.show by rcvd", "",
"Show current hosts list (sort by received packets).",
func(args []string) error {
return d.Show("rcvd")
}))
return d
}
@ -220,6 +232,10 @@ func (d *Discovery) Show(by string) error {
sort.Sort(ByAddressSorter(targets))
} else if by == "seen" {
sort.Sort(BySeenSorter(targets))
} else if by == "sent" {
sort.Sort(BySentSorter(targets))
} else if by == "rcvd" {
sort.Sort(ByRcvdSorter(targets))
}
data = make([][]string, nTargets)