From 4008dcd9d233019366ff8e59b0061baf2f37fbd4 Mon Sep 17 00:00:00 2001 From: Emile Date: Sat, 22 Feb 2020 13:41:22 +0100 Subject: moved to src --- r2pipe.go | 27 --------------------------- src/r2pipe.go | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 r2pipe.go create mode 100644 src/r2pipe.go diff --git a/r2pipe.go b/r2pipe.go deleted file mode 100644 index 977759d..0000000 --- a/r2pipe.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/radare/r2pipe-go" -) - -func main() { - // open a file - // $ r2 ... - r2p, err := r2pipe.NewPipe("/nix/store/xhwhakb1zcf5wl2a8575gcrnmbbqihm2-busybox-1.30.1/bin/ls") - if err != nil { - panic(err) - } - defer r2p.Close() - - // send a command - // [0x004087e0]> ... - buf1, err := r2p.Cmd("?E Hello World") - if err != nil { - panic(err) - } - - // print the result of the first command - fmt.Println(buf1) -} diff --git a/src/r2pipe.go b/src/r2pipe.go new file mode 100644 index 0000000..c6ad3fc --- /dev/null +++ b/src/r2pipe.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + + "github.com/radare/r2pipe-go" +) + +func main() { + // allocate 1024 bytes of memory + r2p, err := r2pipe.NewPipe("malloc://1024") + if err != nil { + panic(err) + } + defer r2p.Close() + + // get a hexdump of the first 100 bytes allocated + hexdump := r2cmd(r2p, "px 100") + fmt.Println(hexdump) + + // compile a warrior using rasm2 + bot := r2cmd(r2p, "rasm2 -a x86 -b 32 -f bots/warrior.asm") + fmt.Println(bot) +} -- cgit 1.4.1