MCPcopy Index your code
hub / github.com/Mizari/herast

github.com/Mizari/herast @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
482 symbols 1,220 edges 50 files 104 documented · 22%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

herast

Rewritten for IDAPython3 (IDA_VERSION >= 7.4) version of @groke's HRAST. Contains more features, more convenient and richer language for AST patterns and its handling, simple GUI for easier management and expanding over time repository with ready AST patterns (PRs are welcome!).

What it does

Herast helps with finding AST subtrees and with following work with found items. Herast provides its API via herapi module and via GUI view via Shift-M hotkey. Herast is designed for easy expandability, simple reusage and for fast scripting.

Installation

\$IDAUSR is "%APPDATA%/Hex-Rays/IDA Pro" on windows and "$HOME/.idapro" on linux and mac

  • Place herast/ to $IDAUSR/python/3/ directory
  • Place herapi.py to $IDAUSR/python/3/ directory
  • Place herast.py to $IDAUSR/plugins directory

Use already written AST handlers

Add this folder for IDB in Schemes Storages View (Shift-M) or globally via herapi.add_storage_folder(folder_name, global_settings=True). Then enable needed storages and see the results applied to pseudocode.

Couple examples:
collapse_exception_branch replaces

into

propagate_error replaces

into

Create your own AST handlers

  • Write patterns that describe parts of AST
  • Write schemes that describe handling of found patterns
  • Either export schemes to passive matcher (herapi.register_storage_scheme), that will later automatically apply them on the fly and modify every decompilation output (see examples) OR
  • Use them as scripts with the help of Matcher (see examples)

Core symbols most depended-on inside this repo

check
called by 19
herast/tree/patterns/expressions.py
get_item
called by 14
herast/tree/match_context.py
check
called by 14
herast/tree/patterns/instructions.py
register_storage_scheme
called by 11
herast/passive_manager.py
save
called by 8
herast/settings/base_settings.py
get_storage
called by 7
herast/passive_manager.py
refresh_all
called by 7
herast/views/storage_manager_view.py
get_children
called by 7
herast/tree/ast_iteration.py

Shape

Method 294
Function 99
Class 89

Languages

Python100%

Modules by API surface

herast/views/storage_manager_view.py63 symbols
herast/tree/patterns/expressions.py63 symbols
herast/tree/patterns/instructions.py45 symbols
herast/passive_manager.py23 symbols
herast/tree/utils.py18 symbols
herast/tree/actions.py18 symbols
herast/tree/patterns/abstracts.py15 symbols
herast/settings/settings_manager.py15 symbols
herast/settings/base_settings.py15 symbols
herast/tree/ast_processor.py12 symbols
herast/tree/ast_patch.py12 symbols
herast/tree/patterns/helpers.py11 symbols

For agents

$ claude mcp add herast \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact