Skip to content

Commit

Permalink
fix: fixed handshakes filename if wifi.aggregate is false
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Aug 22, 2024
1 parent 7d85483 commit 81adcc9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions modules/wifi/wifi_recon_handshakes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ func allZeros(s []byte) bool {
return true
}

func (mod *WiFiModule) getHandshakeFileFor(ap *network.AccessPoint) string {
shakesFileName := mod.shakesFile
if !mod.shakesAggregate {
parentDir := path.Dir(shakesFileName)
shakesFileName = path.Join(parentDir, fmt.Sprintf("%s.pcap", ap.PathFriendlyName()))
}
return shakesFileName
}

func (mod *WiFiModule) discoverHandshakes(radiotap *layers.RadioTap, dot11 *layers.Dot11, packet gopacket.Packet) {
isEAPOL := false

Expand Down Expand Up @@ -94,10 +103,7 @@ func (mod *WiFiModule) discoverHandshakes(radiotap *layers.RadioTap, dot11 *laye

// if we have unsaved packets as part of the handshake, save them.
numUnsaved := station.Handshake.NumUnsaved()
shakesFileName := mod.shakesFile
if mod.shakesAggregate == false {
shakesFileName = path.Join(shakesFileName, fmt.Sprintf("%s.pcap", ap.PathFriendlyName()))
}
shakesFileName := mod.getHandshakeFileFor(ap)
doSave := numUnsaved > 0
if doSave && shakesFileName != "" {
mod.Debug("(aggregate %v) saving handshake frames to %s", mod.shakesAggregate, shakesFileName)
Expand Down Expand Up @@ -176,10 +182,7 @@ func (mod *WiFiModule) discoverHandshakes(radiotap *layers.RadioTap, dot11 *laye

target.Handshake.AddExtra(packet)

shakesFileName := mod.shakesFile
if mod.shakesAggregate == false {
shakesFileName = path.Join(shakesFileName, fmt.Sprintf("%s.pcap", targetAP.PathFriendlyName()))
}
shakesFileName := mod.getHandshakeFileFor(targetAP)
if shakesFileName != "" {
mod.Debug("(aggregate %v) saving handshake frames to %s", mod.shakesAggregate, shakesFileName)
if err := mod.Session.WiFi.SaveHandshakesTo(shakesFileName, mod.handle.LinkType()); err != nil {
Expand Down

0 comments on commit 81adcc9

Please sign in to comment.