Package radareutil provides functionality for working with radare2.
This library currently provides very rudimentary support for radare2's CLI
and HTTP APIs. This is achieved using a basic interface called Api
.
The underlying radare2 process is managed and interacted with using this
interface. It is strongly recommended that you use the CLI API
implementation to drive radare2. The HTTP API is not nearly as secure as the
CLI API. You should only use the HTTP API if you know what you are doing (at
which point you should ask yourself where it all went wrong).
As noted before, you should really use the CLI API to drive radare2. This
is done using the NewCliApi()
function:
package main
import (
"fmt"
"log"
"github.com/stephen-fox/radareutil"
)
func main() {
cliApi, err := radareutil.NewCliApi(&radareutil.Radare2Config{
// The executable path does not need to be fully qualified.
ExecutablePath: "radare2",
})
if err != nil {
log.Fatalf("failed to create a CLI API - %s", err.Error())
}
err = cliApi.Start()
if err != nil {
log.Fatalf("failed to start CLI API - %s", err.Error())
}
defer cliApi.Kill()
output, err := cliApi.Execute("?")
if err != nil {
log.Fatalf("failed to execute API command - %s", err.Error())
}
fmt.Println(output)
}