A cargo subcommand that displays ghidra function output through the use of the rizin rz-ghidra project.

Overview

cargo-rz-ghidra

A cargo subcommand that displays ghidra function output through the use of the rizin rz-ghidra project.

Install

cargo install --git https://github.com/wcampbell0x2a/cargo-rz-ghidra

Usage

cargo-rz-ghidra

USAGE:
    cargo-rz-ghidra [OPTIONS] --s <S> --bin <BIN> <NAME>

OPTIONS:
    -b, --bin <BIN>    cargo --bin
    -h, --help         Print help information
    -r, --release      cargo --release
    -s, --s <S>        function symbol used in rizin for ghidra decompile

Example

For instance, check the ghidra output of a function quickly with and without cpu features.

> git clone https://github.com/rsadsb/dump1090_rs
> cd dump1090_rs

without

> cargo rz-ghidra -s to_mag --release --bin dump1090
void sym.dump1090_rs::utils::to_mag::h21b8408e85bb7f8c(void *arg1, int64_t arg2, int64_t arg3)
{
    float fVar1;
    float fVar2;
    float fVar3;
    int64_t iVar4;
    int64_t iVar5;
    float fVar6;
    float fVar7;

    // dump1090_rs::utils::to_mag::h21b8408e85bb7f8c
    (*_reloc.memset)(arg1, 0, 0x4029c);
    fVar3 = *(float *)0x9e854;
    fVar2 = *(float *)0x9e850;
    fVar1 = *(float *)0x9e84c;
    if (arg3 != 0) {
        iVar4 = 0;
        iVar5 = 0;
        do {
            if (0x20145 < iVar5 + 0x146U) {
                dbg.panic_bounds_check(iVar5 + 0x146U, 0x20146, 0xbc658);
                do {
                    invalidInstructionException();
                } while( true );
            }
            fVar6 = (float)(int32_t)*(int16_t *)(arg2 + 2 + iVar4) * fVar1;
            fVar7 = (float)(int32_t)*(int16_t *)(arg2 + iVar4) * fVar1;
            fVar7 = SQRT(fVar7 * fVar7 + fVar6 * fVar6) * fVar2 + fVar3;
            fVar6 = 0.0;
            if (0.0 <= fVar7) {
                fVar6 = fVar7;
            }
            fVar7 = fVar2;
            if (fVar6 <= fVar2) {
                fVar7 = fVar6;
            }
            *(int16_t *)((int64_t)arg1 + iVar5 * 2 + 0x29c) = (int16_t)(int32_t)fVar7;
    // WARNING: Load size is inaccurate
            iVar5 = *arg1 + 1;
            *(int64_t *)arg1 = iVar5;
            iVar4 = iVar4 + 4;
        } while (arg3 << 2 != iVar4);
    }
    return;
}

with

> RUSTFLAGS="-C target-cpu=native" cargo rz-ghidra -s mag --release --bin dump1090
void sym.dump1090_rs::utils::to_mag::hc0809f05591c941a(void *arg1, int64_t arg2, int64_t arg3)
{
    undefined auVar1 [16];
    undefined auVar2 [16];
    undefined auVar3 [16];
    undefined auVar4 [16];
    undefined auVar5 [16];
    int64_t iVar6;
    int64_t iVar7;
    undefined4 uVar8;
    undefined auVar9 [16];
    undefined in_YMM3 [32];
    undefined in_XMM6 [16];

    // dump1090_rs::utils::to_mag::hc0809f05591c941a
    auVar9 = SUB3216(in_YMM3, 0);
    (*_reloc.memset)(arg1, 0, 0x4029c);
    if (arg3 != 0) {
        iVar6 = 0;
        auVar2 = vmovss_avx(*(undefined4 *)0xa1b04);
        auVar3 = vmovss_avx(*(undefined4 *)0xa1b08);
        auVar4 = vmovss_avx(*(undefined4 *)0xa1b0c);
        auVar9 = vxorps_avx(auVar9, auVar9);
        iVar7 = 0;
        do {
            if (0x20145 < iVar7 + 0x146U) {
                dbg.panic_bounds_check(iVar7 + 0x146U, 0x20146, 0xbf618);
                do {
                    invalidInstructionException();
                } while( true );
            }
            auVar1 = vcvtsi2ss_avx(in_XMM6, (int32_t)*(int16_t *)(arg2 + 2 + iVar6));
            auVar5 = vmulss_avx(auVar1, auVar2);
            auVar1 = vcvtsi2ss_avx(in_XMM6, (int32_t)*(int16_t *)(arg2 + iVar6));
            auVar1 = vmulss_avx(auVar1, auVar2);
            auVar5 = vmulss_avx(auVar5, auVar5);
            auVar1 = vmulss_avx(auVar1, auVar1);
            auVar1 = vaddss_avx(auVar5, auVar1);
            auVar1 = vsqrtss_avx(auVar1, auVar1);
            auVar1 = vmulss_avx(auVar1, auVar3);
            auVar1 = vaddss_avx(auVar1, auVar4);
            auVar1 = vmaxss_avx(auVar9, auVar1);
            auVar1 = vminss_avx(auVar3, auVar1);
            uVar8 = vcvttss2si_avx(auVar1);
            *(int16_t *)((int64_t)arg1 + iVar7 * 2 + 0x29c) = (int16_t)uVar8;
    // WARNING: Load size is inaccurate
            iVar7 = *arg1 + 1;
            *(int64_t *)arg1 = iVar7;
            iVar6 = iVar6 + 4;
        } while (arg3 << 2 != iVar6);
    }
    return;
}

