Coder Social home page Coder Social logo

herast's Introduction

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)

herast's People

Contributors

elyashiv avatar harelon avatar mizari avatar mostobriv avatar namirem705 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

herast's Issues

Detecting areas with dead code.

Would it be possible to use this to ID where there's dead code?
Sometimes it's useful to know what the decompiler omits.
like for example i had

*pDstT = iDu;
v5 = pDstT + 1;
*v5 = iDv;
pDstT = v5 + 1;

which was actually

format = D3DFMT_V8U8;
switch ( format )
{
    case D3DFMT_V8U8:
        *pDstT = iDu;
        v5 = pDstT + 1;
        *v5 = iDv;
        pDstT = v5 + 1;
        break;
    case D3DFMT_L6V5U5:
        *(_WORD *)pDstT = (iDu >> 3) & 0x1F;
        *(_WORD *)pDstT |= 0x20 * ((iDv >> 3) & 0x1F);
        *(_WORD *)pDstT |= (((signed int)uL >> 2) & 0x3F) << 0xA;
        pDstT += 2;
        break;
    case D3DFMT_X8L8V8U8:
        *pDstT = iDu;
        v6 = pDstT + 1;
        *v6++ = iDv;
        *v6++ = uL;
        *v6 = 0;
        pDstT = v6 + 1;
        break;
}

being able to tell that there was something missing here vs the asm automatically would be extremely useful
Finding out it was a switch in this case lead me to finding the original source code which turned out to be from DirectX SDK.
Likewise a similar case would be a
var = 0;
if(var) {}
where the decompiler would omit code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.