
OGhidra は、Ollama を介して大規模言語モデル (LLMs) と Ghidra リバースエンジニアリングプラットフォームを橋渡しし、自然言語による AI 駆動のバイナリ解析を可能にします。会話形式のクエリで Ghidra と対話し、複雑なリバースエンジニアリングワークフローを自動化できます。
# OGhidra 3 - AIを活用したGhidraによるリバースエンジニアリング
Claudeにインスパイアされたオーケストレーターを使用するバージョンは、 https://github.com/llnl/OGhidra/tree/orchestrator を参照してください。



**OGhidra**は、大規模言語モデルとGhidraのリバースエンジニアリングプラットフォームを橋渡しし、自然言語によるAI駆動のバイナリ解析を可能にします。対話的にバイナリを分析し、複雑なワークフローを自動化し、ローカルAIモデルで完全なプライバシーを維持します。
YouTubeセットアップチュートリアル
[](https://www.youtube.com/watch?v=hBD92FUgR0Y)
---
## OGhidraとは?
OGhidraはGhidraにAI機能を追加し、以下のことが可能になります:
- **自然言語分析** - 関数、文字列、インポートについて平易な英語で質問
- **自動化ワークフロー** - 関数の名前変更、パターン検出、包括的なレポート生成
- **ローカルAIモデル** - ハードウェア上で動作するモデルで完全なプライバシー(Ollama)
- **クラウドAIサポート** - 外部APIへの接続(OpenAI, Google Gemini, Anthropic Claude)
- **マルウェア検出** - 12以上の回避・インジェクション手法の自動パターンマッチング
- **スマート列挙** - バイナリ解析から検索可能なナレッジグラフを構築
- **マルチインスタンス解析** - 並列解析のために複数のGhidraインスタンスを実行
### 動作の仕組み
```mermaid
graph TD
A[User Query] --> B[Planning Phase]
B --> C{Execution Phase}
C -- Tool Calls --> D[Ghidra/LLM]
D --> C
C --> E[Review Phase]
E -- Agentic Loop --> B
E --> F[Final Response]
style E fill:#f9f,stroke:#333,stroke-width:2px
style B fill:#bbf,stroke:#333,stroke-width:2px
```
**エージェントループ**: OGhidraは適応型プランニングシステムを使用します。各実行サイクルの後、結果がレビューされ、AIは最終応答を提供する前に、より多くの情報を収集するか分析を洗練するかを選択できます。
---
## クイックスタート
### 前提条件
1. **Python 3.12以上** - バージョンを確認: `python --version`
2. **Ghidra 12.0.3**(推奨) - [Ghidra Releases](https://github.com/NationalSecurityAgency/ghidra/releases)からダウンロード
- プラグインのビルド/インストールパスはGhidra 12.0.3向けに文書化されています
- テスト済み: Ghidra 11.0.3, 11.3.2, 12.0.2, 12.0.3
3. **Java 21** - Ghidra 12.0.3拡張機能のビルドに必要: `java -version`
4. **Ollama**(オプション、ローカルモデル用) - [ollama.com](https://ollama.com/)からインストール
### インストール
```bash
# Clone repository
git clone https://github.com/LLNL/OGhidra.git
cd OGhidra
# Install dependencies (choose one)
uv sync # Using UV (recommended)
pip install -r requirements.txt # Using pip
# Configure environment
cp .env.example .env
# Edit .env with your settings
```
### Ghidraプラグインのセットアップ
以下のOGhidraMCPプラグインビルド手順はGhidra 12.0.3(推奨)を対象としています。
YouTubeのビデオチュートリアルもあります: https://www.youtube.com/watch?v=hBD92FUgR0Y
#### GhidraMCP拡張機能のビルド
開発者は、Ghidraにインストールする前にGhidraMCP拡張機能をビルドする必要があります:
1. **前提条件**:
- Ghidra 12.0.3がインストールされていること
- Java 21
2. **オプション1: 自動ビルドスクリプトを使用**:
- Windows:
```bat
# Set the path to your Ghidra installation (will attempt to find last run copy of Ghidra if not set)
set GHIDRA_INSTALL_DIR=C:\path\to\ghidra_12.0.3_PUBLIC
# Run the build script
build_ghidra_plugin.bat
```
- Unix/Linux/Mac:
```bash
# Set the path to your Ghidra installation (will attempt to find the last run copy of Ghidra if not set)
export GHIDRA_INSTALL_DIR=/path/to/ghidra_12.0.3_PUBLIC
# Run the build script (make it executable first if needed)
chmod +x build_ghidra_plugin.sh
./build_ghidra_plugin.sh
```
3. **オプション2: 手動ビルド手順**:
- Ghidraのインストールパスを指定して`OGhidraMCP/gradle.properties`を作成/更新:
```properties
GHIDRA_INSTALL_DIR=/absolute/path/to/ghidra_12.0.3_PUBLIC
```
- Unix/Linux/macOSの場合:
```bash
cd OGhidraMCP
$GHIDRA_INSTALL_DIR/support/gradle/gradlew buildExtension --info
```
- Windowsの場合:
```bat
cd OGhidraMCP
"%GHIDRA_INSTALL_DIR%\support\gradle\gradlew.bat" buildExtension --info
```
4. **ビルドされた拡張機能の場所**:
- 拡張機能のzipファイルは`OGhidraMCP/dist/`に作成されます
- ファイル名は`ghidra_12.0.3_PUBLIC_YYYYMMDD_OGhidraMCP.zip`のようになります
#### GhidraMCP拡張機能のインストール
拡張機能のビルドが成功したら:
1. **Ghidraにインストール**:
- Ghidraを開き、**File** -> **Install Extensions**
- **Add Extension**(緑のプラスアイコン)をクリック
- `OGhidraMCP/dist/`ディレクトリを参照
- 新しくビルドした拡張機能のzipファイル(例: `ghidra_12.0.3_PUBLIC_YYYYMMDD_OGhidraMCP.zip`)を選択
- Ghidraを再起動
2. **プラグインを有効化**:
- Ghidraプロジェクトを開く
- **File** → **Configure** → **Enable Developer**
- `OGhidraMCP`プラグインを有効化
- サーバーが`http://localhost:8080/methods`で起動します
> **コードブラウザを開いている必要があります**
### AIモデルのプル
```bash
# For Ollama (local models)
ollama pull gemma3:27b # Good balance (20GB RAM)
ollama pull nomic-embed-text # Embedding model for RAG
# Alternative models
ollama pull gpt-oss:120b # High quality (80GB RAM)
ollama pull devstral-2:123b # High quality (80GB RAM)
ollama pull devstral-2:123b-cloud # Cloud Model
```
### OGhidraの起動
```bash
# GUI Mode (recommended)
uv run main.py --ui
# Interactive CLI
uv run main.py --interactive
# In interactive CLI, test connection
health
```
GUIモードで起動した場合は、以下を使用:
```bash
curl http://localhost:8080/methods
```
---
## 設定
`.env`を編集してAIプロバイダを設定:
### オプション1: ローカルモデル(Ollama)
```env
LLM_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434/
OLLAMA_MODEL=gemma3:27b
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
```
### オプション2: 外部API
```env
LLM_PROVIDER=external
EXTERNAL_PROVIDER=google
EXTERNAL_API_KEY=your-api-key-here
EXTERNAL_MODEL=gemini-3.1-flash-lite-preview
EXTERNAL_EMBEDDING_MODEL=gemini-embedding-001
```
### オプション3: カスタムOpenAI互換API
```env
LLM_PROVIDER=custom_api
CUSTOM_API_URL=https://api.example.com/v1/chat/completions
CUSTOM_API_KEY=your-api-key-here
CUSTOM_API_MODEL=your-model-name
CUSTOM_API_EMBEDDING_MODEL=your-embedding-model
```
### コンテキスト管理設定
モデルのコンテキストウィンドウに基づいて調整:
```env
# Context budget in tokens (adjust to your model's limit)
CONTEXT_BUDGET=100000 # 100K tokens for mid-size models
# 200K+ for frontier models
# Execution settings
MAX_EXECUTION_STEPS=5 # Steps per planning cycle
MAX_AGENTIC_CYCLES=3 # How many plan-execute-review loops
AGENTIC_LOOP_ENABLED=true # Enable adaptive replanning
```
---
## 主な機能
### 1. スマートツールボタン(GUI)
一般的なリバースエンジニアリングタスクへのワンクリックアクセス:
| ツール | 説明 |
| ---------------------------- | ----------------------------------------------- |
| **現在の関数を分析** | 選択した関数の動作を詳細に調査 |
| **現在の関数をリネーム** | AIが分析に基づいて意味のある名前を提案 |
| **すべての関数をリネーム** | Smart/Full/リネームのみのオプションで一括リネーム |
| **インポートを分析** | ライブラリと外部依存関係を特定 |
| **文字列を分析** | URL、認証情報、設定データを検出 |
| **レポート生成** | 包括的なセキュリティ評価 |
### 2. タスクモード
専門的な分析目標を設定:
```python
# In GUI: Use "Task Mode" dropdown
# In CLI: set task_mode <mode>
task_mode malware # Malware analysis with pattern detection
task_mode vuln # Vulnerability research focus
task_mode general # General reverse engineering
```
### 3. マルウェアパターン検出
12以上のマルウェアパターンを自動検出:
- **回避**: PEB Walking、動的API解決、アンチデバッグ、アンチVM
- **インジェクション**: プロセスインジェクション(ローカル/リモート)
- **永続化**: レジストリ、ファイルシステムフック
- **難読化**: 文字列エンコーディング、APIハッシュ
- **権限昇格**: トークン操作、UACバイパス
パターンはMITRE ATT&CKマッピングとともにAIのコンテキストで自動アラートをトリガーします。
### 4. スマート列挙
バイナリ解析からリッチで検索可能なナレッジを構築:
```
# Enumerate all functions with AI summaries
# Choose from:
- Rename Only: Only process generic function names
- Smart Enumeration: Focus on security-relevant functions
- Full Enumeration: Analyze every function in the binary
```
機能:
- 構造化メタデータ抽出(LOC、複雑性、操作)
- セマンティック検索の最適化
- インテントベースのコンテキストアセンブリ
- 正確な検索のためのマルチベクターサポート
### 5. セッション管理
分析セッションの保存と復元:
```python
# Save progress
File → Save Session
# Load previous work
File → Load Session
# Auto-save after bulk operations
# Sessions include:
- Analyzed functions with summaries
- RAG vectors for semantic search
- Performance statistics
- UI state
```
---
## バックエンドのセットアップ
OGhidraは2つのバックエンドタイプをサポート:
- **MCP** — GhidraMCPサーバーと統合し、分析中はGhidraクライアントが実行中である必要があります
- **PyGhidra** — Ghidraクライアントなしでヘッドレス分析をサポートし、MCPで必要なサーバーコンポーネントを排除します
### バックエンドの選択
以下のコマンドラインオプションを使用してバックエンドを選択:
```bash
--ghidra-backend={http,pyghidra}
```
| バックエンドオプション | 説明 |
|----------------|-------------|
| `http` | GhidraMCPバックエンドを使用 |
| `pyghidra` | PyGhidraバックエンドを使用 |
---
## PyGhidra設定
### 既存のGhidraプロジェクトを使用
OGhidra起動時にGhidraプロジェクトファイル(`.gpr`)を指定:
```bash
--pyghidra-project=/path/to/project.gpr
```
PyGhidraはOGhidraを起動するために有効なGhidraプロジェクトを必要とします。
---
### プログラムの選択
Ghidraプロジェクト内のどのバイナリを分析するかを指定:
```bash
--pyghidra-program=<program_name>
```
Ghidraプロジェクト内のプログラムを選択する呼び出し例:
```bash
uv run main.py --ui --ghidra-backend=pyghidra --pyghidra-project=/path/to/project.gpr --pyghidra-program=<program_name>
```
要件:
- プログラム名はGhidraプロジェクトGUIに表示される名前と完全に一致する必要があります
- このオプションは既存のプロジェクトを使用する場合に必要です
- プログラムを指定しないとOGhidraは起動しません
---
### バイナリを直接起動
バイナリパスを直接指定することもできます:
```bash
--pyghidra-binary=/path/to/binary
```
このオプションを使用すると、PyGhidraは自動的に以下を実行:
1. 新しいGhidraプロジェクト(`.gpr`)を作成
2. バイナリをインポート
3. 分析のためにOGhidraでバイナリを起動
バイナリを直接起動する呼び出し例:
uv run main.py --ui --ghidra-backend=pyghidra --pyghidra-binary=/path/to/binary
---
## 一般的なワークフロー
### 不審なバイナリの分析
1. **Ghidraにバイナリをロード**し、CodeBrowserで開く
2. **OGhidraMCPプラグインを有効化**(File → Configure)
3. **OGhidraを起動**: `uv run main.py --ui`
4. **タスクモードを設定**: ドロップダウンから"malware"を選択
5. **スマート列挙を実行**: "Rename All Functions"をクリック → "Smart Enumeration"
6. **質問する**: "高リスクの関数は?"や"ネットワーク通信を見せて"など
### セキュリティレポートの生成
```bash
# In GUI: Click "Generate Report" button
# Report includes:
- Executive Summary
- Function Inventory (renamed functions with behavior)
- Security Analysis (high-risk functions, patterns)
- Import Analysis
- String Analysis
- Recommendations
```
### 特定の関数の調査
1. **Ghidraで関数に移動**
2. **"Analyze Current Function"をクリック**
3. **フォローアップの質問**:
- "この関数は何をする?"
- "バッファオーバーフローに対して脆弱ですか?"
- "この関数を呼び出す他の関数は?"
---
## 高度な機能
### RAG(検索拡張生成)
OGhidraは分析済み関数に対するセマンティック検索にベクトル埋め込みを使用:
```env
# Enable in .env
RESULT_CACHE_ENABLED=true
TIERED_CONTEXT_ENABLED=true
```
利点:
- セッションを超えて以前の分析を記憶
- 意味的に類似した関数を見つける
- 冗長なLLM呼び出しを削減
### コンテキスト最適化
階層型コンテキスト圧縮により関連情報を保持:
```env
CURRENT_LOOP_MAX_CHARS=2000 # Recent: full detail
PREV_LOOP_MAX_CHARS=400 # Previous: summaries
OLDER_LOOP_MAX_CHARS=100 # Older: references only
```
### LLMログ
デバッグ用にすべてのAIインタラクションを追跡:
```env
LLM_LOGGING_ENABLED=true
LLM_LOG_FILE=logs/llm_interactions.log
LLM_LOG_FORMAT=json
```
---
## トラブルシューティング
### Ghidra接続の問題
```bash
# Verify plugin is loaded
# Open up codebrowser!
# Check server is running
curl http://localhost:8080/methods
```
### Ollama接続の問題
```bash
# Verify Ollama is running
ollama list
# Check connectivity
curl http://localhost:11434/api/tags
# Restart Ollama service
ollama serve
```
### 空の応答 / コンテキストオーバーフロー
```env
# Reduce context budget
CONTEXT_BUDGET=50000
# Enable compaction
COMPACTION_ENABLED=true
COMPACTION_THRESHOLD=0.75
```
### パフォーマンスの低下
1. **より小さいモデルを使用**: `gemma3:9b`に切り替え
2. **並列ワーカーを減らす**: 一括操作で`max_workers=2`に設定
3. **ベクトル埋め込みを無効化**: `RESULT_CACHE_ENABLED=false`
4. **リクエスト遅延を増やす**: `CUSTOM_API_REQUEST_DELAY=2.0`
---
## アーキテクチャ概要
```
┌─────────────────────────────────────────────────────────────┐
│ OGhidra UI │
│ (GUI / Interactive CLI) │
└────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Bridge (src/bridge.py) │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ • Agentic Loop: Plan → Execute → Review → Replan │ │
│ │ • Tool Router: Ghidra client, LLM client, CAG manager │ │
│ │ • Context Manager: Budget allocation, compression │ │
│ └────────────────────────────────────────────────────────┘ │
└───────────┬────────────────────────┬────────────────────────┘
│ │
▼ ▼
┌───────────────────────┐ ┌─────────────────────────┐
│ Ghidra Client │ │ LLM Clients │
│ • GhidraMCP Plugin │ │ • Ollama (local) │
│ • Binary operations │ │ • External APIs │
│ • Decompilation │ │ • Custom endpoints │
└───────────────────────┘ └─────────────────────────┘
│ │
└────────────┬───────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ CAG Manager (Knowledge System) │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ • Vector Store: Semantic search over functions │ │
│ │ • Pattern Detector: 12+ malware techniques │ │
│ │ • Metadata Extractor: Structured function analysis │ │
│ │ • Session Store: Persistent analysis state │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
---
## コントリビューション
コントリビューションを歓迎します!関心のある分野:
- **新しいマルウェアパターン**の検出
- **LLMプロバイダの統合**
- **UI/UXの改善**
- **パフォーマンスの最適化**
- **ドキュメント**と例
コミュニティガイドラインについては[CODE_OF_CONDUCT.md](https://github.com/llnl/oghidra/blob/main/CODE_OF_CONDUCT.md)を参照してください。
---
## 引用
研究でOGhidraを使用する場合は、以下のように引用してください:
```bibtex
@software{oghidra2025,
title = {OGhidra: AI-Powered Reverse Engineering with Ghidra},
author = {Enoch Wang},
year = {2025},
url = {https://github.com/LLNL/OGhidra}
}
```
---
## 謝辞
OGhidraは優れたオープンソースプロジェクトに基づいています:
- **[Ghidra](https://github.com/NationalSecurityAgency/ghidra)** - NSAのリバースエンジニアリングプラットフォーム
- **[Ollama](https://ollama.com/)** - ローカルLLMランタイム
- **[LaurieWired/GhidraMCP](https://github.com/LaurieWired/GhidraMCP)** - オリジナルのGhidra MCPプラグイン
- **[starsong/GhydraMCP](https://github.com/starsong/GhydraMCP)** - 拡張されたMCP実装
---
## ライセンス
OGhidraは、商用ライセンスの代替を伴うBSD 3-Clauseライセンスの条件の下で配布されています。
詳細は[LICENSE](https://github.com/llnl/oghidra/blob/main/LICENSE)および[NOTICE.md](https://github.com/llnl/oghidra/blob/main/NOTICE.md)を参照してください。
**LLNL-CODE-2013290**
---
## サポート
- **問題**: [GitHub Issues](https://github.com/LLNL/OGhidra/issues)
- **ディスカッション**: [GitHub Discussions](https://github.com/LLNL/OGhidra/discussions)
- **直接メール**: [email protected]