Assumptions

  • rizin installed
  • rz-ghidra installed
  • CARGO_TARGET_DIR=target
You might also like...
Coinlive is an interactive command line tool that displays live cryptocurrency prices.
Coinlive is an interactive command line tool that displays live cryptocurrency prices.

Coinlive is an interactive command line tool that displays live cryptocurrency prices. It can also display simple historical price charts.

Play videos on IT8951-controlled e-paper displays

it8951-video Play videos on IT8951-controlled e-paper displays via USB. This has been tested with a Waveshare 7.8inch e-Paper HAT display. Design This

Kusa is a simple CLI tool that works on any platform and displays GitHub contribution graphs.
Kusa is a simple CLI tool that works on any platform and displays GitHub contribution graphs.

Kusa is a simple CLI tool that works on any platform and displays GitHub contribution graphs. Installation Homebrew (only macOS) $ brew tap Ryu0118/Ku

Cargo-eval - A cargo plugin to quickly evaluate some Rust source code.

cargo eval A cargo plugin to quickly evaluate some Rust source code. Installation $ cargo install --git https://github.com/timClicks/cargo-eval.git Us

Cargo-about - 📜 Cargo plugin to generate list of all licenses for a crate 🦀

📜 cargo-about Cargo plugin for generating a license listing for all dependencies of a crate See the book 📕 for in-depth documentation. Please Note:

Koi is a simple tool built to let you use ChatGPT through the command line

Koi is a simple tool built to let you use ChatGPT through the command line. It adds the ability to let ChatGPT run commands on your computer in order to help you out, or to help you out with complicated tasks.

A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies
A CLI tool that allow you to create a temporary new rust project using cargo with already installed dependencies

cargo-temp A CLI tool that allow you to create a new rust project in a temporary directory with already installed dependencies. Install Requires Rust

Watches over your Cargo project's source.

$ cargo watch Cargo Watch watches over your project's source for changes, and runs Cargo commands when they occur. If you've used nodemon, guard, or e

A simple, modern fuzzy finder tool to run examples in a Cargo project.

cargo-rx cargo-rx is a simple, modern Runner for Examples in a Cargo project. This crate provides a single executable: rx. Basically anywhere you woul

Owner
wcampbell
Rust Software Engineer / Reverse Engineer
wcampbell
Dead simple, memoized cargo subcommand to hoist cargo-built binaries into the current working directory, written in Rust.

cargo-hoist Dead simple cargo subcommand to hoist cargo-built binaries into scope. stable Install | User Docs | Crate Docs | Reference | Contributing

refcell.eth 6 Nov 9, 2023
A cargo plugin to shrink cargo's output

cargo single-line A simple cargo plugin that shrinks the visible cargo output to a single line (okay, in the best case scenario). In principle, the pl

Denis 5 Oct 30, 2022
A very simple third-party cargo subcommand to execute a custom command

cargo-x A very simple third-party cargo subcommand to execute a custom command Usage install cargo-x cargo install cargo-x or upgrade cargo install -

刘冲 9 Dec 26, 2022
a cargo subcommand for counting lines of code in Rust projects

cargo-count Linux: A cargo subcommand for displaying line counts of source code in projects, including a niave unsafe counter for Rust source files. T

Kevin K. 125 Dec 1, 2022
Cargo script subcommand

cargo-script cargo-script is a Cargo subcommand designed to let people quickly and easily run Rust "scripts" which can make use of Cargo's package eco

Daniel Keep 643 Jan 3, 2023
A cargo subcommand for checking and applying updates to installed executables

cargo-update A cargo subcommand for checking and applying updates to installed executables Documentation Manpage Installation Firstly, ensure you have

наб 827 Jan 4, 2023
Cargo subcommand `release`: everything about releasing a rust crate.

cargo release Features Ensure you are in a good state for release, including: Right branch Up-to-date with remote Clean tree Supports workspaces using

null 933 Jan 8, 2023
Cargo subcommand to easily run targets/examples

cargo-select Cargo subcommand to easily run targets/examples/tests Fuzzy match against targets, examples or tests in current rust project. cargo-selec

null 13 Sep 15, 2022
A Rust command that prettifies the ugly `cargo test` output into a beautiful one.

Cargo Pretty Test ✨ A Rust command-line tool that prettifies the ugly cargo test output into a beautiful output. This crate can be also used as a libr

Jose Celano 105 Oct 10, 2023
Tokei is a program that displays statistics about your code.

Tokei is a program that displays statistics about your code. Tokei will show the number of files, total lines within those files and code, comments, and blanks grouped by language.

null 7.5k Jan 1, 2023