2019-11-26 21:45:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
2023-09-02 15:17:51 +00:00
|
|
|
"github.com/maride/pancap/analyze"
|
|
|
|
"github.com/maride/pancap/output"
|
2019-11-26 21:45:27 +00:00
|
|
|
"log"
|
2019-11-28 17:28:32 +00:00
|
|
|
"math/rand"
|
|
|
|
"time"
|
2019-11-26 21:45:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// important things first
|
|
|
|
printMOTD()
|
|
|
|
|
|
|
|
// register flags
|
|
|
|
registerFileFlags()
|
2019-12-03 23:10:42 +00:00
|
|
|
output.RegisterFlags()
|
2019-11-26 21:45:27 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
// Open the given PCAP
|
2019-12-09 11:14:01 +00:00
|
|
|
packetSource, _, fileErr := openPCAP()
|
2019-11-26 21:45:27 +00:00
|
|
|
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
|
2019-12-09 11:14:01 +00:00
|
|
|
analyzeErr := analyze.Analyze(packetSource)
|
2019-11-26 21:45:27 +00:00
|
|
|
if analyzeErr != nil {
|
2019-11-27 15:35:43 +00:00
|
|
|
// Mh, encountered some problems while analyzing file
|
2019-11-26 21:45:27 +00:00
|
|
|
log.Fatalf("Error occurred while analyzing: %s", analyzeErr.Error())
|
|
|
|
}
|
2019-12-03 23:10:42 +00:00
|
|
|
|
2020-01-08 15:34:31 +00:00
|
|
|
// Extract found and requested files
|
|
|
|
output.StoreFiles()
|
|
|
|
|
2019-12-09 11:14:01 +00:00
|
|
|
// Show user analysis
|
|
|
|
analyze.PrintSummary()
|
|
|
|
|
2020-01-08 15:34:31 +00:00
|
|
|
// Print filemanager summary
|
|
|
|
output.PrintSummary()
|
|
|
|
|
2019-12-03 23:10:42 +00:00
|
|
|
// Finalize output
|
|
|
|
output.Finalize()
|
2019-11-26 21:45:27 +00:00
|
|
|
}
|
|
|
|
|
2019-11-28 17:28:32 +00:00
|
|
|
// Prints a simple figlet-style ASCII art and a random quote
|
2019-11-26 21:45:27 +00:00
|
|
|
func printMOTD() {
|
2019-11-28 17:28:32 +00:00
|
|
|
randomQuotes := []string{
|
|
|
|
"PanCAP: Analyzer for capture files",
|
|
|
|
"PanCAP: Analyzer for pancake files",
|
|
|
|
"You want some syrup with these packets?",
|
|
|
|
"Check out CONTRIBUTORS.md!",
|
2023-09-02 15:17:51 +00:00
|
|
|
"Push your commits to github.com/maride/pancap",
|
2019-11-28 17:28:32 +00:00
|
|
|
"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.",
|
2023-09-02 15:31:43 +00:00
|
|
|
"Make public data available, protect private data.", // https://www.ccc.de/en/hackerethik
|
2020-11-24 23:09:24 +00:00
|
|
|
"Most traffic is just there to confuse the russians.", // hat-tip to twitter.com/_harryr_
|
2019-11-28 17:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Maybe switch to urand? Possibly a security issue... ;)
|
|
|
|
rand.Seed(time.Now().Unix())
|
|
|
|
|
2019-11-26 21:45:27 +00:00
|
|
|
fmt.Println(" _ __ __ _ _ __ ___ __ _ _ __")
|
|
|
|
fmt.Println("| '_ \\ / _` | '_ \\ / __/ _` | '_ \\")
|
|
|
|
fmt.Println("| |_) | (_| | | | | (_| (_| | |_) |")
|
|
|
|
fmt.Println("| .__/ \\__,_|_| |_|\\___\\__,_| .__/")
|
|
|
|
fmt.Println("|_| |_|")
|
2019-11-28 17:28:32 +00:00
|
|
|
fmt.Println(randomQuotes[rand.Intn(len(randomQuotes))])
|
|
|
|
fmt.Println("")
|
2019-11-26 21:45:27 +00:00
|
|
|
}
|