new: new wifi.handshakes.aggregate parameter to control how handshakes get saved

This commit is contained in:
evilsocket 2019-08-22 13:21:52 -04:00
commit da565afa9a
No known key found for this signature in database
GPG key ID: 82E42E7F3B34C97E
4 changed files with 63 additions and 26 deletions

View file

@ -3,6 +3,7 @@ package network
import (
"encoding/json"
"os"
"path/filepath"
"strconv"
"sync"
"time"
@ -214,8 +215,15 @@ func (w *WiFi) SaveHandshakesTo(fileName string, linkType layers.LinkType) error
w.Lock()
defer w.Unlock()
doHead := !fs.Exists(fileName)
// check if folder exists first
dirName := filepath.Dir(fileName)
if _, err := os.Stat(dirName); err != nil {
if err = os.MkdirAll(dirName, os.ModePerm); err != nil {
return err
}
}
doHead := !fs.Exists(fileName)
fp, err := os.OpenFile(fileName, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return err