ebpf-challenge/GetRuntimeAddresses/main.go

44 lines
881 B
Go
Raw Normal View History

2020-01-14 15:32:06 +01:00
package main
import (
"fmt"
"os"
"github.com/optimyze-interviews/OezguerKesim/GetRuntimeAddresses/ebpf"
"github.com/optimyze-interviews/OezguerKesim/GetRuntimeAddresses/symbolyze"
2020-01-14 15:32:06 +01:00
)
func main() {
mapFD, err := ebpf.CreateMap()
if err != nil {
fmt.Printf("Failed to create eBPF map: %s\n", err)
os.Exit(1)
}
fmt.Printf("Created eBPF map (FD: %d)\n", mapFD)
//
// Solution to your tasks goes here
//
scanner := symbolyze.New("_PyRuntime", "*python3*")
scanner.OnFound(mapFD.Set)
err = scanner.Run()
if err != nil {
fmt.Printf("Failed to run the symbolyze scanner: %s", err)
os.Exit(1)
}
2020-01-15 12:48:36 +01:00
mapContents, err := mapFD.GetMap()
2020-01-14 15:32:06 +01:00
if err != nil {
fmt.Printf("Failed to get the map contents: %s", err)
os.Exit(1)
}
fmt.Printf("Printing contents of map %d\n", mapFD)
for k, v := range mapContents {
fmt.Printf("\t%d -> 0x%x\n", k, v)
}
os.Exit(0)
}