-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
80 lines (66 loc) · 2.09 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"flag"
"fmt"
"log"
"math/rand"
"time"
"github.com/maride/pancap/analyze"
"github.com/maride/pancap/output"
)
func main() {
// important things first
printMOTD()
// register flags
registerFileFlags()
output.RegisterFlags()
flag.Parse()
// Open the given PCAP
packetSource, _, fileErr := openPCAP()
if fileErr != nil {
// Encountered problems with the PCAP - permission and/or existance error
log.Fatalf("Error occured while opeining specified file: %s", fileErr.Error())
}
// Start analyzing
analyzeErr := analyze.Analyze(packetSource)
if analyzeErr != nil {
// Mh, encountered some problems while analyzing file
log.Fatalf("Error occurred while analyzing: %s", analyzeErr.Error())
}
// Extract found and requested files
output.StoreFiles()
// Create communication graph
output.CreateGraph()
// Show user analysis
analyze.PrintSummary()
// Print filemanager summary
output.PrintSummary()
// Finalize output
output.Finalize()
}
// Prints a simple figlet-style ASCII art and a random quote
func printMOTD() {
randomQuotes := []string{
"PanCAP: Analyzer for capture files",
"PanCAP: Analyzer for pancake files",
"You want some syrup with these packets?",
"Check out CONTRIBUTORS.md!",
"Push your commits to github.com/maride/pancap",
"Don't let the white noise traffic confuse you.",
"Grab a Club Mate if you don't have one yet.",
"In Soviet Russia, traffic analyzes you.",
"Who captures the captors?",
"Respect other's privacy. Always.",
"Make public data available, protect private data.", // https://www.ccc.de/en/hackerethik
"Most traffic is just there to confuse the russians.", // hat-tip to twitter.com/_harryr_
}
// Maybe switch to urand? Possibly a security issue... ;)
rand.Seed(time.Now().Unix())
fmt.Println(" _ __ __ _ _ __ ___ __ _ _ __")
fmt.Println("| '_ \\ / _` | '_ \\ / __/ _` | '_ \\")
fmt.Println("| |_) | (_| | | | | (_| (_| | |_) |")
fmt.Println("| .__/ \\__,_|_| |_|\\___\\__,_| .__/")
fmt.Println("|_| |_|")
fmt.Println(randomQuotes[rand.Intn(len(randomQuotes))])
fmt.Println("")
}