mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 04:59:25 -07:00
Implemented a way to not send deauthentication and/or association packets to AP's for which key material was already acquired
This commit is contained in:
parent
8ae28f4b3d
commit
a0a0963cd5
3 changed files with 34 additions and 0 deletions
|
@ -49,9 +49,11 @@ type WiFiModule struct {
|
||||||
deauthSkip []net.HardwareAddr
|
deauthSkip []net.HardwareAddr
|
||||||
deauthSilent bool
|
deauthSilent bool
|
||||||
deauthOpen bool
|
deauthOpen bool
|
||||||
|
deauthAcquired bool
|
||||||
assocSkip []net.HardwareAddr
|
assocSkip []net.HardwareAddr
|
||||||
assocSilent bool
|
assocSilent bool
|
||||||
assocOpen bool
|
assocOpen bool
|
||||||
|
assocAcquired bool
|
||||||
filterProbeSTA *regexp.Regexp
|
filterProbeSTA *regexp.Regexp
|
||||||
filterProbeAP *regexp.Regexp
|
filterProbeAP *regexp.Regexp
|
||||||
apRunning bool
|
apRunning bool
|
||||||
|
@ -80,9 +82,11 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
deauthSkip: []net.HardwareAddr{},
|
deauthSkip: []net.HardwareAddr{},
|
||||||
deauthSilent: false,
|
deauthSilent: false,
|
||||||
deauthOpen: false,
|
deauthOpen: false,
|
||||||
|
deauthAcquired: false,
|
||||||
assocSkip: []net.HardwareAddr{},
|
assocSkip: []net.HardwareAddr{},
|
||||||
assocSilent: false,
|
assocSilent: false,
|
||||||
assocOpen: false,
|
assocOpen: false,
|
||||||
|
assocAcquired: false,
|
||||||
showManuf: false,
|
showManuf: false,
|
||||||
shakesAggregate: true,
|
shakesAggregate: true,
|
||||||
writes: &sync.WaitGroup{},
|
writes: &sync.WaitGroup{},
|
||||||
|
@ -209,6 +213,10 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
"true",
|
"true",
|
||||||
"Send wifi deauth packets to open networks."))
|
"Send wifi deauth packets to open networks."))
|
||||||
|
|
||||||
|
mod.AddParam(session.NewBoolParameter("wifi.deauth.acquired",
|
||||||
|
"false",
|
||||||
|
"Send wifi deauth packets from AP's for which key material was already acquired."))
|
||||||
|
|
||||||
assoc := 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 {
|
||||||
|
@ -272,6 +280,10 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
"false",
|
"false",
|
||||||
"Send association requests to open networks."))
|
"Send association requests to open networks."))
|
||||||
|
|
||||||
|
mod.AddParam(session.NewBoolParameter("wifi.assoc.acquired",
|
||||||
|
"false",
|
||||||
|
"Send association to AP's for which key material was already acquired."))
|
||||||
|
|
||||||
mod.AddHandler(session.NewModuleHandler("wifi.ap", "",
|
mod.AddHandler(session.NewModuleHandler("wifi.ap", "",
|
||||||
"Inject fake management beacons in order to create a rogue access point.",
|
"Inject fake management beacons in order to create a rogue access point.",
|
||||||
func(args []string) error {
|
func(args []string) error {
|
||||||
|
|
|
@ -51,6 +51,15 @@ func (mod *WiFiModule) doAssocOpen() bool {
|
||||||
return mod.assocOpen
|
return mod.assocOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mod *WiFiModule) doAssocAcquired() bool {
|
||||||
|
if err, is := mod.BoolParam("wifi.assoc.acquired"); err != nil {
|
||||||
|
mod.Warning("%v", err)
|
||||||
|
} else {
|
||||||
|
mod.assocAcquired = is
|
||||||
|
}
|
||||||
|
return mod.assocAcquired
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
|
func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
|
||||||
// parse skip list
|
// parse skip list
|
||||||
if err, assocSkip := mod.StringParam("wifi.assoc.skip"); err != nil {
|
if err, assocSkip := mod.StringParam("wifi.assoc.skip"); err != nil {
|
||||||
|
@ -110,6 +119,8 @@ func (mod *WiFiModule) startAssoc(to net.HardwareAddr) error {
|
||||||
|
|
||||||
if ap.IsOpen() && !mod.doAssocOpen() {
|
if ap.IsOpen() && !mod.doAssocOpen() {
|
||||||
mod.Debug("skipping association for open network %s (wifi.assoc.open is false)", ap.ESSID())
|
mod.Debug("skipping association for open network %s (wifi.assoc.open is false)", ap.ESSID())
|
||||||
|
} else if ap.HasKeyMaterial() && !mod.doAssocAcquired() {
|
||||||
|
mod.Debug("skipping association for AP %s (key material already acquired)", ap.ESSID())
|
||||||
} else {
|
} else {
|
||||||
logger("sending association request to AP %s (channel:%d encryption:%s)", ap.ESSID(), ap.Channel, ap.Encryption)
|
logger("sending association request to AP %s (channel:%d encryption:%s)", ap.ESSID(), ap.Channel, ap.Encryption)
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,15 @@ func (mod *WiFiModule) doDeauthOpen() bool {
|
||||||
return mod.deauthOpen
|
return mod.deauthOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mod *WiFiModule) doDeauthAcquired() bool {
|
||||||
|
if err, is := mod.BoolParam("wifi.deauth.acquired"); err != nil {
|
||||||
|
mod.Warning("%v", err)
|
||||||
|
} else {
|
||||||
|
mod.deauthAcquired = is
|
||||||
|
}
|
||||||
|
return mod.deauthAcquired
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
||||||
// parse skip list
|
// parse skip list
|
||||||
if err, deauthSkip := mod.StringParam("wifi.deauth.skip"); err != nil {
|
if err, deauthSkip := mod.StringParam("wifi.deauth.skip"); err != nil {
|
||||||
|
@ -136,6 +145,8 @@ func (mod *WiFiModule) startDeauth(to net.HardwareAddr) error {
|
||||||
|
|
||||||
if ap.IsOpen() && !mod.doDeauthOpen() {
|
if ap.IsOpen() && !mod.doDeauthOpen() {
|
||||||
mod.Debug("skipping deauth for open network %s (wifi.deauth.open is false)", ap.ESSID())
|
mod.Debug("skipping deauth for open network %s (wifi.deauth.open is false)", ap.ESSID())
|
||||||
|
} else if ap.HasKeyMaterial() && !mod.doDeauthAcquired() {
|
||||||
|
mod.Debug("skipping deauth for AP %s (key material already acquired)", ap.ESSID())
|
||||||
} else {
|
} else {
|
||||||
logger("deauthing client %s from AP %s (channel:%d encryption:%s)", client.String(), ap.ESSID(), ap.Channel, ap.Encryption)
|
logger("deauthing client %s from AP %s (channel:%d encryption:%s)", client.String(), ap.ESSID(), ap.Channel, ap.Encryption)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue