Ghidra plugin for HashDB

Overview

hashdb-ghidra

This is a Ghidra plugin for HashDB. It allows you to compile a list of API hashes and then to query the HashDB web service for possible matching strings. It collects these associations into an enum or a struct. From there on, you are on your own.

Installation

Two options:

  1. Copy HashDB.java to your ghidra_script directory.
  2. Add the location where HashDB.java is located to your script directory search path in Ghidra's ScriptManager.

We recommend to bind the HashDB.java script's execution to a hotkey, preferably F3.

Usage

The plugin consists of a single window containing a table showing the "currently collected" hashes. You can bring up the window by executing the script (i.e. hitting F3). In addition to opening the window (or showing it, if it was hidden) the script will do different things depending on where your cursor is:

  • If the cursor is on an immediate or constant, it will add that value as a hash to the table.
  • If you selected a memory region, it will interpret it as a list of hashes.
  • Otherwise, it will assume that you want to scan for parameters to the currently opened function.

The GUI is actually perfect and completely intuitive to use with a great UX. But since we are also amazing at documentation, we include the following guidance:

  • The plugin allows to transform the hash before lookup. You can put a JavaScript expression into the "Hash Transformation" input field. See the REvil example below.
  • When you hit the "Query!" button, the script will use the HashDB web API to list all known and matching hashing algorithms. If there's only one, it will also just resolve all hashes. Otherwise, you have to select the correct algorithm in the "Hash Algorithm" field. Pretty much the same is true for the "String Permutation" field. tl;dr: just click "Query!".
  • You can check the "Resolve Entire module" checkbox if you not only want to add all hashes from the table but also all other hashes from the parent DLLs.
  • The "Scan Function" tab allows you to specify a function name and a parameter location. The script will crawl all function calls and add the corresponding argument to the table.
  • Depending on the different switches and toggles in the "Output"-tab (which is very well-designed), the script will create one or two enums or structs. The order of fields in the resulting structs is the same as in the table. Structs are always overwritten, enums are always merged.

Example Workflow: Netwalker

Consider the sample with the following SHA256 hash

de04d2402154f676f757cf1380671f396f3fc9f7dbb683d9461edd2718c4e09d

and navigate to the function at 0x00401360. The code will look like the following:

iVar1 = FUN_00401220(0x84c05e40);
if (iVar1 != 0) {
  pcVar2 = (code *)FUN_00401000(iVar1,-0x5e2ba68c);
  if (pcVar2 != (code *)0x0) {
    uVar6 = 0x254;
    uVar5 = 8;
    uVar3 = FUN_00406a40();
    DAT_00417194 = (int *)(*pcVar2)(uVar3,uVar5,uVar6);
    if (DAT_00417194 != (int *)0x0) {
      iVar4 = FUN_00401000(iVar1,-0x5e2ba68c);
      *DAT_00417194 = iVar4;
      iVar4 = FUN_00401000(iVar1,-0x50ee43dc);
      DAT_00417194[1] = iVar4;
      iVar4 = FUN_00401000(iVar1,-0x468c4724);
      DAT_00417194[2] = iVar4;
      iVar4 = FUN_00401000(iVar1,-0x7b9c69f6);
/* ... */

You can either click on 0x84C05E40, hit F3; click on -0x5E2BA68C, hit F3, and so on and so forth, until you are ready to "Query!". Alternatively you can double click FUN_00401000 and then hit F3 to bring up the scan function tab. Confirm that the pre-populated value in the "Parameter" field is correct, hit "Scan" and grab a cold cup of water.

Example Workflow: REvil

Consider the sample with the following SHA256 hash

5f56d5748940e4039053f85978074bde16d64bd5ba97f6f0026ba8172cb29e93

and navigate to the memory region 0x004113F8 and convert it to an array of 140 DWORDs and hit F3. This memory region contains all API hashes. Our goal is to create a struct that has the corresponding API function pointers in the exact same location. This way, changing the type of this global constant to the struct will make the code all pretty.

REvil's API hashing requires that you figure out a transformation that it applies to the hash. For this sample, the transformation is the following:

((((X ^ 0x76C7) << 0x10) ^ X) ^ 0xAFB9) & 0x1FFFFF /*REvil*/

It will be different for other REvil samples. Make sure to select "Generate Struct" in the "Output" tab and "Query!". When it is done, change the type of 0x004113F8 to HashDB. Happy times.

Contributors

Contact us on Twitter

or join the OALabs Discord oalabs-dev channel.

You might also like...

HopLa Burp Suite Extender plugin - Adds autocompletion support and useful payloads in Burp Suite

 HopLa Burp Suite Extender plugin -  Adds autocompletion support and useful payloads in Burp Suite

HopLa 💥 All the power of PayloadsAllTheThings, without the overhead. This extension adds autocompletion support and useful payloads in Burp Suite to

Dec 24, 2022

Flutter plugin to listen to the process text intent stream.

Flutter plugin to listen to the process text intent stream.

Flutter Process Text Plugin Show some ❤️ and ⭐ the repo Why use Flutter Process Text? Flutter Process Text Plugin is known for : Flutter Process Text

Jul 1, 2022

AspectJ Maven Plugin

AspectJ Maven Plugin Overview This plugin weaves AspectJ aspects into your classes using the AspectJ compiler ajc. Typically, aspects are used in one

Dec 9, 2022

Ask and replay plugin for Mirai-Console

Ask and replay plugin for Mirai-Console

EntryLib EntryLib 是一个基于 Mirai-Console 的插件,用于实现群词条、自定义回复或更多功能。 目录 声明 使用方法 基本指令列表 额外说明 配置项 控制台 数据库结构 To-Do List 插件依赖 声明 本插件仅作为学习交流等使用,请勿用于盈利,否则法律后果自负。 欢

Oct 25, 2022

Flutter plugin to listen to the process text intent stream.

Flutter plugin to listen to the process text intent stream.

Flutter Process Text Plugin Compatibility ✅ Android ❌ iOS (active issue: iOS support) Show some ❤️ and ⭐ the repo Why use Flutter Process Text? Flutte

Jul 1, 2022

This simple Android Studio plugin includes keyboard shortcuts for many common actions.

This simple Android Studio plugin includes keyboard shortcuts for many common actions.

Hotkeys This simple Android Studio plugin includes keyboard shortcuts for many common actions. Features • Build process • Contribute • License Feature

Apr 26, 2022

A simple but helpful fight plugin with rank support

RankFight A simple but helpful fight plugin with rank support HighLights PlceholderAPI Support %rankfight_rank% %rankfight_credit% %rankfight_shopCred

Nov 20, 2021

The best plugin to protect anarchy servers and mc servers in general against op attacks.

AdminSecure The best plugin to protect anarchy servers and mc servers in general against op attacks How does it work? When the server detects a player

Sep 2, 2021

Source code of Trend's Manhunt plugin

Trend's Manhunt This is the official repository of my Manhunt plugin. Contribution You are allowed to contribute, but NOT to yoink all of my plugin co

Oct 19, 2022
Comments
  • Simple XOR transformation not detected as self-inverse

    Simple XOR transformation not detected as self-inverse

    The transformation string X ^ 0x43013fcc /* XOR */ is to my knowledge a self-inverse transformation, where the inverse would be X ^ 0x43013fcc /* XOR */

    When using this transformation string the "[HashDB] You lied. This transformation is not invertible. I fixed it for you." debug message shows up and the "transformation not invertible" checkbox is checked.

    Perhaps worth checking if there is a casing or datatype mismatch between the original X value and the scriptengine output

    bug 
    opened by michaeljgoodman 4
  • Some hashes not resolving via plugin, but are confirmed present in hashdb

    Some hashes not resolving via plugin, but are confirmed present in hashdb

    When processing some hashes from a sample, only half the hashes get hits when using the script. When testing, a number of these have been confirmed to be present in hashdb. example:

    hash: 7B334076h algorithm: add_ror13 transformation: X ^ 0x43013fcc

    result in plugin: nothing found, 0 enums added

    steps of manual check for reference: hash hex to dec: 2066956406 xor key hex to dec: 1124155340 xor result: 94283359 [GET] call to hashdb api: https://hashdb.openanalysis.net/hash/add_ror13/942833594

    result:

    {
      "hashes": [
        {
          "hash": 942833594,
          "string": {
            "string": "ole32.dll",
            "is_api": false
          }
        }
      ]
    }
    
    bug 
    opened by michaeljgoodman 3
  • Use selected function _call_ to populate the

    Use selected function _call_ to populate the "Scan"-tab

    Right now, we only support scanning for calls of the function currently open in the Decompiler. We should also allow to populate the name by the currently selected function call.

    ux 
    opened by larsborn 0
  • Close struct-editor windows before creating the struct

    Close struct-editor windows before creating the struct

    We resolved hashes are supposed to populate a struct, we will first check if a struct with the same name already exists and remove it. If this struct is open in an Editor, Ghidra raises an exception.

    bug 
    opened by larsborn 0
Owner
OALabs
OALabs
Ghidra Plugin for Texas Instrument CC 8051 SOC's especially CC1110 and CC2510

Texas Instruments CCxxxx Ghidra CPU Plugin Ghidra Plugin for Texas Instrument CC 8051 core SOC's especially CC1110 and CC2510 This helps to name the d

null 6 Dec 22, 2022
Ghidra Plugin for Fujitsu FR60 Processors. Focused on DVRP's MB91302A in the Sony PSX.

Fujitsu FR60 Ghidra Plugin This repository contains a plugin for Ghidra that enables decompilation support for FR60 processors from Fujitsu. In partic

null 13 Jan 3, 2023
Ghidra plugin for querying the Symgrate databases.

Howdy y'all, This repo contains client scripts for accessing the Symgrate databases from Ghidra to recover symbol names, part number and I/O addresses

null 8 Jul 15, 2022
Hexagon decompiler for Ghidra

Ghidra hexagon plugin WIP Hexagon decompiler plugin for ghidra Pcode is more or less autogenerated, essentially copying and adapting from binja-hexago

Toshi Piazza 17 Dec 15, 2022
Plugin-fineagent - A plugin for the ja-netfilter, it allows you to use fineagent in ja-netfilter.

plugin-fineagent A plugin for the ja-netfilter, it allows you to use fineagent in ja-netfilter. Use the mvn clean package command to compile and use F

null 19 Jun 25, 2022
:package: Gradle/Maven plugin to package Java applications as native Windows, Mac OS X, or GNU/Linux executables and create installers for them.

JavaPackager JavaPackager is a hybrid plugin for Maven and Gradle which provides an easy way to package Java applications in native Windows, Mac OS X

Francisco Vargas Ruiz 665 Jan 8, 2023
maven plugin for making chmod +x jar files

To use it, add a plugin to your pom like <!-- You need to build an exectuable uberjar, I like Shade for that --> <plugin> <groupId>org.apache.mave

Brian McCallister 113 Dec 8, 2022
Launch4j Maven Plugin

Launch4j Maven Plugin

Lukasz Lenart 301 Dec 29, 2022
A BurpSuite plugin for BBRF

bbrf-burp-plugin What's BBRF? The Bug Bounty Reconnaissance Framework (BBRF) is intended to facilitate the workflows of security researchers across mu

Pieter 19 Jun 22, 2022
Maven plugin to help creating CHANGELOG by keeping one format and solving merge request conflicts problem by extraction of new CHANGELOG entries to seperate files.

keep-changelog-maven-plugin CHANGELOG.md is one of the most important files in a repository. It allows others to find out about the most important cha

Piotr Zmilczak 22 Aug 28, 2022