class Cradare2::Client

Overview

The central client representing an open radare2 session.

Defined in:

cradare2/bridge/elf_bridge.cr
cradare2/client.cr
cradare2/dsl/comments.cr
cradare2/dsl/disasm.cr
cradare2/dsl/flags.cr
cradare2/dsl/types.cr
cradare2/godot.cr
cradare2/ps2.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(transport : Transport::Base) #

[View source]

Instance Method Detail

def all_strings : Array(Model::StringItem) #

Returns strings from the entire binary (izzj).


[View source]
def analyze : DSL::Analysis #

Access the Analysis DSL. Supports fluent chaining or block syntax.


[View source]
def analyze(&block : DSL::Analysis -> ) : self #

[View source]
def backtrace : Array(Model::StackFrame) #

Returns call stack backtrace frames.


[View source]
def base_address_of(module_name : String) : UInt64 | Nil #

Returns the base load address of a specific loaded module by name.


[View source]
def batch(commands : Array(String)) : Hash(String, String) #

Executes a batch of commands sequentially, returning a mapping of Command => Output.


[View source]
def breakpoint(target : Address) : self #

Sets a software breakpoint at the given address or symbol.


[View source]
def breakpoints : Array(Model::Breakpoint) #

Returns active breakpoints.


[View source]
def citrine : Platform::PS2::Helper #

Citrine alias for #ps2


[View source]
def citrine(&block : Platform::PS2::Helper -> ) : self #

[View source]
def clear_breakpoints : self #

Clears all breakpoints and watchpoints.


[View source]
def clear_command_hooks : self #

Clears all registered command listeners.


[View source]
def close : Nil #

Closes the radare2 session.


[View source]
def closed? : Bool #

Returns true if the session is closed.


[View source]
def cmd(command : String) : String #

Executes a command string in radare2 and returns the raw output string.


[View source]
def cmdj(command : String, as type : T.class) : T forall T #

Executes a command and deserializes the JSON string into the specified type T.


[View source]
def cmdj(command : String) : JSON::Any #

Executes a command and parses the returned JSON string as JSON::Any.


[View source]
def comments : DSL::Comments #

Access the Comments DSL for managing code comments safely with Base64 encoding.


[View source]
def comments(&block : DSL::Comments -> ) : self #

[View source]
def continue : self #

Continues execution of the debugged process.


[View source]
def crystal : CrystalHelper #

Access the Crystal binary analysis and memory inspection helper.


[View source]
def crystal(&block : CrystalHelper -> ) : self #

[View source]
def current_offset : UInt64 #

Returns the current seek position / offset.


[View source]
def debug : DSL::Debugger #

Access the Debugger DSL. Supports fluent chaining or block syntax.


[View source]
def debug(&block : DSL::Debugger -> ) : self #

[View source]
def decompile(target : Address | Nil = nil) : String #

Decompiles current function or target to C-like pseudocode.


[View source]
def demangle(symbol : String) : String #

Demangles a symbol using radare2 and internal caching.


[View source]
def diagnose_crash : Model::CrashDiagnosis #

Diagnoses execution crash.


[View source]
def disasm : DSL::Disassembly #

Access the Disassembly DSL.


[View source]
def disasm_text(count : Int32 = 10, at : Address | Nil = nil) : String #

Disassembles instructions returning human-readable text.


[View source]
def disassemble(count : Int32 = 10, at : Address | Nil = nil) : Array(Model::Instruction) #

Disassembles instructions returning typed Instruction models.


[View source]
def elf_bridge(binary_path : String = "binary.elf") : Cradare2::Bridge::ElfBridge #

[View source]
def exports : Array(Model::Export) #

Returns exported symbols (iEj).


[View source]
def exports_matching(pattern : Regex | String) : Array(Model::Export) #

Filters exports matching a substring or regex pattern.


[View source]
def find_function(name : String) : Model::Function | Nil #

Finds a specific function by name.


[View source]
def find_symbol(name : String) : Model::Symbol | Nil #

Finds a specific symbol by name or display name.


[View source]
def flags : DSL::Flags #

Access the Flags DSL for managing symbols, labels, and markers.


[View source]
def flags(&block : DSL::Flags -> ) : self #

[View source]
def functions : Array(Model::Function) #

Returns analyzed functions (aflj).


[View source]
def functions_matching(pattern : Regex | String) : Array(Model::Function) #

Filters functions matching a substring or regex pattern.


[View source]
def godot : Engine::Godot::Helper #

Access the Godot Engine and Lapis GDExtension helper.


[View source]
def godot(&block : Engine::Godot::Helper -> ) : self #

[View source]
def godot_object(address : Address) : Engine::Godot::GodotObjectHeader #

Reads and decodes a Godot 4 Object header at the given virtual address.


[View source]
def godot_variant(address : Address) : Engine::Godot::DecodedVariant #

