mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
new: wifi.deauth and wifi.assoc now support autocompletion
This commit is contained in:
parent
49e2116d46
commit
a4aa5acbcd
3 changed files with 59 additions and 17 deletions
|
@ -8,7 +8,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
golog "log"
|
golog "log"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/modules/utils"
|
"github.com/bettercap/bettercap/modules/utils"
|
||||||
|
@ -77,7 +76,7 @@ func NewBLERecon(s *session.Session) *BLERecon {
|
||||||
return mod.enumAllTheThings(network.NormalizeMac(args[0]))
|
return mod.enumAllTheThings(network.NormalizeMac(args[0]))
|
||||||
})
|
})
|
||||||
|
|
||||||
enum.Complete("ble.enum", mod.macCompleter)
|
enum.Complete("ble.enum", s.BLECompleter)
|
||||||
|
|
||||||
mod.AddHandler(enum)
|
mod.AddHandler(enum)
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ func NewBLERecon(s *session.Session) *BLERecon {
|
||||||
return mod.writeBuffer(mac, uuid, data)
|
return mod.writeBuffer(mac, uuid, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
write.Complete("ble.write", mod.macCompleter)
|
write.Complete("ble.write", s.BLECompleter)
|
||||||
|
|
||||||
mod.AddHandler(write)
|
mod.AddHandler(write)
|
||||||
|
|
||||||
|
@ -116,16 +115,6 @@ func (mod BLERecon) Author() string {
|
||||||
return "Simone Margaritelli <evilsocket@gmail.com>"
|
return "Simone Margaritelli <evilsocket@gmail.com>"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *BLERecon) macCompleter(prefix string) []string {
|
|
||||||
macs := []string{""}
|
|
||||||
mod.Session.BLE.EachDevice(func(mac string, dev *network.BLEDevice) {
|
|
||||||
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
|
||||||
macs = append(macs, mac)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return macs
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mod *BLERecon) isEnumerating() bool {
|
func (mod *BLERecon) isEnumerating() bool {
|
||||||
return mod.currDevice != nil
|
return mod.currDevice != nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
"-200",
|
"-200",
|
||||||
"Minimum WiFi signal strength in dBm."))
|
"Minimum WiFi signal strength in dBm."))
|
||||||
|
|
||||||
mod.AddHandler(session.NewModuleHandler("wifi.deauth BSSID", `wifi\.deauth ((?:[a-fA-F0-9:]{11,})|all|\*)`,
|
deauth := session.NewModuleHandler("wifi.deauth BSSID", `wifi\.deauth ((?:[a-fA-F0-9:]{11,})|all|\*)`,
|
||||||
"Start a 802.11 deauth attack, if an access point BSSID is provided, every client will be deauthenticated, otherwise only the selected client. Use 'all', '*' or a broadcast BSSID (ff:ff:ff:ff:ff:ff) to iterate every access point with at least one client and start a deauth attack for each one.",
|
"Start a 802.11 deauth attack, if an access point BSSID is provided, every client will be deauthenticated, otherwise only the selected client. Use 'all', '*' or a broadcast BSSID (ff:ff:ff:ff:ff:ff) to iterate every access point with at least one client and start a deauth attack for each one.",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
if args[0] == "all" || args[0] == "*" {
|
if args[0] == "all" || args[0] == "*" {
|
||||||
|
@ -126,7 +126,11 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return mod.startDeauth(bssid)
|
return mod.startDeauth(bssid)
|
||||||
}))
|
})
|
||||||
|
|
||||||
|
deauth.Complete("wifi.deauth", s.WiFiCompleterFull)
|
||||||
|
|
||||||
|
mod.AddHandler(deauth)
|
||||||
|
|
||||||
mod.AddParam(session.NewStringParameter("wifi.deauth.skip",
|
mod.AddParam(session.NewStringParameter("wifi.deauth.skip",
|
||||||
"",
|
"",
|
||||||
|
@ -141,7 +145,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
"true",
|
"true",
|
||||||
"Send wifi deauth packets to open networks."))
|
"Send wifi deauth packets to open networks."))
|
||||||
|
|
||||||
mod.AddHandler(session.NewModuleHandler("wifi.assoc BSSID", `wifi\.assoc ((?:[a-fA-F0-9:]{11,})|all|\*)`,
|
assoc := session.NewModuleHandler("wifi.assoc BSSID", `wifi\.assoc ((?:[a-fA-F0-9:]{11,})|all|\*)`,
|
||||||
"Send an association request to the selected BSSID in order to receive a RSN PMKID key. Use 'all', '*' or a broadcast BSSID (ff:ff:ff:ff:ff:ff) to iterate for every access point.",
|
"Send an association request to the selected BSSID in order to receive a RSN PMKID key. Use 'all', '*' or a broadcast BSSID (ff:ff:ff:ff:ff:ff) to iterate for every access point.",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
if args[0] == "all" || args[0] == "*" {
|
if args[0] == "all" || args[0] == "*" {
|
||||||
|
@ -152,7 +156,11 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return mod.startAssoc(bssid)
|
return mod.startAssoc(bssid)
|
||||||
}))
|
})
|
||||||
|
|
||||||
|
assoc.Complete("wifi.assoc", s.WiFiCompleter)
|
||||||
|
|
||||||
|
mod.AddHandler(assoc)
|
||||||
|
|
||||||
mod.AddParam(session.NewStringParameter("wifi.assoc.skip",
|
mod.AddParam(session.NewStringParameter("wifi.assoc.skip",
|
||||||
"",
|
"",
|
||||||
|
|
|
@ -154,6 +154,51 @@ func (s *Session) Unlock() {
|
||||||
s.WiFi.Unlock()
|
s.WiFi.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Session) LANCompleter(prefix string) []string {
|
||||||
|
macs := []string{""}
|
||||||
|
s.Lan.EachHost(func(mac string, e *network.Endpoint) {
|
||||||
|
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
||||||
|
macs = append(macs, mac)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return macs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Session) WiFiCompleter(prefix string) []string {
|
||||||
|
macs := []string{""}
|
||||||
|
s.WiFi.EachAccessPoint(func(mac string, ap *network.AccessPoint) {
|
||||||
|
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
||||||
|
macs = append(macs, mac)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return macs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Session) WiFiCompleterFull(prefix string) []string {
|
||||||
|
macs := []string{""}
|
||||||
|
s.WiFi.EachAccessPoint(func(mac string, ap *network.AccessPoint) {
|
||||||
|
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
||||||
|
macs = append(macs, mac)
|
||||||
|
}
|
||||||
|
ap.EachClient(func(mac string, c *network.Station) {
|
||||||
|
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
||||||
|
macs = append(macs, mac)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return macs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Session) BLECompleter(prefix string) []string {
|
||||||
|
macs := []string{""}
|
||||||
|
s.BLE.EachDevice(func(mac string, dev *network.BLEDevice) {
|
||||||
|
if prefix == "" || strings.HasPrefix(mac, prefix) {
|
||||||
|
macs = append(macs, mac)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return macs
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Session) Module(name string) (err error, mod Module) {
|
func (s *Session) Module(name string) (err error, mod Module) {
|
||||||
for _, m := range s.Modules {
|
for _, m := range s.Modules {
|
||||||
if m.Name() == name {
|
if m.Name() == name {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue