{"id":13755429,"url":"https://github.com/sibears/hrast","last_synced_at":"2025-05-10T01:31:00.965Z","repository":{"id":128328051,"uuid":"129508004","full_name":"sibears/HRAST","owner":"sibears","description":"PoC of modifying HexRays AST","archived":false,"fork":false,"pushed_at":"2019-12-17T16:16:57.000Z","size":808,"stargazers_count":236,"open_issues_count":0,"forks_count":37,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-02-11T15:55:32.942Z","etag":null,"topics":["hex-rays-decompiler","idapro","idapython"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sibears.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-14T10:46:36.000Z","updated_at":"2024-02-05T01:35:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"35e32d1b-7717-45f5-9b4d-10ae9e229f33","html_url":"https://github.com/sibears/HRAST","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibears%2FHRAST","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibears%2FHRAST/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibears%2FHRAST/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibears%2FHRAST/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sibears","download_url":"https://codeload.github.com/sibears/HRAST/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253349948,"owners_count":21894807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hex-rays-decompiler","idapro","idapython"],"created_at":"2024-08-03T10:00:54.108Z","updated_at":"2025-05-10T01:31:00.505Z","avatar_url":"https://github.com/sibears.png","language":"Python","readme":"# HexRaysAST matcher\n\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/sibears/HRAST/blob/master/LICENSE)\n\nThis is simple PoC that allows you to define AST pattern you want to process and make some actions with them\n\n### Current code contains templates for:\n1.  Replacing inlined `strlen` called on global variable\n2.  Auto renaming globals in expressions like `global_var = func(arg1, \"newglobalname\")`\n3.  Auto renaming structure fields like `glob_str.f0 = sub_cafebabe` to `glob_str.sub_cafebabe = sub_cafebabe`\n\nScripts are not fully tested (e.g. it can fail on some ctree elements), but you can already make some useful things.\n\n`ast_helper.py` contains some functions that help to create ctree items\n\n*If you got some interr like 50680 etc after yours changes to ctree you should check IDADIR/hexrays_sdk/verifier/cverify.cpp (you need to have IDA 7.1+)*\n\n### Usage:\n1. Load **HRAST.py** into IDA\n1. Write your patterns in **read_patterns.py**. You should define `PATTERNS` list with tuples (`template_code`, `replacement_fcn`, `is_chain`) as elements\n1. Call `reLOAD()` function from IDAPython\n1. Reload decompiler window\n1. You can call `unLOAD()` function to disable modifications\n1. Also `deBUG()` method switches DEBUG mode on/off\n1. If you want to reload **HRAST.py** or remove hex-rays callback call `hr_remove()`\n\n### Examples:\n\n**Before**\n![before screen](pics/before.png)\n\n\n**After**\n![after screen](pics/after.png)\n\ncpp operator \u003c\u003c replace:\n\n**Before**\n![before screen](pics/cpp_before.png)\n\n**After**\n![after screen](pics/cpp_after.png)\n\n### License:\nReleased under [The MIT License](https://github.com/sibears/HRAST/blob/master/LICENSE)\n","funding_links":[],"categories":["\u003ca id=\"d2166f4dac4eab7fadfe0fd06467fbc9\"\u003e\u003c/a\u003e反编译器\u0026\u0026AST"],"sub_categories":["\u003ca id=\"b31acf6c84a9506066d497af4e702bf5\"\u003e\u003c/a\u003e调试数据"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibears%2Fhrast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsibears%2Fhrast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibears%2Fhrast/lists"}