func TestRun(t *testing.T) { file := "samples/simple/O0/strings" f := ioReader(file) _elf, err := elf.NewFile(f) check(wrap(err)) maps := loader.GetSegments(_elf) symbols := loader.GetSymbols(_elf) fmt.Println("done loading") emulator := MakeBlanketEmulator(maps) fmt.Println("done making blanket emulator") for rng, symb := range symbols { if symb.Type == ds.FUNC && strings.Contains(symb.Name, "str") { bbs := extract_bbs(maps, rng) if len(bbs) == 0 { continue } fmt.Printf("found function %v\n", symb.Name) fmt.Printf("running for %v \n", bbs) err := emulator.FullBlanket(bbs) if err != nil { log.WithFields(log.Fields{"error": err}).Fatal("Error running Blanket") } ev := emulator.Config.EventHandler.(*be.EventsToMinHash) fmt.Println("hash %v", ev.GetHash(60)) // fmt.Println("events %v", ev.Inspect()) } } }
func main() { file := os.Args[1] log.SetLevel(log.ErrorLevel) fmt.Printf("%v\n", os.Args) if len(os.Args) >= 3 && os.Args[2] == "d" { log.SetLevel(log.DebugLevel) } f := ioReader(file) _elf, err := elf.NewFile(f) check(wrap(err)) maps := loader.GetSegments(_elf) symbols := loader.GetSymbols(_elf) fmt.Println("done loading") fmt.Printf("maps %v\n", maps) for rng, symb := range symbols { if !are_we_interessted_in_this(symb) { continue } bbs := extract_bbs(maps, rng) if len(bbs) == 0 { continue } fmt.Printf("%v : ", pad_func_name(symb.Name)) emulator := MakeBlanketEmulator(maps) err := emulator.FullBlanket(bbs) if err != nil { log.WithFields(log.Fields{"error": err}).Error("Error running Blanket") continue } ev := emulator.Events fmt.Printf("hash %v\n", hex.EncodeToString(ev.GetHash(32))) log.WithFields(log.Fields{"events": ev.Inspect()}).Debug("Done running Blanket") emulator.Close() emulator = nil } }