mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
fix: fixed a panic in net.show.meta when rendeing open ports
This commit is contained in:
parent
2dcfea02ce
commit
31b06638d8
3 changed files with 26 additions and 4 deletions
|
@ -2,6 +2,7 @@ package net_recon
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bettercap/bettercap/modules/syn_scan"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -12,6 +13,7 @@ import (
|
|||
"github.com/dustin/go-humanize"
|
||||
|
||||
"github.com/evilsocket/islazy/tui"
|
||||
"github.com/evilsocket/islazy/str"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -297,9 +299,29 @@ func (mod *Discovery) showMeta(arg string) (err error) {
|
|||
}
|
||||
|
||||
for _, k := range keys {
|
||||
meta := t.Meta.Get(k)
|
||||
val := ""
|
||||
if s, ok := meta.(string); ok {
|
||||
val = s
|
||||
} else if ports, ok := meta.(map[int]*syn_scan.OpenPort); ok {
|
||||
val = "ports: "
|
||||
for _, info := range ports {
|
||||
val += fmt.Sprintf("%s:%d", info.Proto, info.Port)
|
||||
if info.Service != "" {
|
||||
val += fmt.Sprintf("(%s)", info.Service)
|
||||
}
|
||||
if info.Banner != "" {
|
||||
val += fmt.Sprintf(" [%s]", info.Banner)
|
||||
}
|
||||
val += " "
|
||||
}
|
||||
val = str.Trim(val)
|
||||
} else {
|
||||
val = fmt.Sprintf("%#v", meta)
|
||||
}
|
||||
rows = append(rows, []string{
|
||||
tui.Green(k),
|
||||
tui.Yellow(t.Meta.Get(k).(string)),
|
||||
tui.Yellow(val),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue