angr.go.knowledge_plugins¶
- class angr.go.knowledge_plugins.GoGlobals
Bases:
KnowledgeBasePluginPackage-level variables recovered without data symbols: the runtime’s own globals located by shape (
angr.go.analyses.runtime_globals) and the variables typed from their initializers (angr.go.analyses.package_variables). Computed once per project byangr.go.analyses.go_globals_recovery.GoGlobalsRecovery, lazily on first use unless it was run ahead of time;kb.go_signatures.variable_atconsults it after the symbol-backed sources.- __init__(kb)
- load()
Run
GoGlobalsRecoveryonce; later calls are no-ops.- Return type:
- mark_loaded()
- Return type:
- property loaded: bool
- property variables: dict[int, GoVariable]
- note(var, replace=False)
Record a variable; an address already known keeps its first record unless
replace.- Return type:
- Parameters:
var (GoVariable)
replace (bool)
- variable_at(addr)
- Return type:
- Parameters:
addr (int)
- copy()
- class angr.go.knowledge_plugins.GoSignatures
Bases:
KnowledgeBasePluginGo function signatures and named types known for this binary, merged from every source (external tools, DWARF, the binary’s runtime type descriptors, the stdlib database, in that priority) and turned into Go SimTypes on demand.
- __init__(kb)
- record_version(key)
The counter value when the record
key(a function name,callsite:0x..orclosure:0x..) last changed; 0 when it was never written.
- record_fingerprint(key)
A process-independent spelling of the record
keyas it is now (None when absent), for comparing what a decompilation consulted with what another process knows.
- track()
Record which inference records are consulted while the block runs, each with the version it had when first consulted (
deps). Nested scopes report to the enclosing one.
- untracked()
Suspend dependency tracking: for one-off whole-binary scans that are nobody’s dependency.
- note(name)
Count the inferred record of
nameas consulted by the decompilation in progress.
- deps_current(deps, version)
Whether a decompilation that started from
versionand consulteddeps(key -> version seen) reflects the current records: none of them changed since. Without a dependency list only the global counter decides.
- is_current(cache)
Whether the decompilation in
cache(a DecompilationCache) reflects the current inference records.- Return type:
- stale_decompilations(kb=None)
The
(addr, flavor)keys of the Go decompilations inkb.decompilationsthat are out of date.
- add_source(sigs, priority=None)
Register a signature set; earlier sources win.
priority=0puts it in front.- Return type:
- Parameters:
sigs (GoSignatureSet)
priority (int | None)
- load_sources(go_version=None)
Load the binary’s own DWARF signatures (when present), its runtime type descriptors and the stdlib database for its Go version. Runs once.
- load_stdlib(go_version=None)
Load the binary’s own DWARF signatures (when present), its runtime type descriptors and the stdlib database for its Go version. Runs once.
- signature(name)
- Return type:
- Parameters:
name (str)
- variable_at(addr)
- Return type:
- Parameters:
addr (int)
- named_type(name)
- Return type:
- Parameters:
name (str)
- type_name_at(addr)
The name of the type whose runtime descriptor is at
addr, when a source (DWARF) recorded it.
- property parser: GoTypeParser
- prototype(name)
The function type of
name(receiver first), or None when the signature is unknown.- Return type:
- Parameters:
name (str)
- set_inferred(name, param_types=None, results=None, caller_results=None, result_words=0, groups=None, return_words=0, fp_results=None)
Record what was inferred for
name(kept until a real signature appears): parameter types, callee-side result types, caller-side result types and word groups, how many result registers its returns write, or a whole record (asinferred_recordreturns it, possibly after a round trip through JSON) in place of the parameter types.- Return type:
- Parameters:
- set_callsite_inferred(addr, caller_results=None, result_words=0, groups=None, fp_results=None)
Record what the caller’s reads say about the results of the indirect call at
addr(an interface method or closure without a known signature); the next decompilation types the call-site prototype from it.
- callsite_record(addr)
- Return type:
- Parameters:
addr (int)
- inferred(name)
The inferred parameter types of
name.
- inferred_record(name)
- Return type:
- Parameters:
name (str)
- results_guessed(func)
True when nothing but the calling-convention guess describes the results of
func: its prototype is guessed, or it was rebuilt (a promoted receiver, inferred parameters) around the guessed result type.
- fp_results_open(func)
True when callers may still add floating-point results to
func: no real signature and no user prototype describe it. Its integer results may already be typed (inferred), which says nothing about the float ones.
- untyped_params(func)
Indices of the parameters of
functhat only the calling-convention guess describes: a prototype rebuilt around a promoted receiver or inferred results keeps the guessed words (non-Go types, or theuintptran inferred record spells for words it could not type). Type inference may know better about those, so they are no ground truth. Parameters of a real signature always are.
- inferred_prototype(name, guessed)
The inferred signature of
nameas a function type: inferred parameter types (else the guessed ones) and inferred result types (else the guessed result typeguessed.returnty).- Return type:
- Parameters:
name (str)
- set_closure_context(addr, type_str)
Record the closure record type a parent function builds for the closure body at
addr.
- closure_context(addr)
The closure record type of the body at
addr(captures are its fields afterF), if known.
- arg_size_at(addr)
The byte size of the parameters of the function at
addrfrom the pclntab (results excluded).
- prototype_at(addr)
The function type of the method whose code starts at
addr, from the runtime type descriptors’ method tables (receiver first). Covers methods of named types in stripped binaries, which no signature source names.- Return type:
- Parameters:
addr (int)
- copy()
- class angr.go.knowledge_plugins.GoTypes
Bases:
KnowledgeBasePluginThe runtime type descriptors of this binary (
angr.go.analyses.type_descriptors), parsed once on first use: descriptor address <-> canonical Go type string, itabs, and the named-type records that backkb.go_signatures.- __init__(kb)
- property descriptors: GoTypeDescriptors
- property loaded: bool
- property types: GoSignatureSet
- name_at(addr)
The canonical Go type string of the descriptor at
addr.
- addr_of(name)
The descriptor address of the type spelled
name.
- itab_at(addr)
(interface type, concrete type)of the itab ataddr.
- method_at(addr)
(receiver type, method name, func type)of the method whose code starts ataddr.
- type_at(addr)
The SimType of the descriptor at
addr, built bykb.go_signatures.
- copy()
Submodules