Reads and decodes a Godot 4 Variant payload at the given virtual address.


[View source]
def hardware_breakpoint(target : Address) : self #

Sets a hardware breakpoint at the given address or symbol.


[View source]
def hexdump(address : Address | Nil = nil, size : Int32 = 64) : String #

Returns formatted hexdump text for human inspection.


[View source]
def imports : Array(Model::Import) #

Returns imported symbols (iij).


[View source]
def imports_matching(pattern : Regex | String) : Array(Model::Import) #

Filters imports matching a substring or regex pattern.


[View source]
def info : Model::BinaryInfo #

Returns binary metadata (ij).


[View source]
def lapis : Engine::Godot::Helper #

Lapis alias for #godot


[View source]
def lapis(&block : Engine::Godot::Helper -> ) : self #

[View source]
def memory : DSL::Memory #

Access the Memory DSL.


[View source]
def memory(&block : DSL::Memory -> ) : self #

[View source]
def module_at(address : Address) : Model::ModuleInfo | Nil #

Returns the binary module containing the specified address.


[View source]
def modules : Array(Model::ModuleInfo) #

Returns loaded binary modules in the target process.


[View source]
def on_command(&block : String, Time::Span, Bool -> Nil) : Nil #

Registers a diagnostic listener block invoked after every command execution with (command, duration, success).


[View source]

Access the PlayStation 2 Emotion Engine and Citrine platform helper.


[View source]
def ps2(&block : Platform::PS2::Helper -> ) : self #

[View source]
def quit : Nil #

Alias for close.


[View source]
def read(address : Address, size : Int32) : Bytes #

Reads raw bytes from memory address as a Bytes slice.


[View source]
def read_bytes(address : Address, size : Int32) : Bytes #

Alias for read.


[View source]
def read_cstring(address : Address, max_len : Int32 = 256) : String #

Reads a null-terminated C-string from memory address.


[View source]
def read_pointer_array(address : Address, count : Int32) : Array(UInt64) #

Reads an array of 64-bit pointers from memory address.


[View source]
def read_string(address : Address, max_len : Int32 | Nil = nil) : String #

Reads a null-terminated string from memory address.


[View source]
def registers : Model::Registers #

Returns current CPU registers.


[View source]
def remove_breakpoint(target : Address) : self #

Removes a software or hardware breakpoint at the given address or symbol.


[View source]
def remove_watchpoint(target : Address) : self #

Removes a memory watchpoint at the given address or symbol.


[View source]
def safe_cmdj(command : String, as type : T.class, default : T) : T forall T #

Helper that catches JSON parse errors on empty/unparsed data, returning default value.


[View source]
def safe_cmdj(command : String, as type : T.class) : T | Nil forall T #

Safely parses JSON response into specified model type T, returning nil on parse error or empty output.


[View source]
def safe_cmdj(command : String) : JSON::Any | Nil #

Safely parses dynamic JSON response returning JSON::Any, or nil on parse error or empty output.


[View source]
def sections : Array(Model::Section) #

Returns binary sections (iSj).


[View source]
def security : Model::SecurityInfo #

Evaluates binary security mitigations (ASLR, DEP/NX, Stack Canary, Relocations).


[View source]
def seek(target : Address) : self #

Seeks to the specified target address or symbol (s ).


[View source]
def source_location_at(address : Address) : Lines::SourceLocation | Nil #

Returns the source location corresponding to an instruction address if mapped.


[View source]
def step(count : Int32 = 1) : self #

Steps one single machine instruction (or count instructions).


[View source]
def step_out : self #

Steps out until exiting current stack frame.


[View source]
def step_over(count : Int32 = 1) : self #

Steps over calls or compound instructions.


[View source]
def strings : Array(Model::StringItem) #

Returns strings in data sections (izj).


[View source]
def strings_matching(query : String) : Array(Model::StringItem) #

Filters strings matching a substring.


[View source]
def symbols : Array(Model::Symbol) #

Returns all symbols in the binary (isj).


[View source]
def symbols_matching(pattern : Regex | String) : Array(Model::Symbol) #

Filters symbols matching a substring or regex pattern.


[View source]
def transport : Transport::Base #

[View source]
def types : DSL::Types #

Access the Types DSL for defining and decoding binary structures via radare2 pf and pfj.


[View source]
def types(&block : DSL::Types -> ) : self #

[View source]
def watchpoint(target : Address, access : Symbol = :rw) : self #

Sets a memory watchpoint on read/write/rw access.


[View source]
def xrefs_from(address : Address) : Array(Model::Xref) #

Returns cross-references originating from the specified address or symbol (axfj @ ).


[View source]
def xrefs_to(address : Address) : Array(Model::Xref) #

Returns cross-references targeting the specified address or symbol (axtj @ ).


[View source]