Merge pull request #1150 from Sniffleupagus/patch-1

Improve backwards compatibility with getHandshakeFileFor
This commit is contained in:
Simone Margaritelli 2024-11-20 14:32:39 +01:00 committed by GitHub
commit c4e45b368d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"net" "net"
"os"
"path" "path"
"github.com/bettercap/bettercap/v2/network" "github.com/bettercap/bettercap/v2/network"
@ -27,6 +28,11 @@ func (mod *WiFiModule) getHandshakeFileFor(ap *network.AccessPoint) string {
shakesFileName := mod.shakesFile shakesFileName := mod.shakesFile
if !mod.shakesAggregate { if !mod.shakesAggregate {
parentDir := path.Dir(shakesFileName) parentDir := path.Dir(shakesFileName)
// check for existing directory at "shakesFileName" for backwards compatibility
fileInfo, err := os.Stat(shakesFileName)
if (err == nil) && (fileInfo.IsDir()) {
parentDir = shakesFileName
}
shakesFileName = path.Join(parentDir, fmt.Sprintf("%s.pcap", ap.PathFriendlyName())) shakesFileName = path.Join(parentDir, fmt.Sprintf("%s.pcap", ap.PathFriendlyName()))
} }
return shakesFileName return shakesFileName