r2g2

package module
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2021 License: GPL-3.0 Imports: 10 Imported by: 2

README

r2g2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrR2PipeNotAvailable indicates that R2's pipes are not available.
	ErrR2PipeNotAvailable = errors.New("R2PIPEs are not available")
	// ErrPipeOutNotAvailable indicates that R2's out pipe is not available.
	ErrPipeOutNotAvailable = errors.New("could not connect to Pipe out FD")
	// ErrPipeInNotAvailable indicates that R2's in pipe is not available.
	ErrPipeInNotAvailable = errors.New("could not connect to Pipe in FD")
)
View Source
var (
	// ErrNoActiveFile is returned if no active file is found.
	ErrNoActiveFile = errors.New("no active file")
)

Functions

func CheckForR2Pipe

func CheckForR2Pipe() bool

CheckForR2Pipe returns true if the Environment variables R2PIPE_IN and R2PIPE_OUT has been set. This indicates that the process has been invoked from within r2 via "#!pipe".

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for interacting with radare2.

func New added in v0.2.0

func New(file string) (*Client, error)

New opens the given file with Radare2 and returns a Client handler to the instance.

func OpenPipe

func OpenPipe() (*Client, error)

OpenPipe connects to Radare2 via the pipe interface and returns a Client. This should be used for applications called from with in Radare2 using the "#!pipe" command.

func (*Client) AnalyzeAll added in v0.2.0

func (c *Client) AnalyzeAll() error

AnalyzeAll performs the "aaa" command.

func (*Client) AnalyzeFunction

func (c *Client) AnalyzeFunction(name string, addr uint64) error

AnalyzeFunction analyzing the function starting at the address addr.

func (*Client) AnalyzeFunctionRecursive added in v0.2.0

func (c *Client) AnalyzeFunctionRecursive(name string, addr uint64) error

AnalyzeFunctionRecursive analyzing the function recursivly starting at the address addr.

func (*Client) GetActiveOpenFile

func (c *Client) GetActiveOpenFile() (*OpenFile, error)

GetActiveOpenFile returns the current active file in radare.

func (*Client) GetClipboard added in v0.3.0

func (c *Client) GetClipboard() (*Clipboard, error)

GetClipboard returns the value in radare's clipboard.

func (*Client) GetCurrentAddress

func (c *Client) GetCurrentAddress() (uint64, error)

GetCurrentAddress returns the current address.

func (*Client) GetCurrentFunction

func (c *Client) GetCurrentFunction() (*Function, error)

GetCurrentFunction returns information about the current function.

func (*Client) GetFlags added in v0.2.0

func (c *Client) GetFlags() ([]*Flag, error)

GetFlags returns all the flags in the current session.

func (*Client) GetFunctionAtOffset added in v0.2.0

func (c *Client) GetFunctionAtOffset(offset uint64) (*Function, error)

GetFunctionAtOffset returns function information about a function located at the given offset.

func (*Client) GetSymbolOffset added in v0.2.0

func (c *Client) GetSymbolOffset(sym string) (uint64, error)

GetSymbolOffset returns the offset of a symbol.

func (*Client) ListOpenFiles

func (c *Client) ListOpenFiles() ([]*OpenFile, error)

ListOpenFiles returns a list of open files.

func (*Client) NewFlag

func (c *Client) NewFlag(name string, offset uint64) error

NewFlag creates a flag with the name at the offset with a length of 1.

func (*Client) NewFlagWithLength

func (c *Client) NewFlagWithLength(name string, offset, length uint64) error

NewFlagWithLength creates a flag with the name at the offset with the length.

func (*Client) Run

func (c *Client) Run(cmd string) ([]byte, error)

Run executes a radare command and returns the result as a byte slice.

func (*Client) SeekTo

func (c *Client) SeekTo(addr uint64) error

SeekTo seeks to address addr.

func (*Client) ZignatureFunction added in v0.2.0

func (c *Client) ZignatureFunction(symbol string) (*Zignature, error)

ZignatureFunction creates a Zignature for a function at the given symbol.

func (*Client) ZignatureFunctionOffset added in v0.2.0

func (c *Client) ZignatureFunctionOffset(offset uint64) (*Zignature, error)

ZignatureFunctionOffset creates a Zignature for a function at the given offset.

type Clipboard added in v0.3.0

type Clipboard struct {
	// Address is the address the bytes were yanked from.
	Address int64 `json:"addr"`
	// Bytes are the bytes yanked.
	Bytes string `json:"bytes"`
}

Clipboard is a representation of radare's clipboard.

type CommandHandler

type CommandHandler interface {
	Run(cmd string) ([]byte, error)
}

CommandHandler can send commands to radare and return the output.

type Flag added in v0.2.0

type Flag struct {
	Name     string `json:"name"`
	RealName string `json:"realname"`
	Size     uint64 `json:"size"`
	Offset   uint64 `json:"offset"`
}

Flag is a representation of an radare2 flag.

type Function

type Function struct {
	Name string `json:"name"`
	Size uint64 `json:"size"`
	Addr uint64 `json:"addr"`
	Ops  []*Op  `json:"ops"`
}

Function holds information about a radare function.

type Graph added in v0.2.0

type Graph struct {
	CC    int `json:"cc"`
	Nbbs  int `json:"nbbs"`
	Edges int `json:"edges"`
	Ebbs  int `json:"ebbs"`
	BBSum int `json:"bbsum"`
}

Graph is a graph summary of a function.

type Op

type Op struct {
	Offset   uint64   `json:"offset"`
	Ptr      uint64   `json:"ptr"`
	ESIL     string   `json:"esil"`
	RefPtr   bool     `json:"refptr"`
	FcnAddr  uint64   `json:"fcn_addr"`
	FcnLast  uint64   `json:"fcn_last"`
	Size     uint64   `json:"size"`
	OpCode   string   `json:"opcode"`
	Disasm   string   `json:"disasm"`
	Bytes    string   `json:"bytes"`
	Family   string   `json:"family"`
	Type     string   `json:"type"`
	TypeNum  uint64   `json:"type_num"`
	Type2Num uint64   `json:"type2_num"`
	Flags    []string `json:"flags"`
	Jump     uint64   `json:"jump"`
	Fail     uint64   `json:"fail"`
	XRefs    []*XRef  `json:"xrefs"`
}

Op holds information about an operation.

type OpenFile

type OpenFile struct {
	Active         bool   `json:"raised"`
	FileDescriptor int    `json:"fd"`
	Path           string `json:"uri"`
	From           int    `json:"from"`
	Writable       bool   `json:"writable"`
	Size           uint64 `json:"size"`
}

OpenFile holds information about an open file.

type XRef

type XRef struct {
	Addr uint64 `json:"addr"`
	Type string `jsoin:"type"`
}

XRef holds information about a cross-reference.

type Zignature added in v0.2.0

type Zignature struct {
	Name     string            `json:"name"`
	Bytes    string            `json:"bytes"`
	Mask     string            `json:"mask"`
	Graph    Graph             `json:"graph"`
	Addr     uint64            `json:"addr"`
	RealName string            `json:"realname"`
	Refs     []string          `json:"refs"`
	XRefs    []string          `json:"xrefs"`
	Vars     []string          `json:"vars"`
	Hash     map[string]string `json:"hash"`
}

Zignature is a signature type used by Radare2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL