mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 04:52:10 -07:00
Improve backwards compatibility with getHandshakeFileFor
The getHandshakeFile function was using "path.Dir(shakesFileName)", which drops the last element of the path. This is not backwards compatible with prior versions that used the variable as the dir name. In particular this change causes pwnagotchi to store handshakes in /root instead of /root/handshakes. This commit checks for an existing directory at shakesFileName and will use that as the path instead of taking the parent directory of the path.
This commit is contained in:
parent
00854261a4
commit
cb5f7679d8
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue