From 80e5782a4587ba9e022f986a48fcbaac571029b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Thu, 16 Jan 2020 00:02:59 +0100 Subject: [PATCH] Added commandline flags --- GetRuntimeAddresses/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/GetRuntimeAddresses/main.go b/GetRuntimeAddresses/main.go index 46e41a3..7bbafb6 100644 --- a/GetRuntimeAddresses/main.go +++ b/GetRuntimeAddresses/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "os" @@ -8,7 +9,15 @@ import ( "github.com/optimyze-interviews/OezguerKesim/GetRuntimeAddresses/symbolyze" ) +var ( + symbol = flag.String("symbol", "_PyRuntime", "Symbol to search for") + glob = flag.String("glob", "*python3*", "pattern an ELF-file must match (see filepath.Match)") + debug = flag.Bool("debug", false, "run in debug mode") +) + func main() { + flag.Parse() + mapFD, err := ebpf.CreateMap() if err != nil { fmt.Printf("Failed to create eBPF map: %s\n", err) @@ -17,12 +26,12 @@ func main() { fmt.Printf("Created eBPF map (FD: %d)\n", mapFD) - // - // Solution to your tasks goes here - // - - scanner := symbolyze.New("_PyRuntime", "*python3*") + scanner := symbolyze.New(*symbol, *glob) scanner.OnFound(mapFD.Set) + if *debug { + scanner.DebugOn() + } + err = scanner.Run() if err != nil { fmt.Printf("Failed to run the symbolyze scanner: %s", err)