mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
refact: refactored to use islazy and updated deps
This commit is contained in:
parent
a2b3ee79fb
commit
d070445225
238 changed files with 12662 additions and 1586 deletions
|
@ -8,10 +8,11 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/bettercap/bettercap/core"
|
||||
"github.com/evilsocket/islazy/fs"
|
||||
"github.com/evilsocket/islazy/str"
|
||||
)
|
||||
|
||||
var fileName, _ = core.ExpandPath("~/bettercap.aliases")
|
||||
var fileName, _ = fs.Expand("~/bettercap.aliases")
|
||||
|
||||
type Aliases struct {
|
||||
sync.Mutex
|
||||
|
@ -24,7 +25,7 @@ func LoadAliases() (err error, aliases *Aliases) {
|
|||
data: make(map[string]string),
|
||||
}
|
||||
|
||||
if core.Exists(fileName) {
|
||||
if fs.Exists(fileName) {
|
||||
var file *os.File
|
||||
|
||||
file, err = os.Open(fileName)
|
||||
|
@ -37,8 +38,8 @@ func LoadAliases() (err error, aliases *Aliases) {
|
|||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
parts := strings.SplitN(line, " ", 2)
|
||||
mac := core.Trim(parts[0])
|
||||
alias := core.Trim(parts[1])
|
||||
mac := str.Trim(parts[0])
|
||||
alias := str.Trim(parts[1])
|
||||
aliases.data[mac] = alias
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bettercap/bettercap/core"
|
||||
"github.com/evilsocket/islazy/tui"
|
||||
)
|
||||
|
||||
type OnHostResolvedCallback func(e *Endpoint)
|
||||
|
@ -152,7 +152,7 @@ func (t *Endpoint) String() string {
|
|||
} else if t.Hostname == "" {
|
||||
return fmt.Sprintf("%s%s ( %s )", ipPart, t.HwAddress, t.Vendor)
|
||||
}
|
||||
return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, core.Bold(t.Hostname))
|
||||
return fmt.Sprintf("%s%s ( %s ) - %s", ipPart, t.HwAddress, t.Vendor, tui.Bold(t.Hostname))
|
||||
}
|
||||
|
||||
func (t *Endpoint) OnMeta(meta map[string]string) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/bettercap/bettercap/core"
|
||||
"github.com/evilsocket/islazy/str"
|
||||
|
||||
"github.com/malfunkt/iprange"
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ func ParseTargets(targets string, aliasMap *Aliases) (ips []net.IP, macs []net.H
|
|||
ips = make([]net.IP, 0)
|
||||
macs = make([]net.HardwareAddr, 0)
|
||||
|
||||
if targets = core.Trim(targets); targets == "" {
|
||||
if targets = str.Trim(targets); targets == "" {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ func FindInterface(name string) (*Endpoint, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name = core.Trim(name)
|
||||
name = str.Trim(name)
|
||||
if name != "" {
|
||||
return findInterfaceByName(name, ifaces)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ func FindGateway(iface *Endpoint) (*Endpoint, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
gw := core.Trim(output)
|
||||
gw := str.Trim(output)
|
||||
if IPv4Validator.MatchString(gw) {
|
||||
// we have the address, now we need its mac
|
||||
mac, err := ArpLookup(iface.Name(), gw, false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue