mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
new: net.show now accepts an IP address parameter which, if present, will be the only endpoint listed in the table
This commit is contained in:
parent
b6adb2b65f
commit
7ef447e726
2 changed files with 22 additions and 5 deletions
|
@ -32,25 +32,31 @@ func NewDiscovery(s *session.Session) *Discovery {
|
||||||
d.AddHandler(session.NewModuleHandler("net.show", "",
|
d.AddHandler(session.NewModuleHandler("net.show", "",
|
||||||
"Show cache hosts list (default sorting by ip).",
|
"Show cache hosts list (default sorting by ip).",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
return d.Show("address")
|
return d.Show("address", "")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
d.AddHandler(session.NewModuleHandler("net.show by seen", "",
|
d.AddHandler(session.NewModuleHandler("net.show by seen", "",
|
||||||
"Show cache hosts list (sort by last seen).",
|
"Show cache hosts list (sort by last seen).",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
return d.Show("seen")
|
return d.Show("seen", "")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
d.AddHandler(session.NewModuleHandler("net.show by sent", "",
|
d.AddHandler(session.NewModuleHandler("net.show by sent", "",
|
||||||
"Show cache hosts list (sort by sent packets).",
|
"Show cache hosts list (sort by sent packets).",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
return d.Show("sent")
|
return d.Show("sent", "")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
d.AddHandler(session.NewModuleHandler("net.show by rcvd", "",
|
d.AddHandler(session.NewModuleHandler("net.show by rcvd", "",
|
||||||
"Show cache hosts list (sort by received packets).",
|
"Show cache hosts list (sort by received packets).",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
return d.Show("rcvd")
|
return d.Show("rcvd", "")
|
||||||
|
}))
|
||||||
|
|
||||||
|
d.AddHandler(session.NewModuleHandler("net.show ADDRESS", `net.show ([\d\.]+)`,
|
||||||
|
"Show information about a specific address.",
|
||||||
|
func(args []string) error {
|
||||||
|
return d.Show("address", args[0])
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (d *Discovery) getRow(e *network.Endpoint, withMeta bool) [][]string {
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Discovery) Show(by string) error {
|
func (d *Discovery) Show(by string, addr string) error {
|
||||||
targets := d.Session.Lan.List()
|
targets := d.Session.Lan.List()
|
||||||
if by == "seen" {
|
if by == "seen" {
|
||||||
sort.Sort(BySeenSorter(targets))
|
sort.Sort(BySeenSorter(targets))
|
||||||
|
@ -129,6 +129,17 @@ func (d *Discovery) Show(by string) error {
|
||||||
targets = append([]*network.Endpoint{d.Session.Interface, d.Session.Gateway}, targets...)
|
targets = append([]*network.Endpoint{d.Session.Interface, d.Session.Gateway}, targets...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if addr != "" {
|
||||||
|
tmp := make([]*network.Endpoint, 0)
|
||||||
|
pad = 0
|
||||||
|
for _, t := range targets {
|
||||||
|
if t.IP.String() == addr {
|
||||||
|
tmp = append(tmp, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
targets = tmp
|
||||||
|
}
|
||||||
|
|
||||||
hasMeta := false
|
hasMeta := false
|
||||||
for _, t := range targets {
|
for _, t := range targets {
|
||||||
if !t.Meta.Empty() {
|
if !t.Meta.Empty() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue