-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·47 lines (43 loc) · 1.34 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
_ "errors"
"flag"
"fmt"
_ "net"
"os"
"strings"
"time"
)
var (
service string
path string
device string
application string
outPath string
)
func getUserPlatformFromPath(filePath string) (string, string) {
if strings.Contains(filePath, "/") {
return strings.Split(filePath, "/")[3], strings.Split(strings.Split(filePath, "/")[4], ".")[0]
} else if strings.Contains(filePath, "\\") {
return strings.Split(filePath, "\\")[3], strings.Split(strings.Split(filePath, "\\")[4], ".")[0]
}
return "", ""
}
func main() {
startTime := time.Now()
flag.StringVar(&service, "s", "youtube", "video service provider name")
flag.StringVar(&path, "p", "../"+service+"_collection/pcap", "path to pcap files")
// assume each directory contains pcap files for a specific user platform
// e.g., ../youtube_collection/pcap/win/chrome.pcapng
dirs, _ := os.ReadDir(path)
for _, dir := range dirs {
filePath := path + "/" + dir.Name()
for _, fileName := range findFilesWithExtension(filePath, ".pcapng") {
device, application = getUserPlatformFromPath(fileName)
outPath = fmt.Sprintf("../"+service+"_collection/context_csv/%s_%s", device, application)
ExtractContextAttributes(fileName, service, device, application, outPath)
}
}
endTime := time.Now()
fmt.Println("Time taken: ", endTime.Sub(startTime))
}