本文へスキップ
Skillpedia
セキュリティ35k · #8355

reverse-engineering-rust-malware

できること

このツールは、悪意がある可能性のあるRustで書かれたプログラムを分析するのに役立ちます。Rust特有の特徴を見つけて、どのライブラリを使っているか、どのような不審な機能があるかなど、プログラムの動作を理解します。

使う場面

  • ✓Rustで書かれていると思われる不審なプログラムを調べる場合。
  • ✓Rustを使用しているシステムで、許可を得たセキュリティテストを行う場合。
  • ✓マルウェアのサンプルを分析して、その機能を把握する場合。

スキルのリンク

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/reverse-engineering-rust-malware/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/reverse-engineering-rust-malware/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このバイナリファイルを分析して、Rustで作られたマルウェアのように見えるか、またどのような機能を持っている可能性があるか教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このツールは、Rustのマルウェアによく見られるパターン(特定のライブラリの使用や、データの扱い方の特徴など)をプログラムのコードから探します。依存関係の情報を抽出して、プログラムの機能を把握しようとします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Reverse Engineering Rust Malware

Overview

Rust has become increasingly popular for malware development due to its cross-compilation, memory safety guarantees, and the complexity it introduces for reverse engineers. Rust binaries contain the entire standard library statically linked, producing large binaries with extensive boilerplate code. Key challenges include non-null-terminated strings (Rust uses fat pointers with pointer+length), monomorphization generating duplicated generic code, complex error handling (Result/Option unwrap chains), and unfamiliar calling conventions. Decompiling Rust to C produces unhelpful output compared to C/C++ binaries. Tools like Ghidra scripts for crate extraction, and training focused on Rust-specific patterns (2024-2025) help address these challenges. Notable Rust malware includes BlackCat/ALPHV ransomware, Hive ransomware variants, and Buer Loader.

When to Use

  • When performing authorized security testing that involves reverse engineering rust malware
  • When analyzing malware samples or attack artifacts in a controlled environment
  • When conducting red team exercises or penetration testing engagements
  • When building detection capabilities based on offensive technique understanding

Prerequisites

  • IDA Pro 8.0+ or Ghidra 11.0+
  • Rust toolchain for reference compilation
  • Python 3.9+ for helper scripts
  • Understanding of Rust memory model (ownership, borrowing)
  • Familiarity with Rust string types (String, &str, CString)

Workflow

Step 1: Identify and Parse Rust Binary Metadata

#!/usr/bin/env python3
"""Analyze Rust malware binary metadata and extract crate dependencies."""
import re
import sys
import json


def identify_rust_binary(data):
    """Check if binary is Rust-compiled and extract version info."""
    indicators = {
        "rust_panic_strings": bool(re.search(rb'panicked at', data)),
        "rust_unwrap": bool(re.search(rb'called.*unwrap.*on.*None', data)),
        "core_panic": bool(re.search(rb'core::panicking', data)),
        "std_rt": bool(re.search(rb'std::rt::lang_start', data)),
        "cargo_path": bool(re.search(rb'\.cargo[/\\]registry', data)),
        "rustc_version": None,
    }

    version = re.search(rb'rustc\s+(\d+\.\d+\.\d+)', data)
    if version:
        indicators["rustc_version"] = version.group(1).decode()

    is_rust = sum(1 for v in indicators.values() if v) >= 2
    return is_rust, indicators


def extract_crates(data):
    """Extract Rust crate (dependency) names from binary strings."""
    crate_pattern = re.compile(
        rb'(?:crates\.io-[a-f0-9]+/|\.cargo/registry/src/[^/]+/)'
        rb'([\w-]+)-(\d+\.\d+\.\d+)'
    )
    crates = {}
    for match in crate_pattern.finditer(data):
        name = match.group(1).decode()
        version = match.group(2).decode()
        crates[name] = version

    # Also check for common malware-relevant crates
    suspicious_crates = {
        "reqwest": "HTTP client",
        "hyper": "HTTP library",
        "tokio": "Async runtime",
        "aes": "AES encryption",
        "chacha20": "ChaCha20 encryption",
        "rsa": "RSA encryption",
        "ring": "Crypto library",
        "base64": "Base64 encoding",
        "winapi": "Windows API bindings",
        "winreg": "Registry access",
        "sysinfo": "System information",
        "screenshots": "Screen capture",
        "clipboard": "Clipboard access",
        "keylogger": "Key logging",
    }

    capabilities = []
    for crate_name, description in suspicious_crates.items():
        if crate_name in crates:
            capabilities.append({
                "crate": crate_name,
                "version": crates[crate_name],
                "capability": description,
            })

    return crates, capabilities


def extract_rust_strings(data):
    """Extract strings handling Rust's non-null-terminated format."""
    # Rust strings are stored as pointer+length, but string literals
    # are often in .rodata as contiguous sequences
    strings = []
    ascii_pattern = re.compile(rb'[\x20-\x7e]{8,500}')
    for match in ascii_pattern.finditer(data):
        s = match.group().decode('ascii')
        # Filter for malware-relevant strings
        keywords = ['http', 'socket', 'encrypt', 'decrypt', 'shell',
                    'exec', 'cmd', 'upload', 'download', 'persist',
                    'registry', 'mutex', 'pipe', 'inject']
        if any(kw in s.lower() for kw in keywords):
            strings.append(s)


…
よくある質問

「ファットポインタ」とは何ですか?

Rustでは、文字列が他の言語とは違う方法で保存されることがあります。「ファットポインタ」は、文字列の開始位置だけでなく長さも含めて参照する仕組みで、これによって文字列の探し方や分析方法が変わります。

「モノモーフィゼーション」とは何ですか?

Rustコンパイラが汎用的なコードを最適化するために使う技術です。同じコードが異なる形で何度も現れることがあり、分析が複雑になる原因になります。

なぜマルウェアにRustが使われるのですか?

Rustには、クロスコンパイルが容易であることやメモリ安全性といった利点があります。これらは、より堅牢で分析されにくいプログラムを作りたいマルウェア作成者にとって魅力的になることがあります。

詳細

作者による元の説明

Reverse engineers Rust-compiled malware using IDA Pro and Ghidra, covering techniques for non-null-terminated fat-pointer strings, monomorphized/duplicated generic code, Result/Option unwrap chains, crate dependency extraction, and Rust-specific control flow and calling conventions. Use when analyzing Rust-based malware samples (e.g. BlackCat/ALPHV, Hive, Buer Loader) or attack artifacts in an aut

repo: mukul975/Anthropic-Cybersecurity-Skills

人気

GitHubのスター
35k
ランキング
#8355
